diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ff35971d512c..32939512c10b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -62,7 +62,7 @@ # ServiceLabel: %Storage # PRLabel: %Storage -/sdk/storage/ @annatisch @jalauzon-msft @vincenttran-msft +/sdk/storage/ @annatisch @jalauzon-msft @vincenttran-msft @weirongw23-msft # AzureSdkOwners: @YalinLi0312 # ServiceLabel: %App Configuration @@ -241,9 +241,9 @@ /sdk/ml/azure-ai-ml/azure/ai/ml/_local_endpoints/ @NonStatic2014 @arunsu @stanley-msft @JustinFirsching # PRLabel: %ML-Jobs -/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/job* @DouglasXiaoMS @TonyJ1 @wangchao1230 -/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/ @DouglasXiaoMS @TonyJ1 @wangchao1230 -/sdk/ml/training-experiences.tests.yml @DouglasXiaoMS @TonyJ1 +/sdk/ml/azure-ai-ml/azure/ai/ml/_schema/job* @TonyJ1 @wangchao1230 +/sdk/ml/azure-ai-ml/azure/ai/ml/entities/_job/ @TonyJ1 @wangchao1230 +/sdk/ml/training-experiences.tests.yml @TonyJ1 # PRLabel: %ML-AutoML /sdk/ml/azure-ai-ml/azure/ai/ml/_schema/automl/ @skasturi @rtanase @raduk @PhaniShekhar @sharma-riti @jialiu103 @nick863 @yuanzhuangyuanzhuang @anupsms @MaurisLucis @novaturient95 @@ -951,7 +951,7 @@ #// @shivanissambare # ServiceLabel: %ML-Jobs -#// @DouglasXiaoMS @TonyJ1 @wangchao1230 +#// @TonyJ1 @wangchao1230 # ServiceLabel: %ML-Local Endpoints #// @NonStatic2014 @arunsu @stanley-msft @JustinFirsching @@ -1013,6 +1013,8 @@ ########### /eng/ @scbedd @weshaggard @benbp +/tools/ @scbedd @mccoyp + # Add owners for notifications for specific pipelines /eng/pipelines/templates/jobs/tests-nightly-python.yml @lmazuel @mccoyp /eng/pipelines/aggregate-reports.yml @lmazuel @mccoyp @YalinLi0312 diff --git a/.github/workflows/event-processor.yml b/.github/workflows/event-processor.yml index 649b211e9254..c913b90cca8a 100644 --- a/.github/workflows/event-processor.yml +++ b/.github/workflows/event-processor.yml @@ -17,26 +17,29 @@ on: permissions: {} jobs: - event-handler: + # This event requires the Azure CLI to get the LABEL_SERVICE_API_KEY from the vault. + # Because the azure/login step adds time costly pre/post Az CLI commands to any every job + # it's used in, split this into its own job so only the event that needs the Az CLI pays + # the cost. + event-handler-with-azure: permissions: issues: write pull-requests: write # For OIDC auth id-token: write contents: read - name: Handle ${{ github.event_name }} ${{ github.event.action }} event + name: Handle ${{ github.event_name }} ${{ github.event.action }} event with azure login runs-on: ubuntu-latest + if: ${{ github.event_name == 'issues' && github.event.action == 'opened' }} steps: - name: 'Az CLI login' - if: ${{ github.event_name == 'issues' && github.event.action == 'opened' }} - uses: azure/login@v1.5.1 + uses: azure/login@v1 with: client-id: ${{ secrets.AZURE_CLIENT_ID }} tenant-id: ${{ secrets.AZURE_TENANT_ID }} subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} - name: 'Run Azure CLI commands' - if: ${{ github.event_name == 'issues' && github.event.action == 'opened' }} run: | LABEL_SERVICE_API_KEY=$(az keyvault secret show \ --vault-name issue-labeler \ @@ -55,7 +58,7 @@ jobs: run: > dotnet tool install Azure.Sdk.Tools.GitHubEventProcessor - --version 1.0.0-dev.20240229.2 + --version 1.0.0-dev.20240311.2 --add-source https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json --global shell: bash @@ -94,3 +97,58 @@ jobs: # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} LABEL_SERVICE_API_KEY: ${{ env.LABEL_SERVICE_API_KEY }} + + event-handler: + permissions: + issues: write + pull-requests: write + name: Handle ${{ github.event_name }} ${{ github.event.action }} event + runs-on: ubuntu-latest + if: ${{ github.event_name != 'issues' || github.event.action != 'opened' }} + steps: + # To run github-event-processor built from source, for testing purposes, uncomment everything + # in between the Start/End-Build From Source comments and comment everything in between the + # Start/End-Install comments + # Start-Install + - name: Install GitHub Event Processor + run: > + dotnet tool install + Azure.Sdk.Tools.GitHubEventProcessor + --version 1.0.0-dev.20240311.2 + --add-source https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json + --global + shell: bash + # End-Install + + # Testing checkout of sources from the Azure/azure-sdk-tools repository + # The ref: is the SHA from the pull request in that repository or the + # refs/pull//merge for the latest on any given PR. If the repository + # is a fork eg. /azure-sdk-tools then the repository down below will + # need to point to that fork + # Start-Build + # - name: Checkout tools repo for GitHub Event Processor sources + # uses: actions/checkout@v3 + # with: + # repository: Azure/azure-sdk-tools + # path: azure-sdk-tools + # ref: /merge> or + + # - name: Build and install GitHubEventProcessor from sources + # run: | + # dotnet pack + # dotnet tool install --global --prerelease --add-source ../../../artifacts/packages/Debug Azure.Sdk.Tools.GitHubEventProcessor + # shell: bash + # working-directory: azure-sdk-tools/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor + # End-Build + + - name: Process Action Event + run: | + cat > payload.json << 'EOF' + ${{ toJson(github.event) }} + EOF + github-event-processor ${{ github.event_name }} payload.json + shell: bash + env: + # This is a temporary secret generated by github + # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/scheduled-event-processor.yml b/.github/workflows/scheduled-event-processor.yml index 361c959bc82d..120531ac3d5b 100644 --- a/.github/workflows/scheduled-event-processor.yml +++ b/.github/workflows/scheduled-event-processor.yml @@ -2,6 +2,7 @@ name: GitHub Scheduled Event Processor on: schedule: + # These are generated/confirmed using https://crontab.cronhub.io/ # Close stale issues, runs every day at 1am - CloseStaleIssues - cron: '0 1 * * *' # Identify stale pull requests, every Friday at 5am - IdentifyStalePullRequests @@ -14,9 +15,10 @@ on: - cron: '30 4,10,16,22 * * *' # Lock closed issues, every 6 hours at 05:30 AM, 11:30 AM, 05:30 PM and 11:30 PM - LockClosedIssues - cron: '30 5,11,17,23 * * *' - # Enforce max life of issues, every Monday at 10:00 AM - EnforceMaxLifeOfIssues + # Enforce max life of issues, every M,W,F at 10:00 AM PST - EnforceMaxLifeOfIssues # Note: GitHub uses UTC, to run at 10am PST, the cron task needs to be 6pm (1800 hours) UTC - - cron: '0 18 * * MON' + # When scheduling for multiple days the numeric days 0-6 (0=Sunday) must be used. + - cron: '0 18 * * 1,3,5' # This removes all unnecessary permissions, the ones needed will be set below. # https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token permissions: {} @@ -37,7 +39,7 @@ jobs: run: > dotnet tool install Azure.Sdk.Tools.GitHubEventProcessor - --version 1.0.0-dev.20240229.2 + --version 1.0.0-dev.20240311.2 --add-source https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json --global shell: bash @@ -131,7 +133,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Enforce Max Life of Issues Scheduled Event - if: github.event.schedule == '0 18 * * MON' + if: github.event.schedule == '0 18 * * 1,3,5' run: | cat > payload.json << 'EOF' ${{ toJson(github.event) }} diff --git a/.vscode/cspell.json b/.vscode/cspell.json index ca21e5ade2ac..2fc6fd283d29 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -454,6 +454,9 @@ "amltemp", "deserializers", "dicom", + "WINDOWSVMIMAGE", + "LINUXVMIMAGE", + "MACVMIMAGE" ], "overrides": [ { diff --git a/eng/common/scripts/Prepare-Release.ps1 b/eng/common/scripts/Prepare-Release.ps1 index 269fd113fd69..e82c5982ac96 100644 --- a/eng/common/scripts/Prepare-Release.ps1 +++ b/eng/common/scripts/Prepare-Release.ps1 @@ -116,7 +116,7 @@ $month = $ParsedReleaseDate.ToString("MMMM") Write-Host "Assuming release is in $month with release date $releaseDateString" -ForegroundColor Green if (Test-Path "Function:GetExistingPackageVersions") { - $releasedVersions = GetExistingPackageVersions -PackageName $packageProperties.Name -GroupId $packageProperties.Group + $releasedVersions = @(GetExistingPackageVersions -PackageName $packageProperties.Name -GroupId $packageProperties.Group) if ($null -ne $releasedVersions -and $releasedVersions.Count -gt 0) { $latestReleasedVersion = $releasedVersions[$releasedVersions.Count - 1] diff --git a/eng/common/scripts/Test-SampleMetadata.ps1 b/eng/common/scripts/Test-SampleMetadata.ps1 index 4a0000220fde..9e50fa1dce03 100644 --- a/eng/common/scripts/Test-SampleMetadata.ps1 +++ b/eng/common/scripts/Test-SampleMetadata.ps1 @@ -330,6 +330,7 @@ begin { "blazor-webassembly", "common-data-service", "customer-voice", + "dotnet-api", "dotnet-core", "dotnet-standard", "document-intelligence", diff --git a/eng/common/scripts/job-matrix/job-matrix-functions.ps1 b/eng/common/scripts/job-matrix/job-matrix-functions.ps1 index 198d68f00f7f..f20dbe5281b0 100644 --- a/eng/common/scripts/job-matrix/job-matrix-functions.ps1 +++ b/eng/common/scripts/job-matrix/job-matrix-functions.ps1 @@ -96,7 +96,8 @@ function GenerateMatrix( [String]$displayNameFilter = ".*", [Array]$filters = @(), [Array]$replace = @(), - [Array]$nonSparseParameters = @() + [Array]$nonSparseParameters = @(), + [Switch]$skipEnvironmentVariables ) { $matrixParameters, $importedMatrix, $combinedDisplayNameLookup = ` ProcessImport $config.matrixParameters $selectFromMatrixType $nonSparseParameters $config.displayNamesLookup @@ -124,7 +125,9 @@ function GenerateMatrix( $matrix = FilterMatrix $matrix $filters $matrix = ProcessReplace $matrix $replace $combinedDisplayNameLookup - $matrix = ProcessEnvironmentVariableReferences $matrix $combinedDisplayNameLookup + if (!$skipEnvironmentVariables) { + $matrix = ProcessEnvironmentVariableReferences $matrix $combinedDisplayNameLookup + } $matrix = FilterMatrixDisplayName $matrix $displayNameFilter return $matrix } @@ -427,10 +430,14 @@ function ProcessImport([MatrixParameter[]]$matrix, [String]$selection, [Array]$n exit 1 } $importedMatrixConfig = GetMatrixConfigFromFile (Get-Content -Raw $importPath) + # Add skipEnvironmentVariables so we don't process environment variables on import + # because we want top level filters to work against the the env key, not the value. + # The environment variables will get resolved after the import. $importedMatrix = GenerateMatrix ` -config $importedMatrixConfig ` -selectFromMatrixType $selection ` - -nonSparseParameters $nonSparseParameters + -nonSparseParameters $nonSparseParameters ` + -skipEnvironmentVariables $combinedDisplayNameLookup = $importedMatrixConfig.displayNamesLookup foreach ($lookup in $displayNamesLookup.GetEnumerator()) { diff --git a/eng/pipelines/templates/jobs/ci.yml b/eng/pipelines/templates/jobs/ci.yml index f30d5b0a9ed3..1cf52e53ce43 100644 --- a/eng/pipelines/templates/jobs/ci.yml +++ b/eng/pipelines/templates/jobs/ci.yml @@ -72,8 +72,8 @@ jobs: timeoutInMinutes: 90 pool: - name: azsdk-pool-mms-ubuntu-2004-general - image: azsdk-pool-mms-ubuntu-2004-1espt + name: $(LINUXPOOL) + image: $(LINUXVMIMAGE) os: linux steps: @@ -93,8 +93,8 @@ jobs: timeoutInMinutes: 90 pool: - name: azsdk-pool-mms-ubuntu-2004-general - image: azsdk-pool-mms-ubuntu-2004-1espt + name: $(LINUXPOOL) + image: $(LINUXVMIMAGE) os: linux steps: @@ -114,8 +114,8 @@ jobs: timeoutInMinutes: 90 pool: - name: azsdk-pool-mms-win-2022-general - image: azsdk-pool-mms-win-2022-1espt + name: $(WINDOWSPOOL) + image: $(WINDOWSVMIMAGE) os: windows steps: @@ -135,8 +135,8 @@ jobs: timeoutInMinutes: 90 pool: - name: 'Azure Pipelines' - vmImage: macos-11 + name: $(MACPOOL) + vmImage: $(MACVMIMAGE) os: macOS steps: @@ -161,8 +161,8 @@ jobs: timeoutInMinutes: 90 pool: - name: azsdk-pool-mms-ubuntu-2004-general - image: azsdk-pool-mms-ubuntu-2004-1espt + name: $(LINUXPOOL) + image: $(LINUXVMIMAGE) os: linux steps: @@ -197,8 +197,8 @@ jobs: timeoutInMinutes: 90 pool: - name: azsdk-pool-mms-ubuntu-2004-general - image: azsdk-pool-mms-ubuntu-2004-1espt + name: $(LINUXPOOL) + image: $(LINUXVMIMAGE) os: linux steps: @@ -223,8 +223,8 @@ jobs: - 'Build_Extended' pool: - name: azsdk-pool-mms-ubuntu-2004-general - image: azsdk-pool-mms-ubuntu-2004-1espt + name: $(LINUXPOOL) + image: $(LINUXVMIMAGE) os: linux steps: diff --git a/eng/pipelines/templates/jobs/live.tests.yml b/eng/pipelines/templates/jobs/live.tests.yml index fb8fc5acee78..ac41fda33243 100644 --- a/eng/pipelines/templates/jobs/live.tests.yml +++ b/eng/pipelines/templates/jobs/live.tests.yml @@ -74,6 +74,7 @@ jobs: variables: - template: ../variables/globals.yml + - template: ../variables/image.yml - name: skipComponentGovernanceDetection value: true diff --git a/eng/pipelines/templates/stages/archetype-sdk-client.yml b/eng/pipelines/templates/stages/archetype-sdk-client.yml index 08be0b672594..b38a73fc6c5b 100644 --- a/eng/pipelines/templates/stages/archetype-sdk-client.yml +++ b/eng/pipelines/templates/stages/archetype-sdk-client.yml @@ -146,6 +146,7 @@ extends: variables: - template: /eng/pipelines/templates/variables/globals.yml@self + - template: /eng/pipelines/templates/variables/image.yml@self # The Prerelease and Release stages are conditioned on whether we are building a pull request and the branch. - ${{if and(in(variables['Build.Reason'], 'Manual', ''), eq(variables['System.TeamProject'], 'internal'))}}: diff --git a/eng/pipelines/templates/stages/platform-matrix-ai.json b/eng/pipelines/templates/stages/platform-matrix-ai.json index f46b166ac1af..6a056ce2280b 100644 --- a/eng/pipelines/templates/stages/platform-matrix-ai.json +++ b/eng/pipelines/templates/stages/platform-matrix-ai.json @@ -6,9 +6,9 @@ }, "matrix": { "Agent": { - "windows-2022": { "OSVmImage": "MMS2022", "Pool": "azsdk-pool-mms-win-2022-general" }, - "ubuntu-20.04": { "OSVmImage": "MMSUbuntu20.04", "Pool": "azsdk-pool-mms-ubuntu-2004-general" }, - "macos-11": { "OSVmImage": "macos-11", "Pool": "Azure Pipelines" } + "windows-2022": { "OSVmImage": "env:WINDOWSVMIMAGE", "Pool": "env:WINDOWSPOOL" }, + "ubuntu-20.04": { "OSVmImage": "env:LINUXVMIMAGE", "Pool": "env:LINUXPOOL" }, + "macos-11": { "OSVmImage": "env:MACVMIMAGE", "Pool": "env:MACPOOL" } }, "PythonVersion": ["3.8", "3.10", "3.11" ], "CoverageArg": "--disablecov", @@ -18,8 +18,8 @@ { "CoverageConfig": { "ubuntu2004_39_coverage": { - "OSVmImage": "MMSUbuntu20.04", - "Pool": "azsdk-pool-mms-ubuntu-2004-general", + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", "PythonVersion": "3.9", "CoverageArg": "", "TestSamples": "false" diff --git a/eng/pipelines/templates/stages/python-analyze-weekly.yml b/eng/pipelines/templates/stages/python-analyze-weekly.yml index 674a517352f8..aafcdd8ec38b 100644 --- a/eng/pipelines/templates/stages/python-analyze-weekly.yml +++ b/eng/pipelines/templates/stages/python-analyze-weekly.yml @@ -19,11 +19,14 @@ stages: timeoutInMinutes: 90 variables: - PythonVersion: '3.8' + - template: /eng/pipelines/templates/variables/image.yml + - name: PythonVersion + value: '3.8' pool: - name: azsdk-pool-mms-ubuntu-2004-general - vmImage: MMSUbuntu20.04 + name: $(LINUXPOOL) + vmImage: $(LINUXVMIMAGE) + os: linux steps: - task: UsePythonVersion@0 diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py index 5fa03d474441..49ec53b9952c 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/setup.py @@ -73,8 +73,8 @@ python_requires=">=3.6", install_requires=[ "msrest>=0.6.21", - "azure-core<2.0.0,>=1.28.0", - "azure-appconfiguration<2.0.0,>=1.5.0", - "azure-keyvault-secrets<5.0.0,>=4.3.0", + "azure-core>=1.28.0", + "azure-appconfiguration>=1.5.0", + "azure-keyvault-secrets>=4.3.0", ], ) diff --git a/sdk/appconfiguration/azure-appconfiguration/setup.py b/sdk/appconfiguration/azure-appconfiguration/setup.py index eaa5aebaf03c..f4a0bfb6dde7 100644 --- a/sdk/appconfiguration/azure-appconfiguration/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration/setup.py @@ -68,7 +68,7 @@ packages=find_packages(exclude=exclude_packages), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.28.0", + "azure-core>=1.28.0", "isodate>=0.6.0", ], ) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations/setup.py b/sdk/cognitivelanguage/azure-ai-language-conversations/setup.py index 5018c2142305..3785dae5cb7c 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations/setup.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations/setup.py @@ -51,7 +51,6 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -59,7 +58,7 @@ "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], - python_requires=">=3.7", + python_requires=">=3.8", zip_safe=False, packages=find_packages(exclude=[ 'tests', @@ -75,8 +74,8 @@ 'azure.ai.language.conversations': ['py.typed'], }, install_requires=[ - "azure-core<2.0.0,>=1.28.0", - "isodate<1.0.0,>=0.6.1", + "azure-core>=1.28.0", + "isodate>=0.6.1", "typing-extensions>=4.0.1", ], project_urls={ diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py index 1b1a527e2b65..4e14c96fc277 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/setup.py @@ -41,7 +41,6 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", @@ -49,7 +48,7 @@ "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], - python_requires=">=3.7", + python_requires=">=3.8", zip_safe=False, packages=find_packages(exclude=[ 'tests', @@ -66,8 +65,8 @@ 'azure.ai.language.questionanswering': ['py.typed'], }, install_requires=[ - "azure-core<2.0.0,>=1.28.0", - "isodate<1.0.0,>=0.6.1", + "azure-core>=1.28.0", + "isodate>=0.6.1", "typing-extensions>=4.0.1", ], project_urls={ diff --git a/sdk/communication/azure-communication-callautomation/setup.py b/sdk/communication/azure-communication-callautomation/setup.py index dadf91094373..8df3c705ceef 100644 --- a/sdk/communication/azure-communication-callautomation/setup.py +++ b/sdk/communication/azure-communication-callautomation/setup.py @@ -44,10 +44,11 @@ 'Programming Language :: Python', "Programming Language :: Python :: 3 :: Only", 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], zip_safe=False, @@ -57,14 +58,14 @@ 'azure', 'azure.communication' ]), - python_requires=">=3.7", + python_requires=">=3.8", include_package_data=True, package_data={ 'pytyped': ['py.typed'], }, install_requires=[ "msrest>=0.7.1", - "azure-core<2.0.0,>=1.29.5", + "azure-core>=1.29.5", "typing-extensions>=4.3.0", ], project_urls = { diff --git a/sdk/communication/azure-communication-chat/setup.py b/sdk/communication/azure-communication-chat/setup.py index b8879dc365cb..977faf887492 100644 --- a/sdk/communication/azure-communication-chat/setup.py +++ b/sdk/communication/azure-communication-chat/setup.py @@ -44,7 +44,6 @@ 'Programming Language :: Python', "Programming Language :: Python :: 3 :: Only", 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', @@ -59,14 +58,14 @@ 'azure', 'azure.communication' ]), - python_requires=">=3.7", + python_requires=">=3.8", include_package_data=True, package_data={ 'pytyped': ['py.typed'], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-core<2.0.0,>=1.29.5", + "isodate>=0.6.1", + "azure-core>=1.29.5", "typing-extensions>=4.3.0", ] ) diff --git a/sdk/communication/azure-communication-email/setup.py b/sdk/communication/azure-communication-email/setup.py index 7b9aac2fd155..b5db5e23cf4b 100644 --- a/sdk/communication/azure-communication-email/setup.py +++ b/sdk/communication/azure-communication-email/setup.py @@ -51,11 +51,11 @@ 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], zip_safe=False, @@ -71,8 +71,8 @@ }, install_requires=[ 'msrest>=0.7.1', - 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.2,<2.0.0', + 'azure-common>=1.1', + 'azure-mgmt-core>=1.3.2', ], - python_requires=">=3.7" + python_requires=">=3.8" ) diff --git a/sdk/communication/azure-communication-identity/setup.py b/sdk/communication/azure-communication-identity/setup.py index 4476c4463a02..e18c4e042e7d 100644 --- a/sdk/communication/azure-communication-identity/setup.py +++ b/sdk/communication/azure-communication-identity/setup.py @@ -69,7 +69,7 @@ "pytyped": ["py.typed"], }, python_requires=">=3.8", - install_requires=["msrest>=0.7.1", "azure-core<2.0.0,>=1.24.0"], + install_requires=["msrest>=0.7.1", "azure-core>=1.24.0"], extras_require={":python_version<'3.8'": ["typing-extensions"]}, project_urls={ "Bug Reports": "https://github.com/Azure/azure-sdk-for-python/issues", diff --git a/sdk/communication/azure-communication-jobrouter/setup.py b/sdk/communication/azure-communication-jobrouter/setup.py index 02e082ea74ff..98cb6119670a 100644 --- a/sdk/communication/azure-communication-jobrouter/setup.py +++ b/sdk/communication/azure-communication-jobrouter/setup.py @@ -63,8 +63,8 @@ "azure.communication.jobrouter": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-core<2.0.0,>=1.30.0", + "isodate>=0.6.1", + "azure-core>=1.30.0", "typing-extensions>=4.6.0", ], python_requires=">=3.8", diff --git a/sdk/communication/azure-communication-networktraversal/setup.py b/sdk/communication/azure-communication-networktraversal/setup.py index 1c9d58849263..578425379ff8 100644 --- a/sdk/communication/azure-communication-networktraversal/setup.py +++ b/sdk/communication/azure-communication-networktraversal/setup.py @@ -50,8 +50,11 @@ 'Programming Language :: Python', "Programming Language :: Python :: 3 :: Only", 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], packages=find_packages(exclude=[ @@ -64,10 +67,10 @@ package_data={ 'pytyped': ['py.typed'], }, - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ "msrest>=0.7.1", - "azure-core<2.0.0,>=1.24.0" + "azure-core>=1.24.0" ], extras_require={ ":python_version<'3.8'": ["typing-extensions"] diff --git a/sdk/communication/azure-communication-phonenumbers/phonenumbers-livetest-matrix.json b/sdk/communication/azure-communication-phonenumbers/phonenumbers-livetest-matrix.json index 49064e5cc032..3a21c84b93ad 100644 --- a/sdk/communication/azure-communication-phonenumbers/phonenumbers-livetest-matrix.json +++ b/sdk/communication/azure-communication-phonenumbers/phonenumbers-livetest-matrix.json @@ -7,19 +7,19 @@ "matrix": { "Agent": { "ubuntu-20.04": { - "OSVmImage": "MMSUbuntu20.04", - "Pool": "azsdk-pool-mms-ubuntu-2004-general", + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", "COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST": "true" }, "windows-2022": { - "OSVmImage": "MMS2022", - "Pool": "azsdk-pool-mms-win-2022-general", + "OSVmImage": "env:WINDOWSVMIMAGE", + "Pool": "env:WINDOWSPOOL", "AZURE_TEST_AGENT": "WINDOWS_2019_PYTHON36", "COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST": "false" }, "macos-11": { - "OSVmImage": "macos-11", - "Pool": "Azure Pipelines", + "OSVmImage": "env:MACVMIMAGE", + "Pool": "env:MACPOOL", "AZURE_TEST_AGENT": "MACOS_1015_PYTHON37", "COMMUNICATION_SKIP_CAPABILITIES_LIVE_TEST": "false" } @@ -32,8 +32,8 @@ { "CoverageConfig": { "ubuntu2004_39_coverage": { - "OSVmImage": "MMSUbuntu20.04", - "Pool": "azsdk-pool-mms-ubuntu-2004-general", + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", "PythonVersion": "3.9", "CoverageArg": "", "TestSamples": "false", @@ -45,8 +45,8 @@ { "Config": { "Ubuntu2004_3120": { - "OSVmImage": "MMSUbuntu20.04", - "Pool": "azsdk-pool-mms-ubuntu-2004-general", + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", "PythonVersion": "3.12", "CoverageArg": "--disablecov", "TestSamples": "false", diff --git a/sdk/communication/azure-communication-phonenumbers/setup.py b/sdk/communication/azure-communication-phonenumbers/setup.py index 310d2c5e3473..0c8171f86964 100644 --- a/sdk/communication/azure-communication-phonenumbers/setup.py +++ b/sdk/communication/azure-communication-phonenumbers/setup.py @@ -49,8 +49,11 @@ 'Programming Language :: Python', "Programming Language :: Python :: 3 :: Only", 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], packages=find_packages(exclude=[ @@ -63,10 +66,10 @@ package_data={ 'pytyped': ['py.typed'], }, - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ "msrest>=0.7.1", - 'azure-core<2.0.0,>=1.24.0', + 'azure-core>=1.24.0', ], extras_require={ ":python_version<'3.8'": ["typing-extensions"] diff --git a/sdk/communication/azure-communication-rooms/setup.py b/sdk/communication/azure-communication-rooms/setup.py index fba15e73d76c..bc98da3b7631 100644 --- a/sdk/communication/azure-communication-rooms/setup.py +++ b/sdk/communication/azure-communication-rooms/setup.py @@ -48,10 +48,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -64,10 +65,10 @@ ] ), install_requires=[ - "azure-core<2.0.0,>=1.24.0", + "azure-core>=1.24.0", "msrest>=0.7.1", ], - python_requires=">=3.7", + python_requires=">=3.8", include_package_data=True, extras_require={ ":python_version<'3.8'": ["typing-extensions"] diff --git a/sdk/communication/azure-communication-sms/setup.py b/sdk/communication/azure-communication-sms/setup.py index 70ddbd11dda9..184fc3ce3830 100644 --- a/sdk/communication/azure-communication-sms/setup.py +++ b/sdk/communication/azure-communication-sms/setup.py @@ -49,8 +49,11 @@ 'Programming Language :: Python', "Programming Language :: Python :: 3 :: Only", 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], packages=find_packages(exclude=[ @@ -63,9 +66,9 @@ package_data={ 'pytyped': ['py.typed'], }, - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ - 'azure-core<2.0.0,>=1.24.0', + 'azure-core>=1.24.0', 'msrest>=0.7.1', ], extras_require={ diff --git a/sdk/communication/azure-mgmt-communication/setup.py b/sdk/communication/azure-mgmt-communication/setup.py index 63def4ec4dd6..ce572ed4ecda 100644 --- a/sdk/communication/azure-mgmt-communication/setup.py +++ b/sdk/communication/azure-mgmt-communication/setup.py @@ -53,11 +53,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -76,8 +76,8 @@ install_requires=[ "isodate<1.0.0,>=0.6.1", "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", + "azure-mgmt-core>=1.3.2", "typing-extensions>=4.3.0; python_version<'3.8.0'", ], - python_requires=">=3.7", + python_requires=">=3.8", ) diff --git a/sdk/core/azure-core-experimental/setup.py b/sdk/core/azure-core-experimental/setup.py index cf84dce380ba..c53095664e7a 100644 --- a/sdk/core/azure-core-experimental/setup.py +++ b/sdk/core/azure-core-experimental/setup.py @@ -45,11 +45,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -60,8 +60,8 @@ package_data={ "pytyped": ["py.typed"], }, - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.25.0", + "azure-core>=1.25.0", ], ) diff --git a/sdk/core/azure-core-tracing-opencensus/setup.py b/sdk/core/azure-core-tracing-opencensus/setup.py index f153e9865a41..54974f66047f 100644 --- a/sdk/core/azure-core-tracing-opencensus/setup.py +++ b/sdk/core/azure-core-tracing-opencensus/setup.py @@ -45,11 +45,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -60,11 +60,11 @@ package_data={ "pytyped": ["py.typed"], }, - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ "opencensus>=0.6.0", "opencensus-ext-azure>=0.3.1", "opencensus-ext-threading", - "azure-core<2.0.0,>=1.13.0", + "azure-core>=1.13.0", ], ) diff --git a/sdk/core/azure-core-tracing-opentelemetry/setup.py b/sdk/core/azure-core-tracing-opentelemetry/setup.py index 99c667e5c9a1..ae0a5baf512a 100644 --- a/sdk/core/azure-core-tracing-opentelemetry/setup.py +++ b/sdk/core/azure-core-tracing-opentelemetry/setup.py @@ -45,11 +45,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -60,9 +60,9 @@ package_data={ "pytyped": ["py.typed"], }, - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ - "opentelemetry-api<2.0.0,>=1.12.0", - "azure-core<2.0.0,>=1.24.0", + "opentelemetry-api>=1.12.0", + "azure-core>=1.24.0", ], ) diff --git a/sdk/core/azure-core/perf-tests.yml b/sdk/core/azure-core/perf-tests.yml index a20e66ab2ac5..6a50b1d710d0 100644 --- a/sdk/core/azure-core/perf-tests.yml +++ b/sdk/core/azure-core/perf-tests.yml @@ -14,8 +14,8 @@ Tests: Arguments: - --size 1024 --parallel 64 --duration 60 --policies all - --size 1024 --parallel 64 --duration 60 --policies all --use-entra-id - - --size 10240 --parallel 32 --duration 60 - - --size 10240 --parallel 32 --duration 60 --transport requests + - --size 10240 --parallel 64 --duration 60 + - --size 10240 --parallel 64 --duration 60 --transport requests - Test: download-binary Class: DownloadBinaryDataTest @@ -23,7 +23,7 @@ Tests: - --size 1024 --parallel 64 --duration 60 - --size 1024 --parallel 64 --duration 60 --transport requests - --size 1024 --parallel 64 --duration 60 --use-entra-id - - --size 10240 --parallel 32 --duration 60 --policies all + - --size 10240 --parallel 64 --duration 60 --policies all - Test: update-entity Class: UpdateEntityJSONTest diff --git a/sdk/core/azure-mgmt-core/setup.py b/sdk/core/azure-mgmt-core/setup.py index 61c55fd325f3..f89e829c6a42 100644 --- a/sdk/core/azure-mgmt-core/setup.py +++ b/sdk/core/azure-mgmt-core/setup.py @@ -49,11 +49,11 @@ "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", "License :: OSI Approved :: MIT License", ], zip_safe=False, @@ -69,7 +69,7 @@ "pytyped": ["py.typed"], }, install_requires=[ - "azure-core<2.0.0,>=1.29.0", + "azure-core>=1.29.0", ], - python_requires=">=3.7", + python_requires=">=3.8", ) diff --git a/sdk/core/corehttp/perf-tests.yml b/sdk/core/corehttp/perf-tests.yml index 0a4b09aa61b9..e3a6ba376b4c 100644 --- a/sdk/core/corehttp/perf-tests.yml +++ b/sdk/core/corehttp/perf-tests.yml @@ -14,8 +14,8 @@ Tests: Arguments: - --size 1024 --parallel 64 --duration 60 --policies all - --size 1024 --parallel 64 --duration 60 --policies all --use-entra-id - - --size 10240 --parallel 32 --duration 60 - - --size 10240 --parallel 32 --duration 60 --transport httpx + - --size 10240 --parallel 64 --duration 60 + - --size 10240 --parallel 64 --duration 60 --transport httpx - Test: download-binary Class: DownloadBinaryDataTest @@ -23,7 +23,7 @@ Tests: - --size 1024 --parallel 64 --duration 60 - --size 1024 --parallel 64 --duration 60 --transport httpx - --size 1024 --parallel 64 --duration 60 --use-entra-id - - --size 10240 --parallel 32 --duration 60 --policies all + - --size 10240 --parallel 64 --duration 60 --policies all - Test: update-entity Class: UpdateEntityJSONTest diff --git a/sdk/core/corehttp/tests/perf_tests/upload_binary.py b/sdk/core/corehttp/tests/perf_tests/upload_binary.py index 2603af67b310..2bd341ff15a1 100644 --- a/sdk/core/corehttp/tests/perf_tests/upload_binary.py +++ b/sdk/core/corehttp/tests/perf_tests/upload_binary.py @@ -5,7 +5,7 @@ from time import time from wsgiref.handlers import format_date_time -from devtools_testutils.perfstress_tests import RandomStream, AsyncRandomStream +from devtools_testutils.perfstress_tests import RandomStream, AsyncRandomStream, AsyncIteratorRandomStream from corehttp.rest import HttpRequest from corehttp.exceptions import ( @@ -29,7 +29,14 @@ def __init__(self, arguments): blob_name = "uploadtest" self.blob_endpoint = f"{self.account_endpoint}{self.container_name}/{blob_name}" self.upload_stream = RandomStream(self.args.size) - self.upload_stream_async = AsyncRandomStream(self.args.size) + + # The AsyncIteratorRandomStream is used for upload stream scenario, since the + # async httpx transport requires the request body stream to be type AsyncIterable (i.e. have an __aiter__ method rather than __iter__). + # Specific check in httpx here: https://github.com/encode/httpx/blob/7df47ce4d93a06f2c3310cd692b4c2336d7663ba/httpx/_content.py#L116. + if self.args.transport == "httpx": + self.upload_stream_async = AsyncIteratorRandomStream(self.args.size) + else: + self.upload_stream_async = AsyncRandomStream(self.args.size) def run_sync(self): self.upload_stream.reset() diff --git a/sdk/cosmos/azure-cosmos/CHANGELOG.md b/sdk/cosmos/azure-cosmos/CHANGELOG.md index 5f378094c42c..b775baf81794 100644 --- a/sdk/cosmos/azure-cosmos/CHANGELOG.md +++ b/sdk/cosmos/azure-cosmos/CHANGELOG.md @@ -7,6 +7,7 @@ #### Breaking Changes #### Bugs Fixed +* Keyword arguments were not being passed down for `create_container_if_not_exists()` methods. See [PR 34286](https://github.com/Azure/azure-sdk-for-python/pull/34286). #### Other Changes diff --git a/sdk/cosmos/azure-cosmos/README.md b/sdk/cosmos/azure-cosmos/README.md index 663209b674d0..4bd8666c682b 100644 --- a/sdk/cosmos/azure-cosmos/README.md +++ b/sdk/cosmos/azure-cosmos/README.md @@ -153,15 +153,12 @@ Currently, the features below are **not supported**. For alternatives options, c * Group By queries * Queries with COUNT from a DISTINCT subquery: SELECT COUNT (1) FROM (SELECT DISTINCT C.ID FROM C) -* Transactional batch processing * Direct TCP Mode access * Continuation token support for aggregate cross-partition queries like sorting, counting, and distinct. Streamable queries like `SELECT * FROM WHERE` *do* support continuation tokens. * Change Feed: Processor * Change Feed: Read multiple partitions key values * Change Feed: Read specific time -* Change Feed: Read from the beginning -* Change Feed: Pull model * Cross-partition ORDER BY for mixed types * Enabling diagnostics for async query-type methods diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_database.py b/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_database.py index 1ec4a443c68d..cc9d1ecfa2a1 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_database.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_database.py @@ -310,6 +310,8 @@ async def create_container_if_not_exists( analytical_storage_ttl = kwargs.pop("analytical_storage_ttl", None) offer_throughput = kwargs.pop('offer_throughput', None) computed_properties = kwargs.pop("computed_properties", None) + etag = kwargs.pop("etag", None) + match_condition = kwargs.pop("match_condition", None) try: container_proxy = self.get_container_client(id) await container_proxy.read(**kwargs) @@ -324,7 +326,10 @@ async def create_container_if_not_exists( unique_key_policy=unique_key_policy, conflict_resolution_policy=conflict_resolution_policy, analytical_storage_ttl=analytical_storage_ttl, - computed_properties=computed_properties + computed_properties=computed_properties, + etag=etag, + match_condition=match_condition, + **kwargs ) def get_container_client(self, container: Union[str, ContainerProxy, Dict[str, Any]]) -> ContainerProxy: diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/database.py b/sdk/cosmos/azure-cosmos/azure/cosmos/database.py index b923864aa20f..707c6f03e039 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/database.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/database.py @@ -309,6 +309,8 @@ def create_container_if_not_exists( # pylint:disable=docstring-missing-param """ analytical_storage_ttl = kwargs.pop("analytical_storage_ttl", None) computed_properties = kwargs.pop("computed_properties", None) + etag = kwargs.pop("etag", None) + match_condition = kwargs.pop("match_condition", None) try: container_proxy = self.get_container_client(id) container_proxy.read( @@ -327,7 +329,10 @@ def create_container_if_not_exists( # pylint:disable=docstring-missing-param unique_key_policy=unique_key_policy, conflict_resolution_policy=conflict_resolution_policy, analytical_storage_ttl=analytical_storage_ttl, - computed_properties=computed_properties + computed_properties=computed_properties, + etag=etag, + match_condition=match_condition, + **kwargs ) @distributed_trace diff --git a/sdk/cosmos/azure-cosmos/setup.py b/sdk/cosmos/azure-cosmos/setup.py index 9ab7a1dffdda..d2045ab67abb 100644 --- a/sdk/cosmos/azure-cosmos/setup.py +++ b/sdk/cosmos/azure-cosmos/setup.py @@ -73,7 +73,7 @@ packages=find_packages(exclude=exclude_packages), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.25.1", + "azure-core>=1.25.1", "typing-extensions>=4.6.0", ], ) diff --git a/sdk/cosmos/cosmos-emulator-matrix.json b/sdk/cosmos/cosmos-emulator-matrix.json index f6e22cd8d376..72daff0c3855 100644 --- a/sdk/cosmos/cosmos-emulator-matrix.json +++ b/sdk/cosmos/cosmos-emulator-matrix.json @@ -6,7 +6,7 @@ }, "matrix": { "Agent": { - "windows-2022": { "OSVmImage": "MMS2022", "Pool": "azsdk-pool-mms-win-2022-general" } + "windows-2022": { "OSVmImage": "env:WINDOWSVMIMAGE", "Pool": "env:WINDOWSPOOL" } }, "EmulatorConfig": { "Emulator Tests Python 3.8": { diff --git a/sdk/eventgrid/azure-eventgrid/setup.py b/sdk/eventgrid/azure-eventgrid/setup.py index 6b301741f639..3a1acfc1aea8 100644 --- a/sdk/eventgrid/azure-eventgrid/setup.py +++ b/sdk/eventgrid/azure-eventgrid/setup.py @@ -51,6 +51,7 @@ "Development Status :: 5 - Production/Stable", 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', @@ -67,7 +68,7 @@ 'azure', ]), install_requires=[ - "isodate<1.0.0,>=0.6.1", - 'azure-core<2.0.0,>=1.24.0', + "isodate>=0.6.1", + 'azure-core>=1.24.0', ], ) diff --git a/sdk/eventhub/azure-eventhub-checkpointstoreblob-aio/setup.py b/sdk/eventhub/azure-eventhub-checkpointstoreblob-aio/setup.py index 131137d06dd7..f6df420e3e0e 100644 --- a/sdk/eventhub/azure-eventhub-checkpointstoreblob-aio/setup.py +++ b/sdk/eventhub/azure-eventhub-checkpointstoreblob-aio/setup.py @@ -57,11 +57,12 @@ "Development Status :: 5 - Production/Stable", 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], zip_safe=False, @@ -70,14 +71,14 @@ package_data={ 'pytyped': ['py.typed'], }, - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ # dependencies for the vendored storage blob - "azure-core<2.0.0,>=1.20.1", + "azure-core>=1.20.1", "msrest>=0.6.18", "cryptography>=2.1.4", # end of dependencies for the vendored storage blob - 'azure-eventhub<6.0.0,>=5.0.0', - 'aiohttp<5.0,>=3.8.3', + 'azure-eventhub>=5.0.0', + 'aiohttp>=3.8.3', ] ) diff --git a/sdk/eventhub/azure-eventhub-checkpointstoreblob/setup.py b/sdk/eventhub/azure-eventhub-checkpointstoreblob/setup.py index d73f1c806f7f..f39b19007481 100644 --- a/sdk/eventhub/azure-eventhub-checkpointstoreblob/setup.py +++ b/sdk/eventhub/azure-eventhub-checkpointstoreblob/setup.py @@ -57,14 +57,15 @@ "Development Status :: 5 - Production/Stable", 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], - python_requires=">=3.7", + python_requires=">=3.8", zip_safe=False, packages=find_packages(exclude=exclude_packages), include_package_data=True, @@ -73,10 +74,10 @@ }, install_requires=[ # dependencies for the vendored storage blob - "azure-core<2.0.0,>=1.20.1", + "azure-core>=1.20.1", "msrest>=0.6.18", "cryptography>=2.1.4", # end of dependencies for the vendored storage blob - 'azure-eventhub<6.0.0,>=5.0.0', + 'azure-eventhub>=5.0.0', ] ) diff --git a/sdk/eventhub/azure-eventhub/setup.py b/sdk/eventhub/azure-eventhub/setup.py index 58d29a94a1bb..a8fd87775648 100644 --- a/sdk/eventhub/azure-eventhub/setup.py +++ b/sdk/eventhub/azure-eventhub/setup.py @@ -59,6 +59,7 @@ "Development Status :: 5 - Production/Stable", 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', @@ -70,7 +71,7 @@ zip_safe=False, packages=find_packages(exclude=exclude_packages), install_requires=[ - "azure-core<2.0.0,>=1.14.0", + "azure-core>=1.14.0", "typing-extensions>=4.0.1", ] ) diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/setup.py b/sdk/formrecognizer/azure-ai-formrecognizer/setup.py index 20561ba79c2f..3ef46c4c6a35 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/setup.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/setup.py @@ -69,9 +69,9 @@ }, python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.23.0", + "azure-core>=1.23.0", "msrest>=0.6.21", - 'azure-common~=1.1', + 'azure-common>=1.1', "typing-extensions>=4.0.1", ] ) diff --git a/sdk/identity/azure-identity/setup.py b/sdk/identity/azure-identity/setup.py index 45f26f68f12c..563b5433e04c 100644 --- a/sdk/identity/azure-identity/setup.py +++ b/sdk/identity/azure-identity/setup.py @@ -59,9 +59,9 @@ ), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.23.0", + "azure-core>=1.23.0", "cryptography>=2.5", - "msal<2.0.0,>=1.24.0", - "msal-extensions<2.0.0,>=0.3.0", + "msal>=1.24.0", + "msal-extensions>=0.3.0", ], ) diff --git a/sdk/identity/platform-matrix-integration.json b/sdk/identity/platform-matrix-integration.json index 3f096b3c7b96..54959d7ab218 100644 --- a/sdk/identity/platform-matrix-integration.json +++ b/sdk/identity/platform-matrix-integration.json @@ -3,8 +3,8 @@ { "Agent": { "identity-integration": { - "OSVmImage": "MMSUbuntu20.04", - "Pool": "azsdk-pool-mms-ubuntu-2004-general", + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", "ArmTemplateParameters": "@{ ProvisionLiveResources = $true }" } }, diff --git a/sdk/identity/platform-matrix.json b/sdk/identity/platform-matrix.json index cf9119ab271f..32243683c9c4 100644 --- a/sdk/identity/platform-matrix.json +++ b/sdk/identity/platform-matrix.json @@ -9,8 +9,8 @@ { "Config": { "ubuntu_20.04_3.8_msal": { - "OSVmImage": "MMSUbuntu20.04", - "Pool": "azsdk-pool-mms-ubuntu-2004-general", + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", "PythonVersion": "3.8", "CoverageArg": "--disablecov", "InjectedPackages": "git+https://github.com/AzureAD/microsoft-authentication-library-for-python@dev", diff --git a/sdk/keyvault/azure-keyvault-administration/setup.py b/sdk/keyvault/azure-keyvault-administration/setup.py index 9cae36c420ab..7a067e2fb7f6 100644 --- a/sdk/keyvault/azure-keyvault-administration/setup.py +++ b/sdk/keyvault/azure-keyvault-administration/setup.py @@ -68,7 +68,7 @@ ), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.29.5", + "azure-core>=1.29.5", "isodate>=0.6.1", "typing-extensions>=4.0.1", ], diff --git a/sdk/keyvault/azure-keyvault-certificates/setup.py b/sdk/keyvault/azure-keyvault-certificates/setup.py index 46f30dbca275..3f853ae290c4 100644 --- a/sdk/keyvault/azure-keyvault-certificates/setup.py +++ b/sdk/keyvault/azure-keyvault-certificates/setup.py @@ -68,7 +68,7 @@ ), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.29.5", + "azure-core>=1.29.5", "isodate>=0.6.1", "typing-extensions>=4.0.1", ], diff --git a/sdk/keyvault/azure-keyvault-keys/platform-matrix.json b/sdk/keyvault/azure-keyvault-keys/platform-matrix.json index 4a4601c5b693..7f0a01ac0315 100644 --- a/sdk/keyvault/azure-keyvault-keys/platform-matrix.json +++ b/sdk/keyvault/azure-keyvault-keys/platform-matrix.json @@ -3,8 +3,8 @@ { "Agent": { "ubuntu-20.04_ManagedHSM": { - "OSVmImage": "MMSUbuntu20.04", - "Pool": "azsdk-pool-mms-ubuntu-2004-general", + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", "ArmTemplateParameters": "@{ enableHsm = $true }" } }, diff --git a/sdk/keyvault/azure-keyvault-keys/setup.py b/sdk/keyvault/azure-keyvault-keys/setup.py index 39332069b8c5..e678cb47a8b7 100644 --- a/sdk/keyvault/azure-keyvault-keys/setup.py +++ b/sdk/keyvault/azure-keyvault-keys/setup.py @@ -68,7 +68,7 @@ ), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.29.5", + "azure-core>=1.29.5", "cryptography>=2.1.4", "isodate>=0.6.1", "typing-extensions>=4.0.1", diff --git a/sdk/keyvault/azure-keyvault-secrets/setup.py b/sdk/keyvault/azure-keyvault-secrets/setup.py index ecb34606f9c4..7b752e2cc118 100644 --- a/sdk/keyvault/azure-keyvault-secrets/setup.py +++ b/sdk/keyvault/azure-keyvault-secrets/setup.py @@ -68,7 +68,7 @@ ), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.29.5", + "azure-core>=1.29.5", "isodate>=0.6.1", "typing-extensions>=4.0.1", ], diff --git a/sdk/keyvault/azure-keyvault/setup.py b/sdk/keyvault/azure-keyvault/setup.py index 85d7884bd7ef..89d152d56650 100644 --- a/sdk/keyvault/azure-keyvault/setup.py +++ b/sdk/keyvault/azure-keyvault/setup.py @@ -30,10 +30,11 @@ 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], zip_safe=False, diff --git a/sdk/metricsadvisor/azure-ai-metricsadvisor/setup.py b/sdk/metricsadvisor/azure-ai-metricsadvisor/setup.py index d3622473baec..b580eb841b36 100644 --- a/sdk/metricsadvisor/azure-ai-metricsadvisor/setup.py +++ b/sdk/metricsadvisor/azure-ai-metricsadvisor/setup.py @@ -50,10 +50,11 @@ 'Programming Language :: Python', "Programming Language :: Python :: 3 :: Only", 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], zip_safe=False, @@ -63,9 +64,9 @@ 'azure', 'azure.ai', ]), - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.23.0", + "azure-core>=1.23.0", "msrest>=0.6.21", ], ) diff --git a/sdk/ml/azure-ai-ml/CHANGELOG.md b/sdk/ml/azure-ai-ml/CHANGELOG.md index fd3bd4ee19d8..261e2f23ca48 100644 --- a/sdk/ml/azure-ai-ml/CHANGELOG.md +++ b/sdk/ml/azure-ai-ml/CHANGELOG.md @@ -10,7 +10,7 @@ ### Other Changes -## 1.14.0 (unreleased) +## 1.14.0 (2024-03-11) ### Features Added - Remove `experimental` tag for `ml_client.jobs.validate`. diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_feature_store_operations.py b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_feature_store_operations.py index fdadea599e2a..25c29bfc7472 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_feature_store_operations.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/operations/_feature_store_operations.py @@ -14,7 +14,6 @@ from azure.ai.ml._restclient.v2023_08_01_preview.models import ManagedNetworkProvisionOptions from azure.ai.ml._scope_dependent_operations import OperationsContainer, OperationScope from azure.ai.ml._telemetry import ActivityType, monitor_with_activity -from azure.ai.ml._utils._experimental import experimental from azure.ai.ml._utils._logger_utils import OpsLogger from azure.ai.ml._utils.utils import camel_to_snake from azure.ai.ml.constants import ManagedServiceIdentityType @@ -505,7 +504,6 @@ def begin_delete(self, name: str, *, delete_dependent_resources: bool = False, * @distributed_trace @monitor_with_activity(ops_logger, "FeatureStore.BeginProvisionNetwork", ActivityType.PUBLICAPI) - @experimental def begin_provision_network( self, *, diff --git a/sdk/monitor/azure-monitor-ingestion/setup.py b/sdk/monitor/azure-monitor-ingestion/setup.py index 49b1489f99f1..ba017184ce6a 100644 --- a/sdk/monitor/azure-monitor-ingestion/setup.py +++ b/sdk/monitor/azure-monitor-ingestion/setup.py @@ -65,14 +65,15 @@ "Development Status :: 5 - Production/Stable", 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], - python_requires=">=3.7", + python_requires=">=3.8", zip_safe=False, packages=find_packages(exclude=[ 'tests', @@ -83,7 +84,7 @@ ]), include_package_data=True, install_requires=[ - 'azure-core<2.0.0,>=1.28.0', + 'azure-core>=1.28.0', 'isodate>=0.6.0', "typing-extensions>=4.0.1" ] diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md index 8ca743f46635..d589309891ac 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/CHANGELOG.md @@ -4,6 +4,9 @@ ### Features Added +- Add live metrics collection of requests/dependencies/exceptions + ([#34673](https://github.com/Azure/azure-sdk-for-python/pull/34673)) + ### Breaking Changes ### Bugs Fixed diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/README.md b/sdk/monitor/azure-monitor-opentelemetry-exporter/README.md index 5be012c891d6..e5f360932f58 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/README.md +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/README.md @@ -1,6 +1,6 @@ # Microsoft OpenTelemetry exporter for Azure Monitor -The exporter for Azure Monitor allows Python applications to export data from the OpenTelemetry SDK to Azure Monitor. The exporter is intended for users who require advanced configuration or has more complicated telemetry needs that require all of distributed tracing, logging and metrics. If you have simpler configuration requirements, we recommend using the [Azure Monitor OpenTelemetry Distro](https://learn.microsoft.com/azure/azure-monitor/app/opentelemetry-enable?tabs=python) instead for a simpler one-line setup. +The exporter for Azure Monitor allows Python applications to export data from the OpenTelemetry SDK to Azure Monitor. The exporter is intended for users who require advanced configuration or have more complicated telemetry needs that require all of distributed tracing, logging and metrics. If you have simpler configuration requirements, we recommend using the [Azure Monitor OpenTelemetry Distro](https://learn.microsoft.com/azure/azure-monitor/app/opentelemetry-enable?tabs=python) instead for a simpler one-line setup. Prior to using this SDK, please read and understand [Data Collection Basics](https://learn.microsoft.com/azure/azure-monitor/app/opentelemetry-overview?tabs=python), especially the section on [telemetry types](https://learn.microsoft.com/azure/azure-monitor/app/opentelemetry-overview?tabs=python#telemetry-types). OpenTelemetry terminology differs from Application Insights terminology so it is important to understand the way the telemetry types map to each other. diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_constants.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_constants.py index b591258f2ee0..94155b73f32c 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_constants.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_constants.py @@ -1,5 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +from enum import Enum + # cSpell:disable # (OpenTelemetry metric name, Quickpulse metric name) @@ -33,4 +35,18 @@ ] ) +# Quickpulse intervals +_SHORT_PING_INTERVAL_SECONDS = 5 +_POST_INTERVAL_SECONDS = 1 +_LONG_PING_INTERVAL_SECONDS = 60 +_POST_CANCEL_INTERVAL_SECONDS = 20 + +# Live metrics data types +class _DocumentIngressDocumentType(Enum): + Request = "Request" + RemoteDependency = "RemoteDependency" + Exception = "Exception" + Event = "Event" + Trace = "Trace" + # cSpell:disable diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_exporter.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_exporter.py index ffcfb33312d0..630294218ee6 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_exporter.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_exporter.py @@ -1,8 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -from datetime import datetime, timezone -from enum import Enum -from typing import Any, List, Optional +from typing import Any, Optional from opentelemetry.context import ( _SUPPRESS_INSTRUMENTATION_KEY, @@ -13,16 +11,8 @@ from opentelemetry.sdk.metrics import ( Counter, Histogram, - ObservableCounter, - ObservableGauge, - ObservableUpDownCounter, - UpDownCounter, -) -from opentelemetry.sdk.metrics._internal.point import ( - NumberDataPoint, - HistogramDataPoint, - MetricsData, ) +from opentelemetry.sdk.metrics._internal.point import MetricsData from opentelemetry.sdk.metrics.export import ( AggregationTemporality, MetricExporter, @@ -32,31 +22,33 @@ ) from azure.core.exceptions import HttpResponseError -from azure.monitor.opentelemetry.exporter._quickpulse._constants import _QUICKPULSE_METRIC_NAME_MAPPINGS +from azure.monitor.opentelemetry.exporter._quickpulse._constants import ( + _LONG_PING_INTERVAL_SECONDS, + _POST_CANCEL_INTERVAL_SECONDS, + _POST_INTERVAL_SECONDS, +) from azure.monitor.opentelemetry.exporter._quickpulse._generated._client import QuickpulseClient -from azure.monitor.opentelemetry.exporter._quickpulse._generated.models import ( - DocumentIngress, - MetricPoint, - MonitoringDataPoint, +from azure.monitor.opentelemetry.exporter._quickpulse._generated.models import MonitoringDataPoint +from azure.monitor.opentelemetry.exporter._quickpulse._state import ( + _get_global_quickpulse_state, + _is_ping_state, + _set_global_quickpulse_state, + _get_and_clear_quickpulse_documents, + _QuickpulseState, +) +from azure.monitor.opentelemetry.exporter._quickpulse._utils import ( + _metric_to_quick_pulse_data_points, ) from azure.monitor.opentelemetry.exporter._connection_string_parser import ConnectionStringParser from azure.monitor.opentelemetry.exporter._utils import _ticks_since_dot_net_epoch, PeriodicTask -_APPLICATION_INSIGHTS_METRIC_TEMPORALITIES = { +_QUICKPULSE_METRIC_TEMPORALITIES = { + # Use DELTA temporalities because we want to reset the counts every collection interval Counter: AggregationTemporality.DELTA, Histogram: AggregationTemporality.DELTA, - ObservableCounter: AggregationTemporality.DELTA, - ObservableGauge: AggregationTemporality.CUMULATIVE, - ObservableUpDownCounter: AggregationTemporality.CUMULATIVE, - UpDownCounter: AggregationTemporality.CUMULATIVE, } -_SHORT_PING_INTERVAL_SECONDS = 5 -_POST_INTERVAL_SECONDS = 1 -_LONG_PING_INTERVAL_SECONDS = 60 -_POST_CANCEL_INTERVAL_SECONDS = 20 - class _Response: """Response that encapsulates pipeline response and response headers from @@ -91,7 +83,7 @@ def __init__(self, connection_string: Optional[str]) -> None: MetricExporter.__init__( self, - preferred_temporality=_APPLICATION_INSIGHTS_METRIC_TEMPORALITIES, # type: ignore + preferred_temporality=_QUICKPULSE_METRIC_TEMPORALITIES, # type: ignore ) def export( @@ -116,7 +108,7 @@ def export( data_points = _metric_to_quick_pulse_data_points( metrics_data, base_monitoring_data_point=base_monitoring_data_point, - documents=kwargs.get("documents"), + documents=_get_and_clear_quickpulse_documents(), ) token = attach(set_value(_SUPPRESS_INSTRUMENTATION_KEY, True)) @@ -190,16 +182,6 @@ def _ping(self, monitoring_data_point) -> Optional[_Response]: return ping_response -class _QuickpulseState(Enum): - """Current state of quickpulse service. - The numerical value represents the ping/post interval in ms for those states. - """ - - PING_SHORT = _SHORT_PING_INTERVAL_SECONDS - PING_LONG = _LONG_PING_INTERVAL_SECONDS - POST_SHORT = _POST_INTERVAL_SECONDS - - class _QuickpulseMetricReader(MetricReader): def __init__( @@ -208,7 +190,6 @@ def __init__( base_monitoring_data_point: MonitoringDataPoint, ) -> None: self._exporter = exporter - self._quick_pulse_state = _QuickpulseState.PING_SHORT self._base_monitoring_data_point = base_monitoring_data_point self._elapsed_num_seconds = 0 self._worker = PeriodicTask( @@ -224,9 +205,9 @@ def __init__( self._worker.start() def _ticker(self) -> None: - if self._is_ping_state(): + if _is_ping_state(): # Send a ping if elapsed number of request meets the threshold - if self._elapsed_num_seconds % int(self._quick_pulse_state.value) == 0: + if self._elapsed_num_seconds % _get_global_quickpulse_state().value == 0: print("pinging...") ping_response = self._exporter._ping( # pylint: disable=protected-access self._base_monitoring_data_point, @@ -236,22 +217,22 @@ def _ticker(self) -> None: if header and header == "true": print("ping succeeded: switching to post") # Switch state to post if subscribed - self._quick_pulse_state = _QuickpulseState.POST_SHORT + _set_global_quickpulse_state(_QuickpulseState.POST_SHORT) self._elapsed_num_seconds = 0 else: # Backoff after _LONG_PING_INTERVAL_SECONDS (60s) of no successful requests - if self._quick_pulse_state is _QuickpulseState.PING_SHORT and \ + if _get_global_quickpulse_state() is _QuickpulseState.PING_SHORT and \ self._elapsed_num_seconds >= _LONG_PING_INTERVAL_SECONDS: print("ping failed for 60s, switching to pinging every 60s") - self._quick_pulse_state = _QuickpulseState.PING_LONG + _set_global_quickpulse_state(_QuickpulseState.PING_LONG) # TODO: Implement redirect else: # Erroneous ping responses instigate backoff logic # Backoff after _LONG_PING_INTERVAL_SECONDS (60s) of no successful requests - if self._quick_pulse_state is _QuickpulseState.PING_SHORT and \ + if _get_global_quickpulse_state() is _QuickpulseState.PING_SHORT and \ self._elapsed_num_seconds >= _LONG_PING_INTERVAL_SECONDS: print("ping failed for 60s, switching to pinging every 60s") - self._quick_pulse_state = _QuickpulseState.PING_LONG + _set_global_quickpulse_state(_QuickpulseState.PING_LONG) else: print("posting...") try: @@ -262,7 +243,7 @@ def _ticker(self) -> None: # And resume pinging if self._elapsed_num_seconds >= _POST_CANCEL_INTERVAL_SECONDS: print("post failed for 20s, switching to pinging") - self._quick_pulse_state = _QuickpulseState.PING_SHORT + _set_global_quickpulse_state(_QuickpulseState.PING_SHORT) self._elapsed_num_seconds = 0 self._elapsed_num_seconds += 1 @@ -277,7 +258,6 @@ def _receive_metrics( metrics_data, timeout_millis=timeout_millis, base_monitoring_data_point=self._base_monitoring_data_point, - documents=[], ) if result is MetricExportResult.FAILURE: # There is currently no way to propagate unsuccessful metric post so @@ -288,41 +268,3 @@ def _receive_metrics( def shutdown(self, timeout_millis: float = 30_000, **kwargs) -> None: self._worker.cancel() self._worker.join() - - def _is_ping_state(self): - return self._quick_pulse_state in (_QuickpulseState.PING_SHORT, _QuickpulseState.PING_LONG) - -def _metric_to_quick_pulse_data_points( # pylint: disable=too-many-nested-blocks - metrics_data: OTMetricsData, - base_monitoring_data_point: MonitoringDataPoint, - documents: Optional[List[DocumentIngress]], -) -> List[MonitoringDataPoint]: - metric_points = [] - for resource_metric in metrics_data.resource_metrics: - for scope_metric in resource_metric.scope_metrics: - for metric in scope_metric.metrics: - for point in metric.data.data_points: - if point is not None: - metric_point = MetricPoint( - name=_QUICKPULSE_METRIC_NAME_MAPPINGS[metric.name.lower()], - weight=1, - ) - if isinstance(point, HistogramDataPoint): - metric_point.value = point.sum - elif isinstance(point, NumberDataPoint): - metric_point.value = point.value - else: - metric_point.value = 0 - metric_points.append(metric_point) - return [ - MonitoringDataPoint( - version=base_monitoring_data_point.version, - instance=base_monitoring_data_point.instance, - role_name=base_monitoring_data_point.role_name, - machine_name=base_monitoring_data_point.machine_name, - stream_id=base_monitoring_data_point.stream_id, - timestamp=datetime.now(tz=timezone.utc), - metrics=metric_points, - documents=documents, - ) - ] diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_live_metrics.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_live_metrics.py index 83bb3e073e3d..c84ae7b2a906 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_live_metrics.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_live_metrics.py @@ -3,15 +3,39 @@ import platform from typing import Any, Optional +from opentelemetry.sdk._logs import LogData from opentelemetry.sdk.metrics import MeterProvider -from opentelemetry.sdk.trace.id_generator import RandomIdGenerator from opentelemetry.sdk.resources import Resource +from opentelemetry.sdk.trace import ReadableSpan +from opentelemetry.sdk.trace.id_generator import RandomIdGenerator +from opentelemetry.semconv.trace import SpanAttributes +from opentelemetry.trace import SpanKind + from azure.monitor.opentelemetry.exporter._generated.models import ContextTagKeys +from azure.monitor.opentelemetry.exporter._quickpulse._constants import ( + _DEPENDENCY_DURATION_NAME, + _DEPENDENCY_FAILURE_RATE_NAME, + _DEPENDENCY_RATE_NAME, + _EXCEPTION_RATE_NAME, + _REQUEST_DURATION_NAME, + _REQUEST_FAILURE_RATE_NAME, + _REQUEST_RATE_NAME, +) from azure.monitor.opentelemetry.exporter._quickpulse._exporter import ( _QuickpulseExporter, _QuickpulseMetricReader, ) from azure.monitor.opentelemetry.exporter._quickpulse._generated.models import MonitoringDataPoint +from azure.monitor.opentelemetry.exporter._quickpulse._state import ( + _QuickpulseState, + _is_post_state, + _append_quickpulse_document, + _set_global_quickpulse_state, +) +from azure.monitor.opentelemetry.exporter._quickpulse._utils import ( + _get_log_record_document, + _get_span_document, +) from azure.monitor.opentelemetry.exporter._utils import ( _get_sdk_version, _populate_part_a_fields, @@ -20,7 +44,7 @@ def enable_live_metrics(**kwargs: Any) -> None: - """Azure Monitor base exporter for OpenTelemetry. + """Live metrics entry point. :keyword str connection_string: The connection string used for your Application Insights resource. :keyword Resource resource: The OpenTelemetry Resource used for this Python application. @@ -29,9 +53,11 @@ def enable_live_metrics(**kwargs: Any) -> None: _QuickpulseManager(kwargs.get('connection_string'), kwargs.get('resource')) +# pylint: disable=protected-access,too-many-instance-attributes class _QuickpulseManager(metaclass=Singleton): def __init__(self, connection_string: Optional[str], resource: Optional[Resource]) -> None: + _set_global_quickpulse_state(_QuickpulseState.PING_SHORT) self._exporter = _QuickpulseExporter(connection_string) part_a_fields = {} if resource: @@ -47,3 +73,80 @@ def __init__(self, connection_string: Optional[str], resource: Optional[Resource ) self._reader = _QuickpulseMetricReader(self._exporter, self._base_monitoring_data_point) self._meter_provider = MeterProvider([self._reader]) + self._meter = self._meter_provider.get_meter("azure_monitor_live_metrics") + + self._request_duration = self._meter.create_histogram( + _REQUEST_DURATION_NAME[0], + "ms", + "live metrics avg request duration in ms" + ) + self._dependency_duration = self._meter.create_histogram( + _DEPENDENCY_DURATION_NAME[0], + "ms", + "live metrics avg dependency duration in ms" + ) + # We use a counter to represent rates per second because collection + # interval is one second so we simply need the number of requests + # within the collection interval + self._request_rate_counter = self._meter.create_counter( + _REQUEST_RATE_NAME[0], + "req/sec", + "live metrics request rate per second" + ) + self._request_failed_rate_counter = self._meter.create_counter( + _REQUEST_FAILURE_RATE_NAME[0], + "req/sec", + "live metrics request failed rate per second" + ) + self._dependency_rate_counter = self._meter.create_counter( + _DEPENDENCY_RATE_NAME[0], + "dep/sec", + "live metrics dependency rate per second" + ) + self._dependency_failure_rate_counter = self._meter.create_counter( + _DEPENDENCY_FAILURE_RATE_NAME[0], + "dep/sec", + "live metrics dependency failure rate per second" + ) + self._exception_rate_counter = self._meter.create_counter( + _EXCEPTION_RATE_NAME[0], + "exc/sec", + "live metrics exception rate per second" + ) + + def _record_span(self, span: ReadableSpan) -> None: + # Only record if in post state + if _is_post_state(): + document = _get_span_document(span) + _append_quickpulse_document(document) + duration_ms = 0 + if span.end_time and span.start_time: + duration_ms = (span.end_time - span.start_time) / 1e9 # type: ignore + # TODO: Spec out what "success" is + success = span.status.is_ok + + if span.kind in (SpanKind.SERVER, SpanKind.CONSUMER): + if success: + self._request_rate_counter.add(1) + else: + self._request_failed_rate_counter.add(1) + self._request_duration.record(duration_ms) + else: + if success: + self._dependency_rate_counter.add(1) + else: + self._dependency_failure_rate_counter.add(1) + self._dependency_duration.record(duration_ms) + + def _record_log_record(self, log_data: LogData) -> None: + # Only record if in post state + if _is_post_state(): + if log_data.log_record: + log_record = log_data.log_record + if log_record.attributes: + document = _get_log_record_document(log_data) + _append_quickpulse_document(document) + exc_type = log_record.attributes.get(SpanAttributes.EXCEPTION_TYPE) + exc_message = log_record.attributes.get(SpanAttributes.EXCEPTION_MESSAGE) + if exc_type is not None or exc_message is not None: + self._exception_rate_counter.add(1) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_processor.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_processor.py new file mode 100644 index 000000000000..2e18253976fb --- /dev/null +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_processor.py @@ -0,0 +1,33 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +from opentelemetry.sdk._logs import LogData, LogRecordProcessor +from opentelemetry.sdk.trace import ReadableSpan, SpanProcessor + +from azure.monitor.opentelemetry.exporter._quickpulse._live_metrics import _QuickpulseManager + + +# pylint: disable=protected-access +class _QuickpulseLogRecordProcessor(LogRecordProcessor): + + def emit(self, log_data: LogData) -> None: + qpm = _QuickpulseManager._instance + if qpm: + qpm._record_log_record(log_data) + super().emit(log_data) + + def shutdown(self): + pass + + def force_flush(self, timeout_millis: int = 30000): + super().force_flush(timeout_millis=timeout_millis) + + +# pylint: disable=protected-access +class _QuickpulseSpanProcessor(SpanProcessor): + + def on_end(self, span: ReadableSpan) -> None: + qpm = _QuickpulseManager._instance + if qpm: + qpm._record_span(span) + return super().on_end(span) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_state.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_state.py new file mode 100644 index 000000000000..05c78c72ebb5 --- /dev/null +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_state.py @@ -0,0 +1,69 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +from enum import Enum +from typing import List + +from azure.monitor.opentelemetry.exporter._quickpulse._constants import ( + _LONG_PING_INTERVAL_SECONDS, + _POST_INTERVAL_SECONDS, + _SHORT_PING_INTERVAL_SECONDS, +) +from azure.monitor.opentelemetry.exporter._quickpulse._generated.models import DocumentIngress + + +class _QuickpulseState(Enum): + """Current state of quickpulse service. + The numerical value represents the ping/post interval in ms for those states. + """ + OFFLINE = 0 + PING_SHORT = _SHORT_PING_INTERVAL_SECONDS + PING_LONG = _LONG_PING_INTERVAL_SECONDS + POST_SHORT = _POST_INTERVAL_SECONDS + + +_GLOBAL_QUICKPULSE_STATE = _QuickpulseState.OFFLINE +_QUICKPULSE_DOCUMENTS: List[DocumentIngress] = [] + +def _set_global_quickpulse_state(state: _QuickpulseState): + # pylint: disable=global-statement + global _GLOBAL_QUICKPULSE_STATE + _GLOBAL_QUICKPULSE_STATE = state + + +def _get_global_quickpulse_state() -> _QuickpulseState: + return _GLOBAL_QUICKPULSE_STATE + + +def is_quickpulse_enabled() -> bool: + return _get_global_quickpulse_state() is not _QuickpulseState.OFFLINE + + +def _is_ping_state() -> bool: + return _get_global_quickpulse_state() in ( + _QuickpulseState.PING_SHORT, + _QuickpulseState.PING_LONG + ) + + +def _is_post_state(): + return _get_global_quickpulse_state() is _QuickpulseState.POST_SHORT + + +def _append_quickpulse_document(document: DocumentIngress): + # pylint: disable=global-statement,global-variable-not-assigned + global _QUICKPULSE_DOCUMENTS + # Limit risk of memory leak by limiting doc length to something manageable + if len(_QUICKPULSE_DOCUMENTS) > 20: + try: + _QUICKPULSE_DOCUMENTS.pop(0) + except IndexError: + pass + _QUICKPULSE_DOCUMENTS.append(document) + + +def _get_and_clear_quickpulse_documents() -> List[DocumentIngress]: + # pylint: disable=global-statement + global _QUICKPULSE_DOCUMENTS + documents = list(_QUICKPULSE_DOCUMENTS) + _QUICKPULSE_DOCUMENTS = [] + return documents diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_utils.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_utils.py new file mode 100644 index 000000000000..204b47d2ed01 --- /dev/null +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_quickpulse/_utils.py @@ -0,0 +1,156 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +from datetime import datetime, timedelta, timezone +from typing import List, Optional, Union + +from opentelemetry.sdk._logs import LogData +from opentelemetry.sdk.metrics._internal.point import ( + NumberDataPoint, + HistogramDataPoint, +) +from opentelemetry.sdk.metrics.export import MetricsData as OTMetricsData +from opentelemetry.sdk.trace import ReadableSpan +from opentelemetry.semconv.trace import SpanAttributes +from opentelemetry.trace import SpanKind +from opentelemetry.util.types import Attributes + +from azure.monitor.opentelemetry.exporter._quickpulse._constants import ( + _DocumentIngressDocumentType, + _QUICKPULSE_METRIC_NAME_MAPPINGS, +) +from azure.monitor.opentelemetry.exporter._quickpulse._generated.models import ( + DocumentIngress, + Exception as ExceptionDocument, + MetricPoint, + MonitoringDataPoint, + RemoteDependency as RemoteDependencyDocument, + Request as RequestDocument, + Trace as TraceDocument, +) +def _metric_to_quick_pulse_data_points( # pylint: disable=too-many-nested-blocks + metrics_data: OTMetricsData, + base_monitoring_data_point: MonitoringDataPoint, + documents: Optional[List[DocumentIngress]], +) -> List[MonitoringDataPoint]: + metric_points = [] + for resource_metric in metrics_data.resource_metrics: + for scope_metric in resource_metric.scope_metrics: + for metric in scope_metric.metrics: + for point in metric.data.data_points: + if point is not None: + metric_point = MetricPoint( + name=_QUICKPULSE_METRIC_NAME_MAPPINGS[metric.name.lower()], + weight=1, + ) + if isinstance(point, HistogramDataPoint): + if point.count > 0: + metric_point.value = point.sum / point.count + else: + metric_point.value = 0 + elif isinstance(point, NumberDataPoint): + metric_point.value = point.value + else: + metric_point.value = 0 + metric_points.append(metric_point) + return [ + MonitoringDataPoint( + version=base_monitoring_data_point.version, + instance=base_monitoring_data_point.instance, + role_name=base_monitoring_data_point.role_name, + machine_name=base_monitoring_data_point.machine_name, + stream_id=base_monitoring_data_point.stream_id, + timestamp=datetime.now(tz=timezone.utc), + metrics=metric_points, + documents=documents, + ) + ] + +# mypy: disable-error-code="assignment,union-attr" +def _get_span_document(span: ReadableSpan) -> Union[RemoteDependencyDocument, RequestDocument]: + duration = 0 + if span.end_time and span.start_time: + duration = span.end_time - span.start_time + status_code = span.attributes.get(SpanAttributes.HTTP_STATUS_CODE, "") # type: ignore + grpc_status_code = span.attributes.get(SpanAttributes.RPC_GRPC_STATUS_CODE, "") # type: ignore + span_kind = span.kind + url = _get_url(span_kind, span.attributes) + if span_kind in (SpanKind.CLIENT, SpanKind.PRODUCER, SpanKind.INTERNAL): + document = RemoteDependencyDocument( + document_type=_DocumentIngressDocumentType.RemoteDependency.value, + name=span.name, + command_name=url, + result_code=str(status_code), + duration=_ns_to_iso8601_string(duration), + ) + else: + if status_code: + code = str(status_code) + else: + code = str(grpc_status_code) + document = RequestDocument( + document_type=_DocumentIngressDocumentType.Request.value, + name=span.name, + url=url, + response_code=code, + duration=_ns_to_iso8601_string(duration), + ) + return document + +# mypy: disable-error-code="assignment" +def _get_log_record_document(log_data: LogData) -> Union[ExceptionDocument, TraceDocument]: + exc_type = log_data.log_record.attributes.get(SpanAttributes.EXCEPTION_TYPE) # type: ignore + exc_message = log_data.log_record.attributes.get(SpanAttributes.EXCEPTION_MESSAGE) # type: ignore + if exc_type is not None or exc_message is not None: + document = ExceptionDocument( + document_type=_DocumentIngressDocumentType.Exception.value, + exception_type=str(exc_type), + exception_message=str(exc_message), + ) + else: + document = TraceDocument( + document_type=_DocumentIngressDocumentType.Trace.value, + message=log_data.log_record.body, + ) + return document + + +# mypy: disable-error-code="assignment" +# pylint: disable=no-else-return +def _get_url(span_kind: SpanKind, attributes: Attributes) -> str: + if not attributes: + return "" + http_method = attributes.get(SpanAttributes.HTTP_METHOD) + if http_method: + http_scheme = attributes.get(SpanAttributes.HTTP_SCHEME) + # Client + if span_kind in (SpanKind.CLIENT, SpanKind.PRODUCER): + http_url = attributes.get(SpanAttributes.HTTP_URL) + if http_url: + return str(http_url) + + host = attributes.get(SpanAttributes.NET_PEER_NAME) + port = attributes.get(SpanAttributes.NET_PEER_PORT, "") + ip = attributes.get(SpanAttributes.NET_PEER_IP) + if http_scheme: + if host: + return f"{http_scheme}://{host}:{port}" + else: + return f"{http_scheme}://{ip}:{port}" + else: # Server + host = attributes.get(SpanAttributes.NET_HOST_NAME) + port = attributes.get(SpanAttributes.NET_HOST_PORT) + http_target = attributes.get(SpanAttributes.HTTP_TARGET, "") + if http_scheme and host: + http_host = attributes.get(SpanAttributes.HTTP_HOST) + if http_host: + return f"{http_scheme}://{http_host}:{port}{http_target}" + return "" + + +def _ns_to_iso8601_string(nanoseconds: int) -> str: + seconds, nanoseconds_remainder = divmod(nanoseconds, 1e9) + microseconds = nanoseconds_remainder // 1000 # Convert nanoseconds to microseconds + dt = datetime.utcfromtimestamp(seconds) + dt_microseconds = timedelta(microseconds=microseconds) + dt_with_microseconds = dt + dt_microseconds + return dt_with_microseconds.isoformat() diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py index a1510d736290..9ef51c6202f5 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/_utils.py @@ -116,7 +116,7 @@ def _getlocale(): } -def ns_to_duration(nanoseconds: int): +def ns_to_duration(nanoseconds: int) -> str: value = (nanoseconds + 500000) // 1000000 # duration in milliseconds value, microseconds = divmod(value, 1000) value, seconds = divmod(value, 60) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_exporter.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_exporter.py index d053b3da4e59..18f40e87c303 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_exporter.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_exporter.py @@ -27,6 +27,11 @@ _Response, _UnsuccessfulQuickPulsePostError, ) +from azure.monitor.opentelemetry.exporter._quickpulse._state import ( + _get_global_quickpulse_state, + _set_global_quickpulse_state, + _QuickpulseState, +) def throw(exc_type, *args, **kwargs): @@ -39,6 +44,7 @@ def func(*_args, **_kwargs): class TestQuickpulse(unittest.TestCase): @classmethod def setUpClass(cls): + _set_global_quickpulse_state(_QuickpulseState.PING_SHORT) cls._resource = Resource.create( { ResourceAttributes.SERVICE_INSTANCE_ID: "test_instance", @@ -209,10 +215,9 @@ def test_quickpulsereader_init(self, task_mock): self._data_point, ) self.assertEqual(reader._exporter, self._exporter) - self.assertEqual(reader._quick_pulse_state, _QuickpulseState.PING_SHORT) + self.assertEqual(_get_global_quickpulse_state(), _QuickpulseState.PING_SHORT) self.assertEqual(reader._base_monitoring_data_point, self._data_point) self.assertEqual(reader._elapsed_num_seconds, 0) - self.assertEqual(reader._elapsed_num_seconds, 0) self.assertEqual(reader._worker, task_inst_mock) task_mock.assert_called_with( interval=_POST_INTERVAL_SECONDS, @@ -231,7 +236,7 @@ def test_quickpulsereader_ticker_ping_true(self, task_mock, ping_mock): self._exporter, self._data_point, ) - reader._quick_pulse_state = _QuickpulseState.PING_SHORT + _set_global_quickpulse_state(_QuickpulseState.PING_SHORT) reader._elapsed_num_seconds = _QuickpulseState.PING_SHORT.value ping_mock.return_value = _Response( None, @@ -244,7 +249,7 @@ def test_quickpulsereader_ticker_ping_true(self, task_mock, ping_mock): ping_mock.assert_called_once_with( self._data_point, ) - self.assertEqual(reader._quick_pulse_state, _QuickpulseState.POST_SHORT) + self.assertEqual(_get_global_quickpulse_state(), _QuickpulseState.POST_SHORT) self.assertEqual(reader._elapsed_num_seconds, 1) # TODO: Other ticker cases @@ -267,7 +272,6 @@ def test_quickpulsereader_receive_metrics(self, task_mock, export_mock): self._metrics_data, timeout_millis=20_000, base_monitoring_data_point=self._data_point, - documents=[], ) @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._exporter._QuickpulseExporter.export") diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_live_metrics.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_live_metrics.py index 0b0f512865bf..f1699bd6beb7 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_live_metrics.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_live_metrics.py @@ -7,6 +7,8 @@ from opentelemetry.sdk.metrics import MeterProvider from opentelemetry.sdk.resources import Resource, ResourceAttributes +from opentelemetry.semconv.trace import SpanAttributes +from opentelemetry.trace import SpanKind from azure.monitor.opentelemetry.exporter._generated.models import ContextTagKeys from azure.monitor.opentelemetry.exporter._quickpulse._exporter import ( @@ -17,6 +19,11 @@ enable_live_metrics, _QuickpulseManager, ) +from azure.monitor.opentelemetry.exporter._quickpulse._state import ( + _get_global_quickpulse_state, + _set_global_quickpulse_state, + _QuickpulseState, +) from azure.monitor.opentelemetry.exporter._utils import ( _get_sdk_version, _populate_part_a_fields, @@ -36,6 +43,13 @@ def test_enable_live_metrics(self, manager_mock): class TestQuickpulseManager(unittest.TestCase): + @classmethod + def setUpClass(cls): + _set_global_quickpulse_state(_QuickpulseState.PING_SHORT) + + @classmethod + def tearDownClass(cls): + _set_global_quickpulse_state(_QuickpulseState.OFFLINE) @mock.patch("opentelemetry.sdk.trace.id_generator.RandomIdGenerator.generate_trace_id") def test_init(self, generator_mock): @@ -51,6 +65,7 @@ def test_init(self, generator_mock): connection_string="InstrumentationKey=4321abcd-5678-4efa-8abc-1234567890ac;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/", resource=resource, ) + self.assertEqual(_get_global_quickpulse_state(), _QuickpulseState.PING_SHORT) self.assertTrue(isinstance(qpm._exporter, _QuickpulseExporter)) self.assertEqual( qpm._exporter._live_endpoint, @@ -118,3 +133,117 @@ def test_singleton(self): qpm2._base_monitoring_data_point.role_name, part_a_fields.get(ContextTagKeys.AI_CLOUD_ROLE, "") ) + + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._append_quickpulse_document") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._get_span_document") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._is_post_state") + def test_record_span_server_success(self, post_state_mock, span_doc_mock, append_doc_mock): + post_state_mock.return_value = True + span_doc = mock.Mock() + span_doc_mock.return_value = span_doc + span_mock = mock.Mock() + span_mock.end_time = 10 + span_mock.start_time = 5 + span_mock.status.is_ok = True + span_mock.kind = SpanKind.SERVER + qpm = _QuickpulseManager( + connection_string="InstrumentationKey=4321abcd-5678-4efa-8abc-1234567890ac;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/", + resource=Resource.create(), + ) + qpm._request_rate_counter = mock.Mock() + qpm._request_duration = mock.Mock() + qpm._record_span(span_mock) + append_doc_mock.assert_called_once_with(span_doc) + qpm._request_rate_counter.add.assert_called_once_with(1) + qpm._request_duration.record.assert_called_once_with(5 / 1e9) + + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._append_quickpulse_document") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._get_span_document") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._is_post_state") + def test_record_span_server_failure(self, post_state_mock, span_doc_mock, append_doc_mock): + post_state_mock.return_value = True + span_doc = mock.Mock() + span_doc_mock.return_value = span_doc + span_mock = mock.Mock() + span_mock.end_time = 10 + span_mock.start_time = 5 + span_mock.status.is_ok = False + span_mock.kind = SpanKind.SERVER + qpm = _QuickpulseManager( + connection_string="InstrumentationKey=4321abcd-5678-4efa-8abc-1234567890ac;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/", + resource=Resource.create(), + ) + qpm._request_failed_rate_counter = mock.Mock() + qpm._request_duration = mock.Mock() + qpm._record_span(span_mock) + append_doc_mock.assert_called_once_with(span_doc) + qpm._request_failed_rate_counter.add.assert_called_once_with(1) + qpm._request_duration.record.assert_called_once_with(5 / 1e9) + + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._append_quickpulse_document") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._get_span_document") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._is_post_state") + def test_record_span_dep_success(self, post_state_mock, span_doc_mock, append_doc_mock): + post_state_mock.return_value = True + span_doc = mock.Mock() + span_doc_mock.return_value = span_doc + span_mock = mock.Mock() + span_mock.end_time = 10 + span_mock.start_time = 5 + span_mock.status.is_ok = True + span_mock.kind = SpanKind.CLIENT + qpm = _QuickpulseManager( + connection_string="InstrumentationKey=4321abcd-5678-4efa-8abc-1234567890ac;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/", + resource=Resource.create(), + ) + qpm._dependency_rate_counter = mock.Mock() + qpm._dependency_duration = mock.Mock() + qpm._record_span(span_mock) + append_doc_mock.assert_called_once_with(span_doc) + qpm._dependency_rate_counter.add.assert_called_once_with(1) + qpm._dependency_duration.record.assert_called_once_with(5 / 1e9) + + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._append_quickpulse_document") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._get_span_document") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._is_post_state") + def test_record_span_dep_failure(self, post_state_mock, span_doc_mock, append_doc_mock): + post_state_mock.return_value = True + span_doc = mock.Mock() + span_doc_mock.return_value = span_doc + span_mock = mock.Mock() + span_mock.end_time = 10 + span_mock.start_time = 5 + span_mock.status.is_ok = False + span_mock.kind = SpanKind.CLIENT + qpm = _QuickpulseManager( + connection_string="InstrumentationKey=4321abcd-5678-4efa-8abc-1234567890ac;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/", + resource=Resource.create(), + ) + qpm._dependency_failure_rate_counter = mock.Mock() + qpm._dependency_duration = mock.Mock() + qpm._record_span(span_mock) + append_doc_mock.assert_called_once_with(span_doc) + qpm._dependency_failure_rate_counter.add.assert_called_once_with(1) + qpm._dependency_duration.record.assert_called_once_with(5 / 1e9) + + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._append_quickpulse_document") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._get_log_record_document") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._live_metrics._is_post_state") + def test_record_log_exception(self, post_state_mock, log_doc_mock, append_doc_mock): + post_state_mock.return_value = True + log_record_doc = mock.Mock() + log_doc_mock.return_value = log_record_doc + log_data_mock = mock.Mock() + attributes = { + SpanAttributes.EXCEPTION_TYPE: "exc_type", + SpanAttributes.EXCEPTION_MESSAGE: "exc_msg", + } + log_data_mock.log_record.attributes = attributes + qpm = _QuickpulseManager( + connection_string="InstrumentationKey=4321abcd-5678-4efa-8abc-1234567890ac;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/", + resource=Resource.create(), + ) + qpm._exception_rate_counter = mock.Mock() + qpm._record_log_record(log_data_mock) + append_doc_mock.assert_called_once_with(log_record_doc) + qpm._exception_rate_counter.add.assert_called_once_with(1) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_processor.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_processor.py new file mode 100644 index 000000000000..f3948b31e593 --- /dev/null +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_processor.py @@ -0,0 +1,44 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +import unittest +from unittest import mock + +from azure.monitor.opentelemetry.exporter._quickpulse._processor import ( + _QuickpulseLogRecordProcessor, + _QuickpulseSpanProcessor, +) +from azure.monitor.opentelemetry.exporter._quickpulse._live_metrics import _QuickpulseManager + + +class TestQuickpulseLogRecordProcessor(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.qpm = mock.Mock() + _QuickpulseManager._instance = cls.qpm + + @classmethod + def tearDownClass(cls) -> None: + _QuickpulseManager._instance = None + + def test_emit(self): + processor = _QuickpulseLogRecordProcessor() + log_data = mock.Mock() + processor.emit(log_data) + self.qpm._record_log_record.assert_called_once_with(log_data) + + +class TestQuickpulseSpanProcessor(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.qpm = mock.Mock() + _QuickpulseManager._instance = cls.qpm + + @classmethod + def tearDownClass(cls) -> None: + _QuickpulseManager._instance = None + + def test_on_end(self): + processor = _QuickpulseSpanProcessor() + span = mock.Mock() + processor.on_end(span) + self.qpm._record_span.assert_called_once_with(span) diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_utils.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_utils.py new file mode 100644 index 000000000000..ea03e61f5a7d --- /dev/null +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/quickpulse/test_utils.py @@ -0,0 +1,204 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +from datetime import datetime +import unittest +from unittest import mock + +from opentelemetry.sdk.metrics.export import HistogramDataPoint, NumberDataPoint +from opentelemetry.semconv.trace import SpanAttributes +from opentelemetry.trace import SpanKind + +from azure.monitor.opentelemetry.exporter._quickpulse._constants import ( + _COMMITTED_BYTES_NAME, + _DocumentIngressDocumentType, +) +from azure.monitor.opentelemetry.exporter._quickpulse._generated.models._models import ( + Exception, + MetricPoint, + MonitoringDataPoint, + RemoteDependency, + Request, + Trace, +) +from azure.monitor.opentelemetry.exporter._quickpulse._utils import ( + _get_span_document, + _get_log_record_document, + _metric_to_quick_pulse_data_points, +) + + +class TestUtils(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.base_mdp = MonitoringDataPoint( + version=1.0, + instance="test_instance", + role_name="test_role_name", + machine_name="test_machine_name", + stream_id="test_stream_id" + ) + + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._utils.datetime") + def test_metric_to_qp_data_point_hist(self, datetime_mock): + point = HistogramDataPoint( + {}, + 0, + 0, + 2, + 10, + [1,1,0], + [0,10,20], + 0, + 5, + ) + metric = mock.Mock() + metric.name = _COMMITTED_BYTES_NAME[0] + metric.data.data_points = [point] + scope_metric = mock.Mock() + scope_metric.metrics = [metric] + resource_metric = mock.Mock() + resource_metric.scope_metrics = [scope_metric] + metric_data = mock.Mock() + metric_data.resource_metrics = [resource_metric] + metric_point = MetricPoint( + name=_COMMITTED_BYTES_NAME[1], + weight=1, + value=5 + ) + documents = [mock.Mock()] + date_now = datetime.now() + datetime_mock.now.return_value = date_now + mdp = _metric_to_quick_pulse_data_points(metric_data, self.base_mdp, documents)[0] + self.assertEqual(mdp.version, self.base_mdp.version) + self.assertEqual(mdp.instance, self.base_mdp.instance) + self.assertEqual(mdp.role_name, self.base_mdp.role_name) + self.assertEqual(mdp.machine_name, self.base_mdp.machine_name) + self.assertEqual(mdp.stream_id, self.base_mdp.stream_id) + self.assertEqual(mdp.timestamp, date_now) + self.assertEqual(mdp.metrics, [metric_point]) + self.assertEqual(mdp.documents, documents) + + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._utils.datetime") + def test_metric_to_qp_data_point_num(self, datetime_mock): + point = NumberDataPoint( + {}, + 0, + 0, + 7, + ) + metric = mock.Mock() + metric.name = _COMMITTED_BYTES_NAME[0] + metric.data.data_points = [point] + scope_metric = mock.Mock() + scope_metric.metrics = [metric] + resource_metric = mock.Mock() + resource_metric.scope_metrics = [scope_metric] + metric_data = mock.Mock() + metric_data.resource_metrics = [resource_metric] + metric_point = MetricPoint( + name=_COMMITTED_BYTES_NAME[1], + weight=1, + value=7 + ) + documents = [mock.Mock()] + date_now = datetime.now() + datetime_mock.now.return_value = date_now + mdp = _metric_to_quick_pulse_data_points(metric_data, self.base_mdp, documents)[0] + self.assertEqual(mdp.version, self.base_mdp.version) + self.assertEqual(mdp.instance, self.base_mdp.instance) + self.assertEqual(mdp.role_name, self.base_mdp.role_name) + self.assertEqual(mdp.machine_name, self.base_mdp.machine_name) + self.assertEqual(mdp.stream_id, self.base_mdp.stream_id) + self.assertEqual(mdp.timestamp, date_now) + self.assertEqual(mdp.metrics, [metric_point]) + self.assertEqual(mdp.documents, documents) + + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._utils._ns_to_iso8601_string") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._utils._get_url") + def test_get_span_document_client(self, url_mock, iso_mock): + span_mock = mock.Mock() + span_mock.name = "test_span" + span_mock.end_time = 10 + span_mock.start_time = 4 + span_mock.attributes = { + SpanAttributes.HTTP_STATUS_CODE: "200", + SpanAttributes.RPC_GRPC_STATUS_CODE: "400", + } + span_mock.kind = SpanKind.CLIENT + url_mock.return_value = "test_url" + iso_mock.return_value = "1000" + doc = _get_span_document(span_mock) + self.assertTrue(isinstance(doc, RemoteDependency)) + self.assertEqual(doc.document_type, _DocumentIngressDocumentType.RemoteDependency.value) + self.assertEqual(doc.name, "test_span") + self.assertEqual(doc.command_name, "test_url") + self.assertEqual(doc.result_code, "200") + self.assertEqual(doc.duration, "1000") + + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._utils._ns_to_iso8601_string") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._utils._get_url") + def test_get_span_document_server(self, url_mock, iso_mock): + span_mock = mock.Mock() + span_mock.name = "test_span" + span_mock.end_time = 10 + span_mock.start_time = 4 + span_mock.attributes = { + SpanAttributes.HTTP_STATUS_CODE: "200", + SpanAttributes.RPC_GRPC_STATUS_CODE: "400", + } + span_mock.kind = SpanKind.SERVER + url_mock.return_value = "test_url" + iso_mock.return_value = "1000" + doc = _get_span_document(span_mock) + self.assertTrue(isinstance(doc, Request)) + self.assertEqual(doc.document_type, _DocumentIngressDocumentType.Request.value) + self.assertEqual(doc.name, "test_span") + self.assertEqual(doc.url, "test_url") + self.assertEqual(doc.response_code, "200") + self.assertEqual(doc.duration, "1000") + + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._utils._ns_to_iso8601_string") + @mock.patch("azure.monitor.opentelemetry.exporter._quickpulse._utils._get_url") + def test_get_span_document_server_grpc_status(self, url_mock, iso_mock): + span_mock = mock.Mock() + span_mock.name = "test_span" + span_mock.end_time = 10 + span_mock.start_time = 4 + span_mock.attributes = { + SpanAttributes.RPC_GRPC_STATUS_CODE: "400", + } + span_mock.kind = SpanKind.SERVER + url_mock.return_value = "test_url" + iso_mock.return_value = "1000" + doc = _get_span_document(span_mock) + self.assertTrue(isinstance(doc, Request)) + self.assertEqual(doc.document_type, _DocumentIngressDocumentType.Request.value) + self.assertEqual(doc.name, "test_span") + self.assertEqual(doc.url, "test_url") + self.assertEqual(doc.response_code, "400") + self.assertEqual(doc.duration, "1000") + + def test_get_log_record_document_server_exc(self): + log_record = mock.Mock() + log_record.attributes = { + SpanAttributes.EXCEPTION_TYPE: "exc_type", + SpanAttributes.EXCEPTION_MESSAGE: "exc_message", + } + log_data = mock.Mock() + log_data.log_record = log_record + doc = _get_log_record_document(log_data) + self.assertTrue(isinstance(doc, Exception)) + self.assertEqual(doc.document_type, _DocumentIngressDocumentType.Exception.value) + self.assertEqual(doc.exception_type, "exc_type") + self.assertEqual(doc.exception_message, "exc_message") + + def test_get_log_record_document_server_exc(self): + log_record = mock.Mock() + log_record.attributes = {} + log_record.body = "body" + log_data = mock.Mock() + log_data.log_record = log_record + doc = _get_log_record_document(log_data) + self.assertTrue(isinstance(doc, Trace)) + self.assertEqual(doc.document_type, _DocumentIngressDocumentType.Trace.value) + self.assertEqual(doc.message, "body") diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index 554e3e691a59..c4f267ac827d 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -17,6 +17,17 @@ ### Other Changes +## 1.2.1 (2024-01-31) + +### Bugs Fixed + +- Fixed certain keyword arguments from not being propagated when using `MetricsQueryClient`. + +### Other Changes + +- Internal updates to generated code. +- Bumped minimum dependency on `azure-core` to `>=1.28.0`. + ## 1.3.0b2 (2023-11-20) ### Other Changes diff --git a/sdk/monitor/azure-monitor-query/assets.json b/sdk/monitor/azure-monitor-query/assets.json index 91bc7a37f44c..0dc4dd023e8e 100644 --- a/sdk/monitor/azure-monitor-query/assets.json +++ b/sdk/monitor/azure-monitor-query/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/monitor/azure-monitor-query", - "Tag": "python/monitor/azure-monitor-query_152690fb22" + "Tag": "python/monitor/azure-monitor-query_8640f7c705" } diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/_serialization.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/_serialization.py index baa661cb82d2..2f781d740827 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/_serialization.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/_serialization.py @@ -170,13 +170,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -545,7 +538,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +554,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +642,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -994,7 +987,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1370,7 +1363,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1390,7 +1383,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1443,7 +1436,7 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) @@ -1514,14 +1507,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1577,7 +1570,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1699,7 +1692,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1756,7 +1749,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/aio/operations/_operations.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/aio/operations/_operations.py index 46a3b69d6b6c..9bfabb9251ea 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/aio/operations/_operations.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/aio/operations/_operations.py @@ -384,9 +384,6 @@ async def execute( :keyword prefer: Optional. The prefer header to set server timeout, query statistics and visualization information. Default value is None. :paramtype prefer: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -829,9 +826,6 @@ async def resource_execute( :keyword prefer: Optional. The prefer header to set server timeout, query statistics and visualization information. Default value is None. :paramtype prefer: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -1182,9 +1176,6 @@ async def batch(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: :param body: The batch request body. Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -1669,9 +1660,6 @@ async def resource_execute_xms( :keyword prefer: Optional. The prefer header to set server timeout, query statistics and visualization information. Default value is None. :paramtype prefer: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_client.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_client.py index 55fc0a6c71e6..888ad95aaf75 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_client.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_client.py @@ -29,6 +29,9 @@ class MonitorMetricsClient: # pylint: disable=client-accepts-api-version-keywor :vartype metric_namespaces: monitor_metrics_client.operations.MetricNamespacesOperations :keyword endpoint: Service URL. Default value is "https://management.azure.com". :paramtype endpoint: str + :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_configuration.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_configuration.py index 9e2649da7073..4fb1b263e1ea 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_configuration.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_configuration.py @@ -18,10 +18,16 @@ class MonitorMetricsClientConfiguration: # pylint: disable=too-many-instance-at Note that all parameters used to create this instance are saved as instance attributes. + + :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__(self, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2024-02-01") + self.api_version = api_version kwargs.setdefault("sdk_moniker", "monitor-query/{}".format(VERSION)) self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_serialization.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_serialization.py index baa661cb82d2..2f781d740827 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_serialization.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/_serialization.py @@ -170,13 +170,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -545,7 +538,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +554,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +642,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -994,7 +987,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1370,7 +1363,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1390,7 +1383,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1443,7 +1436,7 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) @@ -1514,14 +1507,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1577,7 +1570,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1699,7 +1692,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1756,7 +1749,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/_client.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/_client.py index 482781e9a6ed..fefa6363e0ac 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/_client.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/_client.py @@ -29,6 +29,9 @@ class MonitorMetricsClient: # pylint: disable=client-accepts-api-version-keywor :vartype metric_namespaces: monitor_metrics_client.aio.operations.MetricNamespacesOperations :keyword endpoint: Service URL. Default value is "https://management.azure.com". :paramtype endpoint: str + :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/_configuration.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/_configuration.py index 0c7eae382445..ef23b1ac5e5d 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/_configuration.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/_configuration.py @@ -18,10 +18,16 @@ class MonitorMetricsClientConfiguration: # pylint: disable=too-many-instance-at Note that all parameters used to create this instance are saved as instance attributes. + + :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__(self, **kwargs: Any) -> None: + api_version: str = kwargs.pop("api_version", "2024-02-01") + self.api_version = api_version kwargs.setdefault("sdk_moniker", "monitor-query/{}".format(VERSION)) self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/operations/_operations.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/operations/_operations.py index 184799a008cd..b04625e97eec 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/operations/_operations.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/aio/operations/_operations.py @@ -9,6 +9,7 @@ import datetime import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, cast +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -121,9 +122,8 @@ def list(self, resource_uri: str, *, metricnamespace: Optional[str] = None, **kw } """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01")) cls: ClsType[JSON] = kwargs.pop("cls", None) error_map = { @@ -140,14 +140,25 @@ def prepare_request(next_link=None): _request = build_metric_definitions_list_request( resource_uri=resource_uri, metricnamespace=metricnamespace, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: - _request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) _request.url = self._client.format_url(_request.url) return _request @@ -365,9 +376,8 @@ async def list( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01")) cls: ClsType[JSON] = kwargs.pop("cls", None) _request = build_metrics_list_request( @@ -384,7 +394,7 @@ async def list( auto_adjust_timegrain=auto_adjust_timegrain, validate_dimensions=validate_dimensions, rollupby=rollupby, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) @@ -460,9 +470,8 @@ def list(self, resource_uri: str, *, start_time: Optional[str] = None, **kwargs: } """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) cls: ClsType[JSON] = kwargs.pop("cls", None) error_map = { @@ -479,14 +488,25 @@ def prepare_request(next_link=None): _request = build_metric_namespaces_list_request( resource_uri=resource_uri, start_time=start_time, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: - _request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) _request.url = self._client.format_url(_request.url) return _request diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_client.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_client.py index 413b9eaad160..3574817422ed 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_client.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_client.py @@ -27,7 +27,7 @@ class MonitorBatchMetricsClient: # pylint: disable=client-accepts-api-version-k https://eastus.metrics.monitor.azure.com. The region should match the region of the requested resources. For global resources, the region should be 'global'. Required. :type endpoint: str - :keyword api_version: Api Version. Default value is "2023-10-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_configuration.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_configuration.py index 12b7d76ce904..16ba9df5b287 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_configuration.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_configuration.py @@ -23,13 +23,13 @@ class MonitorBatchMetricsClientConfiguration: # pylint: disable=too-many-instan https://eastus.metrics.monitor.azure.com. The region should match the region of the requested resources. For global resources, the region should be 'global'. Required. :type endpoint: str - :keyword api_version: Api Version. Default value is "2023-10-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-10-01") + api_version: str = kwargs.pop("api_version", "2024-02-01") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_serialization.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_serialization.py index baa661cb82d2..2f781d740827 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_serialization.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/_serialization.py @@ -170,13 +170,6 @@ def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], return None -try: - basestring # type: ignore - unicode_str = unicode # type: ignore -except NameError: - basestring = str - unicode_str = str - _LOGGER = logging.getLogger(__name__) try: @@ -545,7 +538,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -561,7 +554,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -649,7 +642,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) - local_node.text = unicode_str(new_attr) + local_node.text = str(new_attr) serialized.append(local_node) # type: ignore else: # JSON for k in reversed(keys): # type: ignore @@ -994,7 +987,7 @@ def serialize_object(self, attr, **kwargs): return self.serialize_basic(attr, self.basic_types[obj_type], **kwargs) if obj_type is _long_type: return self.serialize_long(attr) - if obj_type is unicode_str: + if obj_type is str: return self.serialize_unicode(attr) if obj_type is datetime.datetime: return self.serialize_iso(attr) @@ -1370,7 +1363,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): + def __init__(self, classes: Optional[Mapping[str, type]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1390,7 +1383,7 @@ def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} + self.dependencies: Dict[str, type] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1443,7 +1436,7 @@ def _deserialize(self, target_obj, data): response, class_name = self._classify_target(target_obj, data) - if isinstance(response, basestring): + if isinstance(response, str): return self.deserialize_data(data, response) elif isinstance(response, type) and issubclass(response, Enum): return self.deserialize_enum(data, response) @@ -1514,14 +1507,14 @@ def _classify_target(self, target, data): if target is None: return None, None - if isinstance(target, basestring): + if isinstance(target, str): try: target = self.dependencies[target] except KeyError: return target, target try: - target = target._classify(data, self.dependencies) + target = target._classify(data, self.dependencies) # type: ignore except AttributeError: pass # Target is not a Model, no classify return target, target.__class__.__name__ # type: ignore @@ -1577,7 +1570,7 @@ def _unpack_content(raw_data, content_type=None): if hasattr(raw_data, "_content_consumed"): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) - if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): + if isinstance(raw_data, (str, bytes)) or hasattr(raw_data, "read"): return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data @@ -1699,7 +1692,7 @@ def deserialize_object(self, attr, **kwargs): if isinstance(attr, ET.Element): # Do no recurse on XML, just return the tree as-is return attr - if isinstance(attr, basestring): + if isinstance(attr, str): return self.deserialize_basic(attr, "str") obj_type = type(attr) if obj_type in self.basic_types: @@ -1756,7 +1749,7 @@ def deserialize_basic(self, attr, data_type): if data_type == "bool": if attr in [True, False, 1, 0]: return bool(attr) - elif isinstance(attr, basestring): + elif isinstance(attr, str): if attr.lower() in ["true", "1"]: return True elif attr.lower() in ["false", "0"]: diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/_client.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/_client.py index 872d94ad0099..eb91181245ef 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/_client.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/_client.py @@ -27,7 +27,7 @@ class MonitorBatchMetricsClient: # pylint: disable=client-accepts-api-version-k https://eastus.metrics.monitor.azure.com. The region should match the region of the requested resources. For global resources, the region should be 'global'. Required. :type endpoint: str - :keyword api_version: Api Version. Default value is "2023-10-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/_configuration.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/_configuration.py index 1fe0508b3c5e..579e30041e20 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/_configuration.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/_configuration.py @@ -23,13 +23,13 @@ class MonitorBatchMetricsClientConfiguration: # pylint: disable=too-many-instan https://eastus.metrics.monitor.azure.com. The region should match the region of the requested resources. For global resources, the region should be 'global'. Required. :type endpoint: str - :keyword api_version: Api Version. Default value is "2023-10-01". Note that overriding this + :keyword api_version: Api Version. Default value is "2024-02-01". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, **kwargs: Any) -> None: - api_version: str = kwargs.pop("api_version", "2023-10-01") + api_version: str = kwargs.pop("api_version", "2024-02-01") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/operations/_operations.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/operations/_operations.py index 91827da37205..93d9e0df9386 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/operations/_operations.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/aio/operations/_operations.py @@ -465,9 +465,6 @@ async def batch( separate values for each city, you can specify 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries. Default value is None. :paramtype rollupby: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/operations/_operations.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/operations/_operations.py index fb1f0dcdec44..9b29ea972939 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/operations/_operations.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/batch/operations/_operations.py @@ -57,7 +57,7 @@ def build_metrics_batch_batch_request( _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -527,9 +527,6 @@ def batch( separate values for each city, you can specify 'RollUpBy=City' to see the results for Seattle and Tacoma rolled up into one timeseries. Default value is None. :paramtype rollupby: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/operations/_operations.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/operations/_operations.py index 609b991f0ac0..065052297ecc 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/operations/_operations.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/metrics/operations/_operations.py @@ -9,6 +9,7 @@ import datetime import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, cast +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -44,7 +45,7 @@ def build_metric_definitions_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,7 +87,7 @@ def build_metrics_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -136,7 +137,7 @@ def build_metric_namespaces_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -239,9 +240,8 @@ def list(self, resource_uri: str, *, metricnamespace: Optional[str] = None, **kw } """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01")) cls: ClsType[JSON] = kwargs.pop("cls", None) error_map = { @@ -258,14 +258,25 @@ def prepare_request(next_link=None): _request = build_metric_definitions_list_request( resource_uri=resource_uri, metricnamespace=metricnamespace, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: - _request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) _request.url = self._client.format_url(_request.url) return _request @@ -483,9 +494,8 @@ def list( error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01")) cls: ClsType[JSON] = kwargs.pop("cls", None) _request = build_metrics_list_request( @@ -502,7 +512,7 @@ def list( auto_adjust_timegrain=auto_adjust_timegrain, validate_dimensions=validate_dimensions, rollupby=rollupby, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) @@ -578,9 +588,8 @@ def list(self, resource_uri: str, *, start_time: Optional[str] = None, **kwargs: } """ _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + _params = kwargs.pop("params", {}) or {} - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2017-12-01-preview")) cls: ClsType[JSON] = kwargs.pop("cls", None) error_map = { @@ -597,14 +606,25 @@ def prepare_request(next_link=None): _request = build_metric_namespaces_list_request( resource_uri=resource_uri, start_time=start_time, - api_version=api_version, + api_version=self._config.api_version, headers=_headers, params=_params, ) _request.url = self._client.format_url(_request.url) else: - _request = HttpRequest("GET", next_link) + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) _request.url = self._client.format_url(_request.url) return _request diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/operations/_operations.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/operations/_operations.py index 8251268ac118..996cd0f82cbd 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/operations/_operations.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/_generated/operations/_operations.py @@ -589,9 +589,6 @@ def execute( :keyword prefer: Optional. The prefer header to set server timeout, query statistics and visualization information. Default value is None. :paramtype prefer: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -1034,9 +1031,6 @@ def resource_execute( :keyword prefer: Optional. The prefer header to set server timeout, query statistics and visualization information. Default value is None. :paramtype prefer: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -1387,9 +1381,6 @@ def batch(self, body: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: :param body: The batch request body. Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -1874,9 +1865,6 @@ def resource_execute_xms( :keyword prefer: Optional. The prefer header to set server timeout, query statistics and visualization information. Default value is None. :paramtype prefer: str - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: diff --git a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py index 657659065191..48115e494b19 100644 --- a/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py +++ b/sdk/monitor/azure-monitor-query/azure/monitor/query/aio/_metrics_query_client_async.py @@ -154,7 +154,7 @@ def list_metric_namespaces( namespaces. This should be provided as a datetime object. :paramtype start_time: Optional[~datetime.datetime] :return: An iterator like instance of either MetricNamespace or the result of cls(response) - :rtype: ~azure.core.paging.AsyncItemPaged[:class: `~azure.monitor.query.MetricNamespace`] + :rtype: ~azure.core.paging.AsyncItemPaged[~azure.monitor.query.MetricNamespace] :raises ~azure.core.exceptions.HttpResponseError: .. admonition:: Example: @@ -188,7 +188,7 @@ def list_metric_definitions( :keyword namespace: Metric namespace to query metric definitions for. :paramtype namespace: Optional[str] :return: An iterator like instance of either MetricDefinition or the result of cls(response) - :rtype: ~azure.core.paging.AsyncItemPaged[:class: `~azure.monitor.query.MetricDefinition`] + :rtype: ~azure.core.paging.AsyncItemPaged[~azure.monitor.query.MetricDefinition] :raises ~azure.core.exceptions.HttpResponseError: .. admonition:: Example: diff --git a/sdk/monitor/azure-monitor-query/setup.py b/sdk/monitor/azure-monitor-query/setup.py index b478e41d6023..1354d38a54ba 100644 --- a/sdk/monitor/azure-monitor-query/setup.py +++ b/sdk/monitor/azure-monitor-query/setup.py @@ -65,6 +65,7 @@ "Development Status :: 5 - Production/Stable", 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', @@ -86,7 +87,7 @@ 'pytyped': ['py.typed'], }, install_requires=[ - 'azure-core<2.0.0,>=1.28.0', + 'azure-core>=1.28.0', 'isodate>=0.6.0', "typing-extensions>=4.0.1" ] diff --git a/sdk/monitor/azure-monitor-query/swagger/README.md b/sdk/monitor/azure-monitor-query/swagger/README.md index 48798bb57067..4ee5183ca20f 100644 --- a/sdk/monitor/azure-monitor-query/swagger/README.md +++ b/sdk/monitor/azure-monitor-query/swagger/README.md @@ -35,7 +35,7 @@ These settings apply only when `--tag=release_query` is specified on the command ```yaml $(tag) == 'release_query' input-file: - - https://github.com/Azure/azure-rest-api-specs/blob/0373f0edc4414fd402603fac51d0df93f1f70507/specification/operationalinsights/data-plane/Microsoft.OperationalInsights/stable/2022-10-27/OperationalInsights.json + - https://github.com/Azure/azure-rest-api-specs/blob/0b64ca7cbe3af8cd13228dfb783a16b8272b8be2/specification/operationalinsights/data-plane/Microsoft.OperationalInsights/stable/2022-10-27/OperationalInsights.json output-folder: ../azure/monitor/query/_generated title: MonitorQueryClient description: Azure Monitor Query Python Client @@ -47,9 +47,9 @@ These settings apply only when `--tag=release_metrics` is specified on the comma ```yaml $(tag) == 'release_metrics' input-file: - - https://github.com/Azure/azure-rest-api-specs/blob/0373f0edc4414fd402603fac51d0df93f1f70507/specification/monitor/resource-manager/Microsoft.Insights/stable/2023-10-01/metricDefinitions_API.json - - https://github.com/Azure/azure-rest-api-specs/blob/0373f0edc4414fd402603fac51d0df93f1f70507/specification/monitor/resource-manager/Microsoft.Insights/stable/2023-10-01/metrics_API.json - - https://github.com/Azure/azure-rest-api-specs/blob/0373f0edc4414fd402603fac51d0df93f1f70507/specification/monitor/resource-manager/Microsoft.Insights/preview/2017-12-01-preview/metricNamespaces_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/0b64ca7cbe3af8cd13228dfb783a16b8272b8be2/specification/monitor/resource-manager/Microsoft.Insights/stable/2024-02-01/metricDefinitions_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/0b64ca7cbe3af8cd13228dfb783a16b8272b8be2/specification/monitor/resource-manager/Microsoft.Insights/stable/2024-02-01/metrics_API.json + - https://github.com/Azure/azure-rest-api-specs/blob/0b64ca7cbe3af8cd13228dfb783a16b8272b8be2/specification/monitor/resource-manager/Microsoft.Insights/stable/2024-02-01/metricNamespaces_API.json output-folder: ../azure/monitor/query/_generated/metrics title: MonitorMetricsClient description: Azure Monitor Metrics Python Client @@ -61,7 +61,7 @@ These settings apply only when `--tag=release_metrics` is specified on the comma ```yaml $(tag) == 'release_metrics_batch' input-file: - - https://github.com/Azure/azure-rest-api-specs/blob/0373f0edc4414fd402603fac51d0df93f1f70507/specification/monitor/data-plane/Microsoft.Insights/stable/2023-10-01/metricBatch.json + - https://github.com/Azure/azure-rest-api-specs/blob/0b64ca7cbe3af8cd13228dfb783a16b8272b8be2/specification/monitor/data-plane/Microsoft.Insights/stable/2024-02-01/metricBatch.json output-folder: ../azure/monitor/query/_generated/metrics/batch title: MonitorBatchMetricsClient description: Azure Monitor Batch Metrics Python Client diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/_meta.json b/sdk/notificationhubs/azure-mgmt-notificationhubs/_meta.json index f568fcc7a856..45c72e644a6b 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/_meta.json +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/_meta.json @@ -1,11 +1,11 @@ { - "commit": "a2da92ad78961529a087f9d0e65394174ac50794", + "commit": "df9cda2cafdec76d6d9474aa11c5ab8d901ecc49", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.2.1", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.7.1", + "@autorest/modelerfour@4.26.2" ], - "autorest_command": "autorest specification/notificationhubs/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/notificationhubs/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/python@6.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", "readme": "specification/notificationhubs/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/__init__.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/__init__.py index dc3ad97a57c9..fd53206615b1 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/__init__.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/__init__.py @@ -6,20 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._notification_hubs_management_client import NotificationHubsManagementClient +from ._notification_hubs_rp_client import NotificationHubsRPClient from ._version import VERSION __version__ = VERSION try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk __all__ = [ - "NotificationHubsManagementClient", + "NotificationHubsRPClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_configuration.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_configuration.py index 60d03cfabded..84317a245c0f 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_configuration.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,35 +14,29 @@ from ._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class NotificationHubsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for NotificationHubsManagementClient. +class NotificationHubsRPClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for NotificationHubsRPClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(NotificationHubsManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-04-01") # type: Literal["2017-04-01"] + super(NotificationHubsRPClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -57,10 +50,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs kwargs.setdefault("sdk_moniker", "mgmt-notificationhubs/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, **kwargs # type: Any - ): - # type: (...) -> None + def _configure(self, **kwargs: Any) -> None: self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_notification_hubs_management_client.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_notification_hubs_rp_client.py similarity index 72% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_notification_hubs_management_client.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_notification_hubs_rp_client.py index 85f58549fd87..2a5898b95de6 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_notification_hubs_management_client.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_notification_hubs_rp_client.py @@ -12,34 +12,41 @@ from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from . import models -from ._configuration import NotificationHubsManagementClientConfiguration +from . import models as _models +from ._configuration import NotificationHubsRPClientConfiguration from ._serialization import Deserializer, Serializer -from .operations import NamespacesOperations, NotificationHubsOperations, Operations +from .operations import ( + NamespacesOperations, + NotificationHubsOperations, + Operations, + PrivateEndpointConnectionsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class NotificationHubsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure NotificationHub client. +class NotificationHubsRPClient: # pylint: disable=client-accepts-api-version-keyword + """Microsoft Notification Hubs Resource Provider REST API. - :ivar operations: Operations operations - :vartype operations: azure.mgmt.notificationhubs.operations.Operations - :ivar namespaces: NamespacesOperations operations - :vartype namespaces: azure.mgmt.notificationhubs.operations.NamespacesOperations :ivar notification_hubs: NotificationHubsOperations operations :vartype notification_hubs: azure.mgmt.notificationhubs.operations.NotificationHubsOperations + :ivar namespaces: NamespacesOperations operations + :vartype namespaces: azure.mgmt.notificationhubs.operations.NamespacesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.notificationhubs.operations.Operations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.notificationhubs.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -52,20 +59,23 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = NotificationHubsManagementClientConfiguration( + self._config = NotificationHubsRPClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.notification_hubs = NotificationHubsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. @@ -89,15 +99,12 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy.url = self._client.format_url(request_copy.url) return self._client.send_request(request_copy, **kwargs) - def close(self): - # type: () -> None + def close(self) -> None: self._client.close() - def __enter__(self): - # type: () -> NotificationHubsManagementClient + def __enter__(self) -> "NotificationHubsRPClient": self._client.__enter__() return self - def __exit__(self, *exc_details): - # type: (Any) -> None + def __exit__(self, *exc_details: Any) -> None: self._client.__exit__(*exc_details) diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_serialization.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_serialization.py index 7c1dedb5133d..4bae2292227b 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_serialization.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_serialization.py @@ -25,6 +25,7 @@ # -------------------------------------------------------------------------- # pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false from base64 import b64decode, b64encode import calendar @@ -37,23 +38,38 @@ import re import sys import codecs +from typing import ( + Dict, + Any, + cast, + Optional, + Union, + AnyStr, + IO, + Mapping, + Callable, + TypeVar, + MutableMapping, + Type, + List, + Mapping, +) try: from urllib import quote # type: ignore except ImportError: - from urllib.parse import quote # type: ignore + from urllib.parse import quote import xml.etree.ElementTree as ET -import isodate - -from typing import Dict, Any, cast, TYPE_CHECKING +import isodate # type: ignore from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback +from azure.core.serialization import NULL as AzureCoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") -if TYPE_CHECKING: - from typing import Optional, Union, AnyStr, IO, Mapping +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] class RawDeserializer: @@ -65,8 +81,7 @@ class RawDeserializer: CONTEXT_NAME = "deserialized_data" @classmethod - def deserialize_from_text(cls, data, content_type=None): - # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: Optional[str] = None) -> Any: """Decode data according to content-type. Accept a stream of data as well, but will be load at once in memory for now. @@ -132,8 +147,7 @@ def _json_attemp(data): raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod - def deserialize_from_http_generics(cls, body_bytes, headers): - # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + def deserialize_from_http_generics(cls, body_bytes: Optional[Union[AnyStr, IO]], headers: Mapping) -> Any: """Deserialize from HTTP response. Use bytes and headers to NOT use any requests/aiohttp or whatever @@ -160,8 +174,8 @@ def deserialize_from_http_generics(cls, body_bytes, headers): basestring # type: ignore unicode_str = unicode # type: ignore except NameError: - basestring = str # type: ignore - unicode_str = str # type: ignore + basestring = str + unicode_str = str _LOGGER = logging.getLogger(__name__) @@ -188,7 +202,7 @@ def dst(self, dt): try: - from datetime import timezone as _FixedOffset + from datetime import timezone as _FixedOffset # type: ignore except ImportError: # Python 2.7 class _FixedOffset(datetime.tzinfo): # type: ignore @@ -219,7 +233,7 @@ def __getinitargs__(self): try: from datetime import timezone - TZ_UTC = timezone.utc # type: ignore + TZ_UTC = timezone.utc except ImportError: TZ_UTC = UTC() # type: ignore @@ -276,12 +290,12 @@ class Model(object): serialization and deserialization. """ - _subtype_map = {} # type: Dict[str, Dict[str, Any]] - _attribute_map = {} # type: Dict[str, Dict[str, Any]] - _validation = {} # type: Dict[str, Dict[str, Any]] + _subtype_map: Dict[str, Dict[str, Any]] = {} + _attribute_map: Dict[str, Dict[str, Any]] = {} + _validation: Dict[str, Dict[str, Any]] = {} - def __init__(self, **kwargs): - self.additional_properties = {} + def __init__(self, **kwargs: Any) -> None: + self.additional_properties: Dict[str, Any] = {} for k in kwargs: if k not in self._attribute_map: _LOGGER.warning("%s is not a known attribute of class %s and will be ignored", k, self.__class__) @@ -290,27 +304,27 @@ def __init__(self, **kwargs): else: setattr(self, k, kwargs[k]) - def __eq__(self, other): + def __eq__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" if isinstance(other, self.__class__): return self.__dict__ == other.__dict__ return False - def __ne__(self, other): + def __ne__(self, other: Any) -> bool: """Compare objects by comparing all attributes.""" return not self.__eq__(other) - def __str__(self): + def __str__(self) -> str: return str(self.__dict__) @classmethod - def enable_additional_properties_sending(cls): + def enable_additional_properties_sending(cls) -> None: cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} @classmethod - def is_xml_model(cls): + def is_xml_model(cls) -> bool: try: - cls._xml_map + cls._xml_map # type: ignore except AttributeError: return False return True @@ -319,13 +333,13 @@ def is_xml_model(cls): def _create_xml_node(cls): """Create XML node.""" try: - xml_map = cls._xml_map + xml_map = cls._xml_map # type: ignore except AttributeError: xml_map = {} return _create_xml_node(xml_map.get("name", cls.__name__), xml_map.get("prefix", None), xml_map.get("ns", None)) - def serialize(self, keep_readonly=False, **kwargs): + def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: """Return the JSON that would be sent to azure from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -339,8 +353,13 @@ def serialize(self, keep_readonly=False, **kwargs): serializer = Serializer(self._infer_class_models()) return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) - def as_dict(self, keep_readonly=True, key_transformer=attribute_transformer, **kwargs): - """Return a dict that can be JSONify using json.dump. + def as_dict( + self, + keep_readonly: bool = True, + key_transformer: Callable[[str, Dict[str, Any], Any], Any] = attribute_transformer, + **kwargs: Any + ) -> JSON: + """Return a dict that can be serialized using json.dump. Advanced usage might optionally use a callback as parameter: @@ -387,7 +406,7 @@ def _infer_class_models(cls): return client_models @classmethod - def deserialize(cls, data, content_type=None): + def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = None) -> ModelType: """Parse a str using the RestAPI syntax and return a model. :param str data: A str using RestAPI structure. JSON by default. @@ -399,7 +418,12 @@ def deserialize(cls, data, content_type=None): return deserializer(cls.__name__, data, content_type=content_type) @classmethod - def from_dict(cls, data, key_extractors=None, content_type=None): + def from_dict( + cls: Type[ModelType], + data: Any, + key_extractors: Optional[Callable[[str, Dict[str, Any], Any], Any]] = None, + content_type: Optional[str] = None, + ) -> ModelType: """Parse a dict using given key extractor return a model. By default consider key @@ -412,8 +436,8 @@ def from_dict(cls, data, key_extractors=None, content_type=None): :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - deserializer.key_extractors = ( - [ + deserializer.key_extractors = ( # type: ignore + [ # type: ignore attribute_key_case_insensitive_extractor, rest_key_case_insensitive_extractor, last_rest_key_case_insensitive_extractor, @@ -453,7 +477,7 @@ def _classify(cls, response, objects): return cls flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) try: - return objects[flatten_mapping_type[subtype_value]] + return objects[flatten_mapping_type[subtype_value]] # type: ignore except KeyError: _LOGGER.warning( "Subtype value %s has no mapping, use base class %s.", @@ -521,7 +545,7 @@ class Serializer(object): "multiple": lambda x, y: x % y != 0, } - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): self.serialize_type = { "iso-8601": Serializer.serialize_iso, "rfc-1123": Serializer.serialize_rfc, @@ -537,7 +561,7 @@ def __init__(self, classes=None): "[]": self.serialize_iter, "{}": self.serialize_dict, } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} self.key_transformer = full_restapi_key_transformer self.client_side_validation = True @@ -605,14 +629,14 @@ def _serialize(self, target_obj, data_type=None, **kwargs): if xml_desc.get("attr", False): if xml_ns: ET.register_namespace(xml_prefix, xml_ns) - xml_name = "{}{}".format(xml_ns, xml_name) - serialized.set(xml_name, new_attr) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) # type: ignore continue if xml_desc.get("text", False): - serialized.text = new_attr + serialized.text = new_attr # type: ignore continue if isinstance(new_attr, list): - serialized.extend(new_attr) + serialized.extend(new_attr) # type: ignore elif isinstance(new_attr, ET.Element): # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. if "name" not in getattr(orig_attr, "_xml_map", {}): @@ -621,26 +645,26 @@ def _serialize(self, target_obj, data_type=None, **kwargs): new_attr.tag = "}".join([splitted_tag[0], xml_name]) else: new_attr.tag = xml_name - serialized.append(new_attr) + serialized.append(new_attr) # type: ignore else: # That's a basic type # Integrate namespace if necessary local_node = _create_xml_node(xml_name, xml_prefix, xml_ns) local_node.text = unicode_str(new_attr) - serialized.append(local_node) + serialized.append(local_node) # type: ignore else: # JSON - for k in reversed(keys): - unflattened = {k: new_attr} - new_attr = unflattened + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} _new_attr = new_attr _serialized = serialized - for k in keys: + for k in keys: # type: ignore if k not in _serialized: - _serialized.update(_new_attr) - _new_attr = _new_attr[k] + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore _serialized = _serialized[k] - except ValueError: - continue + except ValueError as err: + if isinstance(err, SerializationError): + raise except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) @@ -659,8 +683,8 @@ def body(self, data, data_type, **kwargs): """ # Just in case this is a dict - internal_data_type = data_type.strip("[]{}") - internal_data_type = self.dependencies.get(internal_data_type, None) + internal_data_type_str = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type_str, None) try: is_xml_model_serialization = kwargs["is_xml"] except KeyError: @@ -675,7 +699,7 @@ def body(self, data, data_type, **kwargs): # We're not able to deal with additional properties for now. deserializer.additional_properties_detection = False if is_xml_model_serialization: - deserializer.key_extractors = [ + deserializer.key_extractors = [ # type: ignore attribute_key_case_insensitive_extractor, ] else: @@ -718,6 +742,8 @@ def query(self, name, data, data_type, **kwargs): :param data: The data to be serialized. :param str data_type: The type to be serialized from. + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. :rtype: str :raises: TypeError if serialization fails. :raises: ValueError if data is None @@ -726,10 +752,8 @@ def query(self, name, data, data_type, **kwargs): # Treat the list aside, since we don't want to encode the div separator if data_type.startswith("["): internal_data_type = data_type[1:-1] - data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] - if not kwargs.get("skip_quote", False): - data = [quote(str(d), safe="") for d in data] - return str(self.serialize_iter(data, internal_data_type, **kwargs)) + do_quote = not kwargs.get("skip_quote", False) + return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) # Not a list, regular serialization output = self.serialize_data(data, data_type, **kwargs) @@ -780,6 +804,8 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: + if data is AzureCoreNull: + return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -843,7 +869,7 @@ def serialize_unicode(cls, data): pass try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore # Don't change it, JSON and XML ElementTree are totally able # to serialize correctly u'' strings return data @@ -866,6 +892,8 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): not be None or empty. :param str div: If set, this str will be used to combine the elements in the iterable into a combined string. Default is 'None'. + :keyword bool do_quote: Whether to quote the serialized result of each iterable element. + Defaults to False. :rtype: list, str """ if isinstance(data, str): @@ -878,9 +906,14 @@ def serialize_iter(self, data, iter_type, div=None, **kwargs): for d in data: try: serialized.append(self.serialize_data(d, iter_type, **kwargs)) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized.append(None) + if kwargs.get("do_quote", False): + serialized = ["" if s is None else quote(str(s), safe="") for s in serialized] + if div: serialized = ["" if s is None else str(s) for s in serialized] serialized = div.join(serialized) @@ -925,7 +958,9 @@ def serialize_dict(self, attr, dict_type, **kwargs): for key, value in attr.items(): try: serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) - except ValueError: + except ValueError as err: + if isinstance(err, SerializationError): + raise serialized[self.serialize_unicode(key)] = None if "xml" in serialization_ctxt: @@ -1001,10 +1036,10 @@ def serialize_enum(attr, enum_obj=None): except AttributeError: result = attr try: - enum_obj(result) + enum_obj(result) # type: ignore return result except ValueError: - for enum_value in enum_obj: + for enum_value in enum_obj: # type: ignore if enum_value.value.lower() == str(attr).lower(): return enum_value.value error = "{!r} is not valid value for enum {!r}" @@ -1164,7 +1199,8 @@ def rest_key_extractor(attr, attr_desc, data): working_data = data while "." in key: - dict_keys = _FLATTEN.split(key) + # Need the cast, as for some reasons "split" is typed as list[str | Any] + dict_keys = cast(List[str], _FLATTEN.split(key)) if len(dict_keys) == 1: key = _decode_attribute_map_key(dict_keys[0]) break @@ -1245,7 +1281,7 @@ def _extract_name_from_internal_type(internal_type): xml_name = internal_type_xml_map.get("name", internal_type.__name__) xml_ns = internal_type_xml_map.get("ns", None) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) return xml_name @@ -1269,7 +1305,7 @@ def xml_key_extractor(attr, attr_desc, data): # Integrate namespace if necessary xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) if xml_ns: - xml_name = "{}{}".format(xml_ns, xml_name) + xml_name = "{{{}}}{}".format(xml_ns, xml_name) # If it's an attribute, that's simple if xml_desc.get("attr", False): @@ -1335,7 +1371,7 @@ class Deserializer(object): valid_date = re.compile(r"\d{4}[-]\d{2}[-]\d{2}T\d{2}:\d{2}:\d{2}" r"\.?\d*Z?[-+]?[\d{2}]?:?[\d{2}]?") - def __init__(self, classes=None): + def __init__(self, classes: Optional[Mapping[str, Type[ModelType]]] = None): self.deserialize_type = { "iso-8601": Deserializer.deserialize_iso, "rfc-1123": Deserializer.deserialize_rfc, @@ -1355,7 +1391,7 @@ def __init__(self, classes=None): "duration": (isodate.Duration, datetime.timedelta), "iso-8601": (datetime.datetime), } - self.dependencies = dict(classes) if classes else {} + self.dependencies: Dict[str, Type[ModelType]] = dict(classes) if classes else {} self.key_extractors = [rest_key_extractor, xml_key_extractor] # Additional properties only works if the "rest_key_extractor" is used to # extract the keys. Making it to work whatever the key extractor is too much @@ -1416,7 +1452,7 @@ def _deserialize(self, target_obj, data): if data is None: return data try: - attributes = response._attribute_map + attributes = response._attribute_map # type: ignore d_attrs = {} for attr, attr_desc in attributes.items(): # Check empty string. If it's not empty, someone has a real "additionalProperties"... @@ -1444,7 +1480,7 @@ def _deserialize(self, target_obj, data): value = self.deserialize_data(raw_value, attr_desc["type"]) d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: - msg = "Unable to deserialize to object: " + class_name + msg = "Unable to deserialize to object: " + class_name # type: ignore raise_with_traceback(DeserializationError, msg, err) else: additional_properties = self._build_additional_properties(attributes, data) @@ -1474,7 +1510,7 @@ def _classify_target(self, target, data): Once classification has been determined, initialize object. :param str target: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. """ if target is None: return None, None @@ -1489,7 +1525,7 @@ def _classify_target(self, target, data): target = target._classify(data, self.dependencies) except AttributeError: pass # Target is not a Model, no classify - return target, target.__class__.__name__ + return target, target.__class__.__name__ # type: ignore def failsafe_deserialize(self, target_obj, data, content_type=None): """Ignores any errors encountered in deserialization, @@ -1499,7 +1535,7 @@ def failsafe_deserialize(self, target_obj, data, content_type=None): a deserialization error. :param str target_obj: The target object type to deserialize to. - :param str/dict data: The response data to deseralize. + :param str/dict data: The response data to deserialize. :param str content_type: Swagger "produces" if available. """ try: @@ -1543,7 +1579,7 @@ def _unpack_content(raw_data, content_type=None): return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) if isinstance(raw_data, (basestring, bytes)) or hasattr(raw_data, "read"): - return RawDeserializer.deserialize_from_text(raw_data, content_type) + return RawDeserializer.deserialize_from_text(raw_data, content_type) # type: ignore return raw_data def _instantiate_model(self, response, attrs, additional_properties=None): @@ -1565,7 +1601,7 @@ def _instantiate_model(self, response, attrs, additional_properties=None): response_obj.additional_properties = additional_properties return response_obj except TypeError as err: - msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore raise DeserializationError(msg + str(err)) else: try: @@ -1747,7 +1783,7 @@ def deserialize_unicode(data): # Consider this is real string try: - if isinstance(data, unicode): + if isinstance(data, unicode): # type: ignore return data except NameError: return str(data) @@ -1798,7 +1834,7 @@ def deserialize_bytearray(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return bytearray(b64decode(attr)) + return bytearray(b64decode(attr)) # type: ignore @staticmethod def deserialize_base64(attr): @@ -1810,8 +1846,8 @@ def deserialize_base64(attr): """ if isinstance(attr, ET.Element): attr = attr.text - padding = "=" * (3 - (len(attr) + 3) % 4) - attr = attr + padding + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore encoded = attr.replace("-", "+").replace("_", "/") return b64decode(encoded) @@ -1826,7 +1862,7 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) + return decimal.Decimal(attr) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) raise_with_traceback(DeserializationError, msg, err) @@ -1841,7 +1877,7 @@ def deserialize_long(attr): """ if isinstance(attr, ET.Element): attr = attr.text - return _long_type(attr) + return _long_type(attr) # type: ignore @staticmethod def deserialize_duration(attr): @@ -1871,7 +1907,7 @@ def deserialize_date(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) # This must NOT use defaultmonth/defaultday. Using None ensure this raises an exception. return isodate.parse_date(attr, defaultmonth=None, defaultday=None) @@ -1886,7 +1922,7 @@ def deserialize_time(attr): """ if isinstance(attr, ET.Element): attr = attr.text - if re.search(r"[^\W\d_]", attr, re.I + re.U): + if re.search(r"[^\W\d_]", attr, re.I + re.U): # type: ignore raise DeserializationError("Date must have only digits and -. Received: %s" % attr) return isodate.parse_time(attr) @@ -1901,7 +1937,7 @@ def deserialize_rfc(attr): if isinstance(attr, ET.Element): attr = attr.text try: - parsed_date = email.utils.parsedate_tz(attr) + parsed_date = email.utils.parsedate_tz(attr) # type: ignore date_obj = datetime.datetime( *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) ) @@ -1924,7 +1960,7 @@ def deserialize_iso(attr): if isinstance(attr, ET.Element): attr = attr.text try: - attr = attr.upper() + attr = attr.upper() # type: ignore match = Deserializer.valid_date.match(attr) if not match: raise ValueError("Invalid datetime string: " + attr) @@ -1960,7 +1996,7 @@ def deserialize_unix(attr): :raises: DeserializationError if format invalid """ if isinstance(attr, ET.Element): - attr = int(attr.text) + attr = int(attr.text) # type: ignore try: date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_vendor.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_vendor.py index 9aad73fc743e..0dafe0e287ff 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_vendor.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_vendor.py @@ -14,14 +14,3 @@ def _convert_request(request, files=None): if files: request.set_formdata_body(files) return request - - -def _format_url_section(template, **kwargs): - components = template.split("/") - while components: - try: - return template.format(**kwargs) - except KeyError as key: - formatted_components = template.split("/") - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_version.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_version.py index aa6530bfe9d9..364f3c906cf9 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_version.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "8.1.0b1" +VERSION = "7.0.0" diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/__init__.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/__init__.py index cd883c69682d..0c4866730c3f 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/__init__.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/__init__.py @@ -6,17 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._notification_hubs_management_client import NotificationHubsManagementClient +from ._notification_hubs_rp_client import NotificationHubsRPClient try: from ._patch import __all__ as _patch_all - from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import + from ._patch import * # pylint: disable=unused-wildcard-import except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk __all__ = [ - "NotificationHubsManagementClient", + "NotificationHubsRPClient", ] __all__.extend([p for p in _patch_all if p not in __all__]) diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/_configuration.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/_configuration.py index bce875b2f746..b956ed9ef13d 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/_configuration.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/_configuration.py @@ -6,7 +6,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -15,35 +14,29 @@ from .._version import VERSION -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class NotificationHubsManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes - """Configuration for NotificationHubsManagementClient. +class NotificationHubsRPClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for NotificationHubsRPClient. Note that all parameters used to create this instance are saved as instance attributes. :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(NotificationHubsManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-04-01") # type: Literal["2017-04-01"] + super(NotificationHubsRPClientConfiguration, self).__init__(**kwargs) + api_version: str = kwargs.pop("api_version", "2023-10-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/_notification_hubs_management_client.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/_notification_hubs_rp_client.py similarity index 73% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/_notification_hubs_management_client.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/_notification_hubs_rp_client.py index 34abd0c7aa93..0231680e13cc 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/_notification_hubs_management_client.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/_notification_hubs_rp_client.py @@ -12,35 +12,42 @@ from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from .. import models +from .. import models as _models from .._serialization import Deserializer, Serializer -from ._configuration import NotificationHubsManagementClientConfiguration -from .operations import NamespacesOperations, NotificationHubsOperations, Operations +from ._configuration import NotificationHubsRPClientConfiguration +from .operations import ( + NamespacesOperations, + NotificationHubsOperations, + Operations, + PrivateEndpointConnectionsOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class NotificationHubsManagementClient: # pylint: disable=client-accepts-api-version-keyword - """Azure NotificationHub client. +class NotificationHubsRPClient: # pylint: disable=client-accepts-api-version-keyword + """Microsoft Notification Hubs Resource Provider REST API. - :ivar operations: Operations operations - :vartype operations: azure.mgmt.notificationhubs.aio.operations.Operations - :ivar namespaces: NamespacesOperations operations - :vartype namespaces: azure.mgmt.notificationhubs.aio.operations.NamespacesOperations :ivar notification_hubs: NotificationHubsOperations operations :vartype notification_hubs: azure.mgmt.notificationhubs.aio.operations.NotificationHubsOperations + :ivar namespaces: NamespacesOperations operations + :vartype namespaces: azure.mgmt.notificationhubs.aio.operations.NamespacesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.notificationhubs.aio.operations.Operations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.notificationhubs.aio.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription credentials which uniquely identify Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. Required. + :param subscription_id: The ID of the target subscription. The value must be an UUID. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str - :keyword api_version: Api Version. Default value is "2017-04-01". Note that overriding this - default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2023-10-01-preview". Note that overriding + this default value may result in unsupported behavior. :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. @@ -53,20 +60,23 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = NotificationHubsManagementClientConfiguration( + self._config = NotificationHubsRPClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) - client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) self.notification_hubs = NotificationHubsOperations( self._client, self._config, self._serialize, self._deserialize ) + self.namespaces = NamespacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. @@ -93,9 +103,9 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH async def close(self) -> None: await self._client.close() - async def __aenter__(self) -> "NotificationHubsManagementClient": + async def __aenter__(self) -> "NotificationHubsRPClient": await self._client.__aenter__() return self - async def __aexit__(self, *exc_details) -> None: + async def __aexit__(self, *exc_details: Any) -> None: await self._client.__aexit__(*exc_details) diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/__init__.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/__init__.py index 8d1898cef5c0..fb54f1e71f5c 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/__init__.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/__init__.py @@ -6,18 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._operations import Operations -from ._namespaces_operations import NamespacesOperations from ._notification_hubs_operations import NotificationHubsOperations +from ._namespaces_operations import NamespacesOperations +from ._operations import Operations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ - "Operations", - "NamespacesOperations", "NotificationHubsOperations", + "NamespacesOperations", + "Operations", + "PrivateEndpointConnectionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_namespaces_operations.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_namespaces_operations.py index a18fc7ae1639..d12662c25a73 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_namespaces_operations.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_namespaces_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -38,19 +38,16 @@ build_delete_authorization_rule_request, build_delete_request, build_get_authorization_rule_request, + build_get_pns_credentials_request, build_get_request, build_list_all_request, build_list_authorization_rules_request, build_list_keys_request, build_list_request, - build_patch_request, build_regenerate_keys_request, + build_update_request, ) -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,7 +58,7 @@ class NamespacesOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.notificationhubs.aio.NotificationHubsManagementClient`'s + :class:`~azure.mgmt.notificationhubs.aio.NotificationHubsRPClient`'s :attr:`namespaces` attribute. """ @@ -81,7 +78,10 @@ async def check_availability( """Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. - :param parameters: The namespace name. Required. + Checks the availability of the given service namespace across all Azure subscriptions. This is + useful because the domain name is created based on the service namespace name. + + :param parameters: Request content. Required. :type parameters: ~azure.mgmt.notificationhubs.models.CheckAvailabilityParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -99,7 +99,10 @@ async def check_availability( """Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. - :param parameters: The namespace name. Required. + Checks the availability of the given service namespace across all Azure subscriptions. This is + useful because the domain name is created based on the service namespace name. + + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -117,7 +120,11 @@ async def check_availability( """Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. - :param parameters: The namespace name. Is either a model type or a IO type. Required. + Checks the availability of the given service namespace across all Azure subscriptions. This is + useful because the domain name is created based on the service namespace name. + + :param parameters: Request content. Is either a CheckAvailabilityParameters type or a IO type. + Required. :type parameters: ~azure.mgmt.notificationhubs.models.CheckAvailabilityParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -138,16 +145,14 @@ async def check_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckAvailabilityResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckAvailabilityResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckAvailabilityParameters") @@ -163,17 +168,19 @@ async def check_availability( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("CheckAvailabilityResult", pipeline_response) @@ -182,90 +189,82 @@ async def check_availability( return deserialized - check_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/checkNamespaceAvailability"} # type: ignore + check_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/checkNamespaceAvailability" + } - @overload - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.NamespaceCreateOrUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NamespaceResource: - """Creates/Updates a service namespace. Once created, this namespace's resource manifest is - immutable. This operation is idempotent. + @distributed_trace_async + async def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.NamespaceResource: + """Returns the given namespace. + + Returns the given namespace. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a Namespace Resource. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.NamespaceCreateOrUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NamespaceResource or the result of cls(response) :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource :raises ~azure.core.exceptions.HttpResponseError: """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - async def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NamespaceResource: - """Creates/Updates a service namespace. Once created, this namespace's resource manifest is - immutable. This operation is idempotent. + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param namespace_name: The namespace name. Required. - :type namespace_name: str - :param parameters: Parameters supplied to create a Namespace Resource. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource or the result of cls(response) - :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) - @distributed_trace_async - async def create_or_update( + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NamespaceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + } + + async def _create_or_update_initial( self, resource_group_name: str, namespace_name: str, - parameters: Union[_models.NamespaceCreateOrUpdateParameters, IO], + parameters: Union[_models.NamespaceResource, IO], **kwargs: Any ) -> _models.NamespaceResource: - """Creates/Updates a service namespace. Once created, this namespace's resource manifest is - immutable. This operation is idempotent. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param namespace_name: The namespace name. Required. - :type namespace_name: str - :param parameters: Parameters supplied to create a Namespace Resource. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.NamespaceCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource or the result of cls(response) - :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -277,19 +276,17 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "NamespaceCreateOrUpdateParameters") + _json = self._serialize.body(parameters, "NamespaceResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -299,22 +296,24 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("NamespaceResource", pipeline_response) @@ -323,14 +322,181 @@ async def create_or_update( deserialized = self._deserialize("NamespaceResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + } @overload - async def patch( + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.NamespaceResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NamespaceResource]: + """Creates / Updates a Notification Hub namespace. This operation is idempotent. + + Creates / Updates a Notification Hub namespace. This operation is idempotent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.NamespaceResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either NamespaceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.notificationhubs.models.NamespaceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.NamespaceResource]: + """Creates / Updates a Notification Hub namespace. This operation is idempotent. + + Creates / Updates a Notification Hub namespace. This operation is idempotent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param parameters: Request content. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either NamespaceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.notificationhubs.models.NamespaceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NamespaceResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.NamespaceResource]: + """Creates / Updates a Notification Hub namespace. This operation is idempotent. + + Creates / Updates a Notification Hub namespace. This operation is idempotent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param parameters: Request content. Is either a NamespaceResource type or a IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.NamespaceResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either NamespaceResource or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.notificationhubs.models.NamespaceResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NamespaceResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + } + + @overload + async def update( self, resource_group_name: str, namespace_name: str, @@ -341,11 +507,14 @@ async def patch( ) -> _models.NamespaceResource: """Patches the existing namespace. - :param resource_group_name: The name of the resource group. Required. + Patches the existing namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to patch a Namespace Resource. Required. + :param parameters: Request content. Required. :type parameters: ~azure.mgmt.notificationhubs.models.NamespacePatchParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -357,7 +526,7 @@ async def patch( """ @overload - async def patch( + async def update( self, resource_group_name: str, namespace_name: str, @@ -368,11 +537,14 @@ async def patch( ) -> _models.NamespaceResource: """Patches the existing namespace. - :param resource_group_name: The name of the resource group. Required. + Patches the existing namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to patch a Namespace Resource. Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -384,7 +556,7 @@ async def patch( """ @distributed_trace_async - async def patch( + async def update( self, resource_group_name: str, namespace_name: str, @@ -393,12 +565,15 @@ async def patch( ) -> _models.NamespaceResource: """Patches the existing namespace. - :param resource_group_name: The name of the resource group. Required. + Patches the existing namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to patch a Namespace Resource. Is either a model type or - a IO type. Required. + :param parameters: Request content. Is either a NamespacePatchParameters type or a IO type. + Required. :type parameters: ~azure.mgmt.notificationhubs.models.NamespacePatchParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -419,21 +594,19 @@ async def patch( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "NamespacePatchParameters") - request = build_patch_request( + request = build_update_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, @@ -441,22 +614,24 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("NamespaceResource", pipeline_response) @@ -465,11 +640,30 @@ async def patch( return deserialized - patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + } - async def _delete_initial( # pylint: disable=inconsistent-return-statements + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: + """Deletes an existing namespace. This operation also removes all associated notificationHubs + under the namespace. + + Deletes an existing namespace. This operation also removes all associated notificationHubs + under the namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -481,115 +675,159 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + } - @distributed_trace_async - async def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> AsyncLROPoller[None]: - """Deletes an existing namespace. This operation also removes all associated notificationHubs - under the namespace. + @distributed_trace + def list_all( + self, skip_token: Optional[str] = None, top: int = 100, **kwargs: Any + ) -> AsyncIterable["_models.NamespaceResource"]: + """Lists all the available namespaces within the subscription. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param namespace_name: The namespace name. Required. - :type namespace_name: str + Lists all the available namespaces within the subscription. + + :param skip_token: Skip token for subsequent requests. Default value is None. + :type skip_token: str + :param top: Maximum number of results to return. Default value is 100. + :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for - this operation to not poll, or pass in your own initialized polling object for a personal - polling strategy. - :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[None] + :return: An iterator like instance of either NamespaceResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.notificationhubs.models.NamespaceResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = await self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - namespace_name=namespace_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamespaceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + subscription_id=self._config.subscription_id, + skip_token=skip_token, + top=top, + api_version=api_version, + template_url=self.list_all.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + async def extract_data(pipeline_response): + deserialized = self._deserialize("NamespaceListResult", pipeline_response) + list_of_elem = deserialized.value if cls: - return cls(pipeline_response, None, {}) + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod - elif polling is False: - polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: - polling_method = polling - if cont_token: - return AsyncLROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + response = pipeline_response.http_response - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}"} # type: ignore + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - @distributed_trace_async - async def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.NamespaceResource: - """Returns the description for the specified namespace. + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces"} - :param resource_group_name: The name of the resource group. Required. + @distributed_trace + def list( + self, resource_group_name: str, skip_token: Optional[str] = None, top: int = 100, **kwargs: Any + ) -> AsyncIterable["_models.NamespaceResource"]: + """Lists the available namespaces within a resource group. + + Lists the available namespaces within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. - :type namespace_name: str + :param skip_token: Skip token for subsequent requests. Default value is None. + :type skip_token: str + :param top: Maximum number of results to return. Default value is 100. + :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource or the result of cls(response) - :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource + :return: An iterator like instance of either NamespaceResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.notificationhubs.models.NamespaceResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamespaceListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -598,44 +836,68 @@ async def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceResource] + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + top=top, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("NamespaceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("NamespaceResource", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return AsyncItemPaged(get_next, extract_data) - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces" + } @overload async def create_or_update_authorization_rule( @@ -643,22 +905,24 @@ async def create_or_update_authorization_rule( resource_group_name: str, namespace_name: str, authorization_rule_name: str, - parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + parameters: _models.SharedAccessAuthorizationRuleResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates an authorization rule for a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Required. - :type parameters: - ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -681,13 +945,16 @@ async def create_or_update_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates an authorization rule for a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -704,21 +971,24 @@ async def create_or_update_authorization_rule( resource_group_name: str, namespace_name: str, authorization_rule_name: str, - parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], + parameters: Union[_models.SharedAccessAuthorizationRuleResource, IO], **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates an authorization rule for a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Is either a model type or a IO type. - Required. - :type parameters: - ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters or IO + :param parameters: Request content. Is either a SharedAccessAuthorizationRuleResource type or a + IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleResource or + IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -738,19 +1008,17 @@ async def create_or_update_authorization_rule( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleResource") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -766,26 +1034,34 @@ async def create_or_update_authorization_rule( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -793,9 +1069,12 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: The name of the resource group. Required. + Deletes a namespace authorization rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str @@ -815,10 +1094,8 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, @@ -831,22 +1108,26 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -854,11 +1135,14 @@ async def get_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Gets an authorization rule for a namespace by name. - :param resource_group_name: The name of the resource group. Required. + Gets an authorization rule for a namespace by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param authorization_rule_name: Authorization rule name. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedAccessAuthorizationRuleResource or the result of cls(response) @@ -876,10 +1160,8 @@ async def get_authorization_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) request = build_get_authorization_rule_request( resource_group_name=resource_group_name, @@ -892,17 +1174,19 @@ async def get_authorization_rule( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) @@ -911,175 +1195,9 @@ async def get_authorization_rule( return deserialized - get_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.NamespaceResource"]: - """Lists the available namespaces within a resourceGroup. - - :param resource_group_name: The name of the resource group. If resourceGroupName value is null - the method lists all the namespaces within subscription. Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NamespaceResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.notificationhubs.models.NamespaceResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceListResult] - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("NamespaceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces"} # type: ignore - - @distributed_trace - def list_all(self, **kwargs: Any) -> AsyncIterable["_models.NamespaceResource"]: - """Lists all the available namespaces within the subscription irrespective of the resourceGroups. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NamespaceResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.notificationhubs.models.NamespaceResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceListResult] - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_all_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_all.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("NamespaceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces"} # type: ignore + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_authorization_rules( @@ -1087,9 +1205,12 @@ def list_authorization_rules( ) -> AsyncIterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets the authorization rules for a namespace. - :param resource_group_name: The name of the resource group. Required. + Gets the authorization rules for a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the @@ -1101,10 +1222,8 @@ def list_authorization_rules( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedAccessAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1127,7 +1246,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1143,7 +1262,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1151,26 +1270,30 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) - list_authorization_rules.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules" + } @distributed_trace_async async def list_keys( @@ -1178,12 +1301,14 @@ async def list_keys( ) -> _models.ResourceListKeys: """Gets the Primary and Secondary ConnectionStrings to the namespace. - :param resource_group_name: The name of the resource group. Required. + Gets the Primary and Secondary ConnectionStrings to the namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The connection string of the namespace for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceListKeys or the result of cls(response) @@ -1201,10 +1326,8 @@ async def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) request = build_list_keys_request( resource_group_name=resource_group_name, @@ -1217,17 +1340,19 @@ async def list_keys( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ResourceListKeys", pipeline_response) @@ -1236,7 +1361,9 @@ async def list_keys( return deserialized - list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/listKeys" + } @overload async def regenerate_keys( @@ -1244,23 +1371,24 @@ async def regenerate_keys( resource_group_name: str, namespace_name: str, authorization_rule_name: str, - parameters: _models.PolicykeyResource, + parameters: _models.PolicyKeyResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The connection string of the namespace for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the Namespace Authorization Rule Key. - Required. - :type parameters: ~azure.mgmt.notificationhubs.models.PolicykeyResource + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PolicyKeyResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1283,15 +1411,16 @@ async def regenerate_keys( ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The connection string of the namespace for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the Namespace Authorization Rule Key. - Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1308,21 +1437,22 @@ async def regenerate_keys( resource_group_name: str, namespace_name: str, authorization_rule_name: str, - parameters: Union[_models.PolicykeyResource, IO], + parameters: Union[_models.PolicyKeyResource, IO], **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The connection string of the namespace for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the Namespace Authorization Rule Key. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.PolicykeyResource or IO + :param parameters: Request content. Is either a PolicyKeyResource type or a IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PolicyKeyResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -1342,19 +1472,17 @@ async def regenerate_keys( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicykeyResource") + _json = self._serialize.body(parameters, "PolicyKeyResource") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1370,17 +1498,19 @@ async def regenerate_keys( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ResourceListKeys", pipeline_response) @@ -1389,4 +1519,73 @@ async def regenerate_keys( return deserialized - regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @distributed_trace_async + async def get_pns_credentials( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> _models.PnsCredentialsResource: + """Lists the PNS credentials associated with a namespace. + + Lists the PNS credentials associated with a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PnsCredentialsResource or the result of cls(response) + :rtype: ~azure.mgmt.notificationhubs.models.PnsCredentialsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PnsCredentialsResource] = kwargs.pop("cls", None) + + request = build_get_pns_credentials_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_pns_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PnsCredentialsResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_pns_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/pnsCredentials" + } diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_notification_hubs_operations.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_notification_hubs_operations.py index 9cca72409abd..8079752b0bce 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_notification_hubs_operations.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_notification_hubs_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload import urllib.parse @@ -42,19 +42,10 @@ build_list_authorization_rules_request, build_list_keys_request, build_list_request, - build_patch_request, build_regenerate_keys_request, + build_update_request, ) -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,7 +56,7 @@ class NotificationHubsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.notificationhubs.aio.NotificationHubsManagementClient`'s + :class:`~azure.mgmt.notificationhubs.aio.NotificationHubsRPClient`'s :attr:`notification_hubs` attribute. """ @@ -90,11 +81,14 @@ async def check_notification_hub_availability( ) -> _models.CheckAvailabilityResult: """Checks the availability of the given notificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Checks the availability of the given notificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: The notificationHub name. Required. + :param parameters: Request content. Required. :type parameters: ~azure.mgmt.notificationhubs.models.CheckAvailabilityParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -117,11 +111,14 @@ async def check_notification_hub_availability( ) -> _models.CheckAvailabilityResult: """Checks the availability of the given notificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Checks the availability of the given notificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: The notificationHub name. Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -142,11 +139,15 @@ async def check_notification_hub_availability( ) -> _models.CheckAvailabilityResult: """Checks the availability of the given notificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Checks the availability of the given notificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: The notificationHub name. Is either a model type or a IO type. Required. + :param parameters: Request content. Is either a CheckAvailabilityParameters type or a IO type. + Required. :type parameters: ~azure.mgmt.notificationhubs.models.CheckAvailabilityParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -167,16 +168,14 @@ async def check_notification_hub_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckAvailabilityResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckAvailabilityResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckAvailabilityParameters") @@ -194,17 +193,19 @@ async def check_notification_hub_availability( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("CheckAvailabilityResult", pipeline_response) @@ -213,7 +214,79 @@ async def check_notification_hub_availability( return deserialized - check_notification_hub_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkNotificationHubAvailability"} # type: ignore + check_notification_hub_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkNotificationHubAvailability" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, namespace_name: str, notification_hub_name: str, **kwargs: Any + ) -> _models.NotificationHubResource: + """Gets the notification hub. + + Gets the notification hub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param notification_hub_name: Notification Hub name. Required. + :type notification_hub_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NotificationHubResource or the result of cls(response) + :rtype: ~azure.mgmt.notificationhubs.models.NotificationHubResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NotificationHubResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + notification_hub_name=notification_hub_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NotificationHubResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + } @overload async def create_or_update( @@ -221,22 +294,24 @@ async def create_or_update( resource_group_name: str, namespace_name: str, notification_hub_name: str, - parameters: _models.NotificationHubCreateOrUpdateParameters, + parameters: _models.NotificationHubResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.NotificationHubResource: """Creates/Update a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates/Update a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to the create/update a NotificationHub Resource. - Required. - :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubCreateOrUpdateParameters + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -259,14 +334,16 @@ async def create_or_update( ) -> _models.NotificationHubResource: """Creates/Update a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates/Update a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to the create/update a NotificationHub Resource. - Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -283,21 +360,23 @@ async def create_or_update( resource_group_name: str, namespace_name: str, notification_hub_name: str, - parameters: Union[_models.NotificationHubCreateOrUpdateParameters, IO], + parameters: Union[_models.NotificationHubResource, IO], **kwargs: Any ) -> _models.NotificationHubResource: """Creates/Update a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates/Update a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to the create/update a NotificationHub Resource. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubCreateOrUpdateParameters - or IO + :param parameters: Request content. Is either a NotificationHubResource type or a IO type. + Required. + :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -317,19 +396,17 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationHubResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NotificationHubResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "NotificationHubCreateOrUpdateParameters") + _json = self._serialize.body(parameters, "NotificationHubResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -345,17 +422,19 @@ async def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("NotificationHubResource", pipeline_response) @@ -364,33 +443,37 @@ async def create_or_update( deserialized = self._deserialize("NotificationHubResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + } @overload - async def patch( + async def update( self, resource_group_name: str, namespace_name: str, notification_hub_name: str, - parameters: Optional[_models.NotificationHubPatchParameters] = None, + parameters: _models.NotificationHubPatchParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.NotificationHubResource: """Patch a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Patch a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to patch a NotificationHub Resource. Default value is - None. + :param parameters: Request content. Required. :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubPatchParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -402,26 +485,28 @@ async def patch( """ @overload - async def patch( + async def update( self, resource_group_name: str, namespace_name: str, notification_hub_name: str, - parameters: Optional[IO] = None, + parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.NotificationHubResource: """Patch a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Patch a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to patch a NotificationHub Resource. Default value is - None. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -433,24 +518,27 @@ async def patch( """ @distributed_trace_async - async def patch( + async def update( self, resource_group_name: str, namespace_name: str, notification_hub_name: str, - parameters: Optional[Union[_models.NotificationHubPatchParameters, IO]] = None, + parameters: Union[_models.NotificationHubPatchParameters, IO], **kwargs: Any ) -> _models.NotificationHubResource: """Patch a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Patch a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to patch a NotificationHub Resource. Is either a model - type or a IO type. Default value is None. + :param parameters: Request content. Is either a NotificationHubPatchParameters type or a IO + type. Required. :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubPatchParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -471,24 +559,19 @@ async def patch( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationHubResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NotificationHubResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - if parameters is not None: - _json = self._serialize.body(parameters, "NotificationHubPatchParameters") - else: - _json = None + _json = self._serialize.body(parameters, "NotificationHubPatchParameters") - request = build_patch_request( + request = build_update_request( resource_group_name=resource_group_name, namespace_name=namespace_name, notification_hub_name=notification_hub_name, @@ -497,22 +580,24 @@ async def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("NotificationHubResource", pipeline_response) @@ -521,7 +606,9 @@ async def patch( return deserialized - patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + } @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -529,11 +616,14 @@ async def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a notification hub associated with a namespace. - :param resource_group_name: The name of the resource group. Required. + Deletes a notification hub associated with a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) @@ -551,10 +641,8 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -567,40 +655,62 @@ async def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + } - @distributed_trace_async - async def get( - self, resource_group_name: str, namespace_name: str, notification_hub_name: str, **kwargs: Any - ) -> _models.NotificationHubResource: + @distributed_trace + def list( + self, + resource_group_name: str, + namespace_name: str, + skip_token: Optional[str] = None, + top: int = 100, + **kwargs: Any + ) -> AsyncIterable["_models.NotificationHubResource"]: """Lists the notification hubs associated with a namespace. - :param resource_group_name: The name of the resource group. Required. + Lists the notification hubs associated with a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. - :type notification_hub_name: str + :param skip_token: Continuation token. Default value is None. + :type skip_token: str + :param top: Page size. Default value is 100. + :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: NotificationHubResource or the result of cls(response) - :rtype: ~azure.mgmt.notificationhubs.models.NotificationHubResource + :return: An iterator like instance of either NotificationHubResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.notificationhubs.models.NotificationHubResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NotificationHubListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -609,65 +719,85 @@ async def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationHubResource] + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + top=top, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - notification_hub_name=notification_hub_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) + async def extract_data(pipeline_response): + deserialized = self._deserialize("NotificationHubListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, AsyncList(list_of_elem) - response = pipeline_response.http_response + async def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("NotificationHubResource", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return AsyncItemPaged(get_next, extract_data) - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs" + } @distributed_trace_async async def debug_send( - self, - resource_group_name: str, - namespace_name: str, - notification_hub_name: str, - parameters: Optional[JSON] = None, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, notification_hub_name: str, **kwargs: Any ) -> _models.DebugSendResponse: - """test send a push notification. + """Test send a push notification. - :param resource_group_name: The name of the resource group. Required. + Test send a push notification. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Debug send parameters. Default value is None. - :type parameters: JSON :keyword callable cls: A custom type or function that will be passed the direct response :return: DebugSendResponse or the result of cls(response) :rtype: ~azure.mgmt.notificationhubs.models.DebugSendResponse @@ -681,19 +811,11 @@ async def debug_send( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DebugSendResponse] - - if parameters is not None: - _json = self._serialize.body(parameters, "object") - else: - _json = None + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DebugSendResponse] = kwargs.pop("cls", None) request = build_debug_send_request( resource_group_name=resource_group_name, @@ -701,24 +823,24 @@ async def debug_send( notification_hub_name=notification_hub_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, template_url=self.debug_send.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DebugSendResponse", pipeline_response) @@ -727,7 +849,9 @@ async def debug_send( return deserialized - debug_send.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/debugsend"} # type: ignore + debug_send.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/debugsend" + } @overload async def create_or_update_authorization_rule( @@ -736,24 +860,26 @@ async def create_or_update_authorization_rule( namespace_name: str, notification_hub_name: str, authorization_rule_name: str, - parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + parameters: _models.SharedAccessAuthorizationRuleResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates/Updates an authorization rule for a NotificationHub. - :param resource_group_name: The name of the resource group. Required. + Creates/Updates an authorization rule for a NotificationHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Required. - :type parameters: - ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -777,15 +903,18 @@ async def create_or_update_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Creates/Updates an authorization rule for a NotificationHub. - :param resource_group_name: The name of the resource group. Required. + Creates/Updates an authorization rule for a NotificationHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -803,23 +932,26 @@ async def create_or_update_authorization_rule( namespace_name: str, notification_hub_name: str, authorization_rule_name: str, - parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], + parameters: Union[_models.SharedAccessAuthorizationRuleResource, IO], **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates/Updates an authorization rule for a NotificationHub. - :param resource_group_name: The name of the resource group. Required. + Creates/Updates an authorization rule for a NotificationHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Is either a model type or a IO type. - Required. - :type parameters: - ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters or IO + :param parameters: Request content. Is either a SharedAccessAuthorizationRuleResource type or a + IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleResource or + IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -839,19 +971,17 @@ async def create_or_update_authorization_rule( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleResource") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -868,26 +998,34 @@ async def create_or_update_authorization_rule( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -900,11 +1038,14 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat ) -> None: """Deletes a notificationHub authorization rule. - :param resource_group_name: The name of the resource group. Required. + Deletes a notificationHub authorization rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str @@ -924,10 +1065,8 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, @@ -941,22 +1080,26 @@ async def delete_authorization_rule( # pylint: disable=inconsistent-return-stat params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace_async async def get_authorization_rule( @@ -969,13 +1112,16 @@ async def get_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Gets an authorization rule for a NotificationHub by name. - :param resource_group_name: The name of the resource group. Required. + Gets an authorization rule for a NotificationHub by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param authorization_rule_name: authorization rule name. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedAccessAuthorizationRuleResource or the result of cls(response) @@ -993,10 +1139,8 @@ async def get_authorization_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) request = build_get_authorization_rule_request( resource_group_name=resource_group_name, @@ -1010,17 +1154,19 @@ async def get_authorization_rule( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) @@ -1029,98 +1175,9 @@ async def get_authorization_rule( return deserialized - get_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, namespace_name: str, **kwargs: Any - ) -> AsyncIterable["_models.NotificationHubResource"]: - """Lists the notification hubs associated with a namespace. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param namespace_name: The namespace name. Required. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NotificationHubResource or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.notificationhubs.models.NotificationHubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationHubListResult] - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - async def extract_data(pipeline_response): - deserialized = self._deserialize("NotificationHubListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs"} # type: ignore + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_authorization_rules( @@ -1128,11 +1185,14 @@ def list_authorization_rules( ) -> AsyncIterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets the authorization rules for a NotificationHub. - :param resource_group_name: The name of the resource group. Required. + Gets the authorization rules for a NotificationHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the @@ -1144,10 +1204,8 @@ def list_authorization_rules( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedAccessAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1171,7 +1229,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1187,7 +1245,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1195,26 +1253,30 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return AsyncItemPaged(get_next, extract_data) - list_authorization_rules.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules" + } @distributed_trace_async async def list_keys( @@ -1227,14 +1289,16 @@ async def list_keys( ) -> _models.ResourceListKeys: """Gets the Primary and Secondary ConnectionStrings to the NotificationHub. - :param resource_group_name: The name of the resource group. Required. + Gets the Primary and Secondary ConnectionStrings to the NotificationHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param authorization_rule_name: The connection string of the NotificationHub for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceListKeys or the result of cls(response) @@ -1252,10 +1316,8 @@ async def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) request = build_list_keys_request( resource_group_name=resource_group_name, @@ -1269,17 +1331,19 @@ async def list_keys( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ResourceListKeys", pipeline_response) @@ -1288,7 +1352,9 @@ async def list_keys( return deserialized - list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}/listKeys" + } @overload async def regenerate_keys( @@ -1297,25 +1363,26 @@ async def regenerate_keys( namespace_name: str, notification_hub_name: str, authorization_rule_name: str, - parameters: _models.PolicykeyResource, + parameters: _models.PolicyKeyResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param authorization_rule_name: The connection string of the NotificationHub for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the NotificationHub Authorization Rule - Key. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.PolicykeyResource + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PolicyKeyResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1339,17 +1406,18 @@ async def regenerate_keys( ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param authorization_rule_name: The connection string of the NotificationHub for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the NotificationHub Authorization Rule - Key. Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1367,23 +1435,24 @@ async def regenerate_keys( namespace_name: str, notification_hub_name: str, authorization_rule_name: str, - parameters: Union[_models.PolicykeyResource, IO], + parameters: Union[_models.PolicyKeyResource, IO], **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param authorization_rule_name: The connection string of the NotificationHub for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the NotificationHub Authorization Rule - Key. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.PolicykeyResource or IO + :param parameters: Request content. Is either a PolicyKeyResource type or a IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PolicyKeyResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -1403,19 +1472,17 @@ async def regenerate_keys( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicykeyResource") + _json = self._serialize.body(parameters, "PolicyKeyResource") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1432,17 +1499,19 @@ async def regenerate_keys( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ResourceListKeys", pipeline_response) @@ -1451,19 +1520,24 @@ async def regenerate_keys( return deserialized - regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace_async async def get_pns_credentials( self, resource_group_name: str, namespace_name: str, notification_hub_name: str, **kwargs: Any ) -> _models.PnsCredentialsResource: - """Lists the PNS Credentials associated with a notification hub . + """Lists the PNS Credentials associated with a notification hub. - :param resource_group_name: The name of the resource group. Required. + Lists the PNS Credentials associated with a notification hub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PnsCredentialsResource or the result of cls(response) @@ -1481,10 +1555,8 @@ async def get_pns_credentials( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PnsCredentialsResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PnsCredentialsResource] = kwargs.pop("cls", None) request = build_get_pns_credentials_request( resource_group_name=resource_group_name, @@ -1497,17 +1569,19 @@ async def get_pns_credentials( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("PnsCredentialsResource", pipeline_response) @@ -1516,4 +1590,6 @@ async def get_pns_credentials( return deserialized - get_pns_credentials.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/pnsCredentials"} # type: ignore + get_pns_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/pnsCredentials" + } diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_operations.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_operations.py index a41fcfa1cec7..a2d06c5c2ce5 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_operations.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +39,7 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.notificationhubs.aio.NotificationHubsManagementClient`'s + :class:`~azure.mgmt.notificationhubs.aio.NotificationHubsRPClient`'s :attr:`operations` attribute. """ @@ -59,7 +54,9 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: - """Lists all of the available NotificationHubs REST API operations. + """Lists all available Notification Hubs operations. + + Lists all available Notification Hubs operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) @@ -69,10 +66,8 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -92,7 +87,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -108,7 +103,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -116,14 +111,15 @@ async def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -136,4 +132,4 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.NotificationHubs/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.NotificationHubs/operations"} diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_private_endpoint_connections_operations.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..4f68dead9efe --- /dev/null +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,794 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_group_id_request, + build_get_request, + build_list_group_ids_request, + build_list_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.notificationhubs.aio.NotificationHubsRPClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + async def _update_initial( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnectionResource, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnectionResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnectionResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnectionResource") + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnectionResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrivateEndpointConnectionResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + async def begin_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnectionResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnectionResource]: + """Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: Private Endpoint Connection Name. Required. + :type private_endpoint_connection_name: str + :param parameters: Description of the Private Endpoint Connection resource. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnectionResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnectionResource]: + """Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: Private Endpoint Connection Name. Required. + :type private_endpoint_connection_name: str + :param parameters: Description of the Private Endpoint Connection resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnectionResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnectionResource, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnectionResource]: + """Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: Private Endpoint Connection Name. Required. + :type private_endpoint_connection_name: str + :param parameters: Description of the Private Endpoint Connection resource. Is either a + PrivateEndpointConnectionResource type or a IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnectionResource or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnectionResource] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes the Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + Deletes the Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: Private Endpoint Connection Name. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace_async + async def get( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnectionResource: + """Returns a Private Endpoint Connection with a given name. + This is a public API that can be called directly by Notification Hubs users. + + Returns a Private Endpoint Connection with a given name. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: Private Endpoint Connection Name. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnectionResource or the result of cls(response) + :rtype: ~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnectionResource"]: + """Returns all Private Endpoint Connections that belong to the given Notification Hubs namespace. + This is a public API that can be called directly by Notification Hubs users. + + Returns all Private Endpoint Connections that belong to the given Notification Hubs namespace. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnectionResource or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections" + } + + @distributed_trace_async + async def get_group_id( + self, resource_group_name: str, namespace_name: str, sub_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Returns Group Id response. + This is a public API required by the Networking RP contract. It can be used directly by + Notification Hubs users. + + Even though this namespace requires subscription id, resource group and namespace name, it + returns a constant payload (for a given namespacE) every time it's called. + That's why we don't send it to the sibling RP, but process it directly in the scale unit that + received the request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param sub_resource_name: Name of the Private Link sub-resource. The only supported + sub-resource is "namespace". Required. + :type sub_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.notificationhubs.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + request = build_get_group_id_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + sub_resource_name=sub_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_group_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_group_id.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName}" + } + + @distributed_trace + def list_group_ids( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: + """Returns all Group Ids supported by the Notification Hubs RP. + This is a public API required by the Networking RP contract. It can be used directly by + Notification Hubs users. + + Even though this namespace requires subscription id, resource group and namespace name, it + returns a constant payload (for a given namespacE) every time it's called. + That's why we don't send it to the sibling RP, but process it directly in the scale unit that + received the request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.notificationhubs.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_group_ids_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_group_ids.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_group_ids.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/__init__.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/__init__.py index a314b7ef4970..f3bd596e24c6 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/__init__.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/__init__.py @@ -7,79 +7,171 @@ # -------------------------------------------------------------------------- from ._models_py3 import AdmCredential +from ._models_py3 import AdmCredentialProperties from ._models_py3 import ApnsCredential +from ._models_py3 import ApnsCredentialProperties +from ._models_py3 import Availability from ._models_py3 import BaiduCredential +from ._models_py3 import BaiduCredentialProperties +from ._models_py3 import BrowserCredential +from ._models_py3 import BrowserCredentialProperties from ._models_py3 import CheckAvailabilityParameters from ._models_py3 import CheckAvailabilityResult +from ._models_py3 import ConnectionDetails from ._models_py3 import DebugSendResponse +from ._models_py3 import DebugSendResult +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail from ._models_py3 import ErrorResponse +from ._models_py3 import FcmV1Credential +from ._models_py3 import FcmV1CredentialProperties from ._models_py3 import GcmCredential +from ._models_py3 import GcmCredentialProperties +from ._models_py3 import GroupConnectivityInformation +from ._models_py3 import IpRule +from ._models_py3 import LogSpecification +from ._models_py3 import MetricSpecification from ._models_py3 import MpnsCredential -from ._models_py3 import NamespaceCreateOrUpdateParameters +from ._models_py3 import MpnsCredentialProperties from ._models_py3 import NamespaceListResult from ._models_py3 import NamespacePatchParameters +from ._models_py3 import NamespaceProperties from ._models_py3 import NamespaceResource -from ._models_py3 import NotificationHubCreateOrUpdateParameters +from ._models_py3 import NetworkAcls from ._models_py3 import NotificationHubListResult from ._models_py3 import NotificationHubPatchParameters +from ._models_py3 import NotificationHubProperties from ._models_py3 import NotificationHubResource from ._models_py3 import Operation from ._models_py3 import OperationDisplay from ._models_py3 import OperationListResult +from ._models_py3 import OperationProperties +from ._models_py3 import PnsCredentials from ._models_py3 import PnsCredentialsResource -from ._models_py3 import PolicykeyResource +from ._models_py3 import PolicyKeyResource +from ._models_py3 import PrivateEndpointConnectionProperties +from ._models_py3 import PrivateEndpointConnectionResource +from ._models_py3 import PrivateEndpointConnectionResourceListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkResourceProperties +from ._models_py3 import PrivateLinkServiceConnection +from ._models_py3 import ProxyResource +from ._models_py3 import PublicInternetAuthorizationRule +from ._models_py3 import RegistrationResult +from ._models_py3 import RemotePrivateEndpointConnection +from ._models_py3 import RemotePrivateLinkServiceConnectionState from ._models_py3 import Resource from ._models_py3 import ResourceListKeys -from ._models_py3 import SharedAccessAuthorizationRuleCreateOrUpdateParameters +from ._models_py3 import ServiceSpecification from ._models_py3 import SharedAccessAuthorizationRuleListResult from ._models_py3 import SharedAccessAuthorizationRuleProperties from ._models_py3 import SharedAccessAuthorizationRuleResource from ._models_py3 import Sku -from ._models_py3 import SubResource +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource from ._models_py3 import WnsCredential +from ._models_py3 import WnsCredentialProperties +from ._models_py3 import XiaomiCredential +from ._models_py3 import XiaomiCredentialProperties -from ._notification_hubs_management_client_enums import AccessRights -from ._notification_hubs_management_client_enums import NamespaceType -from ._notification_hubs_management_client_enums import SkuName +from ._notification_hubs_rp_client_enums import AccessRights +from ._notification_hubs_rp_client_enums import CreatedByType +from ._notification_hubs_rp_client_enums import NamespaceStatus +from ._notification_hubs_rp_client_enums import NamespaceType +from ._notification_hubs_rp_client_enums import OperationProvisioningState +from ._notification_hubs_rp_client_enums import PolicyKeyType +from ._notification_hubs_rp_client_enums import PrivateEndpointConnectionProvisioningState +from ._notification_hubs_rp_client_enums import PrivateLinkConnectionStatus +from ._notification_hubs_rp_client_enums import PublicNetworkAccess +from ._notification_hubs_rp_client_enums import ReplicationRegion +from ._notification_hubs_rp_client_enums import SkuName +from ._notification_hubs_rp_client_enums import ZoneRedundancyPreference from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ "AdmCredential", + "AdmCredentialProperties", "ApnsCredential", + "ApnsCredentialProperties", + "Availability", "BaiduCredential", + "BaiduCredentialProperties", + "BrowserCredential", + "BrowserCredentialProperties", "CheckAvailabilityParameters", "CheckAvailabilityResult", + "ConnectionDetails", "DebugSendResponse", + "DebugSendResult", + "ErrorAdditionalInfo", + "ErrorDetail", "ErrorResponse", + "FcmV1Credential", + "FcmV1CredentialProperties", "GcmCredential", + "GcmCredentialProperties", + "GroupConnectivityInformation", + "IpRule", + "LogSpecification", + "MetricSpecification", "MpnsCredential", - "NamespaceCreateOrUpdateParameters", + "MpnsCredentialProperties", "NamespaceListResult", "NamespacePatchParameters", + "NamespaceProperties", "NamespaceResource", - "NotificationHubCreateOrUpdateParameters", + "NetworkAcls", "NotificationHubListResult", "NotificationHubPatchParameters", + "NotificationHubProperties", "NotificationHubResource", "Operation", "OperationDisplay", "OperationListResult", + "OperationProperties", + "PnsCredentials", "PnsCredentialsResource", - "PolicykeyResource", + "PolicyKeyResource", + "PrivateEndpointConnectionProperties", + "PrivateEndpointConnectionResource", + "PrivateEndpointConnectionResourceListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkResourceProperties", + "PrivateLinkServiceConnection", + "ProxyResource", + "PublicInternetAuthorizationRule", + "RegistrationResult", + "RemotePrivateEndpointConnection", + "RemotePrivateLinkServiceConnectionState", "Resource", "ResourceListKeys", - "SharedAccessAuthorizationRuleCreateOrUpdateParameters", + "ServiceSpecification", "SharedAccessAuthorizationRuleListResult", "SharedAccessAuthorizationRuleProperties", "SharedAccessAuthorizationRuleResource", "Sku", - "SubResource", + "SystemData", + "TrackedResource", "WnsCredential", + "WnsCredentialProperties", + "XiaomiCredential", + "XiaomiCredentialProperties", "AccessRights", + "CreatedByType", + "NamespaceStatus", "NamespaceType", + "OperationProvisioningState", + "PolicyKeyType", + "PrivateEndpointConnectionProvisioningState", + "PrivateLinkConnectionStatus", + "PublicNetworkAccess", + "ReplicationRegion", "SkuName", + "ZoneRedundancyPreference", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/_models_py3.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/_models_py3.py index 625801ab1f36..6d6a11c8b659 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/_models_py3.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/_models_py3.py @@ -8,53 +8,73 @@ # -------------------------------------------------------------------------- import datetime -import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from .. import _serialization -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports - if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from .. import models as _models -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object class AdmCredential(_serialization.Model): """Description of a NotificationHub AdmCredential. - :ivar client_id: The client identifier. + All required parameters must be populated in order to send to Azure. + + :ivar properties: Description of a NotificationHub AdmCredential. Required. + :vartype properties: ~azure.mgmt.notificationhubs.models.AdmCredentialProperties + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "AdmCredentialProperties"}, + } + + def __init__(self, *, properties: "_models.AdmCredentialProperties", **kwargs: Any) -> None: + """ + :keyword properties: Description of a NotificationHub AdmCredential. Required. + :paramtype properties: ~azure.mgmt.notificationhubs.models.AdmCredentialProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class AdmCredentialProperties(_serialization.Model): + """Description of a NotificationHub AdmCredential. + + All required parameters must be populated in order to send to Azure. + + :ivar client_id: Gets or sets the client identifier. Required. :vartype client_id: str - :ivar client_secret: The credential secret access key. + :ivar client_secret: Gets or sets the credential secret access key. Required. :vartype client_secret: str - :ivar auth_token_url: The URL of the authorization token. + :ivar auth_token_url: Gets or sets the URL of the authorization token. Required. :vartype auth_token_url: str """ + _validation = { + "client_id": {"required": True, "min_length": 1}, + "client_secret": {"required": True, "min_length": 1}, + "auth_token_url": {"required": True, "min_length": 1}, + } + _attribute_map = { - "client_id": {"key": "properties.clientId", "type": "str"}, - "client_secret": {"key": "properties.clientSecret", "type": "str"}, - "auth_token_url": {"key": "properties.authTokenUrl", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + "client_secret": {"key": "clientSecret", "type": "str"}, + "auth_token_url": {"key": "authTokenUrl", "type": "str"}, } - def __init__( - self, - *, - client_id: Optional[str] = None, - client_secret: Optional[str] = None, - auth_token_url: Optional[str] = None, - **kwargs - ): + def __init__(self, *, client_id: str, client_secret: str, auth_token_url: str, **kwargs: Any) -> None: """ - :keyword client_id: The client identifier. + :keyword client_id: Gets or sets the client identifier. Required. :paramtype client_id: str - :keyword client_secret: The credential secret access key. + :keyword client_secret: Gets or sets the credential secret access key. Required. :paramtype client_secret: str - :keyword auth_token_url: The URL of the authorization token. + :keyword auth_token_url: Gets or sets the URL of the authorization token. Required. :paramtype auth_token_url: str """ super().__init__(**kwargs) @@ -66,83 +86,102 @@ def __init__( class ApnsCredential(_serialization.Model): """Description of a NotificationHub ApnsCredential. - :ivar apns_certificate: The APNS certificate. Specify if using Certificate Authentication Mode. + All required parameters must be populated in order to send to Azure. + + :ivar properties: Description of a NotificationHub ApnsCredential. Required. + :vartype properties: ~azure.mgmt.notificationhubs.models.ApnsCredentialProperties + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "ApnsCredentialProperties"}, + } + + def __init__(self, *, properties: "_models.ApnsCredentialProperties", **kwargs: Any) -> None: + """ + :keyword properties: Description of a NotificationHub ApnsCredential. Required. + :paramtype properties: ~azure.mgmt.notificationhubs.models.ApnsCredentialProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class ApnsCredentialProperties(_serialization.Model): + """Description of a NotificationHub ApnsCredential. + + All required parameters must be populated in order to send to Azure. + + :ivar apns_certificate: Gets or sets the APNS certificate. :vartype apns_certificate: str - :ivar certificate_key: The APNS certificate password if it exists. + :ivar certificate_key: Gets or sets the certificate key. :vartype certificate_key: str - :ivar endpoint: The APNS endpoint of this credential. If using Certificate Authentication Mode - and Sandbox specify 'gateway.sandbox.push.apple.com'. If using Certificate Authentication Mode - and Production specify 'gateway.push.apple.com'. If using Token Authentication Mode and Sandbox - specify 'https://api.development.push.apple.com:443/3/device'. If using Token Authentication - Mode and Production specify 'https://api.push.apple.com:443/3/device'. + :ivar endpoint: Gets or sets the endpoint of this credential. Required. :vartype endpoint: str - :ivar thumbprint: The APNS certificate thumbprint. Specify if using Certificate Authentication - Mode. + :ivar thumbprint: Gets or sets the APNS certificate Thumbprint. :vartype thumbprint: str - :ivar key_id: A 10-character key identifier (kid) key, obtained from your developer account. - Specify if using Token Authentication Mode. + :ivar key_id: Gets or sets a 10-character key identifier (kid) key, obtained from + your developer account. :vartype key_id: str - :ivar app_name: The name of the application or BundleId. Specify if using Token Authentication - Mode. + :ivar app_name: Gets or sets the name of the application. :vartype app_name: str - :ivar app_id: The issuer (iss) registered claim key. The value is a 10-character TeamId, - obtained from your developer account. Specify if using Token Authentication Mode. + :ivar app_id: Gets or sets the issuer (iss) registered claim key, whose value is + your 10-character Team ID, obtained from your developer account. :vartype app_id: str - :ivar token: Provider Authentication Token, obtained through your developer account. Specify if - using Token Authentication Mode. + :ivar token: Gets or sets provider Authentication Token, obtained through your + developer account. :vartype token: str """ + _validation = { + "endpoint": {"required": True, "min_length": 1}, + } + _attribute_map = { - "apns_certificate": {"key": "properties.apnsCertificate", "type": "str"}, - "certificate_key": {"key": "properties.certificateKey", "type": "str"}, - "endpoint": {"key": "properties.endpoint", "type": "str"}, - "thumbprint": {"key": "properties.thumbprint", "type": "str"}, - "key_id": {"key": "properties.keyId", "type": "str"}, - "app_name": {"key": "properties.appName", "type": "str"}, - "app_id": {"key": "properties.appId", "type": "str"}, - "token": {"key": "properties.token", "type": "str"}, + "apns_certificate": {"key": "apnsCertificate", "type": "str"}, + "certificate_key": {"key": "certificateKey", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "key_id": {"key": "keyId", "type": "str"}, + "app_name": {"key": "appName", "type": "str"}, + "app_id": {"key": "appId", "type": "str"}, + "token": {"key": "token", "type": "str"}, } def __init__( self, *, + endpoint: str, apns_certificate: Optional[str] = None, certificate_key: Optional[str] = None, - endpoint: Optional[str] = None, thumbprint: Optional[str] = None, key_id: Optional[str] = None, app_name: Optional[str] = None, app_id: Optional[str] = None, token: Optional[str] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword apns_certificate: The APNS certificate. Specify if using Certificate Authentication - Mode. + :keyword apns_certificate: Gets or sets the APNS certificate. :paramtype apns_certificate: str - :keyword certificate_key: The APNS certificate password if it exists. + :keyword certificate_key: Gets or sets the certificate key. :paramtype certificate_key: str - :keyword endpoint: The APNS endpoint of this credential. If using Certificate Authentication - Mode and Sandbox specify 'gateway.sandbox.push.apple.com'. If using Certificate Authentication - Mode and Production specify 'gateway.push.apple.com'. If using Token Authentication Mode and - Sandbox specify 'https://api.development.push.apple.com:443/3/device'. If using Token - Authentication Mode and Production specify 'https://api.push.apple.com:443/3/device'. + :keyword endpoint: Gets or sets the endpoint of this credential. Required. :paramtype endpoint: str - :keyword thumbprint: The APNS certificate thumbprint. Specify if using Certificate - Authentication Mode. + :keyword thumbprint: Gets or sets the APNS certificate Thumbprint. :paramtype thumbprint: str - :keyword key_id: A 10-character key identifier (kid) key, obtained from your developer account. - Specify if using Token Authentication Mode. + :keyword key_id: Gets or sets a 10-character key identifier (kid) key, obtained from + your developer account. :paramtype key_id: str - :keyword app_name: The name of the application or BundleId. Specify if using Token - Authentication Mode. + :keyword app_name: Gets or sets the name of the application. :paramtype app_name: str - :keyword app_id: The issuer (iss) registered claim key. The value is a 10-character TeamId, - obtained from your developer account. Specify if using Token Authentication Mode. + :keyword app_id: Gets or sets the issuer (iss) registered claim key, whose value is + your 10-character Team ID, obtained from your developer account. :paramtype app_id: str - :keyword token: Provider Authentication Token, obtained through your developer account. Specify - if using Token Authentication Mode. + :keyword token: Gets or sets provider Authentication Token, obtained through your + developer account. :paramtype token: str """ super().__init__(**kwargs) @@ -156,37 +195,92 @@ def __init__( self.token = token +class Availability(_serialization.Model): + """Represents metric availability (part of RP operation descriptions). + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar time_grain: Time grain of the availability. + :vartype time_grain: str + :ivar blob_duration: Duration of the availability blob. + :vartype blob_duration: str + """ + + _validation = { + "time_grain": {"readonly": True}, + "blob_duration": {"readonly": True}, + } + + _attribute_map = { + "time_grain": {"key": "timeGrain", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.time_grain = None + self.blob_duration = None + + class BaiduCredential(_serialization.Model): """Description of a NotificationHub BaiduCredential. - :ivar baidu_api_key: Baidu Api Key. + All required parameters must be populated in order to send to Azure. + + :ivar properties: Description of a NotificationHub BaiduCredential. Required. + :vartype properties: ~azure.mgmt.notificationhubs.models.BaiduCredentialProperties + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "BaiduCredentialProperties"}, + } + + def __init__(self, *, properties: "_models.BaiduCredentialProperties", **kwargs: Any) -> None: + """ + :keyword properties: Description of a NotificationHub BaiduCredential. Required. + :paramtype properties: ~azure.mgmt.notificationhubs.models.BaiduCredentialProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BaiduCredentialProperties(_serialization.Model): + """Description of a NotificationHub BaiduCredential. + + All required parameters must be populated in order to send to Azure. + + :ivar baidu_api_key: Gets or sets baidu Api Key. Required. :vartype baidu_api_key: str - :ivar baidu_end_point: Baidu Endpoint. + :ivar baidu_end_point: Gets or sets baidu Endpoint. Required. :vartype baidu_end_point: str - :ivar baidu_secret_key: Baidu Secret Key. + :ivar baidu_secret_key: Gets or sets baidu Secret Key. Required. :vartype baidu_secret_key: str """ + _validation = { + "baidu_api_key": {"required": True, "min_length": 1}, + "baidu_end_point": {"required": True, "min_length": 1}, + "baidu_secret_key": {"required": True, "min_length": 1}, + } + _attribute_map = { - "baidu_api_key": {"key": "properties.baiduApiKey", "type": "str"}, - "baidu_end_point": {"key": "properties.baiduEndPoint", "type": "str"}, - "baidu_secret_key": {"key": "properties.baiduSecretKey", "type": "str"}, + "baidu_api_key": {"key": "baiduApiKey", "type": "str"}, + "baidu_end_point": {"key": "baiduEndPoint", "type": "str"}, + "baidu_secret_key": {"key": "baiduSecretKey", "type": "str"}, } - def __init__( - self, - *, - baidu_api_key: Optional[str] = None, - baidu_end_point: Optional[str] = None, - baidu_secret_key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, baidu_api_key: str, baidu_end_point: str, baidu_secret_key: str, **kwargs: Any) -> None: """ - :keyword baidu_api_key: Baidu Api Key. + :keyword baidu_api_key: Gets or sets baidu Api Key. Required. :paramtype baidu_api_key: str - :keyword baidu_end_point: Baidu Endpoint. + :keyword baidu_end_point: Gets or sets baidu Endpoint. Required. :paramtype baidu_end_point: str - :keyword baidu_secret_key: Baidu Secret Key. + :keyword baidu_secret_key: Gets or sets baidu Secret Key. Required. :paramtype baidu_secret_key: str """ super().__init__(**kwargs) @@ -195,33 +289,99 @@ def __init__( self.baidu_secret_key = baidu_secret_key +class BrowserCredential(_serialization.Model): + """Description of a NotificationHub BrowserCredential. + + All required parameters must be populated in order to send to Azure. + + :ivar properties: Description of a NotificationHub BrowserCredential. Required. + :vartype properties: ~azure.mgmt.notificationhubs.models.BrowserCredentialProperties + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "BrowserCredentialProperties"}, + } + + def __init__(self, *, properties: "_models.BrowserCredentialProperties", **kwargs: Any) -> None: + """ + :keyword properties: Description of a NotificationHub BrowserCredential. Required. + :paramtype properties: ~azure.mgmt.notificationhubs.models.BrowserCredentialProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class BrowserCredentialProperties(_serialization.Model): + """Description of a NotificationHub BrowserCredential. + + All required parameters must be populated in order to send to Azure. + + :ivar subject: Gets or sets web push subject. Required. + :vartype subject: str + :ivar vapid_private_key: Gets or sets VAPID private key. Required. + :vartype vapid_private_key: str + :ivar vapid_public_key: Gets or sets VAPID public key. Required. + :vartype vapid_public_key: str + """ + + _validation = { + "subject": {"required": True, "min_length": 1}, + "vapid_private_key": {"required": True, "min_length": 1}, + "vapid_public_key": {"required": True, "min_length": 1}, + } + + _attribute_map = { + "subject": {"key": "subject", "type": "str"}, + "vapid_private_key": {"key": "vapidPrivateKey", "type": "str"}, + "vapid_public_key": {"key": "vapidPublicKey", "type": "str"}, + } + + def __init__(self, *, subject: str, vapid_private_key: str, vapid_public_key: str, **kwargs: Any) -> None: + """ + :keyword subject: Gets or sets web push subject. Required. + :paramtype subject: str + :keyword vapid_private_key: Gets or sets VAPID private key. Required. + :paramtype vapid_private_key: str + :keyword vapid_public_key: Gets or sets VAPID public key. Required. + :paramtype vapid_public_key: str + """ + super().__init__(**kwargs) + self.subject = subject + self.vapid_private_key = vapid_private_key + self.vapid_public_key = vapid_public_key + + class CheckAvailabilityParameters(_serialization.Model): - """Parameters supplied to the Check Name Availability for Namespace and NotificationHubs. + """Parameters supplied to the Check Name Availability for Namespace and + NotificationHubs. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar id: Resource Id. + :ivar id: Gets resource Id. :vartype id: str - :ivar name: Resource name. Required. + :ivar name: Gets or sets resource name. Required. :vartype name: str - :ivar type: Resource type. + :ivar type: Gets resource type. :vartype type: str - :ivar location: Resource location. + :ivar location: Gets or sets resource location. :vartype location: str - :ivar tags: Resource tags. + :ivar tags: Gets or sets resource tags. :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. - :vartype sku: ~azure.mgmt.notificationhubs.models.Sku - :ivar is_availiable: True if the name is available and can be used to create new - Namespace/NotificationHub. Otherwise false. + :ivar is_availiable: Not used and deprecated since API version 2023-01-01-preview. :vartype is_availiable: bool + :ivar sku: The Sku description for a namespace. + :vartype sku: ~azure.mgmt.notificationhubs.models.Sku """ _validation = { "id": {"readonly": True}, - "name": {"required": True}, + "name": {"required": True, "min_length": 1}, "type": {"readonly": True}, } @@ -231,8 +391,8 @@ class CheckAvailabilityParameters(_serialization.Model): "type": {"key": "type", "type": "str"}, "location": {"key": "location", "type": "str"}, "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, "is_availiable": {"key": "isAvailiable", "type": "bool"}, + "sku": {"key": "sku", "type": "Sku"}, } def __init__( @@ -241,22 +401,21 @@ def __init__( name: str, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, is_availiable: Optional[bool] = None, - **kwargs - ): + sku: Optional["_models.Sku"] = None, + **kwargs: Any + ) -> None: """ - :keyword name: Resource name. Required. + :keyword name: Gets or sets resource name. Required. :paramtype name: str - :keyword location: Resource location. + :keyword location: Gets or sets resource location. :paramtype location: str - :keyword tags: Resource tags. + :keyword tags: Gets or sets resource tags. :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. - :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - :keyword is_availiable: True if the name is available and can be used to create new - Namespace/NotificationHub. Otherwise false. + :keyword is_availiable: Not used and deprecated since API version 2023-01-01-preview. :paramtype is_availiable: bool + :keyword sku: The Sku description for a namespace. + :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku """ super().__init__(**kwargs) self.id = None @@ -264,252 +423,518 @@ def __init__( self.type = None self.location = location self.tags = tags - self.sku = sku self.is_availiable = is_availiable + self.sku = sku class Resource(_serialization.Model): - """Resource. + """Common fields that are returned in the response for all Azure Resource Manager resources. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. - :vartype sku: ~azure.mgmt.notificationhubs.models.Sku + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.notificationhubs.models.SystemData """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - **kwargs - ): - """ - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. - :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) self.id = None self.name = None self.type = None - self.location = location - self.tags = tags - self.sku = sku + self.system_data = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have + tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.notificationhubs.models.SystemData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) -class CheckAvailabilityResult(Resource): +class CheckAvailabilityResult(ProxyResource): """Description of a CheckAvailability resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.notificationhubs.models.SystemData + :ivar is_availiable: Gets or sets true if the name is available and can be used to + create new Namespace/NotificationHub. Otherwise false. + :vartype is_availiable: bool + :ivar location: Deprecated - only for compatibility. :vartype location: str - :ivar tags: Resource tags. + :ivar tags: Deprecated - only for compatibility. :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. + :ivar sku: The Sku description for a namespace. :vartype sku: ~azure.mgmt.notificationhubs.models.Sku - :ivar is_availiable: True if the name is available and can be used to create new - Namespace/NotificationHub. Otherwise false. - :vartype is_availiable: bool """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "is_availiable": {"key": "isAvailiable", "type": "bool"}, "location": {"key": "location", "type": "str"}, "tags": {"key": "tags", "type": "{str}"}, "sku": {"key": "sku", "type": "Sku"}, - "is_availiable": {"key": "isAvailiable", "type": "bool"}, } def __init__( self, *, + is_availiable: Optional[bool] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, sku: Optional["_models.Sku"] = None, - is_availiable: Optional[bool] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword location: Resource location. + :keyword is_availiable: Gets or sets true if the name is available and can be used to + create new Namespace/NotificationHub. Otherwise false. + :paramtype is_availiable: bool + :keyword location: Deprecated - only for compatibility. :paramtype location: str - :keyword tags: Resource tags. + :keyword tags: Deprecated - only for compatibility. :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. + :keyword sku: The Sku description for a namespace. :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - :keyword is_availiable: True if the name is available and can be used to create new - Namespace/NotificationHub. Otherwise false. - :paramtype is_availiable: bool """ - super().__init__(location=location, tags=tags, sku=sku, **kwargs) + super().__init__(**kwargs) self.is_availiable = is_availiable + self.location = location + self.tags = tags + self.sku = sku + + +class ConnectionDetails(_serialization.Model): + """Part of Private Endpoint description that stores information about a connection between Private + Endpoint and Notification Hubs namespace. + This is internal class, not visible to customers, and we use it only to discover the link + identifier. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: A unique ID of the connection. This is not the ARM id, but rather an internal + identifier set by the Networking RP. Notification Hubs code + does not analyze it. + :vartype id: str + :ivar private_ip_address: IP address of the Private Endpoint. This is not used by Notification + Hubs. + :vartype private_ip_address: str + :ivar link_identifier: Link identifier. This is a string representation of an integer that is + also encoded in every IPv6 frame received by Front Door, + and we use it to create implicit authorization rule that allows connection from the associated + Private Endpoint. + :vartype link_identifier: str + :ivar group_id: Group name. Always "namespace" for Notification Hubs. + :vartype group_id: str + :ivar member_name: Member name. Always "namespace" for Notification Hubs. + :vartype member_name: str + """ + + _validation = { + "id": {"readonly": True}, + "private_ip_address": {"readonly": True}, + "link_identifier": {"readonly": True}, + "group_id": {"readonly": True}, + "member_name": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "private_ip_address": {"key": "privateIpAddress", "type": "str"}, + "link_identifier": {"key": "linkIdentifier", "type": "str"}, + "group_id": {"key": "groupId", "type": "str"}, + "member_name": {"key": "memberName", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + self.private_ip_address = None + self.link_identifier = None + self.group_id = None + self.member_name = None -class DebugSendResponse(Resource): +class DebugSendResponse(ProxyResource): """Description of a NotificationHub Resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.notificationhubs.models.SystemData + :ivar properties: Result of DebugSend operations. + :vartype properties: ~azure.mgmt.notificationhubs.models.DebugSendResult + :ivar location: Deprecated - only for compatibility. :vartype location: str - :ivar tags: Resource tags. + :ivar tags: Deprecated - only for compatibility. :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. - :vartype sku: ~azure.mgmt.notificationhubs.models.Sku - :ivar success: successful send. - :vartype success: float - :ivar failure: send failure. - :vartype failure: float - :ivar results: actual failure description. - :vartype results: JSON """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "DebugSendResult"}, "location": {"key": "location", "type": "str"}, "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "success": {"key": "properties.success", "type": "float"}, - "failure": {"key": "properties.failure", "type": "float"}, - "results": {"key": "properties.results", "type": "object"}, } def __init__( self, *, + properties: Optional["_models.DebugSendResult"] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - success: Optional[float] = None, - failure: Optional[float] = None, - results: Optional[JSON] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword location: Resource location. + :keyword properties: Result of DebugSend operations. + :paramtype properties: ~azure.mgmt.notificationhubs.models.DebugSendResult + :keyword location: Deprecated - only for compatibility. :paramtype location: str - :keyword tags: Resource tags. + :keyword tags: Deprecated - only for compatibility. :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. - :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - :keyword success: successful send. - :paramtype success: float - :keyword failure: send failure. - :paramtype failure: float - :keyword results: actual failure description. - :paramtype results: JSON """ - super().__init__(location=location, tags=tags, sku=sku, **kwargs) - self.success = success - self.failure = failure - self.results = results + super().__init__(**kwargs) + self.properties = properties + self.location = location + self.tags = tags -class ErrorResponse(_serialization.Model): - """Error response indicates NotificationHubs service is not able to process the incoming request. The reason is provided in the error message. +class DebugSendResult(_serialization.Model): + """Result of DebugSend operations. - :ivar code: Error code. - :vartype code: str - :ivar message: Error message indicating why the operation failed. - :vartype message: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar success: Gets or sets successful send. + :vartype success: int + :ivar failure: Gets or sets send failure. + :vartype failure: int + :ivar results: Gets or sets actual failure description. + :vartype results: list[~azure.mgmt.notificationhubs.models.RegistrationResult] """ + _validation = { + "success": {"readonly": True}, + "failure": {"readonly": True}, + "results": {"readonly": True}, + } + _attribute_map = { - "code": {"key": "code", "type": "str"}, - "message": {"key": "message", "type": "str"}, + "success": {"key": "success", "type": "int"}, + "failure": {"key": "failure", "type": "int"}, + "results": {"key": "results", "type": "[RegistrationResult]"}, } - def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): - """ - :keyword code: Error code. - :paramtype code: str - :keyword message: Error message indicating why the operation failed. - :paramtype message: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.code = code - self.message = message + self.success = None + self.failure = None + self.results = None -class GcmCredential(_serialization.Model): - """Description of a NotificationHub GcmCredential. +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. - :ivar gcm_endpoint: The FCM legacy endpoint. Default value is - 'https://fcm.googleapis.com/fcm/send'. - :vartype gcm_endpoint: str - :ivar google_api_key: The Google API key. - :vartype google_api_key: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The additional info type. + :vartype type: str + :ivar info: The additional info. + :vartype info: JSON """ + _validation = { + "type": {"readonly": True}, + "info": {"readonly": True}, + } + _attribute_map = { - "gcm_endpoint": {"key": "properties.gcmEndpoint", "type": "str"}, - "google_api_key": {"key": "properties.googleApiKey", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__(self, *, gcm_endpoint: Optional[str] = None, google_api_key: Optional[str] = None, **kwargs): + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ErrorDetail(_serialization.Model): + """The error detail. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar code: The error code. + :vartype code: str + :ivar message: The error message. + :vartype message: str + :ivar target: The error target. + :vartype target: str + :ivar details: The error details. + :vartype details: list[~azure.mgmt.notificationhubs.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.notificationhubs.models.ErrorAdditionalInfo] + """ + + _validation = { + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, + } + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[ErrorDetail]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class ErrorResponse(_serialization.Model): + """Common error response for all Azure Resource Manager APIs to return error details for failed + operations. (This also follows the OData error response format.). + + :ivar error: The error object. + :vartype error: ~azure.mgmt.notificationhubs.models.ErrorDetail + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: Any) -> None: + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.notificationhubs.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class FcmV1Credential(_serialization.Model): + """Description of a NotificationHub FcmV1Credential. + + All required parameters must be populated in order to send to Azure. + + :ivar properties: Description of a NotificationHub FcmV1Credential. Required. + :vartype properties: ~azure.mgmt.notificationhubs.models.FcmV1CredentialProperties + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "FcmV1CredentialProperties"}, + } + + def __init__(self, *, properties: "_models.FcmV1CredentialProperties", **kwargs: Any) -> None: + """ + :keyword properties: Description of a NotificationHub FcmV1Credential. Required. + :paramtype properties: ~azure.mgmt.notificationhubs.models.FcmV1CredentialProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class FcmV1CredentialProperties(_serialization.Model): + """Description of a NotificationHub FcmV1Credential. + + All required parameters must be populated in order to send to Azure. + + :ivar client_email: Gets or sets client email. Required. + :vartype client_email: str + :ivar private_key: Gets or sets private key. Required. + :vartype private_key: str + :ivar project_id: Gets or sets project id. Required. + :vartype project_id: str + """ + + _validation = { + "client_email": {"required": True, "min_length": 1}, + "private_key": {"required": True, "min_length": 1}, + "project_id": {"required": True, "min_length": 1}, + } + + _attribute_map = { + "client_email": {"key": "clientEmail", "type": "str"}, + "private_key": {"key": "privateKey", "type": "str"}, + "project_id": {"key": "projectId", "type": "str"}, + } + + def __init__(self, *, client_email: str, private_key: str, project_id: str, **kwargs: Any) -> None: + """ + :keyword client_email: Gets or sets client email. Required. + :paramtype client_email: str + :keyword private_key: Gets or sets private key. Required. + :paramtype private_key: str + :keyword project_id: Gets or sets project id. Required. + :paramtype project_id: str + """ + super().__init__(**kwargs) + self.client_email = client_email + self.private_key = private_key + self.project_id = project_id + + +class GcmCredential(_serialization.Model): + """Description of a NotificationHub GcmCredential. + + All required parameters must be populated in order to send to Azure. + + :ivar properties: Description of a NotificationHub GcmCredential. Required. + :vartype properties: ~azure.mgmt.notificationhubs.models.GcmCredentialProperties + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "GcmCredentialProperties"}, + } + + def __init__(self, *, properties: "_models.GcmCredentialProperties", **kwargs: Any) -> None: """ - :keyword gcm_endpoint: The FCM legacy endpoint. Default value is - 'https://fcm.googleapis.com/fcm/send'. + :keyword properties: Description of a NotificationHub GcmCredential. Required. + :paramtype properties: ~azure.mgmt.notificationhubs.models.GcmCredentialProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class GcmCredentialProperties(_serialization.Model): + """Description of a NotificationHub GcmCredential. + + All required parameters must be populated in order to send to Azure. + + :ivar gcm_endpoint: Gets or sets the GCM endpoint. + :vartype gcm_endpoint: str + :ivar google_api_key: Gets or sets the Google API key. Required. + :vartype google_api_key: str + """ + + _validation = { + "google_api_key": {"required": True, "min_length": 1}, + } + + _attribute_map = { + "gcm_endpoint": {"key": "gcmEndpoint", "type": "str"}, + "google_api_key": {"key": "googleApiKey", "type": "str"}, + } + + def __init__(self, *, google_api_key: str, gcm_endpoint: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword gcm_endpoint: Gets or sets the GCM endpoint. :paramtype gcm_endpoint: str - :keyword google_api_key: The Google API key. + :keyword google_api_key: Gets or sets the Google API key. Required. :paramtype google_api_key: str """ super().__init__(**kwargs) @@ -517,1038 +942,1671 @@ def __init__(self, *, gcm_endpoint: Optional[str] = None, google_api_key: Option self.google_api_key = google_api_key -class MpnsCredential(_serialization.Model): - """Description of a NotificationHub MpnsCredential. +class GroupConnectivityInformation(_serialization.Model): + """Represents a connectivity information to Notification Hubs namespace. This is part of + PrivateLinkService proxy that tell + the Networking RP how to connect to the Notification Hubs namespace. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar group_id: Group id. Always set to "namespace". + :vartype group_id: str + :ivar member_name: Member name. Always set to "namespace". + :vartype member_name: str + :ivar customer_visible_fqdns: List of customer-visible domain names that point to a + Notification Hubs namespace. + :vartype customer_visible_fqdns: list[str] + :ivar internal_fqdn: One of the domain name from the customer-visible names; this is used + internally by Private Link service to make connection to Notification Hubs + namespace. + :vartype internal_fqdn: str + :ivar redirect_map_id: Not used by Notification Hubs. + :vartype redirect_map_id: str + :ivar private_link_service_arm_region: ARM region for Private Link Service. We use the region + that contains the connected Notification Hubs namespace. + :vartype private_link_service_arm_region: str + """ + + _validation = { + "group_id": {"readonly": True}, + "member_name": {"readonly": True}, + "customer_visible_fqdns": {"readonly": True}, + "internal_fqdn": {"readonly": True}, + "redirect_map_id": {"readonly": True}, + "private_link_service_arm_region": {"readonly": True}, + } + + _attribute_map = { + "group_id": {"key": "groupId", "type": "str"}, + "member_name": {"key": "memberName", "type": "str"}, + "customer_visible_fqdns": {"key": "customerVisibleFqdns", "type": "[str]"}, + "internal_fqdn": {"key": "internalFqdn", "type": "str"}, + "redirect_map_id": {"key": "redirectMapId", "type": "str"}, + "private_link_service_arm_region": {"key": "privateLinkServiceArmRegion", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.group_id = None + self.member_name = None + self.customer_visible_fqdns = None + self.internal_fqdn = None + self.redirect_map_id = None + self.private_link_service_arm_region = None + + +class IpRule(_serialization.Model): + """A network authorization rule that filters traffic based on IP address. + + All required parameters must be populated in order to send to Azure. + + :ivar ip_mask: IP mask. Required. + :vartype ip_mask: str + :ivar rights: List of access rights. Required. + :vartype rights: list[str or ~azure.mgmt.notificationhubs.models.AccessRights] + """ + + _validation = { + "ip_mask": {"required": True, "min_length": 1}, + "rights": {"required": True}, + } + + _attribute_map = { + "ip_mask": {"key": "ipMask", "type": "str"}, + "rights": {"key": "rights", "type": "[str]"}, + } + + def __init__(self, *, ip_mask: str, rights: List[Union[str, "_models.AccessRights"]], **kwargs: Any) -> None: + """ + :keyword ip_mask: IP mask. Required. + :paramtype ip_mask: str + :keyword rights: List of access rights. Required. + :paramtype rights: list[str or ~azure.mgmt.notificationhubs.models.AccessRights] + """ + super().__init__(**kwargs) + self.ip_mask = ip_mask + self.rights = rights + + +class LogSpecification(_serialization.Model): + """A single log category specification. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the log category. + :vartype name: str + :ivar display_name: Display name of the log category. + :vartype display_name: str + :ivar blob_duration: Duration of data written to a single blob. + :vartype blob_duration: str + :ivar category_groups: Category group for the log specification. + :vartype category_groups: list[str] + """ + + _validation = { + "name": {"readonly": True}, + "display_name": {"readonly": True}, + "blob_duration": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "blob_duration": {"key": "blobDuration", "type": "str"}, + "category_groups": {"key": "categoryGroups", "type": "[str]"}, + } + + def __init__(self, *, category_groups: Optional[List[str]] = None, **kwargs: Any) -> None: + """ + :keyword category_groups: Category group for the log specification. + :paramtype category_groups: list[str] + """ + super().__init__(**kwargs) + self.name = None + self.display_name = None + self.blob_duration = None + self.category_groups = category_groups + + +class MetricSpecification(_serialization.Model): + """A metric specification. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Metric name / id. + :vartype name: str + :ivar display_name: User-visible metric name. + :vartype display_name: str + :ivar display_description: Description of the metric. + :vartype display_description: str + :ivar unit: Metric unit. + :vartype unit: str + :ivar aggregation_type: Type of the aggregation (Average, Minimum, Maximum, Total or Count). + :vartype aggregation_type: str + :ivar availabilities: List of availabilities. + :vartype availabilities: list[~azure.mgmt.notificationhubs.models.Availability] + :ivar supported_time_grain_types: List of supported time grain types. + :vartype supported_time_grain_types: list[str] + :ivar metric_filter_pattern: The matching regex pattern to be applied to the field pointed by + the "metricsFilterPathSelector" flag in the ARM manifest. + :vartype metric_filter_pattern: str + :ivar fill_gap_with_zero: Optional property. If set to true, then zero will be returned for + time duration where no metric is emitted / published. + :vartype fill_gap_with_zero: bool + """ + + _validation = { + "name": {"readonly": True}, + "display_name": {"readonly": True}, + "display_description": {"readonly": True}, + "unit": {"readonly": True}, + "aggregation_type": {"readonly": True}, + "availabilities": {"readonly": True}, + "supported_time_grain_types": {"readonly": True}, + "metric_filter_pattern": {"readonly": True}, + "fill_gap_with_zero": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "availabilities": {"key": "availabilities", "type": "[Availability]"}, + "supported_time_grain_types": {"key": "supportedTimeGrainTypes", "type": "[str]"}, + "metric_filter_pattern": {"key": "metricFilterPattern", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.name = None + self.display_name = None + self.display_description = None + self.unit = None + self.aggregation_type = None + self.availabilities = None + self.supported_time_grain_types = None + self.metric_filter_pattern = None + self.fill_gap_with_zero = None + + +class MpnsCredential(_serialization.Model): + """Description of a NotificationHub MpnsCredential. + + All required parameters must be populated in order to send to Azure. + + :ivar properties: Description of a NotificationHub MpnsCredential. Required. + :vartype properties: ~azure.mgmt.notificationhubs.models.MpnsCredentialProperties + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "MpnsCredentialProperties"}, + } + + def __init__(self, *, properties: "_models.MpnsCredentialProperties", **kwargs: Any) -> None: + """ + :keyword properties: Description of a NotificationHub MpnsCredential. Required. + :paramtype properties: ~azure.mgmt.notificationhubs.models.MpnsCredentialProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class MpnsCredentialProperties(_serialization.Model): + """Description of a NotificationHub MpnsCredential. + + All required parameters must be populated in order to send to Azure. + + :ivar mpns_certificate: Gets or sets the MPNS certificate. Required. + :vartype mpns_certificate: str + :ivar certificate_key: Gets or sets the certificate key for this credential. Required. + :vartype certificate_key: str + :ivar thumbprint: Gets or sets the MPNS certificate Thumbprint. Required. + :vartype thumbprint: str + """ + + _validation = { + "mpns_certificate": {"required": True, "min_length": 1}, + "certificate_key": {"required": True, "min_length": 1}, + "thumbprint": {"required": True, "min_length": 1}, + } + + _attribute_map = { + "mpns_certificate": {"key": "mpnsCertificate", "type": "str"}, + "certificate_key": {"key": "certificateKey", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + } + + def __init__(self, *, mpns_certificate: str, certificate_key: str, thumbprint: str, **kwargs: Any) -> None: + """ + :keyword mpns_certificate: Gets or sets the MPNS certificate. Required. + :paramtype mpns_certificate: str + :keyword certificate_key: Gets or sets the certificate key for this credential. Required. + :paramtype certificate_key: str + :keyword thumbprint: Gets or sets the MPNS certificate Thumbprint. Required. + :paramtype thumbprint: str + """ + super().__init__(**kwargs) + self.mpns_certificate = mpns_certificate + self.certificate_key = certificate_key + self.thumbprint = thumbprint + + +class NamespaceListResult(_serialization.Model): + """The response of the List Namespace operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets or sets result of the List AuthorizationRules operation. + :vartype value: list[~azure.mgmt.notificationhubs.models.NamespaceResource] + :ivar next_link: Gets or sets link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[NamespaceResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class NamespacePatchParameters(_serialization.Model): + """Patch parameter for NamespaceResource. + + :ivar sku: The Sku description for a namespace. + :vartype sku: ~azure.mgmt.notificationhubs.models.Sku + :ivar properties: Represents namespace properties. + :vartype properties: ~azure.mgmt.notificationhubs.models.NamespaceProperties + :ivar tags: Dictionary of :code:``. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "properties": {"key": "properties", "type": "NamespaceProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__( + self, + *, + sku: Optional["_models.Sku"] = None, + properties: Optional["_models.NamespaceProperties"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword sku: The Sku description for a namespace. + :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku + :keyword properties: Represents namespace properties. + :paramtype properties: ~azure.mgmt.notificationhubs.models.NamespaceProperties + :keyword tags: Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.sku = sku + self.properties = properties + self.tags = tags + + +class NamespaceProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """Represents namespace properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Name of the Notification Hubs namespace. This is immutable property, set + automatically + by the service when the namespace is created. + :vartype name: str + :ivar provisioning_state: Defines values for OperationProvisioningState. Known values are: + "Unknown", "InProgress", "Succeeded", "Failed", "Canceled", "Pending", and "Disabled". + :vartype provisioning_state: str or + ~azure.mgmt.notificationhubs.models.OperationProvisioningState + :ivar status: Namespace status. Known values are: "Created", "Creating", "Suspended", and + "Deleting". + :vartype status: str or ~azure.mgmt.notificationhubs.models.NamespaceStatus + :ivar enabled: Gets or sets whether or not the namespace is currently enabled. + :vartype enabled: bool + :ivar critical: Gets or sets whether or not the namespace is set as Critical. + :vartype critical: bool + :ivar subscription_id: Namespace subscription id. + :vartype subscription_id: str + :ivar region: Region. The value is always set to the same value as Namespace.Location, so we + are deprecating + this property. + :vartype region: str + :ivar metric_id: Azure Insights Metrics id. + :vartype metric_id: str + :ivar created_at: Time when the namespace was created. + :vartype created_at: ~datetime.datetime + :ivar updated_at: Time when the namespace was updated. + :vartype updated_at: ~datetime.datetime + :ivar namespace_type: Defines values for NamespaceType. Known values are: "Messaging" and + "NotificationHub". + :vartype namespace_type: str or ~azure.mgmt.notificationhubs.models.NamespaceType + :ivar replication_region: Allowed replication region. Known values are: "Default", "WestUs2", + "NorthEurope", "AustraliaEast", "BrazilSouth", "SouthEastAsia", "SouthAfricaNorth", and "None". + :vartype replication_region: str or ~azure.mgmt.notificationhubs.models.ReplicationRegion + :ivar zone_redundancy: Namespace SKU name. Known values are: "Disabled" and "Enabled". + :vartype zone_redundancy: str or ~azure.mgmt.notificationhubs.models.ZoneRedundancyPreference + :ivar network_acls: A collection of network authorization rules. + :vartype network_acls: ~azure.mgmt.notificationhubs.models.NetworkAcls + :ivar pns_credentials: Collection of Notification Hub or Notification Hub Namespace PNS + credentials. + :vartype pns_credentials: ~azure.mgmt.notificationhubs.models.PnsCredentials + :ivar service_bus_endpoint: Gets or sets endpoint you can use to perform NotificationHub + operations. + :vartype service_bus_endpoint: str + :ivar private_endpoint_connections: Private Endpoint Connections for namespace. + :vartype private_endpoint_connections: + list[~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource] + :ivar scale_unit: Gets or sets scaleUnit where the namespace gets created. + :vartype scale_unit: str + :ivar data_center: Deprecated. + :vartype data_center: str + :ivar public_network_access: Type of public network access. Known values are: "Enabled" and + "Disabled". + :vartype public_network_access: str or ~azure.mgmt.notificationhubs.models.PublicNetworkAccess + """ + + _validation = { + "name": {"readonly": True}, + "enabled": {"readonly": True}, + "critical": {"readonly": True}, + "subscription_id": {"readonly": True}, + "region": {"readonly": True}, + "metric_id": {"readonly": True}, + "created_at": {"readonly": True}, + "updated_at": {"readonly": True}, + "service_bus_endpoint": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "enabled": {"key": "enabled", "type": "bool"}, + "critical": {"key": "critical", "type": "bool"}, + "subscription_id": {"key": "subscriptionId", "type": "str"}, + "region": {"key": "region", "type": "str"}, + "metric_id": {"key": "metricId", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "updated_at": {"key": "updatedAt", "type": "iso-8601"}, + "namespace_type": {"key": "namespaceType", "type": "str"}, + "replication_region": {"key": "replicationRegion", "type": "str"}, + "zone_redundancy": {"key": "zoneRedundancy", "type": "str"}, + "network_acls": {"key": "networkAcls", "type": "NetworkAcls"}, + "pns_credentials": {"key": "pnsCredentials", "type": "PnsCredentials"}, + "service_bus_endpoint": {"key": "serviceBusEndpoint", "type": "str"}, + "private_endpoint_connections": { + "key": "privateEndpointConnections", + "type": "[PrivateEndpointConnectionResource]", + }, + "scale_unit": {"key": "scaleUnit", "type": "str"}, + "data_center": {"key": "dataCenter", "type": "str"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + } + + def __init__( + self, + *, + provisioning_state: Optional[Union[str, "_models.OperationProvisioningState"]] = None, + status: Optional[Union[str, "_models.NamespaceStatus"]] = None, + namespace_type: Optional[Union[str, "_models.NamespaceType"]] = None, + replication_region: Optional[Union[str, "_models.ReplicationRegion"]] = None, + zone_redundancy: Union[str, "_models.ZoneRedundancyPreference"] = "Disabled", + network_acls: Optional["_models.NetworkAcls"] = None, + pns_credentials: Optional["_models.PnsCredentials"] = None, + scale_unit: Optional[str] = None, + data_center: Optional[str] = None, + public_network_access: Union[str, "_models.PublicNetworkAccess"] = "Enabled", + **kwargs: Any + ) -> None: + """ + :keyword provisioning_state: Defines values for OperationProvisioningState. Known values are: + "Unknown", "InProgress", "Succeeded", "Failed", "Canceled", "Pending", and "Disabled". + :paramtype provisioning_state: str or + ~azure.mgmt.notificationhubs.models.OperationProvisioningState + :keyword status: Namespace status. Known values are: "Created", "Creating", "Suspended", and + "Deleting". + :paramtype status: str or ~azure.mgmt.notificationhubs.models.NamespaceStatus + :keyword namespace_type: Defines values for NamespaceType. Known values are: "Messaging" and + "NotificationHub". + :paramtype namespace_type: str or ~azure.mgmt.notificationhubs.models.NamespaceType + :keyword replication_region: Allowed replication region. Known values are: "Default", + "WestUs2", "NorthEurope", "AustraliaEast", "BrazilSouth", "SouthEastAsia", "SouthAfricaNorth", + and "None". + :paramtype replication_region: str or ~azure.mgmt.notificationhubs.models.ReplicationRegion + :keyword zone_redundancy: Namespace SKU name. Known values are: "Disabled" and "Enabled". + :paramtype zone_redundancy: str or ~azure.mgmt.notificationhubs.models.ZoneRedundancyPreference + :keyword network_acls: A collection of network authorization rules. + :paramtype network_acls: ~azure.mgmt.notificationhubs.models.NetworkAcls + :keyword pns_credentials: Collection of Notification Hub or Notification Hub Namespace PNS + credentials. + :paramtype pns_credentials: ~azure.mgmt.notificationhubs.models.PnsCredentials + :keyword scale_unit: Gets or sets scaleUnit where the namespace gets created. + :paramtype scale_unit: str + :keyword data_center: Deprecated. + :paramtype data_center: str + :keyword public_network_access: Type of public network access. Known values are: "Enabled" and + "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.notificationhubs.models.PublicNetworkAccess + """ + super().__init__(**kwargs) + self.name = None + self.provisioning_state = provisioning_state + self.status = status + self.enabled = None + self.critical = None + self.subscription_id = None + self.region = None + self.metric_id = None + self.created_at = None + self.updated_at = None + self.namespace_type = namespace_type + self.replication_region = replication_region + self.zone_redundancy = zone_redundancy + self.network_acls = network_acls + self.pns_credentials = pns_credentials + self.service_bus_endpoint = None + self.private_endpoint_connections = None + self.scale_unit = scale_unit + self.data_center = data_center + self.public_network_access = public_network_access + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which + has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.notificationhubs.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class NamespaceResource(TrackedResource): + """Notification Hubs Namespace Resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.notificationhubs.models.SystemData + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar sku: The Sku description for a namespace. Required. + :vartype sku: ~azure.mgmt.notificationhubs.models.Sku + :ivar properties: Represents namespace properties. + :vartype properties: ~azure.mgmt.notificationhubs.models.NamespaceProperties + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, + "sku": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "properties": {"key": "properties", "type": "NamespaceProperties"}, + } + + def __init__( + self, + *, + location: str, + sku: "_models.Sku", + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.NamespaceProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword sku: The Sku description for a namespace. Required. + :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku + :keyword properties: Represents namespace properties. + :paramtype properties: ~azure.mgmt.notificationhubs.models.NamespaceProperties + """ + super().__init__(tags=tags, location=location, **kwargs) + self.sku = sku + self.properties = properties + + +class NetworkAcls(_serialization.Model): + """A collection of network authorization rules. + + :ivar ip_rules: List of IP rules. + :vartype ip_rules: list[~azure.mgmt.notificationhubs.models.IpRule] + :ivar public_network_rule: A default (public Internet) network authorization rule, which + contains rights if no other network rule matches. + :vartype public_network_rule: + ~azure.mgmt.notificationhubs.models.PublicInternetAuthorizationRule + """ + + _attribute_map = { + "ip_rules": {"key": "ipRules", "type": "[IpRule]"}, + "public_network_rule": {"key": "publicNetworkRule", "type": "PublicInternetAuthorizationRule"}, + } + + def __init__( + self, + *, + ip_rules: Optional[List["_models.IpRule"]] = None, + public_network_rule: Optional["_models.PublicInternetAuthorizationRule"] = None, + **kwargs: Any + ) -> None: + """ + :keyword ip_rules: List of IP rules. + :paramtype ip_rules: list[~azure.mgmt.notificationhubs.models.IpRule] + :keyword public_network_rule: A default (public Internet) network authorization rule, which + contains rights if no other network rule matches. + :paramtype public_network_rule: + ~azure.mgmt.notificationhubs.models.PublicInternetAuthorizationRule + """ + super().__init__(**kwargs) + self.ip_rules = ip_rules + self.public_network_rule = public_network_rule + + +class NotificationHubListResult(_serialization.Model): + """The response of the List NotificationHub operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets or sets result of the List AuthorizationRules operation. + :vartype value: list[~azure.mgmt.notificationhubs.models.NotificationHubResource] + :ivar next_link: Gets or sets link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[NotificationHubResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class NotificationHubPatchParameters(_serialization.Model): + """Patch parameter for NamespaceResource. + + :ivar properties: NotificationHub properties. + :vartype properties: ~azure.mgmt.notificationhubs.models.NotificationHubProperties + :ivar sku: The Sku description for a namespace. + :vartype sku: ~azure.mgmt.notificationhubs.models.Sku + :ivar tags: Dictionary of :code:``. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "properties": {"key": "properties", "type": "NotificationHubProperties"}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__( + self, + *, + properties: Optional["_models.NotificationHubProperties"] = None, + sku: Optional["_models.Sku"] = None, + tags: Optional[Dict[str, str]] = None, + **kwargs: Any + ) -> None: + """ + :keyword properties: NotificationHub properties. + :paramtype properties: ~azure.mgmt.notificationhubs.models.NotificationHubProperties + :keyword sku: The Sku description for a namespace. + :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku + :keyword tags: Dictionary of :code:``. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.properties = properties + self.sku = sku + self.tags = tags + + +class NotificationHubProperties(_serialization.Model): # pylint: disable=too-many-instance-attributes + """NotificationHub properties. + + Variables are only populated by the server, and will be ignored when sending a request. - :ivar mpns_certificate: The MPNS certificate. - :vartype mpns_certificate: str - :ivar certificate_key: The certificate key for this credential. - :vartype certificate_key: str - :ivar thumbprint: The MPNS certificate Thumbprint. - :vartype thumbprint: str + :ivar name: Gets or sets the NotificationHub name. + :vartype name: str + :ivar registration_ttl: Gets or sets the RegistrationTtl of the created NotificationHub. + :vartype registration_ttl: str + :ivar authorization_rules: Gets or sets the AuthorizationRules of the created NotificationHub. + :vartype authorization_rules: + list[~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleProperties] + :ivar apns_credential: Description of a NotificationHub ApnsCredential. + :vartype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential + :ivar wns_credential: Description of a NotificationHub WnsCredential. + :vartype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential + :ivar gcm_credential: Description of a NotificationHub GcmCredential. + :vartype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential + :ivar mpns_credential: Description of a NotificationHub MpnsCredential. + :vartype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential + :ivar adm_credential: Description of a NotificationHub AdmCredential. + :vartype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential + :ivar baidu_credential: Description of a NotificationHub BaiduCredential. + :vartype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential + :ivar browser_credential: Description of a NotificationHub BrowserCredential. + :vartype browser_credential: ~azure.mgmt.notificationhubs.models.BrowserCredential + :ivar xiaomi_credential: Description of a NotificationHub XiaomiCredential. + :vartype xiaomi_credential: ~azure.mgmt.notificationhubs.models.XiaomiCredential + :ivar fcm_v1_credential: Description of a NotificationHub FcmV1Credential. + :vartype fcm_v1_credential: ~azure.mgmt.notificationhubs.models.FcmV1Credential + :ivar daily_max_active_devices: + :vartype daily_max_active_devices: int """ + _validation = { + "authorization_rules": {"readonly": True}, + "daily_max_active_devices": {"readonly": True}, + } + _attribute_map = { - "mpns_certificate": {"key": "properties.mpnsCertificate", "type": "str"}, - "certificate_key": {"key": "properties.certificateKey", "type": "str"}, - "thumbprint": {"key": "properties.thumbprint", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "registration_ttl": {"key": "registrationTtl", "type": "str"}, + "authorization_rules": {"key": "authorizationRules", "type": "[SharedAccessAuthorizationRuleProperties]"}, + "apns_credential": {"key": "apnsCredential", "type": "ApnsCredential"}, + "wns_credential": {"key": "wnsCredential", "type": "WnsCredential"}, + "gcm_credential": {"key": "gcmCredential", "type": "GcmCredential"}, + "mpns_credential": {"key": "mpnsCredential", "type": "MpnsCredential"}, + "adm_credential": {"key": "admCredential", "type": "AdmCredential"}, + "baidu_credential": {"key": "baiduCredential", "type": "BaiduCredential"}, + "browser_credential": {"key": "browserCredential", "type": "BrowserCredential"}, + "xiaomi_credential": {"key": "xiaomiCredential", "type": "XiaomiCredential"}, + "fcm_v1_credential": {"key": "fcmV1Credential", "type": "FcmV1Credential"}, + "daily_max_active_devices": {"key": "dailyMaxActiveDevices", "type": "int"}, } def __init__( self, *, - mpns_certificate: Optional[str] = None, - certificate_key: Optional[str] = None, - thumbprint: Optional[str] = None, - **kwargs - ): + name: Optional[str] = None, + registration_ttl: Optional[str] = None, + apns_credential: Optional["_models.ApnsCredential"] = None, + wns_credential: Optional["_models.WnsCredential"] = None, + gcm_credential: Optional["_models.GcmCredential"] = None, + mpns_credential: Optional["_models.MpnsCredential"] = None, + adm_credential: Optional["_models.AdmCredential"] = None, + baidu_credential: Optional["_models.BaiduCredential"] = None, + browser_credential: Optional["_models.BrowserCredential"] = None, + xiaomi_credential: Optional["_models.XiaomiCredential"] = None, + fcm_v1_credential: Optional["_models.FcmV1Credential"] = None, + **kwargs: Any + ) -> None: """ - :keyword mpns_certificate: The MPNS certificate. - :paramtype mpns_certificate: str - :keyword certificate_key: The certificate key for this credential. - :paramtype certificate_key: str - :keyword thumbprint: The MPNS certificate Thumbprint. - :paramtype thumbprint: str + :keyword name: Gets or sets the NotificationHub name. + :paramtype name: str + :keyword registration_ttl: Gets or sets the RegistrationTtl of the created NotificationHub. + :paramtype registration_ttl: str + :keyword apns_credential: Description of a NotificationHub ApnsCredential. + :paramtype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential + :keyword wns_credential: Description of a NotificationHub WnsCredential. + :paramtype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential + :keyword gcm_credential: Description of a NotificationHub GcmCredential. + :paramtype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential + :keyword mpns_credential: Description of a NotificationHub MpnsCredential. + :paramtype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential + :keyword adm_credential: Description of a NotificationHub AdmCredential. + :paramtype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential + :keyword baidu_credential: Description of a NotificationHub BaiduCredential. + :paramtype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential + :keyword browser_credential: Description of a NotificationHub BrowserCredential. + :paramtype browser_credential: ~azure.mgmt.notificationhubs.models.BrowserCredential + :keyword xiaomi_credential: Description of a NotificationHub XiaomiCredential. + :paramtype xiaomi_credential: ~azure.mgmt.notificationhubs.models.XiaomiCredential + :keyword fcm_v1_credential: Description of a NotificationHub FcmV1Credential. + :paramtype fcm_v1_credential: ~azure.mgmt.notificationhubs.models.FcmV1Credential """ super().__init__(**kwargs) - self.mpns_certificate = mpns_certificate - self.certificate_key = certificate_key - self.thumbprint = thumbprint + self.name = name + self.registration_ttl = registration_ttl + self.authorization_rules = None + self.apns_credential = apns_credential + self.wns_credential = wns_credential + self.gcm_credential = gcm_credential + self.mpns_credential = mpns_credential + self.adm_credential = adm_credential + self.baidu_credential = baidu_credential + self.browser_credential = browser_credential + self.xiaomi_credential = xiaomi_credential + self.fcm_v1_credential = fcm_v1_credential + self.daily_max_active_devices = None -class NamespaceCreateOrUpdateParameters(Resource): # pylint: disable=too-many-instance-attributes - """Parameters supplied to the CreateOrUpdate Namespace operation. +class NotificationHubResource(TrackedResource): + """Notification Hub Resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. - :vartype location: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.notificationhubs.models.SystemData :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar properties: NotificationHub properties. + :vartype properties: ~azure.mgmt.notificationhubs.models.NotificationHubProperties + :ivar sku: The Sku description for a namespace. :vartype sku: ~azure.mgmt.notificationhubs.models.Sku - :ivar name_properties_name: The name of the namespace. - :vartype name_properties_name: str - :ivar provisioning_state: Provisioning state of the Namespace. - :vartype provisioning_state: str - :ivar region: Specifies the targeted region in which the namespace should be created. It can be - any of the following values: Australia East, Australia Southeast, Central US, East US, East US - 2, West US, North Central US, South Central US, East Asia, Southeast Asia, Brazil South, Japan - East, Japan West, North Europe, West Europe. - :vartype region: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - :ivar status: Status of the namespace. It can be any of these values:1 = Created/Active2 = - Creating3 = Suspended4 = Deleting. - :vartype status: str - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform NotificationHub operations. - :vartype service_bus_endpoint: str - :ivar subscription_id: The Id of the Azure subscription associated with the namespace. - :vartype subscription_id: str - :ivar scale_unit: ScaleUnit where the namespace gets created. - :vartype scale_unit: str - :ivar enabled: Whether or not the namespace is currently enabled. - :vartype enabled: bool - :ivar critical: Whether or not the namespace is set as Critical. - :vartype critical: bool - :ivar data_center: Data center for the namespace. - :vartype data_center: str - :ivar namespace_type: The namespace type. Known values are: "Messaging" and "NotificationHub". - :vartype namespace_type: str or ~azure.mgmt.notificationhubs.models.NamespaceType """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, - "metric_id": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "properties": {"key": "properties", "type": "NotificationHubProperties"}, "sku": {"key": "sku", "type": "Sku"}, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "region": {"key": "properties.region", "type": "str"}, - "metric_id": {"key": "properties.metricId", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, - "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, - "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, - "subscription_id": {"key": "properties.subscriptionId", "type": "str"}, - "scale_unit": {"key": "properties.scaleUnit", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "critical": {"key": "properties.critical", "type": "bool"}, - "data_center": {"key": "properties.dataCenter", "type": "str"}, - "namespace_type": {"key": "properties.namespaceType", "type": "str"}, } def __init__( self, *, - location: Optional[str] = None, + location: str, tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.NotificationHubProperties"] = None, sku: Optional["_models.Sku"] = None, - name_properties_name: Optional[str] = None, - provisioning_state: Optional[str] = None, - region: Optional[str] = None, - status: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - updated_at: Optional[datetime.datetime] = None, - service_bus_endpoint: Optional[str] = None, - subscription_id: Optional[str] = None, - scale_unit: Optional[str] = None, - enabled: Optional[bool] = None, - critical: Optional[bool] = None, - data_center: Optional[str] = None, - namespace_type: Optional[Union[str, "_models.NamespaceType"]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword location: Resource location. - :paramtype location: str :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword properties: NotificationHub properties. + :paramtype properties: ~azure.mgmt.notificationhubs.models.NotificationHubProperties + :keyword sku: The Sku description for a namespace. :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - :keyword name_properties_name: The name of the namespace. - :paramtype name_properties_name: str - :keyword provisioning_state: Provisioning state of the Namespace. - :paramtype provisioning_state: str - :keyword region: Specifies the targeted region in which the namespace should be created. It can - be any of the following values: Australia East, Australia Southeast, Central US, East US, East - US 2, West US, North Central US, South Central US, East Asia, Southeast Asia, Brazil South, - Japan East, Japan West, North Europe, West Europe. - :paramtype region: str - :keyword status: Status of the namespace. It can be any of these values:1 = Created/Active2 = - Creating3 = Suspended4 = Deleting. - :paramtype status: str - :keyword created_at: The time the namespace was created. - :paramtype created_at: ~datetime.datetime - :keyword updated_at: The time the namespace was updated. - :paramtype updated_at: ~datetime.datetime - :keyword service_bus_endpoint: Endpoint you can use to perform NotificationHub operations. - :paramtype service_bus_endpoint: str - :keyword subscription_id: The Id of the Azure subscription associated with the namespace. - :paramtype subscription_id: str - :keyword scale_unit: ScaleUnit where the namespace gets created. - :paramtype scale_unit: str - :keyword enabled: Whether or not the namespace is currently enabled. - :paramtype enabled: bool - :keyword critical: Whether or not the namespace is set as Critical. - :paramtype critical: bool - :keyword data_center: Data center for the namespace. - :paramtype data_center: str - :keyword namespace_type: The namespace type. Known values are: "Messaging" and - "NotificationHub". - :paramtype namespace_type: str or ~azure.mgmt.notificationhubs.models.NamespaceType """ - super().__init__(location=location, tags=tags, sku=sku, **kwargs) - self.name_properties_name = name_properties_name - self.provisioning_state = provisioning_state - self.region = region - self.metric_id = None - self.status = status - self.created_at = created_at - self.updated_at = updated_at - self.service_bus_endpoint = service_bus_endpoint - self.subscription_id = subscription_id - self.scale_unit = scale_unit - self.enabled = enabled - self.critical = critical - self.data_center = data_center - self.namespace_type = namespace_type + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + self.sku = sku -class NamespaceListResult(_serialization.Model): - """The response of the List Namespace operation. +class Operation(_serialization.Model): + """A NotificationHubs REST API operation. - :ivar value: Result of the List Namespace operation. - :vartype value: list[~azure.mgmt.notificationhubs.models.NamespaceResource] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Namespaces. - :vartype next_link: str + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: Gets operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.notificationhubs.models.OperationDisplay + :ivar properties: Optional operation properties. + :vartype properties: ~azure.mgmt.notificationhubs.models.OperationProperties + :ivar is_data_action: Gets or sets IsDataAction property. It is used to differentiate + management and data plane operations. + :vartype is_data_action: bool """ + _validation = { + "name": {"readonly": True}, + "is_data_action": {"readonly": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[NamespaceResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "properties": {"key": "properties", "type": "OperationProperties"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, } def __init__( - self, *, value: Optional[List["_models.NamespaceResource"]] = None, next_link: Optional[str] = None, **kwargs - ): + self, + *, + display: Optional["_models.OperationDisplay"] = None, + properties: Optional["_models.OperationProperties"] = None, + **kwargs: Any + ) -> None: """ - :keyword value: Result of the List Namespace operation. - :paramtype value: list[~azure.mgmt.notificationhubs.models.NamespaceResource] - :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete - list of Namespaces. - :paramtype next_link: str + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.notificationhubs.models.OperationDisplay + :keyword properties: Optional operation properties. + :paramtype properties: ~azure.mgmt.notificationhubs.models.OperationProperties """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.name = None + self.display = display + self.properties = properties + self.is_data_action = None -class NamespacePatchParameters(_serialization.Model): - """Parameters supplied to the Patch Namespace operation. +class OperationDisplay(_serialization.Model): + """The object that represents the operation. - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. - :vartype sku: ~azure.mgmt.notificationhubs.models.Sku + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: Gets service provider: Microsoft.NotificationHubs. + :vartype provider: str + :ivar resource: Gets resource on which the operation is performed: Invoice, etc. + :vartype resource: str + :ivar operation: Gets operation type: Read, write, delete, etc. + :vartype operation: str + :ivar description: Human-friendly operation description. + :vartype description: str """ + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + _attribute_map = { - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__(self, *, tags: Optional[Dict[str, str]] = None, sku: Optional["_models.Sku"] = None, **kwargs): - """ - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. - :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.tags = tags - self.sku = sku + self.provider = None + self.resource = None + self.operation = None + self.description = None -class NamespaceResource(Resource): # pylint: disable=too-many-instance-attributes - """Description of a Namespace resource. +class OperationListResult(_serialization.Model): + """Result of the request to list NotificationHubs operations. It contains + a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. - :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. - :vartype sku: ~azure.mgmt.notificationhubs.models.Sku - :ivar name_properties_name: The name of the namespace. - :vartype name_properties_name: str - :ivar provisioning_state: Provisioning state of the Namespace. - :vartype provisioning_state: str - :ivar region: Specifies the targeted region in which the namespace should be created. It can be - any of the following values: Australia East, Australia Southeast, Central US, East US, East US - 2, West US, North Central US, South Central US, East Asia, Southeast Asia, Brazil South, Japan - East, Japan West, North Europe, West Europe. - :vartype region: str - :ivar metric_id: Identifier for Azure Insights metrics. - :vartype metric_id: str - :ivar status: Status of the namespace. It can be any of these values:1 = Created/Active2 = - Creating3 = Suspended4 = Deleting. - :vartype status: str - :ivar created_at: The time the namespace was created. - :vartype created_at: ~datetime.datetime - :ivar updated_at: The time the namespace was updated. - :vartype updated_at: ~datetime.datetime - :ivar service_bus_endpoint: Endpoint you can use to perform NotificationHub operations. - :vartype service_bus_endpoint: str - :ivar subscription_id: The Id of the Azure subscription associated with the namespace. - :vartype subscription_id: str - :ivar scale_unit: ScaleUnit where the namespace gets created. - :vartype scale_unit: str - :ivar enabled: Whether or not the namespace is currently enabled. - :vartype enabled: bool - :ivar critical: Whether or not the namespace is set as Critical. - :vartype critical: bool - :ivar data_center: Data center for the namespace. - :vartype data_center: str - :ivar namespace_type: The namespace type. Known values are: "Messaging" and "NotificationHub". - :vartype namespace_type: str or ~azure.mgmt.notificationhubs.models.NamespaceType + :ivar value: Gets list of NotificationHubs operations supported by the + Microsoft.NotificationHubs resource provider. + :vartype value: list[~azure.mgmt.notificationhubs.models.Operation] + :ivar next_link: Gets URL to get the next set of operation list results if there are + any. + :vartype next_link: str """ _validation = { - "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, - "metric_id": {"readonly": True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, - "region": {"key": "properties.region", "type": "str"}, - "metric_id": {"key": "properties.metricId", "type": "str"}, - "status": {"key": "properties.status", "type": "str"}, - "created_at": {"key": "properties.createdAt", "type": "iso-8601"}, - "updated_at": {"key": "properties.updatedAt", "type": "iso-8601"}, - "service_bus_endpoint": {"key": "properties.serviceBusEndpoint", "type": "str"}, - "subscription_id": {"key": "properties.subscriptionId", "type": "str"}, - "scale_unit": {"key": "properties.scaleUnit", "type": "str"}, - "enabled": {"key": "properties.enabled", "type": "bool"}, - "critical": {"key": "properties.critical", "type": "bool"}, - "data_center": {"key": "properties.dataCenter", "type": "str"}, - "namespace_type": {"key": "properties.namespaceType", "type": "str"}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class OperationProperties(_serialization.Model): + """Optional operation properties. + + :ivar service_specification: Optional service specification used in Operations API. + :vartype service_specification: ~azure.mgmt.notificationhubs.models.ServiceSpecification + """ + + _attribute_map = { + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, + } + + def __init__( + self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs: Any + ) -> None: + """ + :keyword service_specification: Optional service specification used in Operations API. + :paramtype service_specification: ~azure.mgmt.notificationhubs.models.ServiceSpecification + """ + super().__init__(**kwargs) + self.service_specification = service_specification + + +class PnsCredentials(_serialization.Model): + """Collection of Notification Hub or Notification Hub Namespace PNS credentials. + + :ivar adm_credential: Description of a NotificationHub AdmCredential. + :vartype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential + :ivar apns_credential: Description of a NotificationHub ApnsCredential. + :vartype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential + :ivar baidu_credential: Description of a NotificationHub BaiduCredential. + :vartype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential + :ivar browser_credential: Description of a NotificationHub BrowserCredential. + :vartype browser_credential: ~azure.mgmt.notificationhubs.models.BrowserCredential + :ivar gcm_credential: Description of a NotificationHub GcmCredential. + :vartype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential + :ivar mpns_credential: Description of a NotificationHub MpnsCredential. + :vartype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential + :ivar wns_credential: Description of a NotificationHub WnsCredential. + :vartype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential + :ivar xiaomi_credential: Description of a NotificationHub XiaomiCredential. + :vartype xiaomi_credential: ~azure.mgmt.notificationhubs.models.XiaomiCredential + :ivar fcm_v1_credential: Description of a NotificationHub FcmV1Credential. + :vartype fcm_v1_credential: ~azure.mgmt.notificationhubs.models.FcmV1Credential + """ + + _attribute_map = { + "adm_credential": {"key": "admCredential", "type": "AdmCredential"}, + "apns_credential": {"key": "apnsCredential", "type": "ApnsCredential"}, + "baidu_credential": {"key": "baiduCredential", "type": "BaiduCredential"}, + "browser_credential": {"key": "browserCredential", "type": "BrowserCredential"}, + "gcm_credential": {"key": "gcmCredential", "type": "GcmCredential"}, + "mpns_credential": {"key": "mpnsCredential", "type": "MpnsCredential"}, + "wns_credential": {"key": "wnsCredential", "type": "WnsCredential"}, + "xiaomi_credential": {"key": "xiaomiCredential", "type": "XiaomiCredential"}, + "fcm_v1_credential": {"key": "fcmV1Credential", "type": "FcmV1Credential"}, } def __init__( self, *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - name_properties_name: Optional[str] = None, - provisioning_state: Optional[str] = None, - region: Optional[str] = None, - status: Optional[str] = None, - created_at: Optional[datetime.datetime] = None, - updated_at: Optional[datetime.datetime] = None, - service_bus_endpoint: Optional[str] = None, - subscription_id: Optional[str] = None, - scale_unit: Optional[str] = None, - enabled: Optional[bool] = None, - critical: Optional[bool] = None, - data_center: Optional[str] = None, - namespace_type: Optional[Union[str, "_models.NamespaceType"]] = None, - **kwargs - ): + adm_credential: Optional["_models.AdmCredential"] = None, + apns_credential: Optional["_models.ApnsCredential"] = None, + baidu_credential: Optional["_models.BaiduCredential"] = None, + browser_credential: Optional["_models.BrowserCredential"] = None, + gcm_credential: Optional["_models.GcmCredential"] = None, + mpns_credential: Optional["_models.MpnsCredential"] = None, + wns_credential: Optional["_models.WnsCredential"] = None, + xiaomi_credential: Optional["_models.XiaomiCredential"] = None, + fcm_v1_credential: Optional["_models.FcmV1Credential"] = None, + **kwargs: Any + ) -> None: """ - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. - :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - :keyword name_properties_name: The name of the namespace. - :paramtype name_properties_name: str - :keyword provisioning_state: Provisioning state of the Namespace. - :paramtype provisioning_state: str - :keyword region: Specifies the targeted region in which the namespace should be created. It can - be any of the following values: Australia East, Australia Southeast, Central US, East US, East - US 2, West US, North Central US, South Central US, East Asia, Southeast Asia, Brazil South, - Japan East, Japan West, North Europe, West Europe. - :paramtype region: str - :keyword status: Status of the namespace. It can be any of these values:1 = Created/Active2 = - Creating3 = Suspended4 = Deleting. - :paramtype status: str - :keyword created_at: The time the namespace was created. - :paramtype created_at: ~datetime.datetime - :keyword updated_at: The time the namespace was updated. - :paramtype updated_at: ~datetime.datetime - :keyword service_bus_endpoint: Endpoint you can use to perform NotificationHub operations. - :paramtype service_bus_endpoint: str - :keyword subscription_id: The Id of the Azure subscription associated with the namespace. - :paramtype subscription_id: str - :keyword scale_unit: ScaleUnit where the namespace gets created. - :paramtype scale_unit: str - :keyword enabled: Whether or not the namespace is currently enabled. - :paramtype enabled: bool - :keyword critical: Whether or not the namespace is set as Critical. - :paramtype critical: bool - :keyword data_center: Data center for the namespace. - :paramtype data_center: str - :keyword namespace_type: The namespace type. Known values are: "Messaging" and - "NotificationHub". - :paramtype namespace_type: str or ~azure.mgmt.notificationhubs.models.NamespaceType + :keyword adm_credential: Description of a NotificationHub AdmCredential. + :paramtype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential + :keyword apns_credential: Description of a NotificationHub ApnsCredential. + :paramtype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential + :keyword baidu_credential: Description of a NotificationHub BaiduCredential. + :paramtype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential + :keyword browser_credential: Description of a NotificationHub BrowserCredential. + :paramtype browser_credential: ~azure.mgmt.notificationhubs.models.BrowserCredential + :keyword gcm_credential: Description of a NotificationHub GcmCredential. + :paramtype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential + :keyword mpns_credential: Description of a NotificationHub MpnsCredential. + :paramtype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential + :keyword wns_credential: Description of a NotificationHub WnsCredential. + :paramtype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential + :keyword xiaomi_credential: Description of a NotificationHub XiaomiCredential. + :paramtype xiaomi_credential: ~azure.mgmt.notificationhubs.models.XiaomiCredential + :keyword fcm_v1_credential: Description of a NotificationHub FcmV1Credential. + :paramtype fcm_v1_credential: ~azure.mgmt.notificationhubs.models.FcmV1Credential """ - super().__init__(location=location, tags=tags, sku=sku, **kwargs) - self.name_properties_name = name_properties_name - self.provisioning_state = provisioning_state - self.region = region - self.metric_id = None - self.status = status - self.created_at = created_at - self.updated_at = updated_at - self.service_bus_endpoint = service_bus_endpoint - self.subscription_id = subscription_id - self.scale_unit = scale_unit - self.enabled = enabled - self.critical = critical - self.data_center = data_center - self.namespace_type = namespace_type + super().__init__(**kwargs) + self.adm_credential = adm_credential + self.apns_credential = apns_credential + self.baidu_credential = baidu_credential + self.browser_credential = browser_credential + self.gcm_credential = gcm_credential + self.mpns_credential = mpns_credential + self.wns_credential = wns_credential + self.xiaomi_credential = xiaomi_credential + self.fcm_v1_credential = fcm_v1_credential -class NotificationHubCreateOrUpdateParameters(Resource): # pylint: disable=too-many-instance-attributes - """Parameters supplied to the CreateOrUpdate NotificationHub operation. +class PnsCredentialsResource(ProxyResource): + """Description of a NotificationHub PNS Credentials. This is a response of the POST requests that + return namespace or hubs + PNS credentials. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.notificationhubs.models.SystemData + :ivar properties: Collection of Notification Hub or Notification Hub Namespace PNS credentials. + :vartype properties: ~azure.mgmt.notificationhubs.models.PnsCredentials + :ivar location: Deprecated - only for compatibility. :vartype location: str - :ivar tags: Resource tags. + :ivar tags: Deprecated - only for compatibility. :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. - :vartype sku: ~azure.mgmt.notificationhubs.models.Sku - :ivar name_properties_name: The NotificationHub name. - :vartype name_properties_name: str - :ivar registration_ttl: The RegistrationTtl of the created NotificationHub. - :vartype registration_ttl: str - :ivar authorization_rules: The AuthorizationRules of the created NotificationHub. - :vartype authorization_rules: - list[~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleProperties] - :ivar apns_credential: The ApnsCredential of the created NotificationHub. - :vartype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential - :ivar wns_credential: The WnsCredential of the created NotificationHub. - :vartype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential - :ivar gcm_credential: The GcmCredential of the created NotificationHub. - :vartype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential - :ivar mpns_credential: The MpnsCredential of the created NotificationHub. - :vartype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential - :ivar adm_credential: The AdmCredential of the created NotificationHub. - :vartype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential - :ivar baidu_credential: The BaiduCredential of the created NotificationHub. - :vartype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "PnsCredentials"}, "location": {"key": "location", "type": "str"}, "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "registration_ttl": {"key": "properties.registrationTtl", "type": "str"}, - "authorization_rules": { - "key": "properties.authorizationRules", - "type": "[SharedAccessAuthorizationRuleProperties]", - }, - "apns_credential": {"key": "properties.apnsCredential", "type": "ApnsCredential"}, - "wns_credential": {"key": "properties.wnsCredential", "type": "WnsCredential"}, - "gcm_credential": {"key": "properties.gcmCredential", "type": "GcmCredential"}, - "mpns_credential": {"key": "properties.mpnsCredential", "type": "MpnsCredential"}, - "adm_credential": {"key": "properties.admCredential", "type": "AdmCredential"}, - "baidu_credential": {"key": "properties.baiduCredential", "type": "BaiduCredential"}, } def __init__( self, *, + properties: Optional["_models.PnsCredentials"] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - name_properties_name: Optional[str] = None, - registration_ttl: Optional[str] = None, - authorization_rules: Optional[List["_models.SharedAccessAuthorizationRuleProperties"]] = None, - apns_credential: Optional["_models.ApnsCredential"] = None, - wns_credential: Optional["_models.WnsCredential"] = None, - gcm_credential: Optional["_models.GcmCredential"] = None, - mpns_credential: Optional["_models.MpnsCredential"] = None, - adm_credential: Optional["_models.AdmCredential"] = None, - baidu_credential: Optional["_models.BaiduCredential"] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword location: Resource location. + :keyword properties: Collection of Notification Hub or Notification Hub Namespace PNS + credentials. + :paramtype properties: ~azure.mgmt.notificationhubs.models.PnsCredentials + :keyword location: Deprecated - only for compatibility. :paramtype location: str - :keyword tags: Resource tags. + :keyword tags: Deprecated - only for compatibility. :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. - :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - :keyword name_properties_name: The NotificationHub name. - :paramtype name_properties_name: str - :keyword registration_ttl: The RegistrationTtl of the created NotificationHub. - :paramtype registration_ttl: str - :keyword authorization_rules: The AuthorizationRules of the created NotificationHub. - :paramtype authorization_rules: - list[~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleProperties] - :keyword apns_credential: The ApnsCredential of the created NotificationHub. - :paramtype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential - :keyword wns_credential: The WnsCredential of the created NotificationHub. - :paramtype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential - :keyword gcm_credential: The GcmCredential of the created NotificationHub. - :paramtype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential - :keyword mpns_credential: The MpnsCredential of the created NotificationHub. - :paramtype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential - :keyword adm_credential: The AdmCredential of the created NotificationHub. - :paramtype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential - :keyword baidu_credential: The BaiduCredential of the created NotificationHub. - :paramtype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential """ - super().__init__(location=location, tags=tags, sku=sku, **kwargs) - self.name_properties_name = name_properties_name - self.registration_ttl = registration_ttl - self.authorization_rules = authorization_rules - self.apns_credential = apns_credential - self.wns_credential = wns_credential - self.gcm_credential = gcm_credential - self.mpns_credential = mpns_credential - self.adm_credential = adm_credential - self.baidu_credential = baidu_credential + super().__init__(**kwargs) + self.properties = properties + self.location = location + self.tags = tags -class NotificationHubListResult(_serialization.Model): - """The response of the List NotificationHub operation. +class PolicyKeyResource(_serialization.Model): + """Namespace / NotificationHub Regenerate Keys request. - :ivar value: Result of the List NotificationHub operation. - :vartype value: list[~azure.mgmt.notificationhubs.models.NotificationHubResource] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of NotificationHub. - :vartype next_link: str + All required parameters must be populated in order to send to Azure. + + :ivar policy_key: Type of Shared Access Policy Key (primary or secondary). Required. Known + values are: "PrimaryKey" and "SecondaryKey". + :vartype policy_key: str or ~azure.mgmt.notificationhubs.models.PolicyKeyType """ + _validation = { + "policy_key": {"required": True}, + } + _attribute_map = { - "value": {"key": "value", "type": "[NotificationHubResource]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "policy_key": {"key": "policyKey", "type": "str"}, + } + + def __init__(self, *, policy_key: Union[str, "_models.PolicyKeyType"], **kwargs: Any) -> None: + """ + :keyword policy_key: Type of Shared Access Policy Key (primary or secondary). Required. Known + values are: "PrimaryKey" and "SecondaryKey". + :paramtype policy_key: str or ~azure.mgmt.notificationhubs.models.PolicyKeyType + """ + super().__init__(**kwargs) + self.policy_key = policy_key + + +class PrivateEndpointConnectionProperties(_serialization.Model): + """Private Endpoint Connection properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of Private Endpoint Connection. Known values are: "Unknown", + "Succeeded", "Creating", "Updating", "UpdatingByProxy", "Deleting", "DeletingByProxy", and + "Deleted". + :vartype provisioning_state: str or + ~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionProvisioningState + :ivar private_endpoint: Represents a Private Endpoint that is connected to Notification Hubs + namespace using Private Endpoint Connection. + :vartype private_endpoint: ~azure.mgmt.notificationhubs.models.RemotePrivateEndpointConnection + :ivar group_ids: List of group ids. For Notification Hubs, it always contains a single + "namespace" element. + :vartype group_ids: list[str] + :ivar private_link_service_connection_state: State of the Private Link Service connection. + :vartype private_link_service_connection_state: + ~azure.mgmt.notificationhubs.models.RemotePrivateLinkServiceConnectionState + """ + + _validation = { + "group_ids": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "private_endpoint": {"key": "privateEndpoint", "type": "RemotePrivateEndpointConnection"}, + "group_ids": {"key": "groupIds", "type": "[str]"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "RemotePrivateLinkServiceConnectionState", + }, } def __init__( self, *, - value: Optional[List["_models.NotificationHubResource"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + provisioning_state: Optional[Union[str, "_models.PrivateEndpointConnectionProvisioningState"]] = None, + private_endpoint: Optional["_models.RemotePrivateEndpointConnection"] = None, + private_link_service_connection_state: Optional["_models.RemotePrivateLinkServiceConnectionState"] = None, + **kwargs: Any + ) -> None: """ - :keyword value: Result of the List NotificationHub operation. - :paramtype value: list[~azure.mgmt.notificationhubs.models.NotificationHubResource] - :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete - list of NotificationHub. - :paramtype next_link: str + :keyword provisioning_state: State of Private Endpoint Connection. Known values are: "Unknown", + "Succeeded", "Creating", "Updating", "UpdatingByProxy", "Deleting", "DeletingByProxy", and + "Deleted". + :paramtype provisioning_state: str or + ~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionProvisioningState + :keyword private_endpoint: Represents a Private Endpoint that is connected to Notification Hubs + namespace using Private Endpoint Connection. + :paramtype private_endpoint: + ~azure.mgmt.notificationhubs.models.RemotePrivateEndpointConnection + :keyword private_link_service_connection_state: State of the Private Link Service connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.notificationhubs.models.RemotePrivateLinkServiceConnectionState """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.provisioning_state = provisioning_state + self.private_endpoint = private_endpoint + self.group_ids = None + self.private_link_service_connection_state = private_link_service_connection_state -class NotificationHubPatchParameters(Resource): # pylint: disable=too-many-instance-attributes - """Parameters supplied to the patch NotificationHub operation. +class PrivateEndpointConnectionResource(ProxyResource): + """Represents a Private Endpoint Connection ARM resource - a sub-resource of Notification Hubs + namespace. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. - :vartype sku: ~azure.mgmt.notificationhubs.models.Sku - :ivar name_properties_name: The NotificationHub name. - :vartype name_properties_name: str - :ivar registration_ttl: The RegistrationTtl of the created NotificationHub. - :vartype registration_ttl: str - :ivar authorization_rules: The AuthorizationRules of the created NotificationHub. - :vartype authorization_rules: - list[~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleProperties] - :ivar apns_credential: The ApnsCredential of the created NotificationHub. - :vartype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential - :ivar wns_credential: The WnsCredential of the created NotificationHub. - :vartype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential - :ivar gcm_credential: The GcmCredential of the created NotificationHub. - :vartype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential - :ivar mpns_credential: The MpnsCredential of the created NotificationHub. - :vartype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential - :ivar adm_credential: The AdmCredential of the created NotificationHub. - :vartype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential - :ivar baidu_credential: The BaiduCredential of the created NotificationHub. - :vartype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.notificationhubs.models.SystemData + :ivar properties: Private Endpoint Connection properties. + :vartype properties: ~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "registration_ttl": {"key": "properties.registrationTtl", "type": "str"}, - "authorization_rules": { - "key": "properties.authorizationRules", - "type": "[SharedAccessAuthorizationRuleProperties]", - }, - "apns_credential": {"key": "properties.apnsCredential", "type": "ApnsCredential"}, - "wns_credential": {"key": "properties.wnsCredential", "type": "WnsCredential"}, - "gcm_credential": {"key": "properties.gcmCredential", "type": "GcmCredential"}, - "mpns_credential": {"key": "properties.mpnsCredential", "type": "MpnsCredential"}, - "adm_credential": {"key": "properties.admCredential", "type": "AdmCredential"}, - "baidu_credential": {"key": "properties.baiduCredential", "type": "BaiduCredential"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, } def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - name_properties_name: Optional[str] = None, - registration_ttl: Optional[str] = None, - authorization_rules: Optional[List["_models.SharedAccessAuthorizationRuleProperties"]] = None, - apns_credential: Optional["_models.ApnsCredential"] = None, - wns_credential: Optional["_models.WnsCredential"] = None, - gcm_credential: Optional["_models.GcmCredential"] = None, - mpns_credential: Optional["_models.MpnsCredential"] = None, - adm_credential: Optional["_models.AdmCredential"] = None, - baidu_credential: Optional["_models.BaiduCredential"] = None, - **kwargs - ): + self, *, properties: Optional["_models.PrivateEndpointConnectionProperties"] = None, **kwargs: Any + ) -> None: """ - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. - :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - :keyword name_properties_name: The NotificationHub name. - :paramtype name_properties_name: str - :keyword registration_ttl: The RegistrationTtl of the created NotificationHub. - :paramtype registration_ttl: str - :keyword authorization_rules: The AuthorizationRules of the created NotificationHub. - :paramtype authorization_rules: - list[~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleProperties] - :keyword apns_credential: The ApnsCredential of the created NotificationHub. - :paramtype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential - :keyword wns_credential: The WnsCredential of the created NotificationHub. - :paramtype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential - :keyword gcm_credential: The GcmCredential of the created NotificationHub. - :paramtype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential - :keyword mpns_credential: The MpnsCredential of the created NotificationHub. - :paramtype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential - :keyword adm_credential: The AdmCredential of the created NotificationHub. - :paramtype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential - :keyword baidu_credential: The BaiduCredential of the created NotificationHub. - :paramtype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential + :keyword properties: Private Endpoint Connection properties. + :paramtype properties: ~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionProperties """ - super().__init__(location=location, tags=tags, sku=sku, **kwargs) - self.name_properties_name = name_properties_name - self.registration_ttl = registration_ttl - self.authorization_rules = authorization_rules - self.apns_credential = apns_credential - self.wns_credential = wns_credential - self.gcm_credential = gcm_credential - self.mpns_credential = mpns_credential - self.adm_credential = adm_credential - self.baidu_credential = baidu_credential + super().__init__(**kwargs) + self.properties = properties -class NotificationHubResource(Resource): # pylint: disable=too-many-instance-attributes - """Description of a NotificationHub Resource. +class PrivateEndpointConnectionResourceListResult(_serialization.Model): + """The response of the List Private Endpoint Connections operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets or sets result of the List AuthorizationRules operation. + :vartype value: list[~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource] + :ivar next_link: Gets or sets link to the next set of results. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnectionResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class PrivateLinkResource(ProxyResource): + """A Private Link Arm Resource. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. - :vartype sku: ~azure.mgmt.notificationhubs.models.Sku - :ivar name_properties_name: The NotificationHub name. - :vartype name_properties_name: str - :ivar registration_ttl: The RegistrationTtl of the created NotificationHub. - :vartype registration_ttl: str - :ivar authorization_rules: The AuthorizationRules of the created NotificationHub. - :vartype authorization_rules: - list[~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleProperties] - :ivar apns_credential: The ApnsCredential of the created NotificationHub. - :vartype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential - :ivar wns_credential: The WnsCredential of the created NotificationHub. - :vartype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential - :ivar gcm_credential: The GcmCredential of the created NotificationHub. - :vartype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential - :ivar mpns_credential: The MpnsCredential of the created NotificationHub. - :vartype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential - :ivar adm_credential: The AdmCredential of the created NotificationHub. - :vartype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential - :ivar baidu_credential: The BaiduCredential of the created NotificationHub. - :vartype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.notificationhubs.models.SystemData + :ivar properties: Represents properties of Private Link Resource. + :vartype properties: ~azure.mgmt.notificationhubs.models.PrivateLinkResourceProperties """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "name_properties_name": {"key": "properties.name", "type": "str"}, - "registration_ttl": {"key": "properties.registrationTtl", "type": "str"}, - "authorization_rules": { - "key": "properties.authorizationRules", - "type": "[SharedAccessAuthorizationRuleProperties]", - }, - "apns_credential": {"key": "properties.apnsCredential", "type": "ApnsCredential"}, - "wns_credential": {"key": "properties.wnsCredential", "type": "WnsCredential"}, - "gcm_credential": {"key": "properties.gcmCredential", "type": "GcmCredential"}, - "mpns_credential": {"key": "properties.mpnsCredential", "type": "MpnsCredential"}, - "adm_credential": {"key": "properties.admCredential", "type": "AdmCredential"}, - "baidu_credential": {"key": "properties.baiduCredential", "type": "BaiduCredential"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "PrivateLinkResourceProperties"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - name_properties_name: Optional[str] = None, - registration_ttl: Optional[str] = None, - authorization_rules: Optional[List["_models.SharedAccessAuthorizationRuleProperties"]] = None, - apns_credential: Optional["_models.ApnsCredential"] = None, - wns_credential: Optional["_models.WnsCredential"] = None, - gcm_credential: Optional["_models.GcmCredential"] = None, - mpns_credential: Optional["_models.MpnsCredential"] = None, - adm_credential: Optional["_models.AdmCredential"] = None, - baidu_credential: Optional["_models.BaiduCredential"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.PrivateLinkResourceProperties"] = None, **kwargs: Any) -> None: """ - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. - :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - :keyword name_properties_name: The NotificationHub name. - :paramtype name_properties_name: str - :keyword registration_ttl: The RegistrationTtl of the created NotificationHub. - :paramtype registration_ttl: str - :keyword authorization_rules: The AuthorizationRules of the created NotificationHub. - :paramtype authorization_rules: - list[~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleProperties] - :keyword apns_credential: The ApnsCredential of the created NotificationHub. - :paramtype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential - :keyword wns_credential: The WnsCredential of the created NotificationHub. - :paramtype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential - :keyword gcm_credential: The GcmCredential of the created NotificationHub. - :paramtype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential - :keyword mpns_credential: The MpnsCredential of the created NotificationHub. - :paramtype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential - :keyword adm_credential: The AdmCredential of the created NotificationHub. - :paramtype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential - :keyword baidu_credential: The BaiduCredential of the created NotificationHub. - :paramtype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential + :keyword properties: Represents properties of Private Link Resource. + :paramtype properties: ~azure.mgmt.notificationhubs.models.PrivateLinkResourceProperties """ - super().__init__(location=location, tags=tags, sku=sku, **kwargs) - self.name_properties_name = name_properties_name - self.registration_ttl = registration_ttl - self.authorization_rules = authorization_rules - self.apns_credential = apns_credential - self.wns_credential = wns_credential - self.gcm_credential = gcm_credential - self.mpns_credential = mpns_credential - self.adm_credential = adm_credential - self.baidu_credential = baidu_credential + super().__init__(**kwargs) + self.properties = properties -class Operation(_serialization.Model): - """A NotificationHubs REST API operation. +class PrivateLinkResourceListResult(_serialization.Model): + """The response of the List Private Link Resources operation. Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: Operation name: {provider}/{resource}/{operation}. - :vartype name: str - :ivar display: The object that represents the operation. - :vartype display: ~azure.mgmt.notificationhubs.models.OperationDisplay + :ivar value: Gets or sets result of the List AuthorizationRules operation. + :vartype value: list[~azure.mgmt.notificationhubs.models.PrivateLinkResource] + :ivar next_link: Gets or sets link to the next set of results. + :vartype next_link: str """ _validation = { - "name": {"readonly": True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class PrivateLinkResourceProperties(_serialization.Model): + """Represents properties of Private Link Resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar group_id: A Group Id for Private Link. For Notification Hubs, it is always set to + "namespace". + :vartype group_id: str + :ivar required_members: Required members. For Notification Hubs, it's always a collection with + a single "namespace" item. + :vartype required_members: list[str] + :ivar required_zone_names: Required DNS zone names. For Notification Hubs, it contains two + CNames for Service Bus and Notification Hubs zones. + :vartype required_zone_names: list[str] + """ + + _validation = { + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, + "required_zone_names": {"readonly": True}, } + _attribute_map = { + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.group_id = None + self.required_members = None + self.required_zone_names = None + + +class PrivateLinkServiceConnection(_serialization.Model): + """A customer-visible sub-resource of Private Endpoint, which describe the connection between + Private Endpoint and Notification Hubs namespace. + + :ivar name: Name of the Private Link Service connection. + :vartype name: str + :ivar group_ids: List of group ids. Always contains a single element - "namespace" - for + Notification Hub Namespace. + :vartype group_ids: list[str] + :ivar request_message: Request message provided by the user that created the connection. This + is usually used when the connection requires manual approval. + :vartype request_message: str + """ + _attribute_map = { "name": {"key": "name", "type": "str"}, - "display": {"key": "display", "type": "OperationDisplay"}, + "group_ids": {"key": "groupIds", "type": "[str]"}, + "request_message": {"key": "requestMessage", "type": "str"}, } - def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): + def __init__( + self, + *, + name: Optional[str] = None, + group_ids: Optional[List[str]] = None, + request_message: Optional[str] = None, + **kwargs: Any + ) -> None: """ - :keyword display: The object that represents the operation. - :paramtype display: ~azure.mgmt.notificationhubs.models.OperationDisplay + :keyword name: Name of the Private Link Service connection. + :paramtype name: str + :keyword group_ids: List of group ids. Always contains a single element - "namespace" - for + Notification Hub Namespace. + :paramtype group_ids: list[str] + :keyword request_message: Request message provided by the user that created the connection. + This is usually used when the connection requires manual approval. + :paramtype request_message: str """ super().__init__(**kwargs) - self.name = None - self.display = display + self.name = name + self.group_ids = group_ids + self.request_message = request_message -class OperationDisplay(_serialization.Model): - """The object that represents the operation. +class PublicInternetAuthorizationRule(_serialization.Model): + """A default (public Internet) network authorization rule, which contains rights if no other + network rule matches. - Variables are only populated by the server, and will be ignored when sending a request. + All required parameters must be populated in order to send to Azure. - :ivar provider: Service provider: Microsoft.NotificationHubs. - :vartype provider: str - :ivar resource: Resource on which the operation is performed: Invoice, etc. - :vartype resource: str - :ivar operation: Operation type: Read, write, delete, etc. - :vartype operation: str + :ivar rights: List of access rights. Required. + :vartype rights: list[str or ~azure.mgmt.notificationhubs.models.AccessRights] """ _validation = { - "provider": {"readonly": True}, - "resource": {"readonly": True}, - "operation": {"readonly": True}, + "rights": {"required": True}, } - _attribute_map = { - "provider": {"key": "provider", "type": "str"}, - "resource": {"key": "resource", "type": "str"}, - "operation": {"key": "operation", "type": "str"}, + _attribute_map = { + "rights": {"key": "rights", "type": "[str]"}, } - def __init__(self, **kwargs): - """ """ + def __init__(self, *, rights: List[Union[str, "_models.AccessRights"]], **kwargs: Any) -> None: + """ + :keyword rights: List of access rights. Required. + :paramtype rights: list[str or ~azure.mgmt.notificationhubs.models.AccessRights] + """ super().__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None + self.rights = rights -class OperationListResult(_serialization.Model): - """Result of the request to list NotificationHubs operations. It contains a list of operations and a URL link to get the next set of results. +class RegistrationResult(_serialization.Model): + """Notification result for a single registration. Variables are only populated by the server, and will be ignored when sending a request. - :ivar value: List of NotificationHubs operations supported by the Microsoft.NotificationHubs - resource provider. - :vartype value: list[~azure.mgmt.notificationhubs.models.Operation] - :ivar next_link: URL to get the next set of operation list results if there are any. - :vartype next_link: str + :ivar application_platform: PNS type. + :vartype application_platform: str + :ivar pns_handle: PNS handle. + :vartype pns_handle: str + :ivar registration_id: Registration id. + :vartype registration_id: str + :ivar outcome: Notification outcome. + :vartype outcome: str """ _validation = { - "value": {"readonly": True}, - "next_link": {"readonly": True}, + "application_platform": {"readonly": True}, + "pns_handle": {"readonly": True}, + "registration_id": {"readonly": True}, + "outcome": {"readonly": True}, } _attribute_map = { - "value": {"key": "value", "type": "[Operation]"}, - "next_link": {"key": "nextLink", "type": "str"}, + "application_platform": {"key": "applicationPlatform", "type": "str"}, + "pns_handle": {"key": "pnsHandle", "type": "str"}, + "registration_id": {"key": "registrationId", "type": "str"}, + "outcome": {"key": "outcome", "type": "str"}, } - def __init__(self, **kwargs): + def __init__(self, **kwargs: Any) -> None: """ """ super().__init__(**kwargs) - self.value = None - self.next_link = None + self.application_platform = None + self.pns_handle = None + self.registration_id = None + self.outcome = None -class PnsCredentialsResource(Resource): # pylint: disable=too-many-instance-attributes - """Description of a NotificationHub PNS Credentials. +class RemotePrivateEndpointConnection(_serialization.Model): + """Represents a Private Endpoint that is connected to Notification Hubs namespace using Private + Endpoint Connection. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: ARM resource ID of the Private Endpoint. This may belong to different subscription + and resource group than a Notification Hubs namespace. :vartype id: str - :ivar name: Resource name. - :vartype name: str - :ivar type: Resource type. - :vartype type: str - :ivar location: Resource location. - :vartype location: str - :ivar tags: Resource tags. - :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. - :vartype sku: ~azure.mgmt.notificationhubs.models.Sku - :ivar apns_credential: The ApnsCredential of the created NotificationHub. - :vartype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential - :ivar wns_credential: The WnsCredential of the created NotificationHub. - :vartype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential - :ivar gcm_credential: The GcmCredential of the created NotificationHub. - :vartype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential - :ivar mpns_credential: The MpnsCredential of the created NotificationHub. - :vartype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential - :ivar adm_credential: The AdmCredential of the created NotificationHub. - :vartype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential - :ivar baidu_credential: The BaiduCredential of the created NotificationHub. - :vartype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential """ _validation = { "id": {"readonly": True}, - "name": {"readonly": True}, - "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, - "name": {"key": "name", "type": "str"}, - "type": {"key": "type", "type": "str"}, - "location": {"key": "location", "type": "str"}, - "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "apns_credential": {"key": "properties.apnsCredential", "type": "ApnsCredential"}, - "wns_credential": {"key": "properties.wnsCredential", "type": "WnsCredential"}, - "gcm_credential": {"key": "properties.gcmCredential", "type": "GcmCredential"}, - "mpns_credential": {"key": "properties.mpnsCredential", "type": "MpnsCredential"}, - "adm_credential": {"key": "properties.admCredential", "type": "AdmCredential"}, - "baidu_credential": {"key": "properties.baiduCredential", "type": "BaiduCredential"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - apns_credential: Optional["_models.ApnsCredential"] = None, - wns_credential: Optional["_models.WnsCredential"] = None, - gcm_credential: Optional["_models.GcmCredential"] = None, - mpns_credential: Optional["_models.MpnsCredential"] = None, - adm_credential: Optional["_models.AdmCredential"] = None, - baidu_credential: Optional["_models.BaiduCredential"] = None, - **kwargs - ): - """ - :keyword location: Resource location. - :paramtype location: str - :keyword tags: Resource tags. - :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. - :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - :keyword apns_credential: The ApnsCredential of the created NotificationHub. - :paramtype apns_credential: ~azure.mgmt.notificationhubs.models.ApnsCredential - :keyword wns_credential: The WnsCredential of the created NotificationHub. - :paramtype wns_credential: ~azure.mgmt.notificationhubs.models.WnsCredential - :keyword gcm_credential: The GcmCredential of the created NotificationHub. - :paramtype gcm_credential: ~azure.mgmt.notificationhubs.models.GcmCredential - :keyword mpns_credential: The MpnsCredential of the created NotificationHub. - :paramtype mpns_credential: ~azure.mgmt.notificationhubs.models.MpnsCredential - :keyword adm_credential: The AdmCredential of the created NotificationHub. - :paramtype adm_credential: ~azure.mgmt.notificationhubs.models.AdmCredential - :keyword baidu_credential: The BaiduCredential of the created NotificationHub. - :paramtype baidu_credential: ~azure.mgmt.notificationhubs.models.BaiduCredential - """ - super().__init__(location=location, tags=tags, sku=sku, **kwargs) - self.apns_credential = apns_credential - self.wns_credential = wns_credential - self.gcm_credential = gcm_credential - self.mpns_credential = mpns_credential - self.adm_credential = adm_credential - self.baidu_credential = baidu_credential + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.id = None + +class RemotePrivateLinkServiceConnectionState(_serialization.Model): + """State of the Private Link Service connection. -class PolicykeyResource(_serialization.Model): - """Namespace/NotificationHub Regenerate Keys. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar policy_key: Name of the key that has to be regenerated for the Namespace/Notification Hub - Authorization Rule. The value can be Primary Key/Secondary Key. - :vartype policy_key: str + :ivar status: State of Private Link Connection. Known values are: "Disconnected", "Pending", + "Approved", and "Rejected". + :vartype status: str or ~azure.mgmt.notificationhubs.models.PrivateLinkConnectionStatus + :ivar description: Human-friendly description. + :vartype description: str + :ivar actions_required: Human-friendly description of required actions. + :vartype actions_required: str """ + _validation = { + "description": {"readonly": True}, + "actions_required": {"readonly": True}, + } + _attribute_map = { - "policy_key": {"key": "policyKey", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } - def __init__(self, *, policy_key: Optional[str] = None, **kwargs): + def __init__( + self, *, status: Optional[Union[str, "_models.PrivateLinkConnectionStatus"]] = None, **kwargs: Any + ) -> None: """ - :keyword policy_key: Name of the key that has to be regenerated for the Namespace/Notification - Hub Authorization Rule. The value can be Primary Key/Secondary Key. - :paramtype policy_key: str + :keyword status: State of Private Link Connection. Known values are: "Disconnected", "Pending", + "Approved", and "Rejected". + :paramtype status: str or ~azure.mgmt.notificationhubs.models.PrivateLinkConnectionStatus """ super().__init__(**kwargs) - self.policy_key = policy_key + self.status = status + self.description = None + self.actions_required = None class ResourceListKeys(_serialization.Model): - """Namespace/NotificationHub Connection String. + """Response for the POST request that returns Namespace or NotificationHub access keys (connection + strings). - :ivar primary_connection_string: PrimaryConnectionString of the AuthorizationRule. + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar primary_connection_string: Gets or sets primaryConnectionString of the AuthorizationRule. :vartype primary_connection_string: str - :ivar secondary_connection_string: SecondaryConnectionString of the created AuthorizationRule. + :ivar secondary_connection_string: Gets or sets secondaryConnectionString of the created + AuthorizationRule. :vartype secondary_connection_string: str - :ivar primary_key: PrimaryKey of the created AuthorizationRule. + :ivar primary_key: Gets or sets primaryKey of the created AuthorizationRule. :vartype primary_key: str - :ivar secondary_key: SecondaryKey of the created AuthorizationRule. + :ivar secondary_key: Gets or sets secondaryKey of the created AuthorizationRule. :vartype secondary_key: str - :ivar key_name: KeyName of the created AuthorizationRule. + :ivar key_name: Gets or sets keyName of the created AuthorizationRule. :vartype key_name: str """ + _validation = { + "primary_connection_string": {"readonly": True}, + "secondary_connection_string": {"readonly": True}, + "primary_key": {"readonly": True}, + "secondary_key": {"readonly": True}, + "key_name": {"readonly": True}, + } + _attribute_map = { "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, @@ -1557,98 +2615,70 @@ class ResourceListKeys(_serialization.Model): "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - primary_connection_string: Optional[str] = None, - secondary_connection_string: Optional[str] = None, - primary_key: Optional[str] = None, - secondary_key: Optional[str] = None, - key_name: Optional[str] = None, - **kwargs - ): - """ - :keyword primary_connection_string: PrimaryConnectionString of the AuthorizationRule. - :paramtype primary_connection_string: str - :keyword secondary_connection_string: SecondaryConnectionString of the created - AuthorizationRule. - :paramtype secondary_connection_string: str - :keyword primary_key: PrimaryKey of the created AuthorizationRule. - :paramtype primary_key: str - :keyword secondary_key: SecondaryKey of the created AuthorizationRule. - :paramtype secondary_key: str - :keyword key_name: KeyName of the created AuthorizationRule. - :paramtype key_name: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.primary_connection_string = primary_connection_string - self.secondary_connection_string = secondary_connection_string - self.primary_key = primary_key - self.secondary_key = secondary_key - self.key_name = key_name + self.primary_connection_string = None + self.secondary_connection_string = None + self.primary_key = None + self.secondary_key = None + self.key_name = None -class SharedAccessAuthorizationRuleCreateOrUpdateParameters(_serialization.Model): - """Parameters supplied to the CreateOrUpdate Namespace AuthorizationRules. +class ServiceSpecification(_serialization.Model): + """Optional service specification used in Operations API. - All required parameters must be populated in order to send to Azure. + Variables are only populated by the server, and will be ignored when sending a request. - :ivar properties: Properties of the Namespace AuthorizationRules. Required. - :vartype properties: - ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleProperties + :ivar log_specifications: Log specifications. + :vartype log_specifications: list[~azure.mgmt.notificationhubs.models.LogSpecification] + :ivar metric_specifications: Metric specification. + :vartype metric_specifications: list[~azure.mgmt.notificationhubs.models.MetricSpecification] """ _validation = { - "properties": {"required": True}, + "log_specifications": {"readonly": True}, + "metric_specifications": {"readonly": True}, } _attribute_map = { - "properties": {"key": "properties", "type": "SharedAccessAuthorizationRuleProperties"}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__(self, *, properties: "_models.SharedAccessAuthorizationRuleProperties", **kwargs): - """ - :keyword properties: Properties of the Namespace AuthorizationRules. Required. - :paramtype properties: - ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleProperties - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.properties = properties + self.log_specifications = None + self.metric_specifications = None class SharedAccessAuthorizationRuleListResult(_serialization.Model): """The response of the List Namespace operation. - :ivar value: Result of the List AuthorizationRules operation. + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets or sets result of the List AuthorizationRules operation. :vartype value: list[~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleResource] - :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list - of AuthorizationRules. + :ivar next_link: Gets or sets link to the next set of results. :vartype next_link: str """ + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + _attribute_map = { "value": {"key": "value", "type": "[SharedAccessAuthorizationRuleResource]"}, "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SharedAccessAuthorizationRuleResource"]] = None, - next_link: Optional[str] = None, - **kwargs - ): - """ - :keyword value: Result of the List AuthorizationRules operation. - :paramtype value: - list[~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleResource] - :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete - list of AuthorizationRules. - :paramtype next_link: str - """ + def __init__(self, **kwargs: Any) -> None: + """ """ super().__init__(**kwargs) - self.value = value - self.next_link = next_link + self.value = None + self.next_link = None class SharedAccessAuthorizationRuleProperties(_serialization.Model): @@ -1656,36 +2686,37 @@ class SharedAccessAuthorizationRuleProperties(_serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :ivar rights: The rights associated with the rule. + All required parameters must be populated in order to send to Azure. + + :ivar rights: Gets or sets the rights associated with the rule. Required. :vartype rights: list[str or ~azure.mgmt.notificationhubs.models.AccessRights] - :ivar primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. + :ivar primary_key: Gets a base64-encoded 256-bit primary key for signing and + validating the SAS token. :vartype primary_key: str - :ivar secondary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. + :ivar secondary_key: Gets a base64-encoded 256-bit primary key for signing and + validating the SAS token. :vartype secondary_key: str - :ivar key_name: A string that describes the authorization rule. + :ivar key_name: Gets a string that describes the authorization rule. :vartype key_name: str - :ivar claim_type: A string that describes the claim type. + :ivar modified_time: Gets the last modified time for this rule. + :vartype modified_time: ~datetime.datetime + :ivar created_time: Gets the created time for this rule. + :vartype created_time: ~datetime.datetime + :ivar claim_type: Gets a string that describes the claim type. :vartype claim_type: str - :ivar claim_value: A string that describes the claim value. + :ivar claim_value: Gets a string that describes the claim value. :vartype claim_value: str - :ivar modified_time: The last modified time for this rule. - :vartype modified_time: str - :ivar created_time: The created time for this rule. - :vartype created_time: str - :ivar revision: The revision number for the rule. + :ivar revision: Gets the revision number for the rule. :vartype revision: int """ _validation = { - "primary_key": {"readonly": True}, - "secondary_key": {"readonly": True}, + "rights": {"required": True}, "key_name": {"readonly": True}, - "claim_type": {"readonly": True}, - "claim_value": {"readonly": True}, "modified_time": {"readonly": True}, "created_time": {"readonly": True}, + "claim_type": {"readonly": True}, + "claim_value": {"readonly": True}, "revision": {"readonly": True}, } @@ -1694,130 +2725,106 @@ class SharedAccessAuthorizationRuleProperties(_serialization.Model): "primary_key": {"key": "primaryKey", "type": "str"}, "secondary_key": {"key": "secondaryKey", "type": "str"}, "key_name": {"key": "keyName", "type": "str"}, + "modified_time": {"key": "modifiedTime", "type": "iso-8601"}, + "created_time": {"key": "createdTime", "type": "iso-8601"}, "claim_type": {"key": "claimType", "type": "str"}, "claim_value": {"key": "claimValue", "type": "str"}, - "modified_time": {"key": "modifiedTime", "type": "str"}, - "created_time": {"key": "createdTime", "type": "str"}, "revision": {"key": "revision", "type": "int"}, } - def __init__(self, *, rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, **kwargs): + def __init__( + self, + *, + rights: List[Union[str, "_models.AccessRights"]], + primary_key: Optional[str] = None, + secondary_key: Optional[str] = None, + **kwargs: Any + ) -> None: """ - :keyword rights: The rights associated with the rule. + :keyword rights: Gets or sets the rights associated with the rule. Required. :paramtype rights: list[str or ~azure.mgmt.notificationhubs.models.AccessRights] + :keyword primary_key: Gets a base64-encoded 256-bit primary key for signing and + validating the SAS token. + :paramtype primary_key: str + :keyword secondary_key: Gets a base64-encoded 256-bit primary key for signing and + validating the SAS token. + :paramtype secondary_key: str """ super().__init__(**kwargs) self.rights = rights - self.primary_key = None - self.secondary_key = None + self.primary_key = primary_key + self.secondary_key = secondary_key self.key_name = None - self.claim_type = None - self.claim_value = None self.modified_time = None self.created_time = None + self.claim_type = None + self.claim_value = None self.revision = None -class SharedAccessAuthorizationRuleResource(Resource): # pylint: disable=too-many-instance-attributes - """Description of a Namespace AuthorizationRules. +class SharedAccessAuthorizationRuleResource(ProxyResource): + """Response for POST requests that return single SharedAccessAuthorizationRule. Variables are only populated by the server, and will be ignored when sending a request. - :ivar id: Resource Id. + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". :vartype id: str - :ivar name: Resource name. + :ivar name: The name of the resource. :vartype name: str - :ivar type: Resource type. + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar location: Resource location. + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.notificationhubs.models.SystemData + :ivar properties: SharedAccessAuthorizationRule properties. + :vartype properties: + ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleProperties + :ivar location: Deprecated - only for compatibility. :vartype location: str - :ivar tags: Resource tags. + :ivar tags: Deprecated - only for compatibility. :vartype tags: dict[str, str] - :ivar sku: The sku of the created namespace. - :vartype sku: ~azure.mgmt.notificationhubs.models.Sku - :ivar rights: The rights associated with the rule. - :vartype rights: list[str or ~azure.mgmt.notificationhubs.models.AccessRights] - :ivar primary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :vartype primary_key: str - :ivar secondary_key: A base64-encoded 256-bit primary key for signing and validating the SAS - token. - :vartype secondary_key: str - :ivar key_name: A string that describes the authorization rule. - :vartype key_name: str - :ivar claim_type: A string that describes the claim type. - :vartype claim_type: str - :ivar claim_value: A string that describes the claim value. - :vartype claim_value: str - :ivar modified_time: The last modified time for this rule. - :vartype modified_time: str - :ivar created_time: The created time for this rule. - :vartype created_time: str - :ivar revision: The revision number for the rule. - :vartype revision: int """ _validation = { "id": {"readonly": True}, "name": {"readonly": True}, "type": {"readonly": True}, - "primary_key": {"readonly": True}, - "secondary_key": {"readonly": True}, - "key_name": {"readonly": True}, - "claim_type": {"readonly": True}, - "claim_value": {"readonly": True}, - "modified_time": {"readonly": True}, - "created_time": {"readonly": True}, - "revision": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "properties": {"key": "properties", "type": "SharedAccessAuthorizationRuleProperties"}, "location": {"key": "location", "type": "str"}, "tags": {"key": "tags", "type": "{str}"}, - "sku": {"key": "sku", "type": "Sku"}, - "rights": {"key": "properties.rights", "type": "[str]"}, - "primary_key": {"key": "properties.primaryKey", "type": "str"}, - "secondary_key": {"key": "properties.secondaryKey", "type": "str"}, - "key_name": {"key": "properties.keyName", "type": "str"}, - "claim_type": {"key": "properties.claimType", "type": "str"}, - "claim_value": {"key": "properties.claimValue", "type": "str"}, - "modified_time": {"key": "properties.modifiedTime", "type": "str"}, - "created_time": {"key": "properties.createdTime", "type": "str"}, - "revision": {"key": "properties.revision", "type": "int"}, } def __init__( self, *, + properties: Optional["_models.SharedAccessAuthorizationRuleProperties"] = None, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["_models.Sku"] = None, - rights: Optional[List[Union[str, "_models.AccessRights"]]] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword location: Resource location. + :keyword properties: SharedAccessAuthorizationRule properties. + :paramtype properties: + ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleProperties + :keyword location: Deprecated - only for compatibility. :paramtype location: str - :keyword tags: Resource tags. + :keyword tags: Deprecated - only for compatibility. :paramtype tags: dict[str, str] - :keyword sku: The sku of the created namespace. - :paramtype sku: ~azure.mgmt.notificationhubs.models.Sku - :keyword rights: The rights associated with the rule. - :paramtype rights: list[str or ~azure.mgmt.notificationhubs.models.AccessRights] """ - super().__init__(location=location, tags=tags, sku=sku, **kwargs) - self.rights = rights - self.primary_key = None - self.secondary_key = None - self.key_name = None - self.claim_type = None - self.claim_value = None - self.modified_time = None - self.created_time = None - self.revision = None + super().__init__(**kwargs) + self.properties = properties + self.location = location + self.tags = tags class Sku(_serialization.Model): @@ -1825,16 +2832,15 @@ class Sku(_serialization.Model): All required parameters must be populated in order to send to Azure. - :ivar name: Name of the notification hub sku. Required. Known values are: "Free", "Basic", and - "Standard". + :ivar name: Namespace SKU name. Required. Known values are: "Free", "Basic", and "Standard". :vartype name: str or ~azure.mgmt.notificationhubs.models.SkuName - :ivar tier: The tier of particular sku. + :ivar tier: Gets or sets the tier of particular sku. :vartype tier: str - :ivar size: The Sku size. + :ivar size: Gets or sets the Sku size. :vartype size: str - :ivar family: The Sku Family. + :ivar family: Gets or sets the Sku Family. :vartype family: str - :ivar capacity: The capacity of the resource. + :ivar capacity: Gets or sets the capacity of the resource. :vartype capacity: int """ @@ -1858,19 +2864,18 @@ def __init__( size: Optional[str] = None, family: Optional[str] = None, capacity: Optional[int] = None, - **kwargs - ): + **kwargs: Any + ) -> None: """ - :keyword name: Name of the notification hub sku. Required. Known values are: "Free", "Basic", - and "Standard". + :keyword name: Namespace SKU name. Required. Known values are: "Free", "Basic", and "Standard". :paramtype name: str or ~azure.mgmt.notificationhubs.models.SkuName - :keyword tier: The tier of particular sku. + :keyword tier: Gets or sets the tier of particular sku. :paramtype tier: str - :keyword size: The Sku size. + :keyword size: Gets or sets the Sku size. :paramtype size: str - :keyword family: The Sku Family. + :keyword family: Gets or sets the Sku Family. :paramtype family: str - :keyword capacity: The capacity of the resource. + :keyword capacity: Gets or sets the capacity of the resource. :paramtype capacity: int """ super().__init__(**kwargs) @@ -1881,41 +2886,117 @@ def __init__( self.capacity = capacity -class SubResource(_serialization.Model): - """SubResource. +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. - :ivar id: Resource Id. - :vartype id: str + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :vartype created_by_type: str or ~azure.mgmt.notificationhubs.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.notificationhubs.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { - "id": {"key": "id", "type": "str"}, + "created_by": {"key": "createdBy", "type": "str"}, + "created_by_type": {"key": "createdByType", "type": "str"}, + "created_at": {"key": "createdAt", "type": "iso-8601"}, + "last_modified_by": {"key": "lastModifiedBy", "type": "str"}, + "last_modified_by_type": {"key": "lastModifiedByType", "type": "str"}, + "last_modified_at": {"key": "lastModifiedAt", "type": "iso-8601"}, } - def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs: Any + ) -> None: """ - :keyword id: Resource Id. - :paramtype id: str + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". + :paramtype created_by_type: str or ~azure.mgmt.notificationhubs.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.notificationhubs.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime """ super().__init__(**kwargs) - self.id = id + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at class WnsCredential(_serialization.Model): """Description of a NotificationHub WnsCredential. - :ivar package_sid: The package ID for this credential. + All required parameters must be populated in order to send to Azure. + + :ivar properties: Description of a NotificationHub WnsCredential. Required. + :vartype properties: ~azure.mgmt.notificationhubs.models.WnsCredentialProperties + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "WnsCredentialProperties"}, + } + + def __init__(self, *, properties: "_models.WnsCredentialProperties", **kwargs: Any) -> None: + """ + :keyword properties: Description of a NotificationHub WnsCredential. Required. + :paramtype properties: ~azure.mgmt.notificationhubs.models.WnsCredentialProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class WnsCredentialProperties(_serialization.Model): + """Description of a NotificationHub WnsCredential. + + :ivar package_sid: Gets or sets the package ID for this credential. :vartype package_sid: str - :ivar secret_key: The secret key. + :ivar secret_key: Gets or sets the secret key. :vartype secret_key: str - :ivar windows_live_endpoint: The Windows Live endpoint. + :ivar windows_live_endpoint: Gets or sets the Windows Live endpoint. :vartype windows_live_endpoint: str + :ivar certificate_key: Ges or sets the WNS Certificate Key. + :vartype certificate_key: str + :ivar wns_certificate: Gets or sets the WNS Certificate. + :vartype wns_certificate: str """ _attribute_map = { - "package_sid": {"key": "properties.packageSid", "type": "str"}, - "secret_key": {"key": "properties.secretKey", "type": "str"}, - "windows_live_endpoint": {"key": "properties.windowsLiveEndpoint", "type": "str"}, + "package_sid": {"key": "packageSid", "type": "str"}, + "secret_key": {"key": "secretKey", "type": "str"}, + "windows_live_endpoint": {"key": "windowsLiveEndpoint", "type": "str"}, + "certificate_key": {"key": "certificateKey", "type": "str"}, + "wns_certificate": {"key": "wnsCertificate", "type": "str"}, } def __init__( @@ -1924,17 +3005,77 @@ def __init__( package_sid: Optional[str] = None, secret_key: Optional[str] = None, windows_live_endpoint: Optional[str] = None, - **kwargs - ): + certificate_key: Optional[str] = None, + wns_certificate: Optional[str] = None, + **kwargs: Any + ) -> None: """ - :keyword package_sid: The package ID for this credential. + :keyword package_sid: Gets or sets the package ID for this credential. :paramtype package_sid: str - :keyword secret_key: The secret key. + :keyword secret_key: Gets or sets the secret key. :paramtype secret_key: str - :keyword windows_live_endpoint: The Windows Live endpoint. + :keyword windows_live_endpoint: Gets or sets the Windows Live endpoint. :paramtype windows_live_endpoint: str + :keyword certificate_key: Ges or sets the WNS Certificate Key. + :paramtype certificate_key: str + :keyword wns_certificate: Gets or sets the WNS Certificate. + :paramtype wns_certificate: str """ super().__init__(**kwargs) self.package_sid = package_sid self.secret_key = secret_key self.windows_live_endpoint = windows_live_endpoint + self.certificate_key = certificate_key + self.wns_certificate = wns_certificate + + +class XiaomiCredential(_serialization.Model): + """Description of a NotificationHub XiaomiCredential. + + All required parameters must be populated in order to send to Azure. + + :ivar properties: Description of a NotificationHub XiaomiCredentialProperties. Required. + :vartype properties: ~azure.mgmt.notificationhubs.models.XiaomiCredentialProperties + """ + + _validation = { + "properties": {"required": True}, + } + + _attribute_map = { + "properties": {"key": "properties", "type": "XiaomiCredentialProperties"}, + } + + def __init__(self, *, properties: "_models.XiaomiCredentialProperties", **kwargs: Any) -> None: + """ + :keyword properties: Description of a NotificationHub XiaomiCredentialProperties. Required. + :paramtype properties: ~azure.mgmt.notificationhubs.models.XiaomiCredentialProperties + """ + super().__init__(**kwargs) + self.properties = properties + + +class XiaomiCredentialProperties(_serialization.Model): + """Description of a NotificationHub XiaomiCredentialProperties. + + :ivar app_secret: Gets or sets app secret. + :vartype app_secret: str + :ivar endpoint: Gets or sets xiaomi service endpoint. + :vartype endpoint: str + """ + + _attribute_map = { + "app_secret": {"key": "appSecret", "type": "str"}, + "endpoint": {"key": "endpoint", "type": "str"}, + } + + def __init__(self, *, app_secret: Optional[str] = None, endpoint: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword app_secret: Gets or sets app secret. + :paramtype app_secret: str + :keyword endpoint: Gets or sets xiaomi service endpoint. + :paramtype endpoint: str + """ + super().__init__(**kwargs) + self.app_secret = app_secret + self.endpoint = endpoint diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/_notification_hubs_management_client_enums.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/_notification_hubs_management_client_enums.py deleted file mode 100644 index 4b83766ae12b..000000000000 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/_notification_hubs_management_client_enums.py +++ /dev/null @@ -1,33 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from enum import Enum -from azure.core import CaseInsensitiveEnumMeta - - -class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """AccessRights.""" - - MANAGE = "Manage" - SEND = "Send" - LISTEN = "Listen" - - -class NamespaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The namespace type.""" - - MESSAGING = "Messaging" - NOTIFICATION_HUB = "NotificationHub" - - -class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of the notification hub sku.""" - - FREE = "Free" - BASIC = "Basic" - STANDARD = "Standard" diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/_notification_hubs_rp_client_enums.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/_notification_hubs_rp_client_enums.py new file mode 100644 index 000000000000..536468b280a1 --- /dev/null +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/models/_notification_hubs_rp_client_enums.py @@ -0,0 +1,119 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccessRights(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines values for AccessRights.""" + + MANAGE = "Manage" + SEND = "Send" + LISTEN = "Listen" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class NamespaceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Namespace status.""" + + CREATED = "Created" + CREATING = "Creating" + SUSPENDED = "Suspended" + DELETING = "Deleting" + + +class NamespaceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines values for NamespaceType.""" + + MESSAGING = "Messaging" + NOTIFICATION_HUB = "NotificationHub" + + +class OperationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines values for OperationProvisioningState.""" + + UNKNOWN = "Unknown" + IN_PROGRESS = "InProgress" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + CANCELED = "Canceled" + PENDING = "Pending" + DISABLED = "Disabled" + + +class PolicyKeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of Shared Access Policy Key (primary or secondary).""" + + PRIMARY_KEY = "PrimaryKey" + SECONDARY_KEY = "SecondaryKey" + + +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of Private Endpoint Connection.""" + + UNKNOWN = "Unknown" + SUCCEEDED = "Succeeded" + CREATING = "Creating" + UPDATING = "Updating" + UPDATING_BY_PROXY = "UpdatingByProxy" + DELETING = "Deleting" + DELETING_BY_PROXY = "DeletingByProxy" + DELETED = "Deleted" + + +class PrivateLinkConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of Private Link Connection.""" + + DISCONNECTED = "Disconnected" + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Type of public network access.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ReplicationRegion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allowed replication region.""" + + DEFAULT = "Default" + WEST_US2 = "WestUs2" + NORTH_EUROPE = "NorthEurope" + AUSTRALIA_EAST = "AustraliaEast" + BRAZIL_SOUTH = "BrazilSouth" + SOUTH_EAST_ASIA = "SouthEastAsia" + SOUTH_AFRICA_NORTH = "SouthAfricaNorth" + NONE = "None" + + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Namespace SKU name.""" + + FREE = "Free" + BASIC = "Basic" + STANDARD = "Standard" + + +class ZoneRedundancyPreference(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Namespace SKU name.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/__init__.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/__init__.py index 8d1898cef5c0..fb54f1e71f5c 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/__init__.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/__init__.py @@ -6,18 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from ._operations import Operations -from ._namespaces_operations import NamespacesOperations from ._notification_hubs_operations import NotificationHubsOperations +from ._namespaces_operations import NamespacesOperations +from ._operations import Operations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._patch import __all__ as _patch_all -from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk __all__ = [ - "Operations", - "NamespacesOperations", "NotificationHubsOperations", + "NamespacesOperations", + "Operations", + "PrivateEndpointConnectionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_namespaces_operations.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_namespaces_operations.py index fd6b8feeee2e..71860e9c36f5 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_namespaces_operations.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_namespaces_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload import urllib.parse @@ -30,12 +30,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,8 +43,8 @@ def build_check_availability_request(subscription_id: str, **kwargs: Any) -> Htt _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -60,7 +56,7 @@ def build_check_availability_request(subscription_id: str, **kwargs: Any) -> Htt "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -73,14 +69,13 @@ def build_check_availability_request(subscription_id: str, **kwargs: Any) -> Htt return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,32 +84,34 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_patch_request( +def build_create_or_update_request( resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -123,12 +120,16 @@ def build_patch_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -138,41 +139,54 @@ def build_patch_request( _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_update_request( resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +def build_delete_request( resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -181,12 +195,16 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -194,120 +212,154 @@ def build_get_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_authorization_rule_request( - resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any +def build_list_all_request( + subscription_id: str, *, skip_token: Optional[str] = None, top: int = 100, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop( - "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", - ) # pylint: disable=line-too-long + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces") path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_authorization_rule_request( - resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any +def build_list_request( + resource_group_name: str, subscription_id: str, *, skip_token: Optional[str] = None, top: int = 100, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_authorization_rule_request( +def build_create_or_update_authorization_rule_request( resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", + authorization_rule_name, + "str", + max_length=256, + min_length=1, + pattern=r"^[a-zA-Z0-9!()*-._]+$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_delete_authorization_rule_request( + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", + authorization_rule_name, + "str", + max_length=256, + min_length=1, + pattern=r"^[a-zA-Z0-9!()*-._]+$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -315,23 +367,42 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_all_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_get_authorization_rule_request( + resource_group_name: str, namespace_name: str, authorization_rule_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces") + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}", + ) # pylint: disable=line-too-long path_format_arguments = { "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", + authorization_rule_name, + "str", + max_length=256, + min_length=1, + pattern=r"^[a-zA-Z0-9!()*-._]+$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -348,21 +419,25 @@ def build_list_authorization_rules_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -379,22 +454,33 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/listKeys", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", + authorization_rule_name, + "str", + max_length=256, + min_length=1, + pattern=r"^[a-zA-Z0-9!()*-._]+$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -411,23 +497,34 @@ def build_regenerate_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/regenerateKeys", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", + authorization_rule_name, + "str", + max_length=256, + min_length=1, + pattern=r"^[a-zA-Z0-9!()*-._]+$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -440,13 +537,48 @@ def build_regenerate_keys_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) +def build_get_pns_credentials_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/pnsCredentials", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + class NamespacesOperations: """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.notificationhubs.NotificationHubsManagementClient`'s + :class:`~azure.mgmt.notificationhubs.NotificationHubsRPClient`'s :attr:`namespaces` attribute. """ @@ -466,7 +598,10 @@ def check_availability( """Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. - :param parameters: The namespace name. Required. + Checks the availability of the given service namespace across all Azure subscriptions. This is + useful because the domain name is created based on the service namespace name. + + :param parameters: Request content. Required. :type parameters: ~azure.mgmt.notificationhubs.models.CheckAvailabilityParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -484,7 +619,10 @@ def check_availability( """Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. - :param parameters: The namespace name. Required. + Checks the availability of the given service namespace across all Azure subscriptions. This is + useful because the domain name is created based on the service namespace name. + + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -502,7 +640,11 @@ def check_availability( """Checks the availability of the given service namespace across all Azure subscriptions. This is useful because the domain name is created based on the service namespace name. - :param parameters: The namespace name. Is either a model type or a IO type. Required. + Checks the availability of the given service namespace across all Azure subscriptions. This is + useful because the domain name is created based on the service namespace name. + + :param parameters: Request content. Is either a CheckAvailabilityParameters type or a IO type. + Required. :type parameters: ~azure.mgmt.notificationhubs.models.CheckAvailabilityParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -523,16 +665,14 @@ def check_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckAvailabilityResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckAvailabilityResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckAvailabilityParameters") @@ -548,17 +688,19 @@ def check_availability( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("CheckAvailabilityResult", pipeline_response) @@ -567,90 +709,82 @@ def check_availability( return deserialized - check_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/checkNamespaceAvailability"} # type: ignore + check_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/checkNamespaceAvailability" + } - @overload - def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - parameters: _models.NamespaceCreateOrUpdateParameters, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NamespaceResource: - """Creates/Updates a service namespace. Once created, this namespace's resource manifest is - immutable. This operation is idempotent. + @distributed_trace + def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.NamespaceResource: + """Returns the given namespace. + + Returns the given namespace. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to create a Namespace Resource. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.NamespaceCreateOrUpdateParameters - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response :return: NamespaceResource or the result of cls(response) :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource :raises ~azure.core.exceptions.HttpResponseError: """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def create_or_update( - self, - resource_group_name: str, - namespace_name: str, - parameters: IO, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.NamespaceResource: - """Creates/Updates a service namespace. Once created, this namespace's resource manifest is - immutable. This operation is idempotent. + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param namespace_name: The namespace name. Required. - :type namespace_name: str - :param parameters: Parameters supplied to create a Namespace Resource. Required. - :type parameters: IO - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource or the result of cls(response) - :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) - @distributed_trace - def create_or_update( + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NamespaceResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + } + + def _create_or_update_initial( self, resource_group_name: str, namespace_name: str, - parameters: Union[_models.NamespaceCreateOrUpdateParameters, IO], + parameters: Union[_models.NamespaceResource, IO], **kwargs: Any ) -> _models.NamespaceResource: - """Creates/Updates a service namespace. Once created, this namespace's resource manifest is - immutable. This operation is idempotent. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param namespace_name: The namespace name. Required. - :type namespace_name: str - :param parameters: Parameters supplied to create a Namespace Resource. Is either a model type - or a IO type. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.NamespaceCreateOrUpdateParameters or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource or the result of cls(response) - :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -662,19 +796,17 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "NamespaceCreateOrUpdateParameters") + _json = self._serialize.body(parameters, "NamespaceResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -684,22 +816,24 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata["url"], + template_url=self._create_or_update_initial.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("NamespaceResource", pipeline_response) @@ -708,41 +842,54 @@ def create_or_update( deserialized = self._deserialize("NamespaceResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}"} # type: ignore + _create_or_update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + } @overload - def patch( + def begin_create_or_update( self, resource_group_name: str, namespace_name: str, - parameters: _models.NamespacePatchParameters, + parameters: _models.NamespaceResource, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NamespaceResource: - """Patches the existing namespace. + ) -> LROPoller[_models.NamespaceResource]: + """Creates / Updates a Notification Hub namespace. This operation is idempotent. - :param resource_group_name: The name of the resource group. Required. + Creates / Updates a Notification Hub namespace. This operation is idempotent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to patch a Namespace Resource. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.NamespacePatchParameters + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.NamespaceResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource or the result of cls(response) - :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either NamespaceResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.notificationhubs.models.NamespaceResource] :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def patch( + def begin_create_or_update( self, resource_group_name: str, namespace_name: str, @@ -750,98 +897,257 @@ def patch( *, content_type: str = "application/json", **kwargs: Any - ) -> _models.NamespaceResource: - """Patches the existing namespace. + ) -> LROPoller[_models.NamespaceResource]: + """Creates / Updates a Notification Hub namespace. This operation is idempotent. - :param resource_group_name: The name of the resource group. Required. + Creates / Updates a Notification Hub namespace. This operation is idempotent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to patch a Namespace Resource. Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource or the result of cls(response) - :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either NamespaceResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.notificationhubs.models.NamespaceResource] :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def patch( + def begin_create_or_update( self, resource_group_name: str, namespace_name: str, - parameters: Union[_models.NamespacePatchParameters, IO], + parameters: Union[_models.NamespaceResource, IO], **kwargs: Any - ) -> _models.NamespaceResource: - """Patches the existing namespace. + ) -> LROPoller[_models.NamespaceResource]: + """Creates / Updates a Notification Hub namespace. This operation is idempotent. - :param resource_group_name: The name of the resource group. Required. + Creates / Updates a Notification Hub namespace. This operation is idempotent. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: Parameters supplied to patch a Namespace Resource. Is either a model type or - a IO type. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.NamespacePatchParameters or IO + :param parameters: Request content. Is either a NamespaceResource type or a IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.NamespaceResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource or the result of cls(response) - :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either NamespaceResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.notificationhubs.models.NamespaceResource] :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) - content_type = content_type or "application/json" - _json = None - _content = None - if isinstance(parameters, (IO, bytes)): - _content = parameters - else: - _json = self._serialize.body(parameters, "NamespacePatchParameters") + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("NamespaceResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized - request = build_patch_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - content_type=content_type, - json=_json, - content=_content, - template_url=self.patch.metadata["url"], + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + } + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: _models.NamespacePatchParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NamespaceResource: + """Patches the existing namespace. + + Patches the existing namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.NamespacePatchParameters + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamespaceResource or the result of cls(response) + :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.NamespaceResource: + """Patches the existing namespace. + + Patches the existing namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param parameters: Request content. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamespaceResource or the result of cls(response) + :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + namespace_name: str, + parameters: Union[_models.NamespacePatchParameters, IO], + **kwargs: Any + ) -> _models.NamespaceResource: + """Patches the existing namespace. + + Patches the existing namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param parameters: Request content. Is either a NamespacePatchParameters type or a IO type. + Required. + :type parameters: ~azure.mgmt.notificationhubs.models.NamespacePatchParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NamespaceResource or the result of cls(response) + :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NamespaceResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NamespacePatchParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("NamespaceResource", pipeline_response) @@ -850,11 +1156,30 @@ def patch( return deserialized - patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + } - def _delete_initial( # pylint: disable=inconsistent-return-statements + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, namespace_name: str, **kwargs: Any ) -> None: + """Deletes an existing namespace. This operation also removes all associated notificationHubs + under the namespace. + + Deletes an existing namespace. This operation also removes all associated notificationHubs + under the namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -866,115 +1191,157 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, namespace_name=namespace_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._delete_initial.metadata["url"], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}" + } @distributed_trace - def begin_delete(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> LROPoller[None]: - """Deletes an existing namespace. This operation also removes all associated notificationHubs - under the namespace. + def list_all( + self, skip_token: Optional[str] = None, top: int = 100, **kwargs: Any + ) -> Iterable["_models.NamespaceResource"]: + """Lists all the available namespaces within the subscription. - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param namespace_name: The namespace name. Required. - :type namespace_name: str + Lists all the available namespaces within the subscription. + + :param skip_token: Skip token for subsequent requests. Default value is None. + :type skip_token: str + :param top: Maximum number of results to return. Default value is 100. + :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this - operation to not poll, or pass in your own initialized polling object for a personal polling - strategy. - :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. - :return: An instance of LROPoller that returns either None or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[None] + :return: An iterator like instance of either NamespaceResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.notificationhubs.models.NamespaceResource] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] - polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) - cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] - if cont_token is None: - raw_result = self._delete_initial( # type: ignore - resource_group_name=resource_group_name, - namespace_name=namespace_name, - api_version=api_version, - cls=lambda x, y, z: x, - headers=_headers, - params=_params, - **kwargs - ) - kwargs.pop("error_map", None) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamespaceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + def prepare_request(next_link=None): + if not next_link: + + request = build_list_all_request( + subscription_id=self._config.subscription_id, + skip_token=skip_token, + top=top, + api_version=api_version, + template_url=self.list_all.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("NamespaceListResult", pipeline_response) + list_of_elem = deserialized.value if cls: - return cls(pipeline_response, None, {}) + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod - elif polling is False: - polling_method = cast(PollingMethod, NoPolling()) - else: - polling_method = polling - if cont_token: - return LROPoller.from_continuation_token( - polling_method=polling_method, - continuation_token=cont_token, - client=self._client, - deserialization_callback=get_long_running_output, + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + response = pipeline_response.http_response - begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}"} # type: ignore + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces"} @distributed_trace - def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _models.NamespaceResource: - """Returns the description for the specified namespace. + def list( + self, resource_group_name: str, skip_token: Optional[str] = None, top: int = 100, **kwargs: Any + ) -> Iterable["_models.NamespaceResource"]: + """Lists the available namespaces within a resource group. - :param resource_group_name: The name of the resource group. Required. + Lists the available namespaces within a resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. - :type namespace_name: str + :param skip_token: Skip token for subsequent requests. Default value is None. + :type skip_token: str + :param top: Maximum number of results to return. Default value is 100. + :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: NamespaceResource or the result of cls(response) - :rtype: ~azure.mgmt.notificationhubs.models.NamespaceResource + :return: An iterator like instance of either NamespaceResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.notificationhubs.models.NamespaceResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NamespaceListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -983,44 +1350,68 @@ def get(self, resource_group_name: str, namespace_name: str, **kwargs: Any) -> _ } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceResource] + request = build_list_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + top=top, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("NamespaceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("NamespaceResource", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return ItemPaged(get_next, extract_data) - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces" + } @overload def create_or_update_authorization_rule( @@ -1028,22 +1419,24 @@ def create_or_update_authorization_rule( resource_group_name: str, namespace_name: str, authorization_rule_name: str, - parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + parameters: _models.SharedAccessAuthorizationRuleResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates an authorization rule for a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Required. - :type parameters: - ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1066,13 +1459,16 @@ def create_or_update_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates an authorization rule for a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1089,21 +1485,24 @@ def create_or_update_authorization_rule( resource_group_name: str, namespace_name: str, authorization_rule_name: str, - parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], + parameters: Union[_models.SharedAccessAuthorizationRuleResource, IO], **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates an authorization rule for a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates an authorization rule for a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Is either a model type or a IO type. - Required. - :type parameters: - ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters or IO + :param parameters: Request content. Is either a SharedAccessAuthorizationRuleResource type or a + IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleResource or + IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -1123,19 +1522,17 @@ def create_or_update_authorization_rule( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleResource") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1151,26 +1548,34 @@ def create_or_update_authorization_rule( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -1178,9 +1583,12 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a namespace authorization rule. - :param resource_group_name: The name of the resource group. Required. + Deletes a namespace authorization rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str @@ -1200,10 +1608,8 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, @@ -1216,22 +1622,26 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -1239,11 +1649,14 @@ def get_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Gets an authorization rule for a namespace by name. - :param resource_group_name: The name of the resource group. Required. + Gets an authorization rule for a namespace by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param authorization_rule_name: Authorization rule name. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedAccessAuthorizationRuleResource or the result of cls(response) @@ -1261,10 +1674,8 @@ def get_authorization_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) request = build_get_authorization_rule_request( resource_group_name=resource_group_name, @@ -1277,17 +1688,19 @@ def get_authorization_rule( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) @@ -1296,173 +1709,9 @@ def get_authorization_rule( return deserialized - get_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - - @distributed_trace - def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.NamespaceResource"]: - """Lists the available namespaces within a resourceGroup. - - :param resource_group_name: The name of the resource group. If resourceGroupName value is null - the method lists all the namespaces within subscription. Required. - :type resource_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NamespaceResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.notificationhubs.models.NamespaceResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceListResult] - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("NamespaceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces"} # type: ignore - - @distributed_trace - def list_all(self, **kwargs: Any) -> Iterable["_models.NamespaceResource"]: - """Lists all the available namespaces within the subscription irrespective of the resourceGroups. - - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NamespaceResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.notificationhubs.models.NamespaceResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NamespaceListResult] - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_all_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list_all.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("NamespaceListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list_all.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.NotificationHubs/namespaces"} # type: ignore + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_authorization_rules( @@ -1470,9 +1719,12 @@ def list_authorization_rules( ) -> Iterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets the authorization rules for a namespace. - :param resource_group_name: The name of the resource group. Required. + Gets the authorization rules for a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the @@ -1484,10 +1736,8 @@ def list_authorization_rules( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedAccessAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1510,7 +1760,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1526,7 +1776,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1534,26 +1784,30 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) - list_authorization_rules.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules" + } @distributed_trace def list_keys( @@ -1561,12 +1815,14 @@ def list_keys( ) -> _models.ResourceListKeys: """Gets the Primary and Secondary ConnectionStrings to the namespace. - :param resource_group_name: The name of the resource group. Required. + Gets the Primary and Secondary ConnectionStrings to the namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The connection string of the namespace for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceListKeys or the result of cls(response) @@ -1584,10 +1840,8 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) request = build_list_keys_request( resource_group_name=resource_group_name, @@ -1600,17 +1854,19 @@ def list_keys( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ResourceListKeys", pipeline_response) @@ -1619,7 +1875,9 @@ def list_keys( return deserialized - list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/listKeys" + } @overload def regenerate_keys( @@ -1627,23 +1885,24 @@ def regenerate_keys( resource_group_name: str, namespace_name: str, authorization_rule_name: str, - parameters: _models.PolicykeyResource, + parameters: _models.PolicyKeyResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The connection string of the namespace for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the Namespace Authorization Rule Key. - Required. - :type parameters: ~azure.mgmt.notificationhubs.models.PolicykeyResource + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PolicyKeyResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1666,15 +1925,16 @@ def regenerate_keys( ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The connection string of the namespace for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the Namespace Authorization Rule Key. - Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1691,21 +1951,22 @@ def regenerate_keys( resource_group_name: str, namespace_name: str, authorization_rule_name: str, - parameters: Union[_models.PolicykeyResource, IO], + parameters: Union[_models.PolicyKeyResource, IO], **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the Namespace Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param authorization_rule_name: The connection string of the namespace for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the Namespace Authorization Rule Key. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.PolicykeyResource or IO + :param parameters: Request content. Is either a PolicyKeyResource type or a IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PolicyKeyResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -1725,19 +1986,17 @@ def regenerate_keys( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicykeyResource") + _json = self._serialize.body(parameters, "PolicyKeyResource") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1753,17 +2012,19 @@ def regenerate_keys( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ResourceListKeys", pipeline_response) @@ -1772,4 +2033,73 @@ def regenerate_keys( return deserialized - regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } + + @distributed_trace + def get_pns_credentials( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> _models.PnsCredentialsResource: + """Lists the PNS credentials associated with a namespace. + + Lists the PNS credentials associated with a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PnsCredentialsResource or the result of cls(response) + :rtype: ~azure.mgmt.notificationhubs.models.PnsCredentialsResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PnsCredentialsResource] = kwargs.pop("cls", None) + + request = build_get_pns_credentials_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_pns_credentials.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PnsCredentialsResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_pns_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/pnsCredentials" + } diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_notification_hubs_operations.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_notification_hubs_operations.py index c37de532d797..3fa021a47ef6 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_notification_hubs_operations.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_notification_hubs_operations.py @@ -6,7 +6,7 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys +from io import IOBase from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload import urllib.parse @@ -28,17 +28,8 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section - -if sys.version_info >= (3, 9): - from collections.abc import MutableMapping -else: - from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports -JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object +from .._vendor import _convert_request + T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,8 +43,8 @@ def build_check_notification_hub_availability_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,12 +53,16 @@ def build_check_notification_hub_availability_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkNotificationHubAvailability", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -80,14 +75,13 @@ def build_check_notification_hub_availability_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request( +def build_get_request( resource_group_name: str, namespace_name: str, notification_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,33 +90,42 @@ def build_create_or_update_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_patch_request( +def build_create_or_update_request( resource_group_name: str, namespace_name: str, notification_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -131,13 +134,24 @@ def build_patch_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -147,42 +161,62 @@ def build_patch_request( _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request( +def build_update_request( resource_group_name: str, namespace_name: str, notification_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request( +def build_delete_request( resource_group_name: str, namespace_name: str, notification_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -191,13 +225,24 @@ def build_get_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -205,92 +250,98 @@ def build_get_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_debug_send_request( +def build_list_request( resource_group_name: str, namespace_name: str, - notification_hub_name: str, subscription_id: str, *, - json: Optional[JSON] = None, + skip_token: Optional[str] = None, + top: int = 100, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/debugsend", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if skip_token is not None: + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") + if top is not None: + _params["$top"] = _SERIALIZER.query("top", top, "int") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, json=json, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_authorization_rule_request( - resource_group_name: str, - namespace_name: str, - notification_hub_name: str, - authorization_rule_name: str, - subscription_id: str, - **kwargs: Any +def build_debug_send_request( + resource_group_name: str, namespace_name: str, notification_hub_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/debugsend", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_authorization_rule_request( +def build_create_or_update_authorization_rule_request( resource_group_name: str, namespace_name: str, notification_hub_name: str, @@ -298,31 +349,58 @@ def build_delete_authorization_rule_request( subscription_id: str, **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", + authorization_rule_name, + "str", + max_length=256, + min_length=1, + pattern=r"^[a-zA-Z0-9!()*-._]+$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_authorization_rule_request( +def build_delete_authorization_rule_request( resource_group_name: str, namespace_name: str, notification_hub_name: str, @@ -333,23 +411,41 @@ def build_get_authorization_rule_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", + authorization_rule_name, + "str", + max_length=256, + min_length=1, + pattern=r"^[a-zA-Z0-9!()*-._]+$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -357,30 +453,55 @@ def build_get_authorization_rule_request( # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any +def build_get_authorization_rule_request( + resource_group_name: str, + namespace_name: str, + notification_hub_name: str, + authorization_rule_name: str, + subscription_id: str, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", + authorization_rule_name, + "str", + max_length=256, + min_length=1, + pattern=r"^[a-zA-Z0-9!()*-._]+$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -397,22 +518,33 @@ def build_list_authorization_rules_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -434,23 +566,41 @@ def build_list_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/listKeys", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}/listKeys", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", + authorization_rule_name, + "str", + max_length=256, + min_length=1, + pattern=r"^[a-zA-Z0-9!()*-._]+$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -472,24 +622,42 @@ def build_regenerate_keys_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop( "template_url", - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}/regenerateKeys", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), - "authorizationRuleName": _SERIALIZER.url("authorization_rule_name", authorization_rule_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), + "authorizationRuleName": _SERIALIZER.url( + "authorization_rule_name", + authorization_rule_name, + "str", + max_length=256, + min_length=1, + pattern=r"^[a-zA-Z0-9!()*-._]+$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -508,7 +676,7 @@ def build_get_pns_credentials_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -517,13 +685,24 @@ def build_get_pns_credentials_request( "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/pnsCredentials", ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), - "namespaceName": _SERIALIZER.url("namespace_name", namespace_name, "str"), - "notificationHubName": _SERIALIZER.url("notification_hub_name", notification_hub_name, "str"), "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "notificationHubName": _SERIALIZER.url( + "notification_hub_name", + notification_hub_name, + "str", + max_length=265, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-./_]*$", + ), } - _url = _format_url_section(_url, **path_format_arguments) + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -540,7 +719,7 @@ class NotificationHubsOperations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.notificationhubs.NotificationHubsManagementClient`'s + :class:`~azure.mgmt.notificationhubs.NotificationHubsRPClient`'s :attr:`notification_hubs` attribute. """ @@ -565,11 +744,14 @@ def check_notification_hub_availability( ) -> _models.CheckAvailabilityResult: """Checks the availability of the given notificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Checks the availability of the given notificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: The notificationHub name. Required. + :param parameters: Request content. Required. :type parameters: ~azure.mgmt.notificationhubs.models.CheckAvailabilityParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -592,11 +774,14 @@ def check_notification_hub_availability( ) -> _models.CheckAvailabilityResult: """Checks the availability of the given notificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Checks the availability of the given notificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: The notificationHub name. Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -617,11 +802,15 @@ def check_notification_hub_availability( ) -> _models.CheckAvailabilityResult: """Checks the availability of the given notificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Checks the availability of the given notificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param parameters: The notificationHub name. Is either a model type or a IO type. Required. + :param parameters: Request content. Is either a CheckAvailabilityParameters type or a IO type. + Required. :type parameters: ~azure.mgmt.notificationhubs.models.CheckAvailabilityParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -642,16 +831,14 @@ def check_notification_hub_availability( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckAvailabilityResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.CheckAvailabilityResult] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: _json = self._serialize.body(parameters, "CheckAvailabilityParameters") @@ -669,17 +856,19 @@ def check_notification_hub_availability( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("CheckAvailabilityResult", pipeline_response) @@ -688,7 +877,79 @@ def check_notification_hub_availability( return deserialized - check_notification_hub_availability.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkNotificationHubAvailability"} # type: ignore + check_notification_hub_availability.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/checkNotificationHubAvailability" + } + + @distributed_trace + def get( + self, resource_group_name: str, namespace_name: str, notification_hub_name: str, **kwargs: Any + ) -> _models.NotificationHubResource: + """Gets the notification hub. + + Gets the notification hub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param notification_hub_name: Notification Hub name. Required. + :type notification_hub_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NotificationHubResource or the result of cls(response) + :rtype: ~azure.mgmt.notificationhubs.models.NotificationHubResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NotificationHubResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + notification_hub_name=notification_hub_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("NotificationHubResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + } @overload def create_or_update( @@ -696,22 +957,24 @@ def create_or_update( resource_group_name: str, namespace_name: str, notification_hub_name: str, - parameters: _models.NotificationHubCreateOrUpdateParameters, + parameters: _models.NotificationHubResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.NotificationHubResource: """Creates/Update a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates/Update a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to the create/update a NotificationHub Resource. - Required. - :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubCreateOrUpdateParameters + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -734,14 +997,16 @@ def create_or_update( ) -> _models.NotificationHubResource: """Creates/Update a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates/Update a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to the create/update a NotificationHub Resource. - Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -758,21 +1023,23 @@ def create_or_update( resource_group_name: str, namespace_name: str, notification_hub_name: str, - parameters: Union[_models.NotificationHubCreateOrUpdateParameters, IO], + parameters: Union[_models.NotificationHubResource, IO], **kwargs: Any ) -> _models.NotificationHubResource: """Creates/Update a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Creates/Update a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to the create/update a NotificationHub Resource. Is - either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubCreateOrUpdateParameters - or IO + :param parameters: Request content. Is either a NotificationHubResource type or a IO type. + Required. + :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -792,19 +1059,17 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationHubResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NotificationHubResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "NotificationHubCreateOrUpdateParameters") + _json = self._serialize.body(parameters, "NotificationHubResource") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -820,17 +1085,19 @@ def create_or_update( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize("NotificationHubResource", pipeline_response) @@ -839,33 +1106,37 @@ def create_or_update( deserialized = self._deserialize("NotificationHubResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}"} # type: ignore + create_or_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + } @overload - def patch( + def update( self, resource_group_name: str, namespace_name: str, notification_hub_name: str, - parameters: Optional[_models.NotificationHubPatchParameters] = None, + parameters: _models.NotificationHubPatchParameters, *, content_type: str = "application/json", **kwargs: Any ) -> _models.NotificationHubResource: """Patch a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Patch a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to patch a NotificationHub Resource. Default value is - None. + :param parameters: Request content. Required. :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubPatchParameters :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -877,26 +1148,28 @@ def patch( """ @overload - def patch( + def update( self, resource_group_name: str, namespace_name: str, notification_hub_name: str, - parameters: Optional[IO] = None, + parameters: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.NotificationHubResource: """Patch a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Patch a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to patch a NotificationHub Resource. Default value is - None. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -908,24 +1181,27 @@ def patch( """ @distributed_trace - def patch( + def update( self, resource_group_name: str, namespace_name: str, notification_hub_name: str, - parameters: Optional[Union[_models.NotificationHubPatchParameters, IO]] = None, + parameters: Union[_models.NotificationHubPatchParameters, IO], **kwargs: Any ) -> _models.NotificationHubResource: """Patch a NotificationHub in a namespace. - :param resource_group_name: The name of the resource group. Required. + Patch a NotificationHub in a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Parameters supplied to patch a NotificationHub Resource. Is either a model - type or a IO type. Default value is None. + :param parameters: Request content. Is either a NotificationHubPatchParameters type or a IO + type. Required. :type parameters: ~azure.mgmt.notificationhubs.models.NotificationHubPatchParameters or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. @@ -946,24 +1222,19 @@ def patch( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationHubResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.NotificationHubResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - if parameters is not None: - _json = self._serialize.body(parameters, "NotificationHubPatchParameters") - else: - _json = None + _json = self._serialize.body(parameters, "NotificationHubPatchParameters") - request = build_patch_request( + request = build_update_request( resource_group_name=resource_group_name, namespace_name=namespace_name, notification_hub_name=notification_hub_name, @@ -972,22 +1243,24 @@ def patch( content_type=content_type, json=_json, content=_content, - template_url=self.patch.metadata["url"], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("NotificationHubResource", pipeline_response) @@ -996,7 +1269,9 @@ def patch( return deserialized - patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}"} # type: ignore + update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + } @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -1004,11 +1279,14 @@ def delete( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a notification hub associated with a namespace. - :param resource_group_name: The name of the resource group. Required. + Deletes a notification hub associated with a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: None or the result of cls(response) @@ -1026,10 +1304,8 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_request( resource_group_name=resource_group_name, @@ -1042,40 +1318,62 @@ def delete( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}"} # type: ignore + delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}" + } @distributed_trace - def get( - self, resource_group_name: str, namespace_name: str, notification_hub_name: str, **kwargs: Any - ) -> _models.NotificationHubResource: + def list( + self, + resource_group_name: str, + namespace_name: str, + skip_token: Optional[str] = None, + top: int = 100, + **kwargs: Any + ) -> Iterable["_models.NotificationHubResource"]: """Lists the notification hubs associated with a namespace. - :param resource_group_name: The name of the resource group. Required. + Lists the notification hubs associated with a namespace. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. - :type notification_hub_name: str + :param skip_token: Continuation token. Default value is None. + :type skip_token: str + :param top: Page size. Default value is 100. + :type top: int :keyword callable cls: A custom type or function that will be passed the direct response - :return: NotificationHubResource or the result of cls(response) - :rtype: ~azure.mgmt.notificationhubs.models.NotificationHubResource + :return: An iterator like instance of either NotificationHubResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.notificationhubs.models.NotificationHubResource] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.NotificationHubListResult] = kwargs.pop("cls", None) + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -1084,65 +1382,85 @@ def get( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + def prepare_request(next_link=None): + if not next_link: - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationHubResource] + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + skip_token=skip_token, + top=top, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = build_get_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - notification_hub_name=notification_hub_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.get.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) + def extract_data(pipeline_response): + deserialized = self._deserialize("NotificationHubListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.next_link or None, iter(list_of_elem) - response = pipeline_response.http_response + def get_next(next_link=None): + request = prepare_request(next_link) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - deserialized = self._deserialize("NotificationHubResource", pipeline_response) + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - if cls: - return cls(pipeline_response, deserialized, {}) + return pipeline_response - return deserialized + return ItemPaged(get_next, extract_data) - get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}"} # type: ignore + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs" + } @distributed_trace def debug_send( - self, - resource_group_name: str, - namespace_name: str, - notification_hub_name: str, - parameters: Optional[JSON] = None, - **kwargs: Any + self, resource_group_name: str, namespace_name: str, notification_hub_name: str, **kwargs: Any ) -> _models.DebugSendResponse: - """test send a push notification. + """Test send a push notification. + + Test send a push notification. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param parameters: Debug send parameters. Default value is None. - :type parameters: JSON :keyword callable cls: A custom type or function that will be passed the direct response :return: DebugSendResponse or the result of cls(response) :rtype: ~azure.mgmt.notificationhubs.models.DebugSendResponse @@ -1156,19 +1474,11 @@ def debug_send( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", "application/json")) # type: str - cls = kwargs.pop("cls", None) # type: ClsType[_models.DebugSendResponse] - - if parameters is not None: - _json = self._serialize.body(parameters, "object") - else: - _json = None + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.DebugSendResponse] = kwargs.pop("cls", None) request = build_debug_send_request( resource_group_name=resource_group_name, @@ -1176,24 +1486,24 @@ def debug_send( notification_hub_name=notification_hub_name, subscription_id=self._config.subscription_id, api_version=api_version, - content_type=content_type, - json=_json, template_url=self.debug_send.metadata["url"], headers=_headers, params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("DebugSendResponse", pipeline_response) @@ -1202,7 +1512,9 @@ def debug_send( return deserialized - debug_send.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/debugsend"} # type: ignore + debug_send.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/debugsend" + } @overload def create_or_update_authorization_rule( @@ -1211,24 +1523,26 @@ def create_or_update_authorization_rule( namespace_name: str, notification_hub_name: str, authorization_rule_name: str, - parameters: _models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, + parameters: _models.SharedAccessAuthorizationRuleResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates/Updates an authorization rule for a NotificationHub. - :param resource_group_name: The name of the resource group. Required. + Creates/Updates an authorization rule for a NotificationHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Required. - :type parameters: - ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1252,15 +1566,18 @@ def create_or_update_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Creates/Updates an authorization rule for a NotificationHub. - :param resource_group_name: The name of the resource group. Required. + Creates/Updates an authorization rule for a NotificationHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1278,23 +1595,26 @@ def create_or_update_authorization_rule( namespace_name: str, notification_hub_name: str, authorization_rule_name: str, - parameters: Union[_models.SharedAccessAuthorizationRuleCreateOrUpdateParameters, IO], + parameters: Union[_models.SharedAccessAuthorizationRuleResource, IO], **kwargs: Any ) -> _models.SharedAccessAuthorizationRuleResource: """Creates/Updates an authorization rule for a NotificationHub. - :param resource_group_name: The name of the resource group. Required. + Creates/Updates an authorization rule for a NotificationHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: The shared access authorization rule. Is either a model type or a IO type. - Required. - :type parameters: - ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleCreateOrUpdateParameters or IO + :param parameters: Request content. Is either a SharedAccessAuthorizationRuleResource type or a + IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.SharedAccessAuthorizationRuleResource or + IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -1314,19 +1634,17 @@ def create_or_update_authorization_rule( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleCreateOrUpdateParameters") + _json = self._serialize.body(parameters, "SharedAccessAuthorizationRuleResource") request = build_create_or_update_authorization_rule_request( resource_group_name=resource_group_name, @@ -1343,26 +1661,34 @@ def create_or_update_authorization_rule( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) + if response.status_code == 200: + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized + return deserialized # type: ignore - create_or_update_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + create_or_update_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def delete_authorization_rule( # pylint: disable=inconsistent-return-statements @@ -1375,11 +1701,14 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements ) -> None: """Deletes a notificationHub authorization rule. - :param resource_group_name: The name of the resource group. Required. + Deletes a notificationHub authorization rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str @@ -1399,10 +1728,8 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[None] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) request = build_delete_authorization_rule_request( resource_group_name=resource_group_name, @@ -1416,22 +1743,26 @@ def delete_authorization_rule( # pylint: disable=inconsistent-return-statements params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - delete_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore + delete_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def get_authorization_rule( @@ -1444,13 +1775,16 @@ def get_authorization_rule( ) -> _models.SharedAccessAuthorizationRuleResource: """Gets an authorization rule for a NotificationHub by name. - :param resource_group_name: The name of the resource group. Required. + Gets an authorization rule for a NotificationHub by name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param authorization_rule_name: authorization rule name. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: SharedAccessAuthorizationRuleResource or the result of cls(response) @@ -1468,10 +1802,8 @@ def get_authorization_rule( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedAccessAuthorizationRuleResource] = kwargs.pop("cls", None) request = build_get_authorization_rule_request( resource_group_name=resource_group_name, @@ -1485,17 +1817,19 @@ def get_authorization_rule( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("SharedAccessAuthorizationRuleResource", pipeline_response) @@ -1504,98 +1838,9 @@ def get_authorization_rule( return deserialized - get_authorization_rule.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}"} # type: ignore - - @distributed_trace - def list( - self, resource_group_name: str, namespace_name: str, **kwargs: Any - ) -> Iterable["_models.NotificationHubResource"]: - """Lists the notification hubs associated with a namespace. - - :param resource_group_name: The name of the resource group. Required. - :type resource_group_name: str - :param namespace_name: The namespace name. Required. - :type namespace_name: str - :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either NotificationHubResource or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.notificationhubs.models.NotificationHubResource] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.NotificationHubListResult] - - error_map = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - request = build_list_request( - resource_group_name=resource_group_name, - namespace_name=namespace_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=self.list.metadata["url"], - headers=_headers, - params=_params, - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( - "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params - ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore - request.method = "GET" - return request - - def extract_data(pipeline_response): - deserialized = self._deserialize("NotificationHubListResult", pipeline_response) - list_of_elem = deserialized.value - if cls: - list_of_elem = cls(list_of_elem) - return deserialized.next_link or None, iter(list_of_elem) - - def get_next(next_link=None): - request = prepare_request(next_link) - - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs"} # type: ignore + get_authorization_rule.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}" + } @distributed_trace def list_authorization_rules( @@ -1603,11 +1848,14 @@ def list_authorization_rules( ) -> Iterable["_models.SharedAccessAuthorizationRuleResource"]: """Gets the authorization rules for a NotificationHub. - :param resource_group_name: The name of the resource group. Required. + Gets the authorization rules for a NotificationHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SharedAccessAuthorizationRuleResource or the @@ -1619,10 +1867,8 @@ def list_authorization_rules( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessAuthorizationRuleListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.SharedAccessAuthorizationRuleListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -1646,7 +1892,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -1662,7 +1908,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -1670,26 +1916,30 @@ def extract_data(pipeline_response): deserialized = self._deserialize("SharedAccessAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response return ItemPaged(get_next, extract_data) - list_authorization_rules.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules"} # type: ignore + list_authorization_rules.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules" + } @distributed_trace def list_keys( @@ -1702,14 +1952,16 @@ def list_keys( ) -> _models.ResourceListKeys: """Gets the Primary and Secondary ConnectionStrings to the NotificationHub. - :param resource_group_name: The name of the resource group. Required. + Gets the Primary and Secondary ConnectionStrings to the NotificationHub. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param authorization_rule_name: The connection string of the NotificationHub for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourceListKeys or the result of cls(response) @@ -1727,10 +1979,8 @@ def list_keys( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) request = build_list_keys_request( resource_group_name=resource_group_name, @@ -1744,17 +1994,19 @@ def list_keys( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ResourceListKeys", pipeline_response) @@ -1763,7 +2015,9 @@ def list_keys( return deserialized - list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/listKeys"} # type: ignore + list_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}/listKeys" + } @overload def regenerate_keys( @@ -1772,25 +2026,26 @@ def regenerate_keys( namespace_name: str, notification_hub_name: str, authorization_rule_name: str, - parameters: _models.PolicykeyResource, + parameters: _models.PolicyKeyResource, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param authorization_rule_name: The connection string of the NotificationHub for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the NotificationHub Authorization Rule - Key. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.PolicykeyResource + :param parameters: Request content. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PolicyKeyResource :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str @@ -1814,17 +2069,18 @@ def regenerate_keys( ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param authorization_rule_name: The connection string of the NotificationHub for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the NotificationHub Authorization Rule - Key. Required. + :param parameters: Request content. Required. :type parameters: IO :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". @@ -1842,23 +2098,24 @@ def regenerate_keys( namespace_name: str, notification_hub_name: str, authorization_rule_name: str, - parameters: Union[_models.PolicykeyResource, IO], + parameters: Union[_models.PolicyKeyResource, IO], **kwargs: Any ) -> _models.ResourceListKeys: """Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. - :param resource_group_name: The name of the resource group. Required. + Regenerates the Primary/Secondary Keys to the NotificationHub Authorization Rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str - :param authorization_rule_name: The connection string of the NotificationHub for the specified - authorizationRule. Required. + :param authorization_rule_name: Authorization Rule Name. Required. :type authorization_rule_name: str - :param parameters: Parameters supplied to regenerate the NotificationHub Authorization Rule - Key. Is either a model type or a IO type. Required. - :type parameters: ~azure.mgmt.notificationhubs.models.PolicykeyResource or IO + :param parameters: Request content. Is either a PolicyKeyResource type or a IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PolicyKeyResource or IO :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. Default value is None. :paramtype content_type: str @@ -1878,19 +2135,17 @@ def regenerate_keys( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] - cls = kwargs.pop("cls", None) # type: ClsType[_models.ResourceListKeys] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ResourceListKeys] = kwargs.pop("cls", None) content_type = content_type or "application/json" _json = None _content = None - if isinstance(parameters, (IO, bytes)): + if isinstance(parameters, (IOBase, bytes)): _content = parameters else: - _json = self._serialize.body(parameters, "PolicykeyResource") + _json = self._serialize.body(parameters, "PolicyKeyResource") request = build_regenerate_keys_request( resource_group_name=resource_group_name, @@ -1907,17 +2162,19 @@ def regenerate_keys( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("ResourceListKeys", pipeline_response) @@ -1926,19 +2183,24 @@ def regenerate_keys( return deserialized - regenerate_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/AuthorizationRules/{authorizationRuleName}/regenerateKeys"} # type: ignore + regenerate_keys.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/authorizationRules/{authorizationRuleName}/regenerateKeys" + } @distributed_trace def get_pns_credentials( self, resource_group_name: str, namespace_name: str, notification_hub_name: str, **kwargs: Any ) -> _models.PnsCredentialsResource: - """Lists the PNS Credentials associated with a notification hub . + """Lists the PNS Credentials associated with a notification hub. + + Lists the PNS Credentials associated with a notification hub. - :param resource_group_name: The name of the resource group. Required. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param namespace_name: The namespace name. Required. + :param namespace_name: Namespace name. Required. :type namespace_name: str - :param notification_hub_name: The notification hub name. Required. + :param notification_hub_name: Notification Hub name. Required. :type notification_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: PnsCredentialsResource or the result of cls(response) @@ -1956,10 +2218,8 @@ def get_pns_credentials( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.PnsCredentialsResource] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PnsCredentialsResource] = kwargs.pop("cls", None) request = build_get_pns_credentials_request( resource_group_name=resource_group_name, @@ -1972,17 +2232,19 @@ def get_pns_credentials( params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize("PnsCredentialsResource", pipeline_response) @@ -1991,4 +2253,6 @@ def get_pns_credentials( return deserialized - get_pns_credentials.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/pnsCredentials"} # type: ignore + get_pns_credentials.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/notificationHubs/{notificationHubName}/pnsCredentials" + } diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_operations.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_operations.py index 9e6946896f2b..08b9b7d80756 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_operations.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_operations.py @@ -6,7 +6,6 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import sys from typing import Any, Callable, Dict, Iterable, Optional, TypeVar import urllib.parse @@ -30,10 +29,6 @@ from .._serialization import Serializer from .._vendor import _convert_request -if sys.version_info >= (3, 8): - from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports -else: - from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -45,7 +40,7 @@ def build_list_request(**kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-04-01")) # type: Literal["2017-04-01"] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +61,7 @@ class Operations: **DO NOT** instantiate this class directly. Instead, you should access the following operations through - :class:`~azure.mgmt.notificationhubs.NotificationHubsManagementClient`'s + :class:`~azure.mgmt.notificationhubs.NotificationHubsRPClient`'s :attr:`operations` attribute. """ @@ -81,7 +76,9 @@ def __init__(self, *args, **kwargs): @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: - """Lists all of the available NotificationHubs REST API operations. + """Lists all available Notification Hubs operations. + + Lists all available Notification Hubs operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Operation or the result of cls(response) @@ -91,10 +88,8 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop( - "api_version", _params.pop("api-version", self._config.api_version) - ) # type: Literal["2017-04-01"] - cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.OperationListResult] = kwargs.pop("cls", None) error_map = { 401: ClientAuthenticationError, @@ -114,7 +109,7 @@ def prepare_request(next_link=None): params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) else: # make call to next link with the client's api-version @@ -130,7 +125,7 @@ def prepare_request(next_link=None): "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) request = _convert_request(request) - request.url = self._client.format_url(request.url) # type: ignore + request.url = self._client.format_url(request.url) request.method = "GET" return request @@ -138,14 +133,15 @@ def extract_data(pipeline_response): deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: - list_of_elem = cls(list_of_elem) + list_of_elem = cls(list_of_elem) # type: ignore return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=False, **kwargs + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -158,4 +154,4 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/providers/Microsoft.NotificationHubs/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.NotificationHubs/operations"} diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_private_endpoint_connections_operations.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..10bcc5d43519 --- /dev/null +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/azure/mgmt/notificationhubs/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,1037 @@ +# pylint: disable=too-many-lines +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- +from io import IOBase +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models +from .._serialization import Serializer +from .._vendor import _convert_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_update_request( + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", + private_endpoint_connection_name, + "str", + max_length=87, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]*\.[a-fA-F0-9\-]+$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", + private_endpoint_connection_name, + "str", + max_length=87, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]*\.[a-fA-F0-9\-]+$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", + private_endpoint_connection_name, + "str", + max_length=87, + min_length=1, + pattern=r"^[a-zA-Z][a-zA-Z0-9-]*\.[a-fA-F0-9\-]+$", + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_group_id_request( + resource_group_name: str, namespace_name: str, sub_resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + "subResourceName": _SERIALIZER.url("sub_resource_name", sub_resource_name, "str", pattern=r"^namespace$"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_group_ids_request( + resource_group_name: str, namespace_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-10-01-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "namespaceName": _SERIALIZER.url( + "namespace_name", namespace_name, "str", max_length=50, min_length=1, pattern=r"^[a-zA-Z][a-zA-Z0-9-]*$" + ), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.notificationhubs.NotificationHubsRPClient`'s + :attr:`private_endpoint_connections` attribute. + """ + + models = _models + + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + def _update_initial( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnectionResource, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnectionResource: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnectionResource] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IOBase, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnectionResource") + + request = build_update_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._update_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("PrivateEndpointConnectionResource", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("PrivateEndpointConnectionResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + _update_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @overload + def begin_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: _models.PrivateEndpointConnectionResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnectionResource]: + """Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: Private Endpoint Connection Name. Required. + :type private_endpoint_connection_name: str + :param parameters: Description of the Private Endpoint Connection resource. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnectionResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnectionResource]: + """Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: Private Endpoint Connection Name. Required. + :type private_endpoint_connection_name: str + :param parameters: Description of the Private Endpoint Connection resource. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnectionResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + namespace_name: str, + private_endpoint_connection_name: str, + parameters: Union[_models.PrivateEndpointConnectionResource, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnectionResource]: + """Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + Approves or rejects Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: Private Endpoint Connection Name. Required. + :type private_endpoint_connection_name: str + :param parameters: Description of the Private Endpoint Connection resource. Is either a + PrivateEndpointConnectionResource type or a IO type. Required. + :type parameters: ~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. + Default value is None. + :paramtype content_type: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnectionResource or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PrivateEndpointConnectionResource] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionResource", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_update.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + + request = build_delete_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + response_headers = {} + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + if cls: + return cls(pipeline_response, None, response_headers) + + _delete_initial.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def begin_delete( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Deletes the Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + Deletes the Private Endpoint Connection. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: Private Endpoint Connection Name. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[None] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore + + begin_delete.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def get( + self, resource_group_name: str, namespace_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnectionResource: + """Returns a Private Endpoint Connection with a given name. + This is a public API that can be called directly by Notification Hubs users. + + Returns a Private Endpoint Connection with a given name. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param private_endpoint_connection_name: Private Endpoint Connection Name. Required. + :type private_endpoint_connection_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateEndpointConnectionResource or the result of cls(response) + :rtype: ~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionResource] = kwargs.pop("cls", None) + + request = build_get_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnectionResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections/{privateEndpointConnectionName}" + } + + @distributed_trace + def list( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnectionResource"]: + """Returns all Private Endpoint Connections that belong to the given Notification Hubs namespace. + This is a public API that can be called directly by Notification Hubs users. + + Returns all Private Endpoint Connections that belong to the given Notification Hubs namespace. + This is a public API that can be called directly by Notification Hubs users. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateEndpointConnectionResource or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.notificationhubs.models.PrivateEndpointConnectionResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateEndpointConnectionResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateEndpointConnections" + } + + @distributed_trace + def get_group_id( + self, resource_group_name: str, namespace_name: str, sub_resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResource: + """Returns Group Id response. + This is a public API required by the Networking RP contract. It can be used directly by + Notification Hubs users. + + Even though this namespace requires subscription id, resource group and namespace name, it + returns a constant payload (for a given namespacE) every time it's called. + That's why we don't send it to the sibling RP, but process it directly in the scale unit that + received the request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :param sub_resource_name: Name of the Private Link sub-resource. The only supported + sub-resource is "namespace". Required. + :type sub_resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResource or the result of cls(response) + :rtype: ~azure.mgmt.notificationhubs.models.PrivateLinkResource + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResource] = kwargs.pop("cls", None) + + request = build_get_group_id_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + sub_resource_name=sub_resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_group_id.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResource", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_group_id.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources/{subResourceName}" + } + + @distributed_trace + def list_group_ids( + self, resource_group_name: str, namespace_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: + """Returns all Group Ids supported by the Notification Hubs RP. + This is a public API required by the Networking RP contract. It can be used directly by + Notification Hubs users. + + Even though this namespace requires subscription id, resource group and namespace name, it + returns a constant payload (for a given namespacE) every time it's called. + That's why we don't send it to the sibling RP, but process it directly in the scale unit that + received the request. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param namespace_name: Namespace name. Required. + :type namespace_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.notificationhubs.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) + cls: ClsType[_models.PrivateLinkResourceListResult] = kwargs.pop("cls", None) + + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + request = build_list_group_ids_request( + resource_group_name=resource_group_name, + namespace_name=namespace_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_group_ids.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + request = HttpRequest( + "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_group_ids.metadata = { + "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.NotificationHubs/namespaces/{namespaceName}/privateLinkResources" + } diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_update.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_update.py deleted file mode 100644 index 347264a1fb70..000000000000 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_update.py +++ /dev/null @@ -1,42 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient - -""" -# PREREQUISITES - pip install azure-identity - pip install azure-mgmt-notificationhubs -# USAGE - python name_space_update.py - - Before run the sample, please set the values of the client ID, tenant ID and client secret - of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, - AZURE_CLIENT_SECRET. For more info about how to get the value, please see: - https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal -""" - - -def main(): - client = NotificationHubsManagementClient( - credential=DefaultAzureCredential(), - subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", - ) - - response = client.namespaces.patch( - resource_group_name="5ktrial", - namespace_name="nh-sdk-ns", - parameters={"sku": {"name": "Standard", "tier": "Standard"}, "tags": {"tag1": "value1", "tag2": "value2"}}, - ) - print(response) - - -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceUpdate.json -if __name__ == "__main__": - main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_create.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_create_or_update.py similarity index 84% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_create.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_create_or_update.py index 517dfb8d7ad7..5adbee85bc10 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_create.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_create_or_update.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_authorization_rule_create.py + python authorization_rule_create_or_update.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleCreate.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_delete.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_delete.py similarity index 79% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_delete.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_delete.py index a5db5540cff8..455eb6f1a11b 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_delete.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_delete.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_authorization_rule_delete.py + python authorization_rule_delete.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,19 +24,18 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) - response = client.namespaces.delete_authorization_rule( + client.namespaces.delete_authorization_rule( resource_group_name="5ktrial", namespace_name="nh-sdk-ns", authorization_rule_name="RootManageSharedAccessKey", ) - print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleDelete.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleDelete.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_get.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_get.py similarity index 83% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_get.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_get.py index 4d93508602ca..53eedfce457b 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_get.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_get.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_authorization_rule_get.py + python authorization_rule_get.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleGet.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleGet.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_list_all.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_list.py similarity index 83% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_list_all.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_list.py index 79cc1ffe009c..54630a2ea140 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_list_all.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_list.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_authorization_rule_list_all.py + python authorization_rule_list.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleListAll.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleList.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_list_key.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_list_keys.py similarity index 83% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_list_key.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_list_keys.py index 2b8c1ea62f36..d747f8ff525f 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_list_key.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_list_keys.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_authorization_rule_list_key.py + python authorization_rule_list_keys.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleListKey.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleListKeys.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_regenerate_key.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_regenerate_key.py similarity index 83% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_regenerate_key.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_regenerate_key.py index 86802d7d9308..efa7807a1d3b 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_authorization_rule_regenerate_key.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/authorization_rule_regenerate_key.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_authorization_rule_regenerate_key.py + python authorization_rule_regenerate_key.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceAuthorizationRuleRegenrateKey.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleRegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_check_name_availability.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/check_availability.py similarity index 82% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_check_name_availability.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/check_availability.py index 9a05bf9207ef..52f594691f89 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_check_name_availability.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/check_availability.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_check_name_availability.py + python check_availability.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -35,6 +35,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceCheckNameAvailability.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/CheckAvailability.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_create.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/create_or_update.py similarity index 71% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_create.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/create_or_update.py index 041382f415d2..c67640c6a076 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_create.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/create_or_update.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_create.py + python create_or_update.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,23 +24,30 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) - response = client.namespaces.create_or_update( + response = client.namespaces.begin_create_or_update( resource_group_name="5ktrial", namespace_name="nh-sdk-ns", parameters={ "location": "South Central US", + "properties": { + "networkAcls": { + "ipRules": [{"ipMask": "185.48.100.00/24", "rights": ["Manage", "Send", "Listen"]}], + "publicNetworkRule": {"rights": ["Listen"]}, + }, + "zoneRedundancy": "Enabled", + }, "sku": {"name": "Standard", "tier": "Standard"}, "tags": {"tag1": "value1", "tag2": "value2"}, }, - ) + ).result() print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceCreate.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/delete.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/delete.py new file mode 100644 index 000000000000..51ba9d500748 --- /dev/null +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/delete.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.notificationhubs import NotificationHubsRPClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-notificationhubs +# USAGE + python delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NotificationHubsRPClient( + credential=DefaultAzureCredential(), + subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", + ) + + client.namespaces.delete( + resource_group_name="5ktrial", + namespace_name="nh-sdk-ns", + ) + + +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_get.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/get.py similarity index 85% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_get.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/get.py index b43362b36d08..d8a2db8b8067 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_get.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/get.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_get.py + python get.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -36,6 +36,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceGet.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Get.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_list_by_resource_group.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/list_by_resource_group.py similarity index 83% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_list_by_resource_group.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/list_by_resource_group.py index 33c7a59b6651..96d5da624647 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_list_by_resource_group.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/list_by_resource_group.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_list_by_resource_group.py + python list_by_resource_group.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -36,6 +36,6 @@ def main(): print(item) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceListByResourceGroup.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_list.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/list_by_subscription.py similarity index 84% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_list.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/list_by_subscription.py index 303a21f18ba1..e3ae41b56122 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_list.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/list_by_subscription.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_list.py + python list_by_subscription.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceList.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/ListBySubscription.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_delete.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/pns_credentials_get.py similarity index 81% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_delete.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/pns_credentials_get.py index 1be1d2d26aa6..d6bc04388093 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/name_space_delete.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/pns_credentials_get.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python name_space_delete.py + python pns_credentials_get.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,18 +24,18 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) - response = client.namespaces.begin_delete( + response = client.namespaces.get_pns_credentials( resource_group_name="5ktrial", namespace_name="nh-sdk-ns", - ).result() + ) print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/Namespaces/NHNameSpaceDelete.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PnsCredentialsGet.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_delete.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_delete.py new file mode 100644 index 000000000000..0e8bb160e71e --- /dev/null +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_delete.py @@ -0,0 +1,41 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.notificationhubs import NotificationHubsRPClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-notificationhubs +# USAGE + python private_endpoint_connection_delete.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NotificationHubsRPClient( + credential=DefaultAzureCredential(), + subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", + ) + + client.private_endpoint_connections.begin_delete( + resource_group_name="5ktrial", + namespace_name="nh-sdk-ns", + private_endpoint_connection_name="nh-sdk-ns.1fa229cd-bf3f-47f0-8c49-afb36723997e", + ).result() + + +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_get.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_get.py new file mode 100644 index 000000000000..837efd3c1f3b --- /dev/null +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.notificationhubs import NotificationHubsRPClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-notificationhubs +# USAGE + python private_endpoint_connection_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NotificationHubsRPClient( + credential=DefaultAzureCredential(), + subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", + ) + + response = client.private_endpoint_connections.get( + resource_group_name="5ktrial", + namespace_name="nh-sdk-ns", + private_endpoint_connection_name="nh-sdk-ns.1fa229cd-bf3f-47f0-8c49-afb36723997e", + ) + print(response) + + +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionGet.json +if __name__ == "__main__": + main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_list.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_list.py new file mode 100644 index 000000000000..7a41df382504 --- /dev/null +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.notificationhubs import NotificationHubsRPClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-notificationhubs +# USAGE + python private_endpoint_connection_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NotificationHubsRPClient( + credential=DefaultAzureCredential(), + subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", + ) + + response = client.private_endpoint_connections.list( + resource_group_name="5ktrial", + namespace_name="nh-sdk-ns", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionList.json +if __name__ == "__main__": + main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_update.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_update.py new file mode 100644 index 000000000000..2942023f22aa --- /dev/null +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_endpoint_connection_update.py @@ -0,0 +1,43 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.notificationhubs import NotificationHubsRPClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-notificationhubs +# USAGE + python private_endpoint_connection_update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NotificationHubsRPClient( + credential=DefaultAzureCredential(), + subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", + ) + + response = client.private_endpoint_connections.begin_update( + resource_group_name="5ktrial", + namespace_name="nh-sdk-ns", + private_endpoint_connection_name="nh-sdk-ns.1fa229cd-bf3f-47f0-8c49-afb36723997e", + parameters={"properties": {"privateEndpoint": {}, "privateLinkServiceConnectionState": {"status": "Approved"}}}, + ).result() + print(response) + + +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_link_resource_get.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_link_resource_get.py new file mode 100644 index 000000000000..6eef6ea25bd4 --- /dev/null +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_link_resource_get.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.notificationhubs import NotificationHubsRPClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-notificationhubs +# USAGE + python private_link_resource_get.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NotificationHubsRPClient( + credential=DefaultAzureCredential(), + subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", + ) + + response = client.private_endpoint_connections.get_group_id( + resource_group_name="5ktrial", + namespace_name="nh-sdk-ns", + sub_resource_name="namespace", + ) + print(response) + + +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateLinkResourceGet.json +if __name__ == "__main__": + main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_link_resource_list.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_link_resource_list.py new file mode 100644 index 000000000000..52c4dd9f9f22 --- /dev/null +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/private_link_resource_list.py @@ -0,0 +1,42 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.notificationhubs import NotificationHubsRPClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-notificationhubs +# USAGE + python private_link_resource_list.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NotificationHubsRPClient( + credential=DefaultAzureCredential(), + subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", + ) + + response = client.private_endpoint_connections.list_group_ids( + resource_group_name="5ktrial", + namespace_name="nh-sdk-ns", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateLinkResourceList.json +if __name__ == "__main__": + main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/update.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/update.py new file mode 100644 index 000000000000..d9fb9fd07895 --- /dev/null +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/namespaces/update.py @@ -0,0 +1,55 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.notificationhubs import NotificationHubsRPClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-notificationhubs +# USAGE + python update.py + + Before run the sample, please set the values of the client ID, tenant ID and client secret + of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, + AZURE_CLIENT_SECRET. For more info about how to get the value, please see: + https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal +""" + + +def main(): + client = NotificationHubsRPClient( + credential=DefaultAzureCredential(), + subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", + ) + + response = client.namespaces.update( + resource_group_name="5ktrial", + namespace_name="nh-sdk-ns", + parameters={ + "properties": { + "pnsCredentials": { + "gcmCredential": { + "properties": { + "gcmEndpoint": "https://fcm.googleapis.com/fcm/send", + "googleApiKey": "#############################", + } + } + } + }, + "sku": {"name": "Free"}, + "tags": {"tag1": "value3"}, + }, + ) + print(response) + + +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Update.json +if __name__ == "__main__": + main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/operations_list.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/nh_operations_list.py similarity index 84% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/operations_list.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/nh_operations_list.py index 32d7c10f1361..30d20a3f2574 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/operations_list.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/nh_operations_list.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python operations_list.py + python nh_operations_list.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="SUBSCRIPTION_ID", ) @@ -34,6 +34,6 @@ def main(): print(item) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NHOperationsList.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NHOperationsList.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_create.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_create_or_update.py similarity index 80% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_create.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_create_or_update.py index 157b1a1337f9..64194ea93fe7 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_create.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_create_or_update.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_authorization_rule_create.py + python authorization_rule_create_or_update.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -33,12 +33,12 @@ def main(): resource_group_name="5ktrial", namespace_name="nh-sdk-ns", notification_hub_name="nh-sdk-hub", - authorization_rule_name="DefaultListenSharedAccessSignature", + authorization_rule_name="MyManageSharedAccessKey", parameters={"properties": {"rights": ["Listen", "Send"]}}, ) print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleCreate.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_delete.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_delete.py similarity index 78% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_delete.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_delete.py index e531690e34f1..b6f51f21d4d6 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_delete.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_delete.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_authorization_rule_delete.py + python authorization_rule_delete.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,20 +24,19 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) - response = client.notification_hubs.delete_authorization_rule( + client.notification_hubs.delete_authorization_rule( resource_group_name="5ktrial", namespace_name="nh-sdk-ns", notification_hub_name="nh-sdk-hub", authorization_rule_name="DefaultListenSharedAccessSignature", ) - print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleDelete.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleDelete.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_get.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_get.py similarity index 83% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_get.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_get.py index 80a5c44f5158..8ef04be0e6d9 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_get.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_get.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_authorization_rule_get.py + python authorization_rule_get.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleGet.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleGet.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_list_all.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_list.py similarity index 82% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_list_all.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_list.py index daa013ddfd65..78dd354fcef2 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_list_all.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_list.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_authorization_rule_list_all.py + python authorization_rule_list.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -38,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleListAll.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleList.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_list_key.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_list_keys.py similarity index 83% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_list_key.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_list_keys.py index de5ef6cbd884..3dea30591433 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_list_key.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_list_keys.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_authorization_rule_list_key.py + python authorization_rule_list_keys.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleListKey.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleListKeys.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_regenrate_key.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_regenerate_key.py similarity index 83% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_regenrate_key.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_regenerate_key.py index e4b0ef669fbc..f429402b9b83 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_authorization_rule_regenrate_key.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/authorization_rule_regenerate_key.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_authorization_rule_regenrate_key.py + python authorization_rule_regenerate_key.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -39,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubAuthorizationRuleRegenrateKey.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleRegenerateKey.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_check_name_availability.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/check_availability.py similarity index 83% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_check_name_availability.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/check_availability.py index 9c24882630d0..a08a414289c4 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_check_name_availability.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/check_availability.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_check_name_availability.py + python check_availability.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubCheckNameAvailability.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/CheckAvailability.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_create.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/create_or_update.py similarity index 85% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_create.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/create_or_update.py index 482c6e9bde89..0c7eda32f9fc 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_create.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/create_or_update.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_create.py + python create_or_update.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -38,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubCreate.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/CreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/debugsend.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/debug_send.py similarity index 84% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/debugsend.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/debug_send.py index 4992e39647ba..df03a959d33c 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/debugsend.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/debug_send.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python debugsend.py + python debug_send.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubDebugSend.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/DebugSend.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_delete.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/delete.py similarity index 80% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_delete.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/delete.py index 452c07ed4b99..c1626b4cb4e8 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_delete.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/delete.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_delete.py + python delete.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,19 +24,18 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) - response = client.notification_hubs.delete( + client.notification_hubs.delete( resource_group_name="5ktrial", namespace_name="nh-sdk-ns", notification_hub_name="nh-sdk-hub", ) - print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubDelete.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Delete.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_get.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/get.py similarity index 84% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_get.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/get.py index abc0595213ab..2da6096913a4 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_get.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/get.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_get.py + python get.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubGet.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Get.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_list_by_name_space.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/list.py similarity index 83% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_list_by_name_space.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/list.py index 601f4f83f93c..46b85132aede 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_list_by_name_space.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/list.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_list_by_name_space.py + python list.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -37,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubListByNameSpace.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/List.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_pns_credentials.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/pns_credentials_get.py similarity index 83% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_pns_credentials.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/pns_credentials_get.py index f6ba0e5f64c7..f442a67fe2b7 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_pns_credentials.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/pns_credentials_get.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_pns_credentials.py + python pns_credentials_get.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,7 +24,7 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) @@ -37,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubPnsCredentials.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/PnsCredentialsGet.json if __name__ == "__main__": main() diff --git a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_patch.py b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/update.py similarity index 67% rename from sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_patch.py rename to sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/update.py index f8919992c50c..033b853526e1 100644 --- a/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hub_patch.py +++ b/sdk/notificationhubs/azure-mgmt-notificationhubs/generated_samples/notification_hubs/update.py @@ -7,14 +7,14 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential -from azure.mgmt.notificationhubs import NotificationHubsManagementClient +from azure.mgmt.notificationhubs import NotificationHubsRPClient """ # PREREQUISITES pip install azure-identity pip install azure-mgmt-notificationhubs # USAGE - python notification_hub_patch.py + python update.py Before run the sample, please set the values of the client ID, tenant ID and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, @@ -24,19 +24,30 @@ def main(): - client = NotificationHubsManagementClient( + client = NotificationHubsRPClient( credential=DefaultAzureCredential(), subscription_id="29cfa613-cbbc-4512-b1d6-1b3a92c7fa40", ) - response = client.notification_hubs.patch( + response = client.notification_hubs.update( resource_group_name="sdkresourceGroup", namespace_name="nh-sdk-ns", notification_hub_name="sdk-notificationHubs-8708", + parameters={ + "properties": { + "gcmCredential": { + "properties": { + "gcmEndpoint": "https://fcm.googleapis.com/fcm/send", + "googleApiKey": "###################################", + } + }, + "registrationTtl": "10675199.02:48:05.4775807", + } + }, ) print(response) -# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/stable/2017-04-01/examples/NotificationHubs/NotificationHubPatch.json +# x-ms-original-file: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Update.json if __name__ == "__main__": main() diff --git a/sdk/schemaregistry/azure-schemaregistry-avroencoder/setup.py b/sdk/schemaregistry/azure-schemaregistry-avroencoder/setup.py index 0d88ad8116e5..f159bd638c1f 100644 --- a/sdk/schemaregistry/azure-schemaregistry-avroencoder/setup.py +++ b/sdk/schemaregistry/azure-schemaregistry-avroencoder/setup.py @@ -33,7 +33,7 @@ changelog = f.read() install_packages = [ - 'azure-schemaregistry>=1.0.0,<2.0.0', + 'azure-schemaregistry>=1.0.0', 'avro>=1.11.0', "typing-extensions>=4.0.1", ] @@ -53,13 +53,15 @@ "Development Status :: 5 - Production/Stable", 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], - python_requires=">=3.7", + python_requires=">=3.8", zip_safe=False, packages=find_namespace_packages( include=['azure.schemaregistry.encoder.*'] # Exclude packages that will be covered by PEP420 or nspkg diff --git a/sdk/schemaregistry/azure-schemaregistry/setup.py b/sdk/schemaregistry/azure-schemaregistry/setup.py index ffbb1a99d73d..978f1d1cde7d 100644 --- a/sdk/schemaregistry/azure-schemaregistry/setup.py +++ b/sdk/schemaregistry/azure-schemaregistry/setup.py @@ -57,7 +57,7 @@ "Development Status :: 4 - Beta", 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', - 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', @@ -65,16 +65,16 @@ 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], - python_requires=">=3.7", + python_requires=">=3.8", zip_safe=False, packages=find_packages(exclude=exclude_packages), install_requires=[ 'msrest>=0.6.21', - 'azure-core<2.0.0,>=1.24.0' + 'azure-core>=1.24.0' ], extras_require={ "jsonencoder": [ - "jsonschema<5.0.0,>=4.10.3", + "jsonschema>=4.10.3", ], }, ) diff --git a/sdk/search/azure-search-documents/setup.py b/sdk/search/azure-search-documents/setup.py index 9106e6c2f3a3..209df146e7a8 100644 --- a/sdk/search/azure-search-documents/setup.py +++ b/sdk/search/azure-search-documents/setup.py @@ -64,8 +64,8 @@ ), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.28.0", - "azure-common~=1.1", + "azure-core>=1.28.0", + "azure-common>=1.1", "isodate>=0.6.0", ], ) diff --git a/sdk/servicebus/azure-servicebus/setup.py b/sdk/servicebus/azure-servicebus/setup.py index e96bddbc9845..36da79dcf476 100644 --- a/sdk/servicebus/azure-servicebus/setup.py +++ b/sdk/servicebus/azure-servicebus/setup.py @@ -49,6 +49,7 @@ "Development Status :: 5 - Production/Stable", 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', + 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', @@ -65,7 +66,7 @@ 'azure', ]), install_requires=[ - "azure-core<2.0.0,>=1.28.0", + "azure-core>=1.28.0", "isodate>=0.6.0", "typing-extensions>=4.0.1", ] diff --git a/sdk/storage/azure-storage-blob/setup.py b/sdk/storage/azure-storage-blob/setup.py index d53ccbd095f2..c22e1a5bdb13 100644 --- a/sdk/storage/azure-storage-blob/setup.py +++ b/sdk/storage/azure-storage-blob/setup.py @@ -78,14 +78,14 @@ ]), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.28.0", + "azure-core>=1.28.0", "cryptography>=2.1.4", "typing-extensions>=4.6.0", "isodate>=0.6.1" ], extras_require={ "aio": [ - "azure-core[aio]<2.0.0,>=1.28.0", + "azure-core[aio]>=1.28.0", ], }, ) diff --git a/sdk/storage/azure-storage-file-datalake/setup.py b/sdk/storage/azure-storage-file-datalake/setup.py index c71f3d97d788..cfd219335616 100644 --- a/sdk/storage/azure-storage-file-datalake/setup.py +++ b/sdk/storage/azure-storage-file-datalake/setup.py @@ -77,14 +77,14 @@ ]), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.28.0", - "azure-storage-blob<13.0.0,>=12.20.0b1", + "azure-core>=1.28.0", + "azure-storage-blob>=12.20.0b1", "typing-extensions>=4.6.0", "isodate>=0.6.1" ], extras_require={ "aio": [ - "azure-core[aio]<2.0.0,>=1.28.0", + "azure-core[aio]>=1.28.0", ], }, ) diff --git a/sdk/storage/azure-storage-file-share/setup.py b/sdk/storage/azure-storage-file-share/setup.py index 06135d4616f3..fef43a9b1927 100644 --- a/sdk/storage/azure-storage-file-share/setup.py +++ b/sdk/storage/azure-storage-file-share/setup.py @@ -65,14 +65,14 @@ ]), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.28.0", + "azure-core>=1.28.0", "cryptography>=2.1.4", "typing-extensions>=4.6.0", "isodate>=0.6.1" ], extras_require={ "aio": [ - "azure-core[aio]<2.0.0,>=1.28.0", + "azure-core[aio]>=1.28.0", ], }, ) diff --git a/sdk/storage/azure-storage-queue/setup.py b/sdk/storage/azure-storage-queue/setup.py index e1dce723431b..8130656427c5 100644 --- a/sdk/storage/azure-storage-queue/setup.py +++ b/sdk/storage/azure-storage-queue/setup.py @@ -68,14 +68,14 @@ ]), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.28.0", + "azure-core>=1.28.0", "cryptography>=2.1.4", "typing-extensions>=4.6.0", "isodate>=0.6.1" ], extras_require={ "aio": [ - "azure-core[aio]<2.0.0,>=1.28.0", + "azure-core[aio]>=1.28.0", ], }, ) diff --git a/sdk/storage/platform-matrix-all-versions.json b/sdk/storage/platform-matrix-all-versions.json index 41bfe0869a02..3ffc9af1c078 100644 --- a/sdk/storage/platform-matrix-all-versions.json +++ b/sdk/storage/platform-matrix-all-versions.json @@ -6,9 +6,9 @@ }, "matrix": { "Agent": { - "Ubuntu-20.04": { "OSVmImage": "MMSUbuntu20.04", "Pool": "azsdk-pool-mms-ubuntu-2004-general" }, - "windows-2022": { "OSVmImage": "MMS2022", "Pool": "azsdk-pool-mms-win-2022-general" }, - "macos-11": { "OSVmImage": "macos-11", "Pool": "Azure Pipelines" } + "Ubuntu-20.04": { "OSVmImage": "env:LINUXVMIMAGE", "Pool": "env:LINUXPOOL" }, + "windows-2022": { "OSVmImage": "env:WINDOWSVMIMAGE", "Pool": "env:WINDOWSPOOL" }, + "macos-11": { "OSVmImage": "env:MACVMIMAGE", "Pool": "env:MACPOOL" } }, "PythonVersion": [ "3.8", "3.9", "3.10", "3.11" ], "CoverageArg": "--disablecov", @@ -27,8 +27,8 @@ { "CoverageConfig": { "ubuntu2004_pypy39": { - "OSVmImage": "MMSUbuntu20.04", - "Pool": "azsdk-pool-mms-ubuntu-2004-general", + "OSVmImage": "env:LINUXVMIMAGE", + "Pool": "env:LINUXPOOL", "PythonVersion": "pypy3.9", "CoverageArg": "--disablecov", "TestSamples": "false" diff --git a/sdk/tables/azure-data-tables/setup.py b/sdk/tables/azure-data-tables/setup.py index 2396b2e9ab20..905b3740a101 100644 --- a/sdk/tables/azure-data-tables/setup.py +++ b/sdk/tables/azure-data-tables/setup.py @@ -67,9 +67,9 @@ ), python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.29.4", - "yarl<2.0,>=1.0", - "isodate<1.0.0,>=0.6.1", + "azure-core>=1.29.4", + "yarl>=1.0", + "isodate>=0.6.1", "typing-extensions>=4.3.0", ], ) diff --git a/sdk/textanalytics/azure-ai-textanalytics/setup.py b/sdk/textanalytics/azure-ai-textanalytics/setup.py index 175099ab13ec..3391b4bae3c8 100644 --- a/sdk/textanalytics/azure-ai-textanalytics/setup.py +++ b/sdk/textanalytics/azure-ai-textanalytics/setup.py @@ -49,11 +49,11 @@ 'Programming Language :: Python', "Programming Language :: Python :: 3 :: Only", 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], zip_safe=False, @@ -67,11 +67,11 @@ package_data={ 'azure.ai.textanalytics': ['py.typed'], }, - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.24.0", - 'azure-common~=1.1', - "isodate<1.0.0,>=0.6.1", + "azure-core>=1.24.0", + 'azure-common>=1.1', + "isodate>=0.6.1", "typing-extensions>=4.0.1", ], ) diff --git a/sdk/translation/azure-ai-translation-document/setup.py b/sdk/translation/azure-ai-translation-document/setup.py index b23c38385d03..ec620aee8a48 100644 --- a/sdk/translation/azure-ai-translation-document/setup.py +++ b/sdk/translation/azure-ai-translation-document/setup.py @@ -40,11 +40,11 @@ 'Programming Language :: Python', "Programming Language :: Python :: 3 :: Only", 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', 'License :: OSI Approved :: MIT License', ], packages=find_packages(exclude=[ @@ -54,10 +54,10 @@ 'azure.ai', 'azure.ai.translation' ]), - python_requires=">=3.7", + python_requires=">=3.8", install_requires=[ - "azure-core<2.0.0,>=1.24.0", - "isodate<1.0.0,>=0.6.1", + "azure-core>=1.24.0", + "isodate>=0.6.1", ], project_urls={ 'Bug Reports': 'https://github.com/Azure/azure-sdk-for-python/issues', diff --git a/sdk/translation/azure-ai-translation-text/setup.py b/sdk/translation/azure-ai-translation-text/setup.py index 144e339908e7..0188bfb2d400 100644 --- a/sdk/translation/azure-ai-translation-text/setup.py +++ b/sdk/translation/azure-ai-translation-text/setup.py @@ -64,8 +64,8 @@ "azure.ai.translation.text": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-core<2.0.0,>=1.30.0", + "isodate>=0.6.1", + "azure-core>=1.30.0", "typing-extensions>=4.6.0", ], python_requires=">=3.8", diff --git a/tools/azure-sdk-tools/devtools_testutils/perfstress_tests/__init__.py b/tools/azure-sdk-tools/devtools_testutils/perfstress_tests/__init__.py index fc62d8e08df8..2556fca820a2 100644 --- a/tools/azure-sdk-tools/devtools_testutils/perfstress_tests/__init__.py +++ b/tools/azure-sdk-tools/devtools_testutils/perfstress_tests/__init__.py @@ -9,7 +9,7 @@ from ._perf_stress_runner import _PerfStressRunner from ._perf_stress_test import PerfStressTest from ._random_stream import RandomStream, WriteStream, get_random_bytes -from ._async_random_stream import AsyncRandomStream +from ._async_random_stream import AsyncRandomStream, AsyncIteratorRandomStream from ._batch_perf_test import BatchPerfTest from ._event_perf_test import EventPerfTest @@ -19,6 +19,7 @@ "EventPerfTest", "RandomStream", "WriteStream", + "AsyncIteratorRandomStream", "AsyncRandomStream", "get_random_bytes" ] diff --git a/tools/azure-sdk-tools/devtools_testutils/perfstress_tests/_async_random_stream.py b/tools/azure-sdk-tools/devtools_testutils/perfstress_tests/_async_random_stream.py index ce8be60731df..ee9e2ab8e0ac 100644 --- a/tools/azure-sdk-tools/devtools_testutils/perfstress_tests/_async_random_stream.py +++ b/tools/azure-sdk-tools/devtools_testutils/perfstress_tests/_async_random_stream.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- +from typing import AsyncIterator from io import BytesIO from ._random_stream import get_random_bytes, _DEFAULT_LENGTH @@ -58,3 +59,46 @@ def remaining(self): def close(self): self._closed = True + + +class AsyncIteratorRandomStream(AsyncIterator[bytes]): + """ + Async random stream of bytes for methods that accept AsyncIterator as input. + """ + def __init__(self, length, initial_buffer_length=_DEFAULT_LENGTH): + self._base_data = get_random_bytes(initial_buffer_length) + self._data_length = length + self._base_buffer_length = initial_buffer_length + self._position = 0 + self._remaining = length + + def __len__(self): + return self._remaining + + def __aiter__(self): + return self + + async def __anext__(self): + if self._remaining == 0: + raise StopAsyncIteration + return self.read() + + def reset(self): + self._position = 0 + self._remaining = self._data_length + + def read(self, size=None): + if self._remaining == 0: + return b"" + + if size is None: + e = self._base_buffer_length + else: + e = size + e = min(e, self._remaining) + if e > self._base_buffer_length: + self._base_data = get_random_bytes(e) + self._base_buffer_length = e + self._remaining = self._remaining - e + self._position += e + return self._base_data[:e] diff --git a/tools/azure-sdk-tools/packaging_tools/templates/packaging_files/setup.py b/tools/azure-sdk-tools/packaging_tools/templates/packaging_files/setup.py index 389d0bc8d5c6..6ae6f9077080 100644 --- a/tools/azure-sdk-tools/packaging_tools/templates/packaging_files/setup.py +++ b/tools/azure-sdk-tools/packaging_tools/templates/packaging_files/setup.py @@ -78,16 +78,16 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", + "isodate>=0.6.1", {%- if need_msrestazure %} - "msrestazure>=0.4.32,<2.0.0", + "msrestazure>=0.4.32", {%- endif %} - "azure-common~=1.1", + "azure-common>=1.1", {%- if need_azurecore %} - "azure-core>=1.24.0,<2.0.0", + "azure-core>=1.24.0", {%- endif %} {%- if need_azuremgmtcore %} - "azure-mgmt-core>=1.3.2,<2.0.0", + "azure-mgmt-core>=1.3.2", {%- endif %} ], python_requires=">=3.8",