diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0a7748bfde1b..aa8d336919a9 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -64,6 +64,8 @@ /sdk/eventhub/ @annatisch @kashifkhan @swathipil @l0lawrence # ServiceLabel: %Storage +# ServiceOwners: @jalauzon-msft @vincenttran-msft + # PRLabel: %Storage /sdk/storage/ @annatisch @jalauzon-msft @vincenttran-msft @weirongw23-msft @@ -873,9 +875,6 @@ # ServiceLabel: %Service Attention %SQL - Replication & Failover #// @azureSQLGitHub -# ServiceLabel: %Service Attention %Storage -#// @xgithubtriage - # ServiceLabel: %Service Attention %Storsimple #// @anoobbacker @ganzee @manuaery @patelkunal diff --git a/eng/common/pipelines/templates/steps/detect-api-changes.yml b/eng/common/pipelines/templates/steps/detect-api-changes.yml index 5210ebbe4b61..f39a88eaa3a5 100644 --- a/eng/common/pipelines/templates/steps/detect-api-changes.yml +++ b/eng/common/pipelines/templates/steps/detect-api-changes.yml @@ -22,6 +22,7 @@ steps: -RepoFullName $(Build.Repository.Name) -APIViewUri $(ApiChangeDetectRequestUrl) -ArtifactName ${{ parameters.ArtifactName }} + -DevopsProject $(System.TeamProject) pwsh: true displayName: Detect API changes condition: and(succeededOrFailed(), eq(variables['Build.Reason'],'PullRequest')) diff --git a/eng/common/pipelines/templates/steps/policheck.yml b/eng/common/pipelines/templates/steps/policheck.yml index 5ef30187e564..199af7972952 100644 --- a/eng/common/pipelines/templates/steps/policheck.yml +++ b/eng/common/pipelines/templates/steps/policheck.yml @@ -2,14 +2,20 @@ parameters: ExclusionDataBaseFileName: '' TargetDirectory: '' PublishAnalysisLogs: false - PoliCheckBlobSAS: "$(azuresdk-policheck-blob-SAS)" ExclusionFilePath: "$(Build.SourcesDirectory)/eng/guardian-tools/policheck/PolicheckExclusions.xml" steps: - - pwsh: | - azcopy copy "https://azuresdkartifacts.blob.core.windows.net/policheck/${{ parameters.ExclusionDataBaseFileName }}.mdb?${{ parameters.PoliCheckBlobSAS }}" ` - "$(Build.BinariesDirectory)" - displayName: 'Download PoliCheck Exclusion Database' + - task: AzurePowerShell@5 + displayName: 'Download Policheck Exclusion Database' + inputs: + azureSubscription: 'Azure SDK Artifacts' + ScriptType: 'InlineScript' + azurePowerShellVersion: LatestVersion + pwsh: true + Inline: | + azcopy copy "https://azuresdkartifacts.blob.core.windows.net/policheck/${{ parameters.ExclusionDataBaseFileName }}.mdb" "$(Build.BinariesDirectory)" + env: + AZCOPY_AUTO_LOGIN_TYPE: 'PSCRED' - task: securedevelopmentteam.vss-secure-development-tools.build-task-policheck.PoliCheck@2 displayName: 'Run PoliCheck' @@ -33,4 +39,4 @@ steps: - ${{ if eq(parameters.PublishAnalysisLogs, 'true') }}: - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@3 - displayName: 'Publish Security Analysis Logs' \ No newline at end of file + displayName: 'Publish Security Analysis Logs' diff --git a/eng/common/pipelines/templates/steps/sparse-checkout.yml b/eng/common/pipelines/templates/steps/sparse-checkout.yml index 24f4f547476e..9e3cc3164abf 100644 --- a/eng/common/pipelines/templates/steps/sparse-checkout.yml +++ b/eng/common/pipelines/templates/steps/sparse-checkout.yml @@ -30,7 +30,34 @@ steps: # 7.2 behavior for command argument passing. Newer behaviors will result # in errors from git.exe. $PSNativeCommandArgumentPassing = 'Legacy' - + + function Retry() + { + Run 3 @args + } + + function Run() + { + $retries, $command, $arguments = $args + if ($retries -isnot [int]) { + $command, $arguments = $args + $retries = 0 + } + Write-Host "==>" $command $arguments + $attempt = 0 + $sleep = 5 + + while ($true) { + $attempt++ + & $command $arguments + if (!$LASTEXITCODE) { return } + if ($attempt -gt $retries) { exit $LASTEXITCODE } + Write-Warning "Attempt $attempt failed: $_. Trying again in $sleep seconds..." + Start-Sleep -Seconds $sleep + $sleep *= 2 + } + } + function SparseCheckout([Array]$paths, [Hashtable]$repository) { $dir = $repository.WorkingDirectory @@ -47,23 +74,18 @@ steps: Write-Host "Repository $($repository.Name) is being initialized." if ($repository.Commitish -match '^refs/pull/\d+/merge$') { - Write-Host "git clone --no-checkout --filter=tree:0 -c remote.origin.fetch='+$($repository.Commitish):refs/remotes/origin/$($repository.Commitish)' https://github.com/$($repository.Name) ." - git clone --no-checkout --filter=tree:0 -c remote.origin.fetch=''+$($repository.Commitish):refs/remotes/origin/$($repository.Commitish)'' https://github.com/$($repository.Name) . + Retry git clone --no-checkout --filter=tree:0 -c remote.origin.fetch=''+$($repository.Commitish):refs/remotes/origin/$($repository.Commitish)'' https://github.com/$($repository.Name) . } else { - Write-Host "git clone --no-checkout --filter=tree:0 https://github.com/$($repository.Name) ." - git clone --no-checkout --filter=tree:0 https://github.com/$($repository.Name) . + Retry git clone --no-checkout --filter=tree:0 https://github.com/$($repository.Name) . } # Turn off git GC for sparse checkout. Note: The devops checkout task does this by default - Write-Host "git config gc.auto 0" - git config gc.auto 0 + Run git config gc.auto 0 - Write-Host "git sparse-checkout init" - git sparse-checkout init + Run git sparse-checkout init # Set non-cone mode otherwise path filters will not work in git >= 2.37.0 # See https://github.blog/2022-06-27-highlights-from-git-2-37/#tidbits - Write-Host "git sparse-checkout set --no-cone '/*' '!/*/' '/eng'" git sparse-checkout set --no-cone '/*' '!/*/' '/eng' } @@ -82,10 +104,8 @@ steps: $commitish = $repository.Commitish -replace '^refs/heads/', '' # use -- to prevent git from interpreting the commitish as a path - Write-Host "git -c advice.detachedHead=false checkout $commitish --" - # This will use the default branch if repo.Commitish is empty - git -c advice.detachedHead=false checkout $commitish -- + Retry git -c advice.detachedHead=false checkout $commitish -- } else { Write-Host "Skipping checkout as repo has already been initialized" } diff --git a/eng/common/scripts/ChangeLog-Operations.ps1 b/eng/common/scripts/ChangeLog-Operations.ps1 index 7fc9d048ad51..589583eddee9 100644 --- a/eng/common/scripts/ChangeLog-Operations.ps1 +++ b/eng/common/scripts/ChangeLog-Operations.ps1 @@ -139,27 +139,23 @@ function Confirm-ChangeLogEntry { [String]$VersionString, [boolean]$ForRelease = $false, [Switch]$SantizeEntry, - [PSCustomObject]$ChangeLogStatus = $null + [PSCustomObject]$ChangeLogStatus = $null, + [boolean]$SuppressErrors = $false ) - $suppressErrors = $false if (!$ChangeLogStatus) { $ChangeLogStatus = [PSCustomObject]@{ IsValid = $false Message = "" } } - else { - # Do not stop the script on error when status object is passed as param - $suppressErrors = $true - } $changeLogEntries = Get-ChangeLogEntries -ChangeLogLocation $ChangeLogLocation $changeLogEntry = $changeLogEntries[$VersionString] if (!$changeLogEntry) { $ChangeLogStatus.Message = "ChangeLog[${ChangeLogLocation}] does not have an entry for version ${VersionString}." $ChangeLogStatus.IsValid = $false - if (!$suppressErrors) { + if (!$SuppressErrors) { LogError "$($ChangeLogStatus.Message)" } return $false @@ -179,7 +175,7 @@ function Confirm-ChangeLogEntry { if ([System.String]::IsNullOrEmpty($changeLogEntry.ReleaseStatus)) { $ChangeLogStatus.Message = "Entry does not have a release status. Please ensure the status is set to a date '($CHANGELOG_DATE_FORMAT)' or '$CHANGELOG_UNRELEASED_STATUS' if not yet released. See https://aka.ms/azsdk/guideline/changelogs for more info." $ChangeLogStatus.IsValid = $false - if (!$suppressErrors) { + if (!$SuppressErrors) { LogError "$($ChangeLogStatus.Message)" } return $false @@ -188,7 +184,7 @@ function Confirm-ChangeLogEntry { if ($ForRelease -eq $True) { LogDebug "Verifying as a release build because ForRelease parameter is set to true" - return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus + return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus -SuppressErrors $SuppressErrors } # If the release status is a valid date then verify like its about to be released @@ -196,7 +192,7 @@ function Confirm-ChangeLogEntry { if ($status -as [DateTime]) { LogDebug "Verifying as a release build because the changelog entry has a valid date." - return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus + return Confirm-ChangeLogForRelease -changeLogEntry $changeLogEntry -changeLogEntries $changeLogEntries -ChangeLogStatus $ChangeLogStatus -SuppressErrors $SuppressErrors } $ChangeLogStatus.Message = "ChangeLog[${ChangeLogLocation}] has an entry for version ${VersionString}." @@ -361,26 +357,24 @@ function Confirm-ChangeLogForRelease { $changeLogEntry, [Parameter(Mandatory = $true)] $changeLogEntries, - $ChangeLogStatus = $null + $ChangeLogStatus = $null, + $SuppressErrors = $false ) - $suppressErrors = $false if (!$ChangeLogStatus) { $ChangeLogStatus = [PSCustomObject]@{ IsValid = $false Message = "" } } - else { - $suppressErrors = $true - } + $entries = Sort-ChangeLogEntries -changeLogEntries $changeLogEntries $ChangeLogStatus.IsValid = $true if ($changeLogEntry.ReleaseStatus -eq $CHANGELOG_UNRELEASED_STATUS) { $ChangeLogStatus.Message = "Entry has no release date set. Please ensure to set a release date with format '$CHANGELOG_DATE_FORMAT'. See https://aka.ms/azsdk/guideline/changelogs for more info." $ChangeLogStatus.IsValid = $false - if (!$suppressErrors) { + if (!$SuppressErrors) { LogError "$($ChangeLogStatus.Message)" } } @@ -392,7 +386,7 @@ function Confirm-ChangeLogForRelease { { $ChangeLogStatus.Message = "Date must be in the format $($CHANGELOG_DATE_FORMAT). See https://aka.ms/azsdk/guideline/changelogs for more info." $ChangeLogStatus.IsValid = $false - if (!$suppressErrors) { + if (!$SuppressErrors) { LogError "$($ChangeLogStatus.Message)" } } @@ -401,7 +395,7 @@ function Confirm-ChangeLogForRelease { { $ChangeLogStatus.Message = "Invalid date [ $status ]. The date for the changelog being released must be the latest in the file." $ChangeLogStatus.IsValid = $false - if (!$suppressErrors) { + if (!$SuppressErrors) { LogError "$($ChangeLogStatus.Message)" } } @@ -409,7 +403,7 @@ function Confirm-ChangeLogForRelease { catch { $ChangeLogStatus.Message = "Invalid date [ $status ] passed as status for Version [$($changeLogEntry.ReleaseVersion)]. See https://aka.ms/azsdk/guideline/changelogs for more info." $ChangeLogStatus.IsValid = $false - if (!$suppressErrors) { + if (!$SuppressErrors) { LogError "$($ChangeLogStatus.Message)" } } @@ -418,7 +412,7 @@ function Confirm-ChangeLogForRelease { if ([System.String]::IsNullOrWhiteSpace($changeLogEntry.ReleaseContent)) { $ChangeLogStatus.Message = "Entry has no content. Please ensure to provide some content of what changed in this version. See https://aka.ms/azsdk/guideline/changelogs for more info." $ChangeLogStatus.IsValid = $false - if (!$suppressErrors) { + if (!$SuppressErrors) { LogError "$($ChangeLogStatus.Message)" } } @@ -441,14 +435,14 @@ function Confirm-ChangeLogForRelease { { $ChangeLogStatus.Message = "The changelog entry has the following sections with no content ($($emptySections -join ', ')). Please ensure to either remove the empty sections or add content to the section." $ChangeLogStatus.IsValid = $false - if (!$suppressErrors) { + if (!$SuppressErrors) { LogError "$($ChangeLogStatus.Message)" } } if (!$foundRecommendedSection) { $ChangeLogStatus.Message = "The changelog entry did not contain any of the recommended sections ($($RecommendedSectionHeaders -join ', ')), please add at least one. See https://aka.ms/azsdk/guideline/changelogs for more info." - if (!$suppressErrors) { + if (!$SuppressErrors) { LogError "$($ChangeLogStatus.Message)" } } diff --git a/eng/common/scripts/Create-APIReview.ps1 b/eng/common/scripts/Create-APIReview.ps1 index a3f22a2678de..c5c5e51f31b6 100644 --- a/eng/common/scripts/Create-APIReview.ps1 +++ b/eng/common/scripts/Create-APIReview.ps1 @@ -78,6 +78,7 @@ function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVer try { $Response = Invoke-WebRequest -Method 'POST' -Uri $uri -Body $multipartContent -Headers $headers + Write-Host "API review: $($Response.Content)" $StatusCode = $Response.StatusCode } catch @@ -114,6 +115,7 @@ function Upload-ReviewTokenFile($packageName, $apiLabel, $releaseStatus, $review try { $Response = Invoke-WebRequest -Method 'GET' -Uri $uri -Headers $headers + Write-Host "API review: $($Response.Content)" $StatusCode = $Response.StatusCode } catch diff --git a/eng/common/scripts/Detect-Api-Changes.ps1 b/eng/common/scripts/Detect-Api-Changes.ps1 index 572ef43e1cf5..522346502332 100644 --- a/eng/common/scripts/Detect-Api-Changes.ps1 +++ b/eng/common/scripts/Detect-Api-Changes.ps1 @@ -15,7 +15,8 @@ Param ( [string] $APIViewUri, [string] $RepoFullName = "", [string] $ArtifactName = "packages", - [string] $TargetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "refs/heads/") + [string] $TargetBranch = ("origin/${env:SYSTEM_PULLREQUEST_TARGETBRANCH}" -replace "refs/heads/"), + [string] $DevopsProject = "internal" ) . (Join-Path $PSScriptRoot common.ps1) @@ -37,6 +38,7 @@ function Submit-Request($filePath, $packageName) $query.Add('pullRequestNumber', $PullRequestNumber) $query.Add('packageName', $packageName) $query.Add('language', $LanguageShort) + $query.Add('project', $DevopsProject) $reviewFileFullName = Join-Path -Path $ArtifactPath $packageName $reviewFileName if (Test-Path $reviewFileFullName) { @@ -87,6 +89,7 @@ function Log-Input-Params() Write-Host "Language: $($Language)" Write-Host "Commit SHA: $($CommitSha)" Write-Host "Repo Name: $($RepoFullName)" + Write-Host "Project: $($DevopsProject)" } Log-Input-Params diff --git a/eng/common/scripts/Validate-Package.ps1 b/eng/common/scripts/Validate-Package.ps1 index b12007559a82..4b9b9d864abb 100644 --- a/eng/common/scripts/Validate-Package.ps1 +++ b/eng/common/scripts/Validate-Package.ps1 @@ -60,7 +60,7 @@ function ValidateChangeLog($changeLogPath, $versionString, $validationStatus) Write-Host "Path to change log: [$changeLogFullPath]" if (Test-Path $changeLogFullPath) { - Confirm-ChangeLogEntry -ChangeLogLocation $changeLogFullPath -VersionString $versionString -ForRelease $true -ChangeLogStatus $ChangeLogStatus + Confirm-ChangeLogEntry -ChangeLogLocation $changeLogFullPath -VersionString $versionString -ForRelease $true -ChangeLogStatus $ChangeLogStatus -SuppressErrors $true $validationStatus.Status = if ($ChangeLogStatus.IsValid) { "Success" } else { "Failed" } $validationStatus.Message = $ChangeLogStatus.Message } diff --git a/eng/common/testproxy/target_version.txt b/eng/common/testproxy/target_version.txt index 34e1ab134d42..1979eff49e7b 100644 --- a/eng/common/testproxy/target_version.txt +++ b/eng/common/testproxy/target_version.txt @@ -1 +1 @@ -1.0.0-dev.20240314.1 +1.0.0-dev.20240410.1 diff --git a/eng/pipelines/aggregate-reports.yml b/eng/pipelines/aggregate-reports.yml index 110de819f550..59f95cd7cb2d 100644 --- a/eng/pipelines/aggregate-reports.yml +++ b/eng/pipelines/aggregate-reports.yml @@ -28,7 +28,7 @@ stages: parameters: ScanPath: $(Build.SourcesDirectory)/sdk - - task: AzureFileCopy@4 + - task: AzureFileCopy@6 displayName: 'Upload Dependency Report' condition: and(succeededOrFailed(), eq(variables['System.TeamProject'], 'internal')) inputs: @@ -40,7 +40,7 @@ stages: blobPrefix: dependencies AdditionalArgumentsForBlobCopy: '--exclude-pattern=*data.js*' - - task: AzureFileCopy@4 + - task: AzureFileCopy@6 displayName: 'Upload Dependency Graph' condition: and(succeededOrFailed(), eq(variables['System.TeamProject'], 'internal')) inputs: diff --git a/eng/pipelines/templates/stages/1es-redirect.yml b/eng/pipelines/templates/stages/1es-redirect.yml index c9de0e55758c..a098db098edc 100644 --- a/eng/pipelines/templates/stages/1es-redirect.yml +++ b/eng/pipelines/templates/stages/1es-redirect.yml @@ -30,6 +30,10 @@ extends: ${{ else }}: template: v1/1ES.Unofficial.PipelineTemplate.yml@1ESPipelineTemplates parameters: + ${{ if eq(parameters.oneESTemplateTag, 'canary') }}: + # Enable 1es template team to verify validation has been run on canary + customBuildTags: + - 1ES.PT.Tag-refs/tags/canary settings: skipBuildTagsForGitHubPullRequests: true sdl: diff --git a/eng/pipelines/templates/stages/archetype-python-release.yml b/eng/pipelines/templates/stages/archetype-python-release.yml index 50bd2962ae32..9c9c679c3d9c 100644 --- a/eng/pipelines/templates/stages/archetype-python-release.yml +++ b/eng/pipelines/templates/stages/archetype-python-release.yml @@ -152,6 +152,15 @@ stages: echo "Uploaded sdist to devops feed" displayName: 'Publish package to feed: ${{parameters.DevFeedName}}' + - template: /eng/common/pipelines/templates/steps/create-apireview.yml + parameters: + ArtifactPath: $(Pipeline.Workspace)/${{parameters.ArtifactName}} + Artifacts: ${{parameters.Artifacts}} + ConfigFileDir: $(Pipeline.Workspace)/${{parameters.ArtifactName}}/PackageInfo + MarkPackageAsShipped: true + ArtifactName: ${{parameters.ArtifactName}} + PackageName: ${{artifact.name}} + - ${{if ne(artifact.skipPublishDocs, 'true')}}: - deployment: PublishGitHubIODocs displayName: Publish Docs to GitHubIO Blob Storage diff --git a/eng/tox/install_depend_packages.py b/eng/tox/install_depend_packages.py index 3f577e44a440..93e35c79f5dc 100644 --- a/eng/tox/install_depend_packages.py +++ b/eng/tox/install_depend_packages.py @@ -45,6 +45,7 @@ "six": "1.12.0", "cryptography": "3.3.2", "msal": "1.23.0", + "azure-storage-file-datalake": "12.2.0", } MAXIMUM_VERSION_GENERIC_OVERRIDES = {} diff --git a/scripts/auto_release/PythonSdkLiveTest.yml b/scripts/auto_release/PythonSdkLiveTest.yml index 8c58755f22fb..6cc03a450a9f 100644 --- a/scripts/auto_release/PythonSdkLiveTest.yml +++ b/scripts/auto_release/PythonSdkLiveTest.yml @@ -79,12 +79,8 @@ jobs: # import env variable export AZURE_TEST_RUN_LIVE=$(AZURE_TEST_RUN_LIVE) export TENANT_ID=$(ENV-TENANT-ID) - export CLIENT_ID=$(ENV-CLIENT-ID) - export CLIENT_SECRET=$(ENV-CLIENT-SECRET) export SUBSCRIPTION_ID=$(ENV-SUBSCRIPTION-ID) export AZURE_TENANT_ID=$(ENV-TENANT-ID) - export AZURE_CLIENT_ID=$(ENV-CLIENT-ID) - export AZURE_CLIENT_SECRET=$(ENV-CLIENT-SECRET) export AZURE_SUBSCRIPTION_ID=$(ENV-SUBSCRIPTION-ID) export ISSUE_LINK=$(ISSUE_LINK) export SCRIPT_PATH=$script_path diff --git a/scripts/auto_release/main.py b/scripts/auto_release/main.py index c68ad9a8ab15..558ba11db2a7 100644 --- a/scripts/auto_release/main.py +++ b/scripts/auto_release/main.py @@ -13,6 +13,7 @@ from github import Github from azure.storage.blob import BlobServiceClient, ContainerClient from datetime import datetime, timedelta +import importlib _LOG = logging.getLogger() @@ -98,22 +99,6 @@ def current_time_month() -> str: date = time.localtime(time.time()) return '{}-{:02d}'.format(date.tm_year, date.tm_mon) - -def set_test_env_var(): - setting_path = str(Path(os.getenv('SCRIPT_PATH')) / 'mgmt_settings_real_.py') - # edit mgmt_settings_real.py - with open(setting_path, 'r') as file_in: - list_in = file_in.readlines() - - for i in range(0, len(list_in)): - list_in[i] = list_in[i].replace('ENV_TENANT_ID', os.environ['TENANT_ID']) - list_in[i] = list_in[i].replace('ENV_CLIENT_ID', os.environ['CLIENT_ID']) - list_in[i] = list_in[i].replace('ENV_CLIENT_SECRET', os.environ['CLIENT_SECRET']) - list_in[i] = list_in[i].replace('ENV_SUBSCRIPTION_ID', os.environ['SUBSCRIPTION_ID']) - with open(str(Path('tools/azure-sdk-tools/devtools_testutils/mgmt_settings_real.py')), 'w') as file_out: - file_out.writelines(list_in) - - class CodegenTestPR: """ This class can generate SDK code, run live test and create RP @@ -131,6 +116,7 @@ def __init__(self): self.test_folder = os.getenv('TEST_FOLDER', '') self.package_name = '' # 'dns' of 'sdk/compute/azure-mgmt-dns' + self.whole_package_name = '' # 'azure-mgmt-dns' self.new_branch = '' self.sdk_folder = '' # 'compute' of 'sdk/compute/azure-mgmt-dns' self.autorest_result = '' @@ -183,16 +169,21 @@ def checkout_azure_default_branch(self): if self.spec_repo: os.chdir(Path(self.spec_repo)) self.checkout_branch("DEBUG_REST_BRANCH", "azure-rest-api-specs") + + @property + def from_swagger(self) -> bool: + return "readme.md" in self.spec_readme def generate_code(self): self.checkout_azure_default_branch() # prepare input data + file_name = "relatedReadmeMdFiles" if self.from_swagger else "relatedTypeSpecProjectFolder" input_data = { 'headSha': self.get_latest_commit_in_swagger_repo(), 'repoHttpsUrl': "https://github.com/Azure/azure-rest-api-specs", 'specFolder': self.spec_repo, - 'relatedReadmeMdFiles': [self.readme_local_folder()] + file_name: [self.readme_local_folder()], } log(str(input_data)) @@ -216,7 +207,8 @@ def generate_code(self): def get_package_name_with_autorest_result(self): generate_result = self.get_autorest_result() - self.package_name = generate_result["packages"][0]["packageName"].split('-', 2)[-1] + self.whole_package_name = generate_result["packages"][0]["packageName"] + self.package_name = self.whole_package_name.split('-', 2)[-1] def prepare_branch_with_readme(self): self.generate_code() @@ -229,7 +221,7 @@ def create_new_branch(self): print_check(f'git checkout -b {self.new_branch}') def check_sdk_readme(self): - sdk_readme = str(Path(f'sdk/{self.sdk_folder}/azure-mgmt-{self.package_name}/README.md')) + sdk_readme = str(Path(f'sdk/{self.sdk_folder}/{self.whole_package_name}/README.md')) def edit_sdk_readme(content: List[str]): for i in range(0, len(content)): @@ -249,20 +241,20 @@ def readme_python_md_path(self)-> Path: # Use the template to update readme and setup by packaging_tools @return_origin_path def check_file_with_packaging_tool(self): - python_md = self.readme_python_md_path + print_check(f"pip install {self.get_whl_package} --force-reinstall") + module = importlib.import_module(self.whole_package_name.replace("-", ".")) title = "" - if python_md.exists(): - with open(python_md, "r") as file_in: - md_content = file_in.readlines() - for line in md_content: - if "title:" in line: - title = line.replace("title:", "").strip(" \r\n") - break - else: - log(f"{python_md} does not exist") + for item in getattr(module, "__all__", []): + if item.endswith("Client"): + title = item + break + + if not title: + log(f"Can not find the title in {self.whole_package_name}") + os.chdir(Path(f'sdk/{self.sdk_folder}')) # add `title` and update `is_stable` in sdk_packaging.toml - toml = Path(f"azure-mgmt-{self.package_name}") / "sdk_packaging.toml" + toml = Path(self.whole_package_name) / "sdk_packaging.toml" stable_config = "is_stable = " + ("true" if self.tag_is_stable else "false") + "\n" if toml.exists(): def edit_toml(content: List[str]): @@ -282,7 +274,7 @@ def edit_toml(content: List[str]): else: log(f"{os.getcwd()}/{toml} does not exist") - print_check(f'python -m packaging_tools --build-conf azure-mgmt-{self.package_name}') + print_check(f'python -m packaging_tools --build-conf {self.whole_package_name}') log('packaging_tools --build-conf successfully ') def check_pprint_name(self): @@ -390,7 +382,7 @@ def check_changelog_file(self): self.edit_changelog() def check_dev_requirement(self): - file = Path(f'sdk/{self.sdk_folder}/azure-mgmt-{self.package_name}/dev_requirements.txt') + file = Path(f'sdk/{self.sdk_folder}/{self.whole_package_name}/dev_requirements.txt') content = [ "-e ../../../tools/azure-sdk-tools\n", "../../identity/azure-identity\n" @@ -407,22 +399,23 @@ def check_package_size(self): self.check_package_size_result.append(f'ERROR: Package size is over 2MBytes: {Path(package).name}!!!') def check_model_flatten(self): - last_version = self.get_last_release_version() - if last_version == "" or last_version.startswith("1.0.0b"): - with open(self.readme_md_path, 'r') as file_in: - readme_md_content = file_in.read() - - with open(self.readme_python_md_path, 'r') as file_in: - readme_python_md_content = file_in.read() - - if "flatten-models: false" not in readme_md_content and "flatten-models: false" not in readme_python_md_content and self.issue_link: - api = Github(self.bot_token).get_repo("Azure/sdk-release-request") - issue_number = int(self.issue_link.split('/')[-1]) - issue = api.get_issue(issue_number) - assignee = issue.assignee.login if issue.assignee else "" - message = "please set `flatten-models: false` in readme.md or readme.python.md" - issue.create_comment(f'@{assignee}, {message}') - raise Exception(message) + if self.from_swagger: + last_version = self.get_last_release_version() + if last_version == "" or last_version.startswith("1.0.0b"): + with open(self.readme_md_path, 'r') as file_in: + readme_md_content = file_in.read() + + with open(self.readme_python_md_path, 'r') as file_in: + readme_python_md_content = file_in.read() + + if "flatten-models: false" not in readme_md_content and "flatten-models: false" not in readme_python_md_content and self.issue_link: + api = Github(self.bot_token).get_repo("Azure/sdk-release-request") + issue_number = int(self.issue_link.split('/')[-1]) + issue = api.get_issue(issue_number) + assignee = issue.assignee.login if issue.assignee else "" + message = "please set `flatten-models: false` in readme.md or readme.python.md" + issue.create_comment(f'@{assignee}, {message}') + raise Exception(message) def check_file(self): self.check_file_with_packaging_tool() @@ -435,7 +428,7 @@ def check_file(self): self.check_model_flatten() def sdk_code_path(self) -> str: - return str(Path(f'sdk/{self.sdk_folder}/azure-mgmt-{self.package_name}')) + return str(Path(f'sdk/{self.sdk_folder}/{self.whole_package_name}')) @property def is_single_path(self) -> bool: @@ -451,7 +444,6 @@ def install_package_locally(self): def prepare_test_env(self): self.install_package_locally() - set_test_env_var() @staticmethod def is_live_test()-> bool: @@ -512,7 +504,7 @@ def create_pr_proc(self): pr_body = "" if not self.check_package_size_result else "{}\n".format("\n".join(self.check_package_size_result)) pr_body = pr_body + "{} \n{} \n{}".format(self.issue_link, self.test_result, self.pipeline_link) if not self.is_single_path: - pr_body += f'\nBuildTargetingString\n azure-mgmt-{self.package_name}\nSkip.CreateApiReview\ntrue' + pr_body += f'\nBuildTargetingString\n {self.whole_package_name}\nSkip.CreateApiReview\ntrue' res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body) # Add issue link on PR @@ -547,6 +539,10 @@ def get_private_package(self) -> List[str]: content = self.get_autorest_result() return content["packages"][0]["artifacts"] + @property + def get_whl_package(self) -> str: + return [package for package in self.get_private_package() if package.endswith('.whl')][0] + def upload_private_package_proc(self, container_name: str): container_client = ContainerClient.from_connection_string(conn_str=self.conn_str, container_name=container_name) private_package = self.get_private_package() diff --git a/scripts/auto_release/mgmt_settings_real_.py b/scripts/auto_release/mgmt_settings_real_.py deleted file mode 100644 index 020ec4d96587..000000000000 --- a/scripts/auto_release/mgmt_settings_real_.py +++ /dev/null @@ -1,72 +0,0 @@ -#------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for -# license information. -#-------------------------------------------------------------------------- - -from azure.common.credentials import ( - BasicTokenAuthentication, - UserPassCredentials, - ServicePrincipalCredentials, -) - -SUBSCRIPTION_ID = "ENV_SUBSCRIPTION_ID" -CLIENT_ID = 'ENV_CLIENT_ID' -CLIENT_SECRET = 'ENV_CLIENT_SECRET' - -# Keyvault tests -TENANT_ID = 'ENV_TENANT_ID' -# Cognitive Services tests -CS_SUBSCRIPTION_KEY = '0000000000000000000000000000' -# Event Grid key -EVENT_GRID_KEY = '0000000000000000000000000000' -# HDInsight tests -HDI_ADLS_ACCOUNT_NAME = 'fakehdiadlsaccount' -HDI_ADLS_CLIENT_ID = '00000000-0000-0000-0000-000000000000' - -# Ubuntu image -LINUX_OS_VHD = "https://mystorageaccount.blob.core.windows.net/inputtestdatadonotdelete/ubuntu.vhd" - -# Storage tests related -ACTIVE_DIRECTORY_APPLICATION_ID = '00000000-0000-0000-0000-00000000000' -ACTIVE_DIRECTORY_APPLICATION_SECRET = '000000000ft5g5g5g5g5g5g5g5000000?' -ACTIVE_DIRECTORY_TENANT_ID = '00000000-0000-0000-0000-000000000000' -IS_SERVER_SIDE_FILE_ENCRYPTION_ENABLED = True -ENABLE_LOGGING = True - -# Read for details of this file: -# https://github.com/Azure/azure-sdk-for-python/wiki/Contributing-to-the-tests - -def get_azure_core_credentials(**kwargs): - from azure.identity import ClientSecretCredential - return ClientSecretCredential( - client_id = 'ENV_CLIENT_ID', - client_secret = 'ENV_CLIENT_SECRET', - tenant_id = 'ENV_TENANT_ID' - ) - # # Needed to play recorded tests - # from azure.core.credentials import AccessToken - # class FakeCredential(object): - # def get_token(self, *scopes, **kwargs): - # return AccessToken('fake_token', 2527537086) - # return FakeCredential() - -def get_credentials(**kwargs): - # Put your credentials here in the "real" file - #return UserPassCredentials( - # 'user@myaddomain.onmicrosoft.com', - # 'Password' - #) - # note that UserCredential does not work any longer. Must use a ServicePrincipal. - # for deprecated APIs I believe will still work. - return ServicePrincipalCredentials( - client_id = 'ENV_CLIENT_ID', - secret = 'ENV_CLIENT_SECRET', - tenant = 'ENV_TENANT_ID' - ) - # Needed to play recorded tests - # return BasicTokenAuthentication( - # token = { - # 'access_token':'faked_token' - # } - # ) \ No newline at end of file diff --git a/scripts/release_helper/common.py b/scripts/release_helper/common.py index 51b6e3117003..cc5f584313a4 100644 --- a/scripts/release_helper/common.py +++ b/scripts/release_helper/common.py @@ -1,5 +1,6 @@ import os import re +import json import logging import time import urllib.parse @@ -11,7 +12,7 @@ from github.Repository import Repository from utils import IssuePackage, REQUEST_REPO, AUTO_ASSIGN_LABEL, AUTO_PARSE_LABEL, get_origin_link_and_tag,\ - MULTI_LINK_LABEL, INCONSISTENT_TAG + MULTI_LINK_LABEL, INCONSISTENT_TAG, TYPESPEC_LABEL _LOG = logging.getLogger(__name__) @@ -19,11 +20,11 @@ _LANGUAGE_OWNER = {'msyyc'} # 'github assignee': 'token' -_BOT_NAME = 'azure-sdk' _ASSIGNEE_TOKEN = os.getenv('AZURESDK_BOT_TOKEN') _SWAGGER_URL = 'https://github.com/Azure/azure-rest-api-specs/blob/main/specification' _SWAGGER_PULL = 'https://github.com/Azure/azure-rest-api-specs/pull' +_HINTS = ["FirstGA", "FirstBeta", "HoldOn", "OnTime", "ForCLI", TYPESPEC_LABEL] class IssueProcess: @@ -67,6 +68,17 @@ def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Rep self.is_open = True self.issue_title = issue_package.issue.title.split(": ", 1)[-1] self.spec_repo = Path(os.getenv('SPEC_REPO')) + self.typespec_json = Path(os.getenv('TYPESPEC_JSON')) + self.language_name = "common" + + @property + def for_typespec(self) -> bool: + with open(str(self.typespec_json), "r") as file: + data = json.load(file) + return self.package_name in data.get(self.language_name, []) + + def has_label(self, label: str) -> bool: + return label in self.issue_package.labels_name @property def created_date_format(self) -> str: @@ -199,8 +211,16 @@ def check_tag_consistency(self) -> None: f'it is still `{self.default_readme_tag}`, please modify the readme.md or your ' f'**Readme Tag** above ') + def get_package_name(self) -> None: + issue_body_list = self.get_issue_body() + for line in issue_body_list: + if line.strip('\r\n ').startswith('package-name:'): + self.package_name = line.split(':')[-1].strip('\r\n ') + break + def auto_parse(self) -> None: - if AUTO_PARSE_LABEL in self.issue_package.labels_name: + if self.has_label(AUTO_ASSIGN_LABEL): + self.get_package_name() return self.add_label(AUTO_PARSE_LABEL) @@ -221,8 +241,9 @@ def auto_parse(self) -> None: self.edit_issue_body() def add_label(self, label: str) -> None: - self.issue_package.issue.add_to_labels(label) - self.issue_package.labels_name.add(label) + if not self.has_label(label): + self.issue_package.issue.add_to_labels(label) + self.issue_package.labels_name.add(label) def update_assignee(self, assignee_to_del: str, assignee_to_add: str) -> None: if assignee_to_del: @@ -245,7 +266,7 @@ def auto_assign_policy(self) -> str: return assignees[random_idx] def auto_assign(self) -> None: - if AUTO_ASSIGN_LABEL in self.issue_package.labels_name: + if self.has_label(AUTO_PARSE_LABEL): self.update_issue_instance() return # assign averagely @@ -283,12 +304,12 @@ def new_comment_policy(self): self.bot_advice.append('new comment.') def multi_link_policy(self): - if MULTI_LINK_LABEL in self.issue_package.labels_name: + if self.has_label(MULTI_LINK_LABEL): self.bot_advice.append('multi readme link!') def inconsistent_tag_policy(self): - if INCONSISTENT_TAG in self.issue_package.labels_name: - self.bot_advice.append('Attention to inconsistent tag') + if self.has_label(INCONSISTENT_TAG): + self.bot_advice.append('Attention to inconsistent tag.') def remind_logic(self) -> bool: return abs(self.date_from_target) <= 2 @@ -298,14 +319,25 @@ def print_date_from_target_date(self) -> str: def date_remind_policy(self): if self.remind_logic(): - self.bot_advice.append('close to release date. ') + self.bot_advice.append('close to release date.') + + def hint_policy(self): + for item in _HINTS: + if self.has_label(item): + self.bot_advice.append(f"{item}.") + + def typespec_policy(self): + if self.for_typespec: + self.add_label(TYPESPEC_LABEL) def auto_bot_advice(self): self.new_issue_policy() + self.typespec_policy() self.new_comment_policy() self.multi_link_policy() self.date_remind_policy() self.inconsistent_tag_policy() + self.hint_policy() def get_target_date(self): body = self.get_issue_body() @@ -351,6 +383,10 @@ def __init__(self, issues_package: List[IssuePackage], language_owner: Set[str], for assignee in self.assignee_candidates: self.request_repo_dict[assignee] = Github(assignee_token).get_repo(REQUEST_REPO) + @staticmethod + def for_test(): + return bool(os.getenv("TEST_ISSUE_NUMBER")) + def log_error(self, message: str) -> None: _LOG.error(message) diff --git a/scripts/release_helper/go.py b/scripts/release_helper/go.py index 43f3ec2300db..3cc365e3578e 100644 --- a/scripts/release_helper/go.py +++ b/scripts/release_helper/go.py @@ -7,13 +7,16 @@ class IssueProcessGo(IssueProcess): - pass + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.language_name = 'go' class Go(Common): def __init__(self, issues, language_owner, sdk_assignees): super(Go, self).__init__(issues, language_owner, sdk_assignees) - self.file_out_name = 'release_go_status.md' + if not self.for_test(): + self.file_out_name = 'release_go_status.md' def go_process(issues: List[Any]) -> Go: diff --git a/scripts/release_helper/java.py b/scripts/release_helper/java.py index 8d17072ba553..9a630c7e8ff4 100644 --- a/scripts/release_helper/java.py +++ b/scripts/release_helper/java.py @@ -3,18 +3,21 @@ # assignee dict which will be assigned to handle issues _JAVA_OWNER = {'azure-sdk'} -_JS_ASSIGNEE = {'weidongxu-microsoft', 'haolingdong-msft', 'XiaofeiCao'} +_JAVA_ASSIGNEE = {'weidongxu-microsoft', 'haolingdong-msft', 'XiaofeiCao', 'v-hongli1'} class IssueProcessJava(IssueProcess): - pass + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.language_name = 'java' class Java(Common): def __init__(self, issues, language_owner, sdk_assignees): super(Java, self).__init__(issues, language_owner, sdk_assignees) - self.file_out_name = 'release_java_status.md' + if not self.for_test(): + self.file_out_name = 'release_java_status.md' def java_process(issues: List[Any]) -> Java: - return Java(issues, _JAVA_OWNER, _JS_ASSIGNEE) + return Java(issues, _JAVA_OWNER, _JAVA_ASSIGNEE) diff --git a/scripts/release_helper/js.py b/scripts/release_helper/js.py index b22faa761e4d..a73c94e950fe 100644 --- a/scripts/release_helper/js.py +++ b/scripts/release_helper/js.py @@ -8,6 +8,10 @@ class IssueProcessJs(IssueProcess): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.language_name = 'js' + def auto_assign_policy(self) -> str: weeks = datetime.datetime.now().isocalendar()[1] assignees = list(self.assignee_candidates) @@ -19,9 +23,9 @@ def auto_assign_policy(self) -> str: class Js(Common): def __init__(self, issues, language_owner, sdk_assignees): super(Js, self).__init__(issues, language_owner, sdk_assignees) - self.file_out_name = 'release_js_status.md' self.issue_process_function = IssueProcessJs - + if not self.for_test(): + self.file_out_name = 'release_js_status.md' def js_process(issues: List[Any]) -> Js: return Js(issues, _JS_OWNER, _JS_ASSIGNEE) diff --git a/scripts/release_helper/main.py b/scripts/release_helper/main.py index 9822535301c6..6b087f232202 100644 --- a/scripts/release_helper/main.py +++ b/scripts/release_helper/main.py @@ -39,7 +39,11 @@ def collect_open_issues() -> List[IssuePackage]: hub = Github(os.getenv('AZURESDK_BOT_TOKEN')) request_repo = hub.get_repo(REQUEST_REPO) mgmt_label = request_repo.get_label('ManagementPlane') - open_issues = request_repo.get_issues(state='open', labels=[mgmt_label]) + issue_number = os.getenv("TEST_ISSUE_NUMBER") + if issue_number: + open_issues = [request_repo.get_issue(int(issue_number))] + else: + open_issues = request_repo.get_issues(state='open', labels=[mgmt_label]) rest_repo = hub.get_repo(REST_REPO) issues = [IssuePackage(issue, rest_repo) for issue in open_issues] _LOG.info(f'collect {len(issues)} open issues') diff --git a/scripts/release_helper/python.py b/scripts/release_helper/python.py index 36cdb6c39016..1233e79582be 100644 --- a/scripts/release_helper/python.py +++ b/scripts/release_helper/python.py @@ -1,6 +1,7 @@ from datetime import datetime from collections import Counter import re +import yaml from typing import Any, List, Dict, Set from github.Repository import Repository @@ -19,7 +20,6 @@ _MultiAPI = 'MultiAPI' # record published issues _FILE_OUT = 'published_issues_python.csv' -_HINTS = ["FirstGA", "FirstBeta", "HoldOn", "OnTime", "ForCLI"] class IssueProcessPython(IssueProcess): @@ -27,10 +27,11 @@ class IssueProcessPython(IssueProcess): def __init__(self, issue_package: IssuePackage, request_repo_dict: Dict[str, Repository], assignee_candidates: Set[str], language_owner: Set[str]): IssueProcess.__init__(self, issue_package, request_repo_dict, assignee_candidates, language_owner) - self.output_folder = '' + self.output_folder = '' # network of sdk/network/azure-mgmt-XXX self.delay_time = self.get_delay_time() self.python_tag = '' self.rest_repo_hash = '' + self.language_name = 'python' def get_delay_time(self): q = [comment.updated_at @@ -46,7 +47,7 @@ def get_specefied_param(pattern: str, issue_body_list: List[str]) -> str: return "" def multi_api_policy(self) -> None: - if (_MultiAPI in self.issue_package.labels_name) and (_AUTO_ASK_FOR_CHECK not in self.issue_package.labels_name): + if self.has_label(_MultiAPI) and not self.has_label(_AUTO_ASK_FOR_CHECK): self.bot_advice.append(_MultiAPI) def get_edit_content(self) -> None: @@ -54,12 +55,12 @@ def get_edit_content(self) -> None: @property def is_multiapi(self): - return _MultiAPI in self.issue_package.labels_name + return self.has_label(_MultiAPI) @property def readme_comparison(self) -> bool: # to see whether need change readme - if _CONFIGURED in self.issue_package.labels_name: + if self.has_label(_CONFIGURED): return False if 'package-' not in self.target_readme_tag: return True @@ -71,15 +72,16 @@ def readme_comparison(self) -> bool: return whether_change_readme def auto_reply(self) -> None: - if (_AUTO_ASK_FOR_CHECK not in self.issue_package.labels_name) or (_CONFIGURED in self.issue_package.labels_name): + if not self.has_label(_AUTO_ASK_FOR_CHECK) or self.has_label(_CONFIGURED): issue_number = self.issue_package.issue.number if not self.readme_comparison: try: + spec_readme = self.readme_link + ('' if self.is_typespec_folder else '/readme.md') issue_link = self.issue_package.issue.html_url release_pipeline_url = get_python_release_pipeline(self.output_folder) res_run = run_pipeline(issue_link=issue_link, pipeline_url=release_pipeline_url, - spec_readme=self.readme_link + '/readme.md', + spec_readme=spec_readme, python_tag=self.python_tag, rest_repo_hash=self.rest_repo_hash, target_date=self.target_date, @@ -90,31 +92,24 @@ def auto_reply(self) -> None: self.log(f'{issue_number} run pipeline fail') except Exception as e: self.comment(f'hi @{self.assignee}, please check release-helper: `{e}`') - if _AUTO_ASK_FOR_CHECK not in self.issue_package.labels_name: - self.add_label(_AUTO_ASK_FOR_CHECK) + self.add_label(_AUTO_ASK_FOR_CHECK) else: self.log(f'issue {issue_number} need config readme') - if _CONFIGURED in self.issue_package.labels_name: + if self.has_label(_CONFIGURED): self.issue_package.issue.remove_from_labels(_CONFIGURED) def attention_policy(self): - if _BRANCH_ATTENTION in self.issue_package.labels_name: + if self.has_label(_BRANCH_ATTENTION): self.bot_advice.append('new version is 0.0.0, please check base branch!') - def hint_policy(self): - for item in _HINTS: - if item in self.issue_package.labels_name: - self.bot_advice.append(item) - def auto_bot_advice(self): super().auto_bot_advice() self.multi_api_policy() self.attention_policy() - self.hint_policy() def auto_close(self) -> None: - if AUTO_CLOSE_LABEL in self.issue_package.labels_name: + if self.has_label(AUTO_CLOSE_LABEL): return last_version, last_time = get_last_released_date(self.package_name) if last_version and last_time > self.created_time: @@ -126,28 +121,54 @@ def auto_close(self) -> None: self.log(f"{self.issue_package.issue.number} has been closed!") record_release(self.package_name, self.issue_package.issue, _FILE_OUT, last_version) + def package_name_output_folder_from_readme(self): + try: + contents = self.get_local_file_content('readme.python.md') + except Exception as e: # pylint: disable=too-broad-except + print(f"fail to read readme.python.md: {e}") + return + pattern_package = re.compile(r'package-name: [\w+-.]+') + pattern_output = re.compile(r'\$\(python-sdks-folder\)/(.*?)/azure-') + self.package_name = pattern_package.search(contents).group().split(':')[-1].strip() + self.output_folder = pattern_output.search(contents).group().split('/')[1] + if 'multi-api' in contents: + self.add_label(_MultiAPI) + + def package_name_output_folder_from_tspconfig(self): + try: + contents = self.get_local_file_content('tspconfig.yaml') + except Exception as e: # pylint: disable=too-broad-except + print(f"fail to read tspconfig.yaml: {e}") + return + yaml_contents = yaml.safe_load(contents) + # tspconfig.yaml example: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/contosowidgetmanager/Contoso.WidgetManager/tspconfig.yaml + self.output_folder = yaml_contents.get("parameters", {}).get("service-dir", {}).get("default", "").split('/')[-1] + emitters = yaml_contents.get("options", {}) + for emitter_name in emitters: + if "/typespec-python" in emitter_name: + self.package_name = emitters[emitter_name].get("package-dir", "") + break + + @property + def is_typespec_folder(self) -> bool: + return ".Management" in self.readme_link + def auto_parse(self): super().auto_parse() issue_body_list = self.get_issue_body() self.readme_link = issue_body_list[0].strip("\r\n ") - if not re.findall(".+/Azure/azure-rest-api-specs/.+/resource-manager", self.readme_link): - return + + if not self.package_name and self.is_typespec_folder: + self.package_name_output_folder_from_tspconfig() + if not self.package_name and re.findall(".+/Azure/azure-rest-api-specs/.+/resource-manager", self.readme_link): + self.package_name_output_folder_from_readme() + if not self.package_name: + raise Exception(f"package name not found in readme.python.md or tspconfig.yaml") # Get the specified tag and rest repo hash in issue body self.rest_repo_hash = self.get_specefied_param("->hash:", issue_body_list[:5]) self.python_tag = self.get_specefied_param("->Readme Tag:", issue_body_list[:5]) - try: - contents = self.get_local_file_content('readme.python.md') - except Exception as e: - raise Exception(f"fail to read readme.python.md: {e}") - pattern_package = re.compile(r'package-name: [\w+-.]+') - pattern_output = re.compile(r'\$\(python-sdks-folder\)/(.*?)/azure-') - self.package_name = pattern_package.search(contents).group().split(':')[-1].strip() - self.output_folder = pattern_output.search(contents).group().split('/')[1] - if ('multi-api' in contents) and (_MultiAPI not in self.issue_package.labels_name): - self.add_label(_MultiAPI) - def run(self) -> None: super().run() @@ -158,8 +179,9 @@ def run(self) -> None: class Python(Common): def __init__(self, issues, language_owner, sdk_assignees): super(Python, self).__init__(issues, language_owner, sdk_assignees) - self.file_out_name = 'release_python_status.md' self.issue_process_function = IssueProcessPython + if not self.for_test(): + self.file_out_name = 'release_python_status.md' def duplicated_policy(self): counter = Counter([item.package_name for item in self.result]) diff --git a/scripts/release_helper/release_helper.yml b/scripts/release_helper/release_helper.yml index 8eeb68e53f2d..89e3628067e0 100644 --- a/scripts/release_helper/release_helper.yml +++ b/scripts/release_helper/release_helper.yml @@ -53,14 +53,15 @@ jobs: git clone ${FILE_REPO:0:8}$(USR_NAME):$(Yuchao-GitToken)@${FILE_REPO:8} $(pwd)/file-storage mkdir azure-rest-api-specs - git clone https://github.com/Azure/azure-rest-api-specs.git $(pwd)/azure-rest-api-specs + git clone -b $(SPEC_BRANCH) https://github.com/Azure/azure-rest-api-specs.git $(pwd)/azure-rest-api-specs # import env variable export AZURESDK_BOT_TOKEN=$(azuresdk-github-pat) export PIPELINE_TOKEN=$(PIPELINE-TOKEN) export LANGUAGE=$(RUN_LANGUAGE) export SPEC_REPO=$(pwd)/azure-rest-api-specs/specification - + export TYPESPEC_JSON=$(pwd)/file-storage/data/typespec.json + export TEST_ISSUE_NUMBER=$(TEST_ISSUE_NUMBER) # create virtual env python -m venv venv-sdk diff --git a/scripts/release_helper/requirement.txt b/scripts/release_helper/requirement.txt index fbb1ddc9882f..e5f3216fb0ea 100644 --- a/scripts/release_helper/requirement.txt +++ b/scripts/release_helper/requirement.txt @@ -3,4 +3,5 @@ requests==2.28.0 azure-devops==6.0.0b4 msrest>=0.6.21 packaging==23.1 -urllib3==1.26.15 \ No newline at end of file +urllib3==1.26.15 +PyYAML \ No newline at end of file diff --git a/scripts/release_helper/utils.py b/scripts/release_helper/utils.py index 1b54b57cbedf..725ab677439e 100644 --- a/scripts/release_helper/utils.py +++ b/scripts/release_helper/utils.py @@ -21,6 +21,7 @@ AUTO_CLOSE_LABEL = 'auto-close' MULTI_LINK_LABEL = 'MultiLink' INCONSISTENT_TAG = 'Inconsistent tag' +TYPESPEC_LABEL = 'TypeSpec' _LOG = logging.getLogger(__name__) diff --git a/sdk/alertsmanagement/azure-mgmt-alertsmanagement/pyproject.toml b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/alertsmanagement/azure-mgmt-alertsmanagement/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_async_provider_refresh.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_async_provider_refresh.py index 8fa28c303afc..161d96457455 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_async_provider_refresh.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_async_provider_refresh.py @@ -25,6 +25,9 @@ class TestAppConfigurationProvider(AppConfigTestCase, unittest.TestCase): @pytest.mark.skipif(sys.version_info < (3, 8), reason="Python 3.7 does not support AsyncMock") @pytest.mark.asyncio async def test_refresh(self, appconfiguration_endpoint_string, appconfiguration_keyvault_secret_url): + pytest.skip( + "This test is failing in ci pipeline, fixing in https://github.com/Azure/azure-sdk-for-python/pull/35126" + ) mock_callback = AsyncMock() async with await self.create_aad_client( appconfiguration_endpoint_string, diff --git a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py index ab8c88f8951b..e122bf731171 100644 --- a/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py +++ b/sdk/appconfiguration/azure-appconfiguration-provider/tests/test_provider_refresh.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- import time import unittest +import pytest from unittest.mock import Mock from azure.appconfiguration.provider import WatchKey from devtools_testutils import recorded_by_proxy @@ -18,6 +19,9 @@ class TestAppConfigurationProvider(AppConfigTestCase, unittest.TestCase): @recorded_by_proxy @app_config_decorator_aad def test_refresh(self, appconfiguration_endpoint_string, appconfiguration_keyvault_secret_url): + pytest.skip( + "This test is failing in ci pipeline, fixing in https://github.com/Azure/azure-sdk-for-python/pull/35126" + ) mock_callback = Mock() client = self.create_aad_client( appconfiguration_endpoint_string, diff --git a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md index 3c5d0cebc498..79bd4dc0ffbd 100644 --- a/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md +++ b/sdk/appconfiguration/azure-appconfiguration/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.6.0b3 (Unreleased) +## 1.6.1 (Unreleased) ### Features Added @@ -10,6 +10,17 @@ ### Other Changes +## 1.6.0 (2024-04-09) + +### Features Added +- Exposed `send_request()` method in each client to send custom requests using the client's existing pipeline. +- Supported to get page ETag while iterating `list_configuration_setting()` result by page. + +### Bugs Fixed +- Fixed a bug in consuming "etag" value in sync operation `set_configuration_setting()`. +- Changed invalid default value `None` to `False` for property `enabled` in `FeatureFlagConfigurationSetting`. +- Fixed the issue that `description`, `display_name` and other customer fields are missing when de/serializing `FeatureFlagConfigurationSetting` objects. + ## 1.6.0b2 (2024-03-21) ### Bugs Fixed diff --git a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_version.py b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_version.py index 0467afe48b84..7be7a862d293 100644 --- a/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_version.py +++ b/sdk/appconfiguration/azure-appconfiguration/azure/appconfiguration/_version.py @@ -3,4 +3,4 @@ # Licensed under the MIT License. # ------------------------------------ -VERSION = "1.6.0b3" +VERSION = "1.6.1" diff --git a/sdk/appconfiguration/azure-appconfiguration/setup.py b/sdk/appconfiguration/azure-appconfiguration/setup.py index 5dc4cc38ea40..f4a0bfb6dde7 100644 --- a/sdk/appconfiguration/azure-appconfiguration/setup.py +++ b/sdk/appconfiguration/azure-appconfiguration/setup.py @@ -53,7 +53,7 @@ url="https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/appconfiguration/azure-appconfiguration", keywords="azure, azure sdk", classifiers=[ - "Development Status :: 4 - Beta", + "Development Status :: 5 - Production/Stable", "Programming Language :: Python", "Programming Language :: Python :: 3 :: Only", "Programming Language :: Python :: 3", diff --git a/sdk/astro/azure-mgmt-astro/pyproject.toml b/sdk/astro/azure-mgmt-astro/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/astro/azure-mgmt-astro/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/azurelargeinstance/azure-mgmt-azurelargeinstance/pyproject.toml b/sdk/azurelargeinstance/azure-mgmt-azurelargeinstance/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/azurelargeinstance/azure-mgmt-azurelargeinstance/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/pyproject.toml b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md b/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md index 8ae1a7b8b329..566059112168 100644 --- a/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md +++ b/sdk/cdn/azure-mgmt-cdn/CHANGELOG.md @@ -1,5 +1,12 @@ # Release History +## 13.1.0 (2024-04-15) + +### Features Added + + - Model Profile has a new parameter log_scrubbing + - Model ProfileUpdateParameters has a new parameter log_scrubbing + ## 13.0.0 (2023-10-23) ### Features Added diff --git a/sdk/cdn/azure-mgmt-cdn/README.md b/sdk/cdn/azure-mgmt-cdn/README.md index e1e640c5ab2f..6aa59315c876 100644 --- a/sdk/cdn/azure-mgmt-cdn/README.md +++ b/sdk/cdn/azure-mgmt-cdn/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure CDN Management Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package diff --git a/sdk/cdn/azure-mgmt-cdn/_meta.json b/sdk/cdn/azure-mgmt-cdn/_meta.json index 1b82bb935c9b..13d690b668ba 100644 --- a/sdk/cdn/azure-mgmt-cdn/_meta.json +++ b/sdk/cdn/azure-mgmt-cdn/_meta.json @@ -1,11 +1,11 @@ { - "commit": "c280892951a9e45c059132c05aace25a9c752d48", + "commit": "926540515b9d8059904f023d38c45dda8ba87c9f", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.7", "use": [ - "@autorest/python@6.7.1", - "@autorest/modelerfour@4.26.2" + "@autorest/python@6.13.7", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/cdn/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.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", + "autorest_command": "autorest specification/cdn/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.13.7 --use=@autorest/modelerfour@4.27.0 --version=3.9.7 --version-tolerant=False", "readme": "specification/cdn/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py index da38726eabce..99307737ccda 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_cdn_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import CdnManagementClientConfiguration @@ -98,7 +100,7 @@ class CdnManagementClient( :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 "2023-05-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 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -115,7 +117,25 @@ def __init__( self._config = CdnManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -151,7 +171,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -171,7 +191,7 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py index 72b1ae5992c6..42db4d3db8e6 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class CdnManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class CdnManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for CdnManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class CdnManagementClientConfiguration(Configuration): # pylint: disable=too-ma :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Azure Subscription ID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-05-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, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(CdnManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-05-01") + api_version: str = kwargs.pop("api_version", "2024-02-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-cdn/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py index 4bae2292227b..2f781d740827 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,7 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -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: @@ -295,7 +288,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[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__) @@ -340,7 +333,7 @@ def _create_xml_node(cls): 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: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +344,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +383,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +408,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +438,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -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 @@ -668,7 +661,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -710,7 +703,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -730,6 +723,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -744,7 +738,7 @@ def query(self, name, data, data_type, **kwargs): :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 + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -753,7 +747,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return 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) @@ -804,7 +798,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -824,7 +818,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -993,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) @@ -1170,10 +1164,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1209,7 +1203,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1230,7 +1223,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1371,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, @@ -1391,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 @@ -1444,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) @@ -1481,7 +1473,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1515,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 @@ -1578,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 @@ -1652,7 +1644,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1700,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: @@ -1757,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"]: @@ -1808,7 +1800,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1862,10 +1853,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1893,7 +1884,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1910,7 +1901,7 @@ def deserialize_date(attr): 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) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1945,7 +1936,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1982,7 +1973,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1998,9 +1989,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py index fa8e008c199f..e4382a083348 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "13.0.0" +VERSION = "13.1.0" diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py index 97f7f6a3456b..d0f896981425 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_cdn_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -98,7 +100,7 @@ class CdnManagementClient( :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 "2023-05-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 :keyword int polling_interval: Default waiting time between two polls for LRO operations if no @@ -115,7 +117,25 @@ def __init__( self._config = CdnManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -151,7 +171,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -171,7 +193,7 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_configuration.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_configuration.py index af108b166c25..7c40851bb371 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_configuration.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class CdnManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class CdnManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for CdnManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class CdnManagementClientConfiguration(Configuration): # pylint: disable=too-ma :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Azure Subscription ID. Required. :type subscription_id: str - :keyword api_version: Api Version. Default value is "2023-05-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, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(CdnManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-05-01") + api_version: str = kwargs.pop("api_version", "2024-02-01") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-cdn/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py index 292b9d83ff26..79a84a50a046 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_custom_domains_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -75,7 +75,6 @@ def list_by_profile( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AFDDomain or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -97,17 +96,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,13 +117,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("AFDDomainListResult", pipeline_response) @@ -135,11 +133,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,10 +150,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any @@ -171,7 +165,6 @@ async def get( :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. :type custom_domain_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AFDDomain or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.AFDDomain :raises ~azure.core.exceptions.HttpResponseError: @@ -190,22 +183,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -218,20 +210,16 @@ async def get( deserialized = self._deserialize("AFDDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain: Union[_models.AFDDomain, IO], + custom_domain: Union[_models.AFDDomain, IO[bytes]], **kwargs: Any ) -> _models.AFDDomain: error_map = { @@ -257,7 +245,7 @@ async def _create_initial( else: _json = self._serialize.body(custom_domain, "AFDDomain") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -266,16 +254,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -302,10 +289,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } - @overload async def begin_create( self, @@ -332,14 +315,6 @@ async def begin_create( :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 AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] @@ -352,7 +327,7 @@ async def begin_create( resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain: IO, + custom_domain: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -368,18 +343,10 @@ async def begin_create( Required. :type custom_domain_name: str :param custom_domain: Domain properties. Required. - :type custom_domain: IO + :type custom_domain: IO[bytes] :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 AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] @@ -392,7 +359,7 @@ async def begin_create( resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain: Union[_models.AFDDomain, IO], + custom_domain: Union[_models.AFDDomain, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AFDDomain]: """Creates a new domain within the specified profile. @@ -405,19 +372,9 @@ async def begin_create( :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. :type custom_domain_name: str - :param custom_domain: Domain properties. Is either a AFDDomain type or a IO type. Required. - :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain 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. + :param custom_domain: Domain properties. Is either a AFDDomain type or a IO[bytes] type. + Required. + :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain or IO[bytes] :return: An instance of AsyncLROPoller that returns either AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] @@ -450,7 +407,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -463,24 +420,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AFDDomain].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } + return AsyncLROPoller[_models.AFDDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO], + custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AFDDomain: error_map = { @@ -506,7 +461,7 @@ async def _update_initial( else: _json = self._serialize.body(custom_domain_update_properties, "AFDDomainUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -515,16 +470,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -548,10 +502,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } - @overload async def begin_update( self, @@ -578,14 +528,6 @@ async def begin_update( :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 AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] @@ -598,7 +540,7 @@ async def begin_update( resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain_update_properties: IO, + custom_domain_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -614,18 +556,10 @@ async def begin_update( Required. :type custom_domain_name: str :param custom_domain_update_properties: Domain properties. Required. - :type custom_domain_update_properties: IO + :type custom_domain_update_properties: IO[bytes] :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 AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] @@ -638,7 +572,7 @@ async def begin_update( resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO], + custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AFDDomain]: """Updates an existing domain within a profile. @@ -652,19 +586,9 @@ async def begin_update( Required. :type custom_domain_name: str :param custom_domain_update_properties: Domain properties. Is either a - AFDDomainUpdateParameters type or a IO type. Required. - :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters 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. + AFDDomainUpdateParameters type or a IO[bytes] type. Required. + :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDDomain] @@ -697,7 +621,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -710,17 +634,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AFDDomain].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.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } + return AsyncLROPoller[_models.AFDDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any @@ -739,22 +661,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -769,11 +690,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -790,14 +707,6 @@ async def begin_delete( :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. :type custom_domain_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: @@ -825,7 +734,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -837,17 +746,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any @@ -866,22 +771,21 @@ async def _refresh_validation_token_initial( # pylint: disable=inconsistent-ret api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_refresh_validation_token_request( + _request = build_refresh_validation_token_request( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._refresh_validation_token_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -896,11 +800,7 @@ async def _refresh_validation_token_initial( # pylint: disable=inconsistent-ret response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, None, response_headers) - - _refresh_validation_token_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}/refreshValidationToken" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_refresh_validation_token( @@ -916,14 +816,6 @@ async def begin_refresh_validation_token( :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. :type custom_domain_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: @@ -951,7 +843,7 @@ async def begin_refresh_validation_token( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -963,14 +855,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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_refresh_validation_token.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}/refreshValidationToken" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py index 9c31f34f1422..edd59aaea7d3 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -77,7 +77,6 @@ def list_by_profile( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AFDEndpoint or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDEndpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -99,17 +98,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,13 +119,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("AFDEndpointListResult", pipeline_response) @@ -137,11 +135,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,10 +152,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -173,7 +167,6 @@ async def get( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AFDEndpoint or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.AFDEndpoint :raises ~azure.core.exceptions.HttpResponseError: @@ -192,22 +185,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,20 +212,16 @@ async def get( deserialized = self._deserialize("AFDEndpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: Union[_models.AFDEndpoint, IO], + endpoint: Union[_models.AFDEndpoint, IO[bytes]], **kwargs: Any ) -> _models.AFDEndpoint: error_map = { @@ -259,7 +247,7 @@ async def _create_initial( else: _json = self._serialize.body(endpoint, "AFDEndpoint") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -268,16 +256,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -304,10 +291,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } - @overload async def begin_create( self, @@ -335,14 +318,6 @@ async def begin_create( :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 AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -355,7 +330,7 @@ async def begin_create( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: IO, + endpoint: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -372,18 +347,10 @@ async def begin_create( Required. :type endpoint_name: str :param endpoint: Endpoint properties. Required. - :type endpoint: IO + :type endpoint: IO[bytes] :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 AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -396,7 +363,7 @@ async def begin_create( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: Union[_models.AFDEndpoint, IO], + endpoint: Union[_models.AFDEndpoint, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AFDEndpoint]: """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified @@ -410,19 +377,9 @@ async def begin_create( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :param endpoint: Endpoint properties. Is either a AFDEndpoint type or a IO type. Required. - :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint 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. + :param endpoint: Endpoint properties. Is either a AFDEndpoint type or a IO[bytes] type. + Required. + :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint or IO[bytes] :return: An instance of AsyncLROPoller that returns either AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -455,7 +412,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDEndpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -468,24 +425,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AFDEndpoint].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } + return AsyncLROPoller[_models.AFDEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO], + endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AFDEndpoint: error_map = { @@ -511,7 +466,7 @@ async def _update_initial( else: _json = self._serialize.body(endpoint_update_properties, "AFDEndpointUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -520,16 +475,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -553,10 +507,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } - @overload async def begin_update( self, @@ -586,14 +536,6 @@ async def begin_update( :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 AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -606,7 +548,7 @@ async def begin_update( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: IO, + endpoint_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -625,18 +567,10 @@ async def begin_update( Required. :type endpoint_name: str :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: IO + :type endpoint_update_properties: IO[bytes] :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 AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -649,7 +583,7 @@ async def begin_update( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO], + endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AFDEndpoint]: """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the @@ -666,19 +600,9 @@ async def begin_update( Required. :type endpoint_name: str :param endpoint_update_properties: Endpoint update properties. Is either a - AFDEndpointUpdateParameters type or a IO type. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters 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. + AFDEndpointUpdateParameters type or a IO[bytes] type. Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -711,7 +635,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDEndpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -724,17 +648,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AFDEndpoint].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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } + return AsyncLROPoller[_models.AFDEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -753,22 +675,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -783,11 +704,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -804,14 +721,6 @@ async def begin_delete( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_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: @@ -839,7 +748,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -851,24 +760,20 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _purge_content_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, - contents: Union[_models.AfdPurgeParameters, IO], + contents: Union[_models.AfdPurgeParameters, IO[bytes]], **kwargs: Any ) -> None: error_map = { @@ -894,7 +799,7 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme else: _json = self._serialize.body(contents, "AfdPurgeParameters") - request = build_purge_content_request( + _request = build_purge_content_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -903,16 +808,15 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, content=_content, - template_url=self._purge_content_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -927,11 +831,7 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, None, response_headers) - - _purge_content_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/purge" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload async def begin_purge_content( @@ -962,14 +862,6 @@ async def begin_purge_content( :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -981,7 +873,7 @@ async def begin_purge_content( resource_group_name: str, profile_name: str, endpoint_name: str, - contents: IO, + contents: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1000,18 +892,10 @@ async def begin_purge_content( Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Required. - :type contents: IO + :type contents: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1023,7 +907,7 @@ async def begin_purge_content( resource_group_name: str, profile_name: str, endpoint_name: str, - contents: Union[_models.AfdPurgeParameters, IO], + contents: Union[_models.AfdPurgeParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Removes a content from AzureFrontDoor. @@ -1039,19 +923,8 @@ async def begin_purge_content( :param contents: The list of paths to the content and the list of linked domains to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Is - either a AfdPurgeParameters type or a IO type. Required. - :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters 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. + either a AfdPurgeParameters type or a IO[bytes] type. Required. + :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters or IO[bytes] :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: @@ -1082,7 +955,7 @@ async def begin_purge_content( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -1094,17 +967,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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_purge_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/purge" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_resource_usage( @@ -1120,7 +989,6 @@ def list_resource_usage( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -1142,18 +1010,17 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1165,13 +1032,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("UsagesListResult", pipeline_response) @@ -1181,11 +1048,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1198,10 +1065,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/usages" - } - @overload async def validate_custom_domain( self, @@ -1229,7 +1092,6 @@ async def validate_custom_domain( :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -1241,7 +1103,7 @@ async def validate_custom_domain( resource_group_name: str, profile_name: str, endpoint_name: str, - custom_domain_properties: IO, + custom_domain_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1258,11 +1120,10 @@ async def validate_custom_domain( Required. :type endpoint_name: str :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: IO + :type custom_domain_properties: IO[bytes] :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -1274,7 +1135,7 @@ async def validate_custom_domain( resource_group_name: str, profile_name: str, endpoint_name: str, - custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO], + custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO[bytes]], **kwargs: Any ) -> _models.ValidateCustomDomainOutput: """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint @@ -1289,12 +1150,8 @@ async def validate_custom_domain( Required. :type endpoint_name: str :param custom_domain_properties: Custom domain to be validated. Is either a - ValidateCustomDomainInput type or a IO type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput 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 + ValidateCustomDomainInput type or a IO[bytes] type. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or IO[bytes] :return: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -1322,7 +1179,7 @@ async def validate_custom_domain( else: _json = self._serialize.body(custom_domain_properties, "ValidateCustomDomainInput") - request = build_validate_custom_domain_request( + _request = build_validate_custom_domain_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1331,16 +1188,15 @@ async def validate_custom_domain( content_type=content_type, json=_json, content=_content, - template_url=self.validate_custom_domain.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1353,10 +1209,6 @@ async def validate_custom_domain( deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - validate_custom_domain.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/validateCustomDomain" - } + return deserialized # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py index 3da4f232ba85..4302b39a1663 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origin_groups_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -75,7 +75,6 @@ def list_by_profile( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDOriginGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -97,17 +96,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,13 +117,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("AFDOriginGroupListResult", pipeline_response) @@ -135,11 +133,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,10 +150,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any @@ -170,7 +164,6 @@ async def get( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AFDOriginGroup or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.AFDOriginGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -189,22 +182,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -217,20 +209,16 @@ async def get( deserialized = self._deserialize("AFDOriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group: Union[_models.AFDOriginGroup, IO], + origin_group: Union[_models.AFDOriginGroup, IO[bytes]], **kwargs: Any ) -> _models.AFDOriginGroup: error_map = { @@ -256,7 +244,7 @@ async def _create_initial( else: _json = self._serialize.body(origin_group, "AFDOriginGroup") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -265,16 +253,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -301,10 +288,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } - @overload async def begin_create( self, @@ -331,14 +314,6 @@ async def begin_create( :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 AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -351,7 +326,7 @@ async def begin_create( resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group: IO, + origin_group: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -367,18 +342,10 @@ async def begin_create( Required. :type origin_group_name: str :param origin_group: Origin group properties. Required. - :type origin_group: IO + :type origin_group: IO[bytes] :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 AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -391,7 +358,7 @@ async def begin_create( resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group: Union[_models.AFDOriginGroup, IO], + origin_group: Union[_models.AFDOriginGroup, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AFDOriginGroup]: """Creates a new origin group within the specified profile. @@ -404,20 +371,9 @@ async def begin_create( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_group_name: str - :param origin_group: Origin group properties. Is either a AFDOriginGroup type or a IO type. - Required. - :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup 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. + :param origin_group: Origin group properties. Is either a AFDOriginGroup type or a IO[bytes] + type. Required. + :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup or IO[bytes] :return: An instance of AsyncLROPoller that returns either AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -450,7 +406,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDOriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -463,24 +419,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AFDOriginGroup].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } + return AsyncLROPoller[_models.AFDOriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO], + origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AFDOriginGroup: error_map = { @@ -506,7 +460,7 @@ async def _update_initial( else: _json = self._serialize.body(origin_group_update_properties, "AFDOriginGroupUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -515,16 +469,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -548,10 +501,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } - @overload async def begin_update( self, @@ -578,14 +527,6 @@ async def begin_update( :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 AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -598,7 +539,7 @@ async def begin_update( resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group_update_properties: IO, + origin_group_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -614,18 +555,10 @@ async def begin_update( Required. :type origin_group_name: str :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: IO + :type origin_group_update_properties: IO[bytes] :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 AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -638,7 +571,7 @@ async def begin_update( resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO], + origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AFDOriginGroup]: """Updates an existing origin group within a profile. @@ -652,20 +585,9 @@ async def begin_update( Required. :type origin_group_name: str :param origin_group_update_properties: Origin group properties. Is either a - AFDOriginGroupUpdateParameters type or a IO type. Required. + AFDOriginGroupUpdateParameters type or a IO[bytes] type. Required. :type origin_group_update_properties: ~azure.mgmt.cdn.models.AFDOriginGroupUpdateParameters 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. + IO[bytes] :return: An instance of AsyncLROPoller that returns either AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -698,7 +620,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDOriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -711,17 +633,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AFDOriginGroup].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.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } + return AsyncLROPoller[_models.AFDOriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any @@ -740,22 +660,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -770,11 +689,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -790,14 +705,6 @@ async def begin_delete( :param origin_group_name: Name of the origin group which is unique within the profile. Required. :type origin_group_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: @@ -825,7 +732,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -837,17 +744,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_resource_usage( @@ -863,7 +766,6 @@ def list_resource_usage( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_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 Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -885,18 +787,17 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -908,13 +809,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("UsagesListResult", pipeline_response) @@ -924,11 +825,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -940,7 +841,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/usages" - } diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py index 2333477cb723..52b55b35afc6 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_origins_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -77,7 +77,6 @@ def list_by_origin_group( :param origin_group_name: Name of the origin group which is unique within the profile. Required. :type origin_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 AFDOrigin or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.AFDOrigin] :raises ~azure.core.exceptions.HttpResponseError: @@ -99,18 +98,17 @@ def list_by_origin_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_origin_group_request( + _request = build_list_by_origin_group_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_origin_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,13 +120,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("AFDOriginListResult", pipeline_response) @@ -138,11 +136,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_origin_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any @@ -175,7 +169,6 @@ async def get( :type origin_group_name: str :param origin_name: Name of the origin which is unique within the profile. Required. :type origin_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AFDOrigin or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.AFDOrigin :raises ~azure.core.exceptions.HttpResponseError: @@ -194,23 +187,22 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, origin_name=origin_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -223,13 +215,9 @@ async def get( deserialized = self._deserialize("AFDOrigin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } + return deserialized # type: ignore async def _create_initial( self, @@ -237,7 +225,7 @@ async def _create_initial( profile_name: str, origin_group_name: str, origin_name: str, - origin: Union[_models.AFDOrigin, IO], + origin: Union[_models.AFDOrigin, IO[bytes]], **kwargs: Any ) -> _models.AFDOrigin: error_map = { @@ -263,7 +251,7 @@ async def _create_initial( else: _json = self._serialize.body(origin, "AFDOrigin") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -273,16 +261,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -309,10 +296,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } - @overload async def begin_create( self, @@ -342,14 +325,6 @@ async def begin_create( :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 AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] @@ -363,7 +338,7 @@ async def begin_create( profile_name: str, origin_group_name: str, origin_name: str, - origin: IO, + origin: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -381,18 +356,10 @@ async def begin_create( :param origin_name: Name of the origin that is unique within the profile. Required. :type origin_name: str :param origin: Origin properties. Required. - :type origin: IO + :type origin: IO[bytes] :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 AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] @@ -406,7 +373,7 @@ async def begin_create( profile_name: str, origin_group_name: str, origin_name: str, - origin: Union[_models.AFDOrigin, IO], + origin: Union[_models.AFDOrigin, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AFDOrigin]: """Creates a new origin within the specified origin group. @@ -421,19 +388,8 @@ async def begin_create( :type origin_group_name: str :param origin_name: Name of the origin that is unique within the profile. Required. :type origin_name: str - :param origin: Origin properties. Is either a AFDOrigin type or a IO type. Required. - :type origin: ~azure.mgmt.cdn.models.AFDOrigin 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. + :param origin: Origin properties. Is either a AFDOrigin type or a IO[bytes] type. Required. + :type origin: ~azure.mgmt.cdn.models.AFDOrigin or IO[bytes] :return: An instance of AsyncLROPoller that returns either AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] @@ -467,7 +423,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDOrigin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -480,17 +436,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AFDOrigin].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } + return AsyncLROPoller[_models.AFDOrigin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -498,7 +452,7 @@ async def _update_initial( profile_name: str, origin_group_name: str, origin_name: str, - origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO], + origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AFDOrigin: error_map = { @@ -524,7 +478,7 @@ async def _update_initial( else: _json = self._serialize.body(origin_update_properties, "AFDOriginUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -534,16 +488,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -567,10 +520,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } - @overload async def begin_update( self, @@ -600,14 +549,6 @@ async def begin_update( :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 AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] @@ -621,7 +562,7 @@ async def begin_update( profile_name: str, origin_group_name: str, origin_name: str, - origin_update_properties: IO, + origin_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -639,18 +580,10 @@ async def begin_update( :param origin_name: Name of the origin which is unique within the profile. Required. :type origin_name: str :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: IO + :type origin_update_properties: IO[bytes] :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 AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] @@ -664,7 +597,7 @@ async def begin_update( profile_name: str, origin_group_name: str, origin_name: str, - origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO], + origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.AFDOrigin]: """Updates an existing origin within an origin group. @@ -680,19 +613,8 @@ async def begin_update( :param origin_name: Name of the origin which is unique within the profile. Required. :type origin_name: str :param origin_update_properties: Origin properties. Is either a AFDOriginUpdateParameters type - or a IO type. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters 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. + or a IO[bytes] type. Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.AFDOrigin] @@ -726,7 +648,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDOrigin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -739,17 +661,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.AFDOrigin].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.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } + return AsyncLROPoller[_models.AFDOrigin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any @@ -768,23 +688,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, origin_name=origin_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -799,11 +718,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -821,14 +736,6 @@ async def begin_delete( :type origin_group_name: str :param origin_name: Name of the origin which is unique within the profile. Required. :type origin_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: @@ -857,7 +764,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -869,14 +776,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py index d19dfedfdcd3..18673f28d08f 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_afd_profiles_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -87,7 +87,6 @@ async def check_endpoint_name_availability( :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: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -98,7 +97,7 @@ async def check_endpoint_name_availability( self, resource_group_name: str, profile_name: str, - check_endpoint_name_availability_input: IO, + check_endpoint_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -112,11 +111,10 @@ async def check_endpoint_name_availability( unique within the resource group. Required. :type profile_name: str :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: IO + :type check_endpoint_name_availability_input: IO[bytes] :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: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -127,7 +125,7 @@ async def check_endpoint_name_availability( self, resource_group_name: str, profile_name: str, - check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO], + check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO[bytes]], **kwargs: Any ) -> _models.CheckEndpointNameAvailabilityOutput: """Check the availability of an afdx endpoint name, and return the globally unique endpoint host @@ -139,13 +137,9 @@ async def check_endpoint_name_availability( unique within the resource group. Required. :type profile_name: str :param check_endpoint_name_availability_input: Input to check. Is either a - CheckEndpointNameAvailabilityInput type or a IO type. Required. + CheckEndpointNameAvailabilityInput type or a IO[bytes] type. Required. :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput 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 + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or IO[bytes] :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -173,7 +167,7 @@ async def check_endpoint_name_availability( else: _json = self._serialize.body(check_endpoint_name_availability_input, "CheckEndpointNameAvailabilityInput") - request = build_check_endpoint_name_availability_request( + _request = build_check_endpoint_name_availability_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -181,16 +175,15 @@ async def check_endpoint_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_endpoint_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -203,13 +196,9 @@ async def check_endpoint_name_availability( deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_endpoint_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkEndpointNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list_resource_usage( @@ -222,7 +211,6 @@ def list_resource_usage( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -244,17 +232,16 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -266,13 +253,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("UsagesListResult", pipeline_response) @@ -282,11 +269,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -299,10 +286,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/usages" - } - @overload async def check_host_name_availability( self, @@ -326,7 +309,6 @@ async def check_host_name_availability( :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -337,7 +319,7 @@ async def check_host_name_availability( self, resource_group_name: str, profile_name: str, - check_host_name_availability_input: IO, + check_host_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -351,11 +333,10 @@ async def check_host_name_availability( which is unique within the resource group. Required. :type profile_name: str :param check_host_name_availability_input: Custom domain to be validated. Required. - :type check_host_name_availability_input: IO + :type check_host_name_availability_input: IO[bytes] :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -366,7 +347,7 @@ async def check_host_name_availability( self, resource_group_name: str, profile_name: str, - check_host_name_availability_input: Union[_models.CheckHostNameAvailabilityInput, IO], + check_host_name_availability_input: Union[_models.CheckHostNameAvailabilityInput, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint @@ -378,13 +359,9 @@ async def check_host_name_availability( which is unique within the resource group. Required. :type profile_name: str :param check_host_name_availability_input: Custom domain to be validated. Is either a - CheckHostNameAvailabilityInput type or a IO type. Required. + CheckHostNameAvailabilityInput type or a IO[bytes] type. Required. :type check_host_name_availability_input: ~azure.mgmt.cdn.models.CheckHostNameAvailabilityInput - 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 + or IO[bytes] :return: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -412,7 +389,7 @@ async def check_host_name_availability( else: _json = self._serialize.body(check_host_name_availability_input, "CheckHostNameAvailabilityInput") - request = build_check_host_name_availability_request( + _request = build_check_host_name_availability_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -420,16 +397,15 @@ async def check_host_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_host_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -442,13 +418,9 @@ async def check_host_name_availability( deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_host_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkHostNameAvailability" - } + return deserialized # type: ignore @overload async def validate_secret( @@ -472,7 +444,6 @@ async def validate_secret( :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: ValidateSecretOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -483,7 +454,7 @@ async def validate_secret( self, resource_group_name: str, profile_name: str, - validate_secret_input: IO, + validate_secret_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -496,11 +467,10 @@ async def validate_secret( unique within the resource group. Required. :type profile_name: str :param validate_secret_input: The Secret source. Required. - :type validate_secret_input: IO + :type validate_secret_input: IO[bytes] :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: ValidateSecretOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -511,7 +481,7 @@ async def validate_secret( self, resource_group_name: str, profile_name: str, - validate_secret_input: Union[_models.ValidateSecretInput, IO], + validate_secret_input: Union[_models.ValidateSecretInput, IO[bytes]], **kwargs: Any ) -> _models.ValidateSecretOutput: """Validate a Secret in the profile. @@ -521,13 +491,9 @@ async def validate_secret( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is unique within the resource group. Required. :type profile_name: str - :param validate_secret_input: The Secret source. Is either a ValidateSecretInput type or a IO - type. Required. - :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput 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 + :param validate_secret_input: The Secret source. Is either a ValidateSecretInput type or a + IO[bytes] type. Required. + :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput or IO[bytes] :return: ValidateSecretOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -555,7 +521,7 @@ async def validate_secret( else: _json = self._serialize.body(validate_secret_input, "ValidateSecretInput") - request = build_validate_secret_request( + _request = build_validate_secret_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -563,16 +529,15 @@ async def validate_secret( content_type=content_type, json=_json, content=_content, - template_url=self.validate_secret.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -585,19 +550,15 @@ async def validate_secret( deserialized = self._deserialize("ValidateSecretOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate_secret.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/validateSecret" - } + return deserialized # type: ignore async def _upgrade_initial( self, resource_group_name: str, profile_name: str, - profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO], + profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], **kwargs: Any ) -> _models.Profile: error_map = { @@ -623,7 +584,7 @@ async def _upgrade_initial( else: _json = self._serialize.body(profile_upgrade_parameters, "ProfileUpgradeParameters") - request = build_upgrade_request( + _request = build_upgrade_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -631,16 +592,15 @@ async def _upgrade_initial( content_type=content_type, json=_json, content=_content, - template_url=self._upgrade_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -664,10 +624,6 @@ async def _upgrade_initial( return deserialized # type: ignore - _upgrade_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/upgrade" - } - @overload async def begin_upgrade( self, @@ -690,14 +646,6 @@ async def begin_upgrade( :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] @@ -709,7 +657,7 @@ async def begin_upgrade( self, resource_group_name: str, profile_name: str, - profile_upgrade_parameters: IO, + profile_upgrade_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -722,18 +670,10 @@ async def begin_upgrade( unique within the resource group. Required. :type profile_name: str :param profile_upgrade_parameters: Profile upgrade input parameter. Required. - :type profile_upgrade_parameters: IO + :type profile_upgrade_parameters: IO[bytes] :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] @@ -745,7 +685,7 @@ async def begin_upgrade( self, resource_group_name: str, profile_name: str, - profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO], + profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Profile]: """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. @@ -756,19 +696,8 @@ async def begin_upgrade( unique within the resource group. Required. :type profile_name: str :param profile_upgrade_parameters: Profile upgrade input parameter. Is either a - ProfileUpgradeParameters type or a IO type. Required. - :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters 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. + ProfileUpgradeParameters type or a IO[bytes] type. Required. + :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] @@ -800,7 +729,7 @@ async def begin_upgrade( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -812,14 +741,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Profile].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_upgrade.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/upgrade" - } + return AsyncLROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py index b0b12fa3ff65..0624038aeec3 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_cdn_management_client_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -59,7 +59,6 @@ async def check_endpoint_name_availability( :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: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -69,7 +68,7 @@ async def check_endpoint_name_availability( async def check_endpoint_name_availability( self, resource_group_name: str, - check_endpoint_name_availability_input: IO, + check_endpoint_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -80,11 +79,10 @@ async def check_endpoint_name_availability( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: IO + :type check_endpoint_name_availability_input: IO[bytes] :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: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -94,7 +92,7 @@ async def check_endpoint_name_availability( async def check_endpoint_name_availability( self, resource_group_name: str, - check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO], + check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO[bytes]], **kwargs: Any ) -> _models.CheckEndpointNameAvailabilityOutput: """Check the availability of a resource name. This is needed for resources where name is globally @@ -103,13 +101,9 @@ async def check_endpoint_name_availability( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param check_endpoint_name_availability_input: Input to check. Is either a - CheckEndpointNameAvailabilityInput type or a IO type. Required. + CheckEndpointNameAvailabilityInput type or a IO[bytes] type. Required. :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput 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 + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or IO[bytes] :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -137,23 +131,22 @@ async def check_endpoint_name_availability( else: _json = self._serialize.body(check_endpoint_name_availability_input, "CheckEndpointNameAvailabilityInput") - request = build_check_endpoint_name_availability_request( + _request = build_check_endpoint_name_availability_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_endpoint_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -166,13 +159,9 @@ async def check_endpoint_name_availability( deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_endpoint_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/checkEndpointNameAvailability" - } + return deserialized # type: ignore @overload async def check_name_availability( @@ -190,7 +179,6 @@ async def check_name_availability( :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -198,17 +186,16 @@ async def check_name_availability( @overload async def check_name_availability( - self, check_name_availability_input: IO, *, content_type: str = "application/json", **kwargs: Any + self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a resource name. This is needed for resources where name is globally unique, such as a CDN endpoint. :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: IO + :type check_name_availability_input: IO[bytes] :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -216,18 +203,15 @@ async def check_name_availability( @distributed_trace_async async def check_name_availability( - self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO], **kwargs: Any + self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a resource name. This is needed for resources where name is globally unique, such as a CDN endpoint. :param check_name_availability_input: Input to check. Is either a CheckNameAvailabilityInput - type or a IO type. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput 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 + type or a IO[bytes] type. Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or + IO[bytes] :return: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -255,21 +239,20 @@ async def check_name_availability( else: _json = self._serialize.body(check_name_availability_input, "CheckNameAvailabilityInput") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -282,14 +265,12 @@ async def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = {"url": "/providers/Microsoft.Cdn/checkNameAvailability"} + return deserialized # type: ignore @overload - async def check_name_availability_with_subscription( + async def check_name_availability_with_subscription( # pylint: disable=name-too-long self, check_name_availability_input: _models.CheckNameAvailabilityInput, *, @@ -304,44 +285,39 @@ async def check_name_availability_with_subscription( :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def check_name_availability_with_subscription( - self, check_name_availability_input: IO, *, content_type: str = "application/json", **kwargs: Any + async def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a resource name. This is needed for resources where name is globally unique, such as a CDN endpoint. :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: IO + :type check_name_availability_input: IO[bytes] :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def check_name_availability_with_subscription( - self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO], **kwargs: Any + async def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a resource name. This is needed for resources where name is globally unique, such as a CDN endpoint. :param check_name_availability_input: Input to check. Is either a CheckNameAvailabilityInput - type or a IO type. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput 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 + type or a IO[bytes] type. Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or + IO[bytes] :return: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -369,22 +345,21 @@ async def check_name_availability_with_subscription( else: _json = self._serialize.body(check_name_availability_input, "CheckNameAvailabilityInput") - request = build_check_name_availability_with_subscription_request( + _request = build_check_name_availability_with_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability_with_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -397,13 +372,9 @@ async def check_name_availability_with_subscription( deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability_with_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkNameAvailability" - } + return deserialized # type: ignore @overload async def validate_probe( @@ -418,7 +389,6 @@ async def validate_probe( :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: ValidateProbeOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -426,18 +396,17 @@ async def validate_probe( @overload async def validate_probe( - self, validate_probe_input: IO, *, content_type: str = "application/json", **kwargs: Any + self, validate_probe_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidateProbeOutput: """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to a file hosted on the origin server to help accelerate the delivery of dynamic content via the CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. :param validate_probe_input: Input to check. Required. - :type validate_probe_input: IO + :type validate_probe_input: IO[bytes] :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: ValidateProbeOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -445,19 +414,15 @@ async def validate_probe( @distributed_trace_async async def validate_probe( - self, validate_probe_input: Union[_models.ValidateProbeInput, IO], **kwargs: Any + self, validate_probe_input: Union[_models.ValidateProbeInput, IO[bytes]], **kwargs: Any ) -> _models.ValidateProbeOutput: """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to a file hosted on the origin server to help accelerate the delivery of dynamic content via the CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. - :param validate_probe_input: Input to check. Is either a ValidateProbeInput type or a IO type. - Required. - :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput 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 + :param validate_probe_input: Input to check. Is either a ValidateProbeInput type or a IO[bytes] + type. Required. + :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput or IO[bytes] :return: ValidateProbeOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -485,22 +450,21 @@ async def validate_probe( else: _json = self._serialize.body(validate_probe_input, "ValidateProbeInput") - request = build_validate_probe_request( + _request = build_validate_probe_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.validate_probe.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -513,8 +477,6 @@ async def validate_probe( deserialized = self._deserialize("ValidateProbeOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate_probe.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/validateProbe"} + return deserialized # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py index 03f367f3da8d..a33afbd61b1b 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_custom_domains_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -78,7 +78,6 @@ def list_by_endpoint( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CustomDomain or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.CustomDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -100,18 +99,17 @@ def list_by_endpoint( def prepare_request(next_link=None): if not next_link: - request = build_list_by_endpoint_request( + _request = build_list_by_endpoint_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_endpoint.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -123,13 +121,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("CustomDomainListResult", pipeline_response) @@ -139,11 +137,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -156,10 +154,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any @@ -176,7 +170,6 @@ async def get( :type endpoint_name: str :param custom_domain_name: Name of the custom domain within an endpoint. Required. :type custom_domain_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomDomain or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CustomDomain :raises ~azure.core.exceptions.HttpResponseError: @@ -195,23 +188,22 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, custom_domain_name=custom_domain_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -224,13 +216,9 @@ async def get( deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" - } + return deserialized # type: ignore async def _create_initial( self, @@ -238,7 +226,7 @@ async def _create_initial( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_properties: Union[_models.CustomDomainParameters, IO], + custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], **kwargs: Any ) -> _models.CustomDomain: error_map = { @@ -264,7 +252,7 @@ async def _create_initial( else: _json = self._serialize.body(custom_domain_properties, "CustomDomainParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -274,16 +262,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -310,10 +297,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" - } - @overload async def begin_create( self, @@ -343,14 +326,6 @@ async def begin_create( :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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -364,7 +339,7 @@ async def begin_create( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_properties: IO, + custom_domain_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -382,18 +357,10 @@ async def begin_create( :param custom_domain_name: Name of the custom domain within an endpoint. Required. :type custom_domain_name: str :param custom_domain_properties: Properties required to create a new custom domain. Required. - :type custom_domain_properties: IO + :type custom_domain_properties: IO[bytes] :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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -407,7 +374,7 @@ async def begin_create( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_properties: Union[_models.CustomDomainParameters, IO], + custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.CustomDomain]: """Creates a new custom domain within an endpoint. @@ -423,19 +390,8 @@ async def begin_create( :param custom_domain_name: Name of the custom domain within an endpoint. Required. :type custom_domain_name: str :param custom_domain_properties: Properties required to create a new custom domain. Is either a - CustomDomainParameters type or a IO type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters 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. + CustomDomainParameters type or a IO[bytes] type. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -469,7 +425,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -479,17 +435,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CustomDomain].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" - } + return AsyncLROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any @@ -508,23 +462,22 @@ async def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.CustomDomain]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, custom_domain_name=custom_domain_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -542,13 +495,9 @@ async def _delete_initial( deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" - } + return deserialized # type: ignore @distributed_trace_async async def begin_delete( @@ -566,14 +515,6 @@ async def begin_delete( :type endpoint_name: str :param custom_domain_name: Name of the custom domain within an endpoint. Required. :type custom_domain_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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -608,7 +549,7 @@ def get_long_running_output(pipeline_response): deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -618,17 +559,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CustomDomain].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.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" - } + return AsyncLROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _disable_custom_https_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any @@ -647,23 +586,22 @@ async def _disable_custom_https_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) - request = build_disable_custom_https_request( + _request = build_disable_custom_https_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, custom_domain_name=custom_domain_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._disable_custom_https_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -687,10 +625,6 @@ async def _disable_custom_https_initial( return deserialized # type: ignore - _disable_custom_https_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/disableCustomHttps" - } - @distributed_trace_async async def begin_disable_custom_https( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any @@ -707,14 +641,6 @@ async def begin_disable_custom_https( :type endpoint_name: str :param custom_domain_name: Name of the custom domain within an endpoint. Required. :type custom_domain_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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -745,7 +671,7 @@ async def begin_disable_custom_https( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -755,17 +681,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CustomDomain].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_disable_custom_https.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/disableCustomHttps" - } + return AsyncLROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _enable_custom_https_initial( self, @@ -773,7 +697,7 @@ async def _enable_custom_https_initial( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO]] = None, + custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO[bytes]]] = None, **kwargs: Any ) -> _models.CustomDomain: error_map = { @@ -802,7 +726,7 @@ async def _enable_custom_https_initial( else: _json = None - request = build_enable_custom_https_request( + _request = build_enable_custom_https_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -812,16 +736,15 @@ async def _enable_custom_https_initial( content_type=content_type, json=_json, content=_content, - template_url=self._enable_custom_https_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -845,10 +768,6 @@ async def _enable_custom_https_initial( return deserialized # type: ignore - _enable_custom_https_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/enableCustomHttps" - } - @overload async def begin_enable_custom_https( self, @@ -880,14 +799,6 @@ async def begin_enable_custom_https( :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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -901,7 +812,7 @@ async def begin_enable_custom_https( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_https_parameters: Optional[IO] = None, + custom_domain_https_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -921,18 +832,10 @@ async def begin_enable_custom_https( :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the custom domain - using CDN managed certificate or user's own certificate. If not specified, enabling ssl uses CDN managed certificate by default. Default value is None. - :type custom_domain_https_parameters: IO + :type custom_domain_https_parameters: IO[bytes] :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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -946,7 +849,7 @@ async def begin_enable_custom_https( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO]] = None, + custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[_models.CustomDomain]: """Enable https delivery of the custom domain. @@ -964,19 +867,9 @@ async def begin_enable_custom_https( :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the custom domain - using CDN managed certificate or user's own certificate. If not specified, enabling ssl uses CDN managed certificate by default. Is either a CustomDomainHttpsParameters - type or a IO type. Default value is None. - :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters 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. + type or a IO[bytes] type. Default value is None. + :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -1010,7 +903,7 @@ async def begin_enable_custom_https( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1020,14 +913,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CustomDomain].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_enable_custom_https.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/enableCustomHttps" - } + return AsyncLROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py index 3bc2247052c5..c51f639bcb35 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_edge_nodes_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -58,7 +58,6 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.EdgeNode"]: """Edgenodes are the global Point of Presence (POP) locations used to deliver CDN content to end users. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EdgeNode or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.EdgeNode] :raises ~azure.core.exceptions.HttpResponseError: @@ -80,14 +79,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.EdgeNode"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,13 +97,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("EdgenodeResult", pipeline_response) @@ -115,11 +113,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -131,5 +129,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Cdn/edgenodes"} diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py index 4415f4146918..305ee710a292 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -80,7 +80,6 @@ def list_by_profile( :param profile_name: Name of the CDN profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Endpoint or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Endpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -102,17 +101,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -124,13 +122,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("EndpointListResult", pipeline_response) @@ -140,11 +138,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -157,10 +155,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -176,7 +170,6 @@ async def get( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Endpoint or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Endpoint :raises ~azure.core.exceptions.HttpResponseError: @@ -195,22 +188,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -223,20 +215,16 @@ async def get( deserialized = self._deserialize("Endpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: Union[_models.Endpoint, IO], + endpoint: Union[_models.Endpoint, IO[bytes]], **kwargs: Any ) -> _models.Endpoint: error_map = { @@ -262,7 +250,7 @@ async def _create_initial( else: _json = self._serialize.body(endpoint, "Endpoint") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -271,16 +259,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,10 +294,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } - @overload async def begin_create( self, @@ -338,14 +321,6 @@ async def begin_create( :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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] @@ -358,7 +333,7 @@ async def begin_create( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: IO, + endpoint: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -375,18 +350,10 @@ async def begin_create( Required. :type endpoint_name: str :param endpoint: Endpoint properties. Required. - :type endpoint: IO + :type endpoint: IO[bytes] :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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] @@ -399,7 +366,7 @@ async def begin_create( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: Union[_models.Endpoint, IO], + endpoint: Union[_models.Endpoint, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Endpoint]: """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, @@ -413,19 +380,8 @@ async def begin_create( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :param endpoint: Endpoint properties. Is either a Endpoint type or a IO type. Required. - :type endpoint: ~azure.mgmt.cdn.models.Endpoint 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. + :param endpoint: Endpoint properties. Is either a Endpoint type or a IO[bytes] type. Required. + :type endpoint: ~azure.mgmt.cdn.models.Endpoint or IO[bytes] :return: An instance of AsyncLROPoller that returns either Endpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] @@ -458,7 +414,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Endpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -468,24 +424,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Endpoint].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } + return AsyncLROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO], + endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Endpoint: error_map = { @@ -511,7 +465,7 @@ async def _update_initial( else: _json = self._serialize.body(endpoint_update_properties, "EndpointUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -520,16 +474,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -553,10 +506,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } - @overload async def begin_update( self, @@ -586,14 +535,6 @@ async def begin_update( :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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] @@ -606,7 +547,7 @@ async def begin_update( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: IO, + endpoint_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -625,18 +566,10 @@ async def begin_update( Required. :type endpoint_name: str :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: IO + :type endpoint_update_properties: IO[bytes] :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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] @@ -649,7 +582,7 @@ async def begin_update( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO], + endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Endpoint]: """Updates an existing CDN endpoint with the specified endpoint name under the specified @@ -666,19 +599,8 @@ async def begin_update( Required. :type endpoint_name: str :param endpoint_update_properties: Endpoint update properties. Is either a - EndpointUpdateParameters type or a IO type. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters 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. + EndpointUpdateParameters type or a IO[bytes] type. Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either Endpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] @@ -711,7 +633,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Endpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -721,17 +643,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Endpoint].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.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } + return AsyncLROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -750,22 +670,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -780,11 +699,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -801,14 +716,6 @@ async def begin_delete( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_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: @@ -836,7 +743,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -845,17 +752,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _start_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -874,22 +777,21 @@ async def _start_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -913,10 +815,6 @@ async def _start_initial( return deserialized # type: ignore - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/start" - } - @distributed_trace_async async def begin_start( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -931,14 +829,6 @@ async def begin_start( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] @@ -968,7 +858,7 @@ async def begin_start( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Endpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -978,17 +868,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Endpoint].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_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/start" - } + return AsyncLROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _stop_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -1007,22 +895,21 @@ async def _stop_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1046,10 +933,6 @@ async def _stop_initial( return deserialized # type: ignore - _stop_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/stop" - } - @distributed_trace_async async def begin_stop( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -1064,14 +947,6 @@ async def begin_stop( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Endpoint] @@ -1101,7 +976,7 @@ async def begin_stop( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Endpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1111,24 +986,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Endpoint].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_stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/stop" - } + return AsyncLROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _purge_content_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: Union[_models.PurgeParameters, IO], + content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any ) -> None: error_map = { @@ -1154,7 +1027,7 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme else: _json = self._serialize.body(content_file_paths, "PurgeParameters") - request = build_purge_content_request( + _request = build_purge_content_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1163,16 +1036,15 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, content=_content, - template_url=self._purge_content_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1187,11 +1059,7 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, None, response_headers) - - _purge_content_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/purge" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload async def begin_purge_content( @@ -1221,14 +1089,6 @@ async def begin_purge_content( :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1240,7 +1100,7 @@ async def begin_purge_content( resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: IO, + content_file_paths: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1258,18 +1118,10 @@ async def begin_purge_content( :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Required. - :type content_file_paths: IO + :type content_file_paths: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1281,7 +1133,7 @@ async def begin_purge_content( resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: Union[_models.PurgeParameters, IO], + content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Removes a content from CDN. @@ -1297,19 +1149,8 @@ async def begin_purge_content( :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Is either a PurgeParameters - type or a IO type. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters 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. + type or a IO[bytes] type. Required. + :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters or IO[bytes] :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: @@ -1340,7 +1181,7 @@ async def begin_purge_content( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1349,24 +1190,20 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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_purge_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/purge" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _load_content_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: Union[_models.LoadParameters, IO], + content_file_paths: Union[_models.LoadParameters, IO[bytes]], **kwargs: Any ) -> None: error_map = { @@ -1392,7 +1229,7 @@ async def _load_content_initial( # pylint: disable=inconsistent-return-statemen else: _json = self._serialize.body(content_file_paths, "LoadParameters") - request = build_load_content_request( + _request = build_load_content_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1401,16 +1238,15 @@ async def _load_content_initial( # pylint: disable=inconsistent-return-statemen content_type=content_type, json=_json, content=_content, - template_url=self._load_content_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1425,11 +1261,7 @@ async def _load_content_initial( # pylint: disable=inconsistent-return-statemen response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, None, response_headers) - - _load_content_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/load" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload async def begin_load_content( @@ -1458,14 +1290,6 @@ async def begin_load_content( :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1477,7 +1301,7 @@ async def begin_load_content( resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: IO, + content_file_paths: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1494,18 +1318,10 @@ async def begin_load_content( :type endpoint_name: str :param content_file_paths: The path to the content to be loaded. Path should be a full URL, e.g. ‘/pictures/city.png' which loads a single file. Required. - :type content_file_paths: IO + :type content_file_paths: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1517,7 +1333,7 @@ async def begin_load_content( resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: Union[_models.LoadParameters, IO], + content_file_paths: Union[_models.LoadParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Pre-loads a content to CDN. Available for Verizon Profiles. @@ -1531,20 +1347,9 @@ async def begin_load_content( Required. :type endpoint_name: str :param content_file_paths: The path to the content to be loaded. Path should be a full URL, - e.g. ‘/pictures/city.png' which loads a single file. Is either a LoadParameters type or a IO - type. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters 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. + e.g. ‘/pictures/city.png' which loads a single file. Is either a LoadParameters type or a + IO[bytes] type. Required. + :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters or IO[bytes] :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: @@ -1575,7 +1380,7 @@ async def begin_load_content( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -1584,17 +1389,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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_load_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/load" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @overload async def validate_custom_domain( @@ -1622,7 +1423,6 @@ async def validate_custom_domain( :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -1634,7 +1434,7 @@ async def validate_custom_domain( resource_group_name: str, profile_name: str, endpoint_name: str, - custom_domain_properties: IO, + custom_domain_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1650,11 +1450,10 @@ async def validate_custom_domain( Required. :type endpoint_name: str :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: IO + :type custom_domain_properties: IO[bytes] :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -1666,7 +1465,7 @@ async def validate_custom_domain( resource_group_name: str, profile_name: str, endpoint_name: str, - custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO], + custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO[bytes]], **kwargs: Any ) -> _models.ValidateCustomDomainOutput: """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. @@ -1680,12 +1479,8 @@ async def validate_custom_domain( Required. :type endpoint_name: str :param custom_domain_properties: Custom domain to be validated. Is either a - ValidateCustomDomainInput type or a IO type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput 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 + ValidateCustomDomainInput type or a IO[bytes] type. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or IO[bytes] :return: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -1713,7 +1508,7 @@ async def validate_custom_domain( else: _json = self._serialize.body(custom_domain_properties, "ValidateCustomDomainInput") - request = build_validate_custom_domain_request( + _request = build_validate_custom_domain_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1722,16 +1517,15 @@ async def validate_custom_domain( content_type=content_type, json=_json, content=_content, - template_url=self.validate_custom_domain.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1744,13 +1538,9 @@ async def validate_custom_domain( deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - validate_custom_domain.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/validateCustomDomain" - } + return deserialized # type: ignore @distributed_trace def list_resource_usage( @@ -1766,7 +1556,6 @@ def list_resource_usage( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceUsage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.ResourceUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -1788,18 +1577,17 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1811,13 +1599,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ResourceUsageListResult", pipeline_response) @@ -1827,11 +1615,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1843,7 +1631,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/checkResourceUsage" - } diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py index 7eac211a140d..7068d42bf0f0 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_log_analytics_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -100,7 +100,6 @@ async def get_log_analytics_metrics( :type continents: list[str] :param country_or_regions: Default value is None. :type country_or_regions: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response :return: MetricsResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.MetricsResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -119,7 +118,7 @@ async def get_log_analytics_metrics( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MetricsResponse] = kwargs.pop("cls", None) - request = build_get_log_analytics_metrics_request( + _request = build_get_log_analytics_metrics_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -133,16 +132,15 @@ async def get_log_analytics_metrics( continents=continents, country_or_regions=country_or_regions, api_version=api_version, - template_url=self.get_log_analytics_metrics.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,13 +153,9 @@ async def get_log_analytics_metrics( deserialized = self._deserialize("MetricsResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_log_analytics_metrics.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsMetrics" - } + return deserialized # type: ignore @distributed_trace_async async def get_log_analytics_rankings( @@ -195,7 +189,6 @@ async def get_log_analytics_rankings( :type date_time_end: ~datetime.datetime :param custom_domains: Default value is None. :type custom_domains: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response :return: RankingsResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.RankingsResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -214,7 +207,7 @@ async def get_log_analytics_rankings( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RankingsResponse] = kwargs.pop("cls", None) - request = build_get_log_analytics_rankings_request( + _request = build_get_log_analytics_rankings_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -225,16 +218,15 @@ async def get_log_analytics_rankings( date_time_end=date_time_end, custom_domains=custom_domains, api_version=api_version, - template_url=self.get_log_analytics_rankings.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -247,13 +239,9 @@ async def get_log_analytics_rankings( deserialized = self._deserialize("RankingsResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_log_analytics_rankings.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsRankings" - } + return deserialized # type: ignore @distributed_trace_async async def get_log_analytics_locations( @@ -266,7 +254,6 @@ async def get_log_analytics_locations( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContinentsResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ContinentsResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -285,21 +272,20 @@ async def get_log_analytics_locations( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContinentsResponse] = kwargs.pop("cls", None) - request = build_get_log_analytics_locations_request( + _request = build_get_log_analytics_locations_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_analytics_locations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -312,13 +298,9 @@ async def get_log_analytics_locations( deserialized = self._deserialize("ContinentsResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_log_analytics_locations.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsLocations" - } + return deserialized # type: ignore @distributed_trace_async async def get_log_analytics_resources( @@ -331,7 +313,6 @@ async def get_log_analytics_resources( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourcesResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ResourcesResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -350,21 +331,20 @@ async def get_log_analytics_resources( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourcesResponse] = kwargs.pop("cls", None) - request = build_get_log_analytics_resources_request( + _request = build_get_log_analytics_resources_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_analytics_resources.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -377,13 +357,9 @@ async def get_log_analytics_resources( deserialized = self._deserialize("ResourcesResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_log_analytics_resources.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsResources" - } + return deserialized # type: ignore @distributed_trace_async async def get_waf_log_analytics_metrics( @@ -420,7 +396,6 @@ async def get_waf_log_analytics_metrics( :type group_by: list[str or ~azure.mgmt.cdn.models.WafRankingGroupBy] :param rule_types: Default value is None. :type rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] - :keyword callable cls: A custom type or function that will be passed the direct response :return: WafMetricsResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.WafMetricsResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -439,7 +414,7 @@ async def get_waf_log_analytics_metrics( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WafMetricsResponse] = kwargs.pop("cls", None) - request = build_get_waf_log_analytics_metrics_request( + _request = build_get_waf_log_analytics_metrics_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -451,16 +426,15 @@ async def get_waf_log_analytics_metrics( group_by=group_by, rule_types=rule_types, api_version=api_version, - template_url=self.get_waf_log_analytics_metrics.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -473,13 +447,9 @@ async def get_waf_log_analytics_metrics( deserialized = self._deserialize("WafMetricsResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_waf_log_analytics_metrics.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsMetrics" - } + return deserialized # type: ignore @distributed_trace_async async def get_waf_log_analytics_rankings( @@ -516,7 +486,6 @@ async def get_waf_log_analytics_rankings( :type actions: list[str or ~azure.mgmt.cdn.models.WafAction] :param rule_types: Default value is None. :type rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] - :keyword callable cls: A custom type or function that will be passed the direct response :return: WafRankingsResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.WafRankingsResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -535,7 +504,7 @@ async def get_waf_log_analytics_rankings( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WafRankingsResponse] = kwargs.pop("cls", None) - request = build_get_waf_log_analytics_rankings_request( + _request = build_get_waf_log_analytics_rankings_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -547,16 +516,15 @@ async def get_waf_log_analytics_rankings( actions=actions, rule_types=rule_types, api_version=api_version, - template_url=self.get_waf_log_analytics_rankings.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -569,10 +537,6 @@ async def get_waf_log_analytics_rankings( deserialized = self._deserialize("WafRankingsResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_waf_log_analytics_rankings.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsRankings" - } + return deserialized # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py index c4bec21bda1f..ec3c43ee38a5 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_managed_rule_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -57,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.ManagedRuleSetDefinition"]: """Lists all available managed rule sets. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ManagedRuleSetDefinition or the result of cls(response) :rtype: @@ -81,15 +80,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ManagedRuleSetDefinition def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -101,13 +99,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ManagedRuleSetDefinitionList", pipeline_response) @@ -117,11 +115,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,7 +131,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/cdnWebApplicationFirewallManagedRuleSets" - } diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_operations.py index dc6fbad0f987..dc656030a271 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -57,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available CDN REST API 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) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -79,14 +78,13 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -98,13 +96,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("OperationsListResult", pipeline_response) @@ -114,11 +112,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -130,5 +128,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Cdn/operations"} diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py index 57a10046532f..f454839385e3 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origin_groups_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -77,7 +77,6 @@ def list_by_endpoint( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OriginGroup or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.OriginGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -99,18 +98,17 @@ def list_by_endpoint( def prepare_request(next_link=None): if not next_link: - request = build_list_by_endpoint_request( + _request = build_list_by_endpoint_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_endpoint.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,13 +120,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("OriginGroupListResult", pipeline_response) @@ -138,11 +136,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any @@ -176,7 +170,6 @@ async def get( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OriginGroup or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.OriginGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -195,23 +188,22 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, origin_group_name=origin_group_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -224,13 +216,9 @@ async def get( deserialized = self._deserialize("OriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } + return deserialized # type: ignore async def _create_initial( self, @@ -238,7 +226,7 @@ async def _create_initial( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group: Union[_models.OriginGroup, IO], + origin_group: Union[_models.OriginGroup, IO[bytes]], **kwargs: Any ) -> _models.OriginGroup: error_map = { @@ -264,7 +252,7 @@ async def _create_initial( else: _json = self._serialize.body(origin_group, "OriginGroup") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -274,16 +262,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -310,10 +297,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } - @overload async def begin_create( self, @@ -344,14 +327,6 @@ async def begin_create( :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 OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -365,7 +340,7 @@ async def begin_create( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group: IO, + origin_group: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -384,18 +359,10 @@ async def begin_create( Required. :type origin_group_name: str :param origin_group: Origin group properties. Required. - :type origin_group: IO + :type origin_group: IO[bytes] :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 OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -409,7 +376,7 @@ async def begin_create( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group: Union[_models.OriginGroup, IO], + origin_group: Union[_models.OriginGroup, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.OriginGroup]: """Creates a new origin group within the specified endpoint. @@ -425,20 +392,9 @@ async def begin_create( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_group_name: str - :param origin_group: Origin group properties. Is either a OriginGroup type or a IO type. + :param origin_group: Origin group properties. Is either a OriginGroup type or a IO[bytes] type. Required. - :type origin_group: ~azure.mgmt.cdn.models.OriginGroup 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. + :type origin_group: ~azure.mgmt.cdn.models.OriginGroup or IO[bytes] :return: An instance of AsyncLROPoller that returns either OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -472,7 +428,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("OriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -482,17 +438,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OriginGroup].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } + return AsyncLROPoller[_models.OriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -500,7 +454,7 @@ async def _update_initial( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO], + origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.OriginGroup: error_map = { @@ -526,7 +480,7 @@ async def _update_initial( else: _json = self._serialize.body(origin_group_update_properties, "OriginGroupUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -536,16 +490,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -569,10 +522,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } - @overload async def begin_update( self, @@ -603,14 +552,6 @@ async def begin_update( :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 OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -624,7 +565,7 @@ async def begin_update( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group_update_properties: IO, + origin_group_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -643,18 +584,10 @@ async def begin_update( Required. :type origin_group_name: str :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: IO + :type origin_group_update_properties: IO[bytes] :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 OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -668,7 +601,7 @@ async def begin_update( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO], + origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.OriginGroup]: """Updates an existing origin group within an endpoint. @@ -685,19 +618,9 @@ async def begin_update( Required. :type origin_group_name: str :param origin_group_update_properties: Origin group properties. Is either a - OriginGroupUpdateParameters type or a IO type. Required. - :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters 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. + OriginGroupUpdateParameters type or a IO[bytes] type. Required. + :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters or + IO[bytes] :return: An instance of AsyncLROPoller that returns either OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -731,7 +654,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("OriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -741,17 +664,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.OriginGroup].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.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } + return AsyncLROPoller[_models.OriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any @@ -770,23 +691,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, origin_group_name=origin_group_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -801,11 +721,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -824,14 +740,6 @@ async def begin_delete( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_group_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: @@ -860,7 +768,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -869,14 +777,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py index c8c744403f78..dd1c134303ea 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_origins_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -77,7 +77,6 @@ def list_by_endpoint( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Origin or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Origin] :raises ~azure.core.exceptions.HttpResponseError: @@ -99,18 +98,17 @@ def list_by_endpoint( def prepare_request(next_link=None): if not next_link: - request = build_list_by_endpoint_request( + _request = build_list_by_endpoint_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_endpoint.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,13 +120,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("OriginListResult", pipeline_response) @@ -138,11 +136,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any @@ -175,7 +169,6 @@ async def get( :type endpoint_name: str :param origin_name: Name of the origin which is unique within the endpoint. Required. :type origin_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Origin or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Origin :raises ~azure.core.exceptions.HttpResponseError: @@ -194,23 +187,22 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Origin] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, origin_name=origin_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -223,13 +215,9 @@ async def get( deserialized = self._deserialize("Origin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } + return deserialized # type: ignore async def _create_initial( self, @@ -237,7 +225,7 @@ async def _create_initial( profile_name: str, endpoint_name: str, origin_name: str, - origin: Union[_models.Origin, IO], + origin: Union[_models.Origin, IO[bytes]], **kwargs: Any ) -> _models.Origin: error_map = { @@ -263,7 +251,7 @@ async def _create_initial( else: _json = self._serialize.body(origin, "Origin") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -273,16 +261,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -309,10 +296,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } - @overload async def begin_create( self, @@ -342,14 +325,6 @@ async def begin_create( :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 Origin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] @@ -363,7 +338,7 @@ async def begin_create( profile_name: str, endpoint_name: str, origin_name: str, - origin: IO, + origin: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -381,18 +356,10 @@ async def begin_create( :param origin_name: Name of the origin that is unique within the endpoint. Required. :type origin_name: str :param origin: Origin properties. Required. - :type origin: IO + :type origin: IO[bytes] :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 Origin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] @@ -406,7 +373,7 @@ async def begin_create( profile_name: str, endpoint_name: str, origin_name: str, - origin: Union[_models.Origin, IO], + origin: Union[_models.Origin, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Origin]: """Creates a new origin within the specified endpoint. @@ -421,19 +388,8 @@ async def begin_create( :type endpoint_name: str :param origin_name: Name of the origin that is unique within the endpoint. Required. :type origin_name: str - :param origin: Origin properties. Is either a Origin type or a IO type. Required. - :type origin: ~azure.mgmt.cdn.models.Origin 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. + :param origin: Origin properties. Is either a Origin type or a IO[bytes] type. Required. + :type origin: ~azure.mgmt.cdn.models.Origin or IO[bytes] :return: An instance of AsyncLROPoller that returns either Origin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] @@ -467,7 +423,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Origin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -477,17 +433,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Origin].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } + return AsyncLROPoller[_models.Origin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -495,7 +449,7 @@ async def _update_initial( profile_name: str, endpoint_name: str, origin_name: str, - origin_update_properties: Union[_models.OriginUpdateParameters, IO], + origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Origin: error_map = { @@ -521,7 +475,7 @@ async def _update_initial( else: _json = self._serialize.body(origin_update_properties, "OriginUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -531,16 +485,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -564,10 +517,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } - @overload async def begin_update( self, @@ -597,14 +546,6 @@ async def begin_update( :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 Origin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] @@ -618,7 +559,7 @@ async def begin_update( profile_name: str, endpoint_name: str, origin_name: str, - origin_update_properties: IO, + origin_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -636,18 +577,10 @@ async def begin_update( :param origin_name: Name of the origin which is unique within the endpoint. Required. :type origin_name: str :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: IO + :type origin_update_properties: IO[bytes] :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 Origin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] @@ -661,7 +594,7 @@ async def begin_update( profile_name: str, endpoint_name: str, origin_name: str, - origin_update_properties: Union[_models.OriginUpdateParameters, IO], + origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Origin]: """Updates an existing origin within an endpoint. @@ -677,19 +610,8 @@ async def begin_update( :param origin_name: Name of the origin which is unique within the endpoint. Required. :type origin_name: str :param origin_update_properties: Origin properties. Is either a OriginUpdateParameters type or - a IO type. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters 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. + a IO[bytes] type. Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either Origin or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Origin] @@ -723,7 +645,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Origin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -733,17 +655,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Origin].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.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } + return AsyncLROPoller[_models.Origin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any @@ -762,23 +682,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, origin_name=origin_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -793,11 +712,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -815,14 +730,6 @@ async def begin_delete( :type endpoint_name: str :param origin_name: Name of the origin which is unique within the endpoint. Required. :type origin_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: @@ -851,7 +758,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -860,14 +767,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py index 4997f04c8729..883d963044df 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -69,7 +69,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model :param resource_group_name: Name of the Resource group within the Azure 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 CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -93,16 +92,15 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -114,13 +112,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("CdnWebApplicationFirewallPolicyList", pipeline_response) @@ -130,11 +128,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -147,10 +145,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, policy_name: str, **kwargs: Any @@ -161,7 +155,6 @@ async def get( :type resource_group_name: str :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. :type policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -180,21 +173,20 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, policy_name=policy_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -207,19 +199,15 @@ async def get( deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, policy_name: str, - cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO], + cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any ) -> _models.CdnWebApplicationFirewallPolicy: error_map = { @@ -245,7 +233,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(cdn_web_application_firewall_policy, "CdnWebApplicationFirewallPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, policy_name=policy_name, subscription_id=self._config.subscription_id, @@ -253,16 +241,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -289,10 +276,6 @@ async def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } - @overload async def begin_create_or_update( self, @@ -315,14 +298,6 @@ async def begin_create_or_update( :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 CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -335,7 +310,7 @@ async def begin_create_or_update( self, resource_group_name: str, policy_name: str, - cdn_web_application_firewall_policy: IO, + cdn_web_application_firewall_policy: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -347,18 +322,10 @@ async def begin_create_or_update( :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. :type policy_name: str :param cdn_web_application_firewall_policy: Policy to be created. Required. - :type cdn_web_application_firewall_policy: IO + :type cdn_web_application_firewall_policy: IO[bytes] :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 CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -371,7 +338,7 @@ async def begin_create_or_update( self, resource_group_name: str, policy_name: str, - cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO], + cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: """Create or update policy with specified rule set name within a resource group. @@ -381,20 +348,9 @@ async def begin_create_or_update( :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. :type policy_name: str :param cdn_web_application_firewall_policy: Policy to be created. Is either a - CdnWebApplicationFirewallPolicy type or a IO type. Required. + CdnWebApplicationFirewallPolicy type or a IO[bytes] type. Required. :type cdn_web_application_firewall_policy: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy 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. + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy or IO[bytes] :return: An instance of AsyncLROPoller that returns either CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -427,7 +383,7 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -437,24 +393,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy].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.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } + return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, policy_name: str, cdn_web_application_firewall_policy_patch_parameters: Union[ - _models.CdnWebApplicationFirewallPolicyPatchParameters, IO + _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] ], **kwargs: Any ) -> _models.CdnWebApplicationFirewallPolicy: @@ -483,7 +437,7 @@ async def _update_initial( cdn_web_application_firewall_policy_patch_parameters, "CdnWebApplicationFirewallPolicyPatchParameters" ) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, policy_name=policy_name, subscription_id=self._config.subscription_id, @@ -491,16 +445,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -524,10 +477,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } - @overload async def begin_update( self, @@ -552,14 +501,6 @@ async def begin_update( :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 CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -572,7 +513,7 @@ async def begin_update( self, resource_group_name: str, policy_name: str, - cdn_web_application_firewall_policy_patch_parameters: IO, + cdn_web_application_firewall_policy_patch_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -586,18 +527,10 @@ async def begin_update( :type policy_name: str :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy parameters to be patched. Required. - :type cdn_web_application_firewall_policy_patch_parameters: IO + :type cdn_web_application_firewall_policy_patch_parameters: IO[bytes] :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 CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -611,7 +544,7 @@ async def begin_update( resource_group_name: str, policy_name: str, cdn_web_application_firewall_policy_patch_parameters: Union[ - _models.CdnWebApplicationFirewallPolicyPatchParameters, IO + _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] ], **kwargs: Any ) -> AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]: @@ -624,20 +557,9 @@ async def begin_update( :type policy_name: str :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy parameters to be patched. Is either a CdnWebApplicationFirewallPolicyPatchParameters type or a - IO type. Required. + IO[bytes] type. Required. :type cdn_web_application_firewall_policy_patch_parameters: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters 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. + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -670,7 +592,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -680,17 +602,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy].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.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } + return AsyncLROPoller[_models.CdnWebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -702,7 +622,6 @@ async def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. :type policy_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: @@ -721,21 +640,20 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, policy_name=policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -746,8 +664,4 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py index 9a49825950e1..796e01903a2c 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_profiles_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -75,7 +75,6 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Profile"]: """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within an Azure subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Profile or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -97,15 +96,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Profile"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,13 +115,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ProfileListResult", pipeline_response) @@ -133,11 +131,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,8 +148,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/profiles"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Profile"]: """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within a @@ -159,7 +155,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy :param resource_group_name: Name of the Resource group within the Azure 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 Profile or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -181,16 +176,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -202,13 +196,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ProfileListResult", pipeline_response) @@ -218,11 +212,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -235,10 +229,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles" - } - @distributed_trace_async async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.Profile: """Gets an Azure Front Door Standard or Azure Front Door Premium or CDN profile with the specified @@ -249,7 +239,6 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Profile or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Profile :raises ~azure.core.exceptions.HttpResponseError: @@ -268,21 +257,20 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Profile] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -295,16 +283,12 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" - } + return deserialized # type: ignore async def _create_initial( - self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO], **kwargs: Any + self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO[bytes]], **kwargs: Any ) -> _models.Profile: error_map = { 401: ClientAuthenticationError, @@ -329,7 +313,7 @@ async def _create_initial( else: _json = self._serialize.body(profile, "Profile") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -337,16 +321,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -373,10 +356,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" - } - @overload async def begin_create( self, @@ -400,14 +379,6 @@ async def begin_create( :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] @@ -419,7 +390,7 @@ async def begin_create( self, resource_group_name: str, profile_name: str, - profile: IO, + profile: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -433,18 +404,10 @@ async def begin_create( profile which is unique within the resource group. Required. :type profile_name: str :param profile: Profile properties needed to create a new profile. Required. - :type profile: IO + :type profile: IO[bytes] :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] @@ -453,7 +416,7 @@ async def begin_create( @distributed_trace_async async def begin_create( - self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO], **kwargs: Any + self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Profile]: """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a profile name under the specified subscription and resource group. @@ -464,19 +427,8 @@ async def begin_create( profile which is unique within the resource group. Required. :type profile_name: str :param profile: Profile properties needed to create a new profile. Is either a Profile type or - a IO type. Required. - :type profile: ~azure.mgmt.cdn.models.Profile 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. + a IO[bytes] type. Required. + :type profile: ~azure.mgmt.cdn.models.Profile or IO[bytes] :return: An instance of AsyncLROPoller that returns either Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] @@ -508,7 +460,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -518,23 +470,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Profile].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" - } + return AsyncLROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, profile_name: str, - profile_update_parameters: Union[_models.ProfileUpdateParameters, IO], + profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Profile: error_map = { @@ -560,7 +510,7 @@ async def _update_initial( else: _json = self._serialize.body(profile_update_parameters, "ProfileUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -568,16 +518,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -601,10 +550,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" - } - @overload async def begin_update( self, @@ -629,14 +574,6 @@ async def begin_update( :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] @@ -648,7 +585,7 @@ async def begin_update( self, resource_group_name: str, profile_name: str, - profile_update_parameters: IO, + profile_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -663,18 +600,10 @@ async def begin_update( :type profile_name: str :param profile_update_parameters: Profile properties needed to update an existing profile. Required. - :type profile_update_parameters: IO + :type profile_update_parameters: IO[bytes] :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] @@ -686,7 +615,7 @@ async def begin_update( self, resource_group_name: str, profile_name: str, - profile_update_parameters: Union[_models.ProfileUpdateParameters, IO], + profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Profile]: """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with @@ -698,19 +627,8 @@ async def begin_update( profile which is unique within the resource group. Required. :type profile_name: str :param profile_update_parameters: Profile properties needed to update an existing profile. Is - either a ProfileUpdateParameters type or a IO type. Required. - :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters 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. + either a ProfileUpdateParameters type or a IO[bytes] type. Required. + :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Profile] @@ -742,7 +660,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -752,17 +670,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Profile].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.Cdn/profiles/{profileName}" - } + return AsyncLROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, **kwargs: Any @@ -781,21 +697,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -810,11 +725,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -827,14 +738,6 @@ async def begin_delete(self, resource_group_name: str, profile_name: str, **kwar :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile which is unique within the resource group. Required. :type profile_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: @@ -861,7 +764,7 @@ async def begin_delete(self, resource_group_name: str, profile_name: str, **kwar def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -870,20 +773,19 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _can_migrate_initial( - self, resource_group_name: str, can_migrate_parameters: Union[_models.CanMigrateParameters, IO], **kwargs: Any + self, + resource_group_name: str, + can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], + **kwargs: Any ) -> Optional[_models.CanMigrateResult]: error_map = { 401: ClientAuthenticationError, @@ -908,23 +810,22 @@ async def _can_migrate_initial( else: _json = self._serialize.body(can_migrate_parameters, "CanMigrateParameters") - request = build_can_migrate_request( + _request = build_can_migrate_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._can_migrate_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -943,13 +844,9 @@ async def _can_migrate_initial( response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _can_migrate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/canMigrate" - } + return deserialized # type: ignore @overload async def begin_can_migrate( @@ -970,14 +867,6 @@ async def begin_can_migrate( :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 CanMigrateResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] @@ -988,7 +877,7 @@ async def begin_can_migrate( async def begin_can_migrate( self, resource_group_name: str, - can_migrate_parameters: IO, + can_migrate_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -999,18 +888,10 @@ async def begin_can_migrate( :type resource_group_name: str :param can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor can be migrated. Required. - :type can_migrate_parameters: IO + :type can_migrate_parameters: IO[bytes] :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 CanMigrateResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] @@ -1019,26 +900,18 @@ async def begin_can_migrate( @distributed_trace_async async def begin_can_migrate( - self, resource_group_name: str, can_migrate_parameters: Union[_models.CanMigrateParameters, IO], **kwargs: Any + self, + resource_group_name: str, + can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.CanMigrateResult]: """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor - can be migrated. Is either a CanMigrateParameters type or a IO type. Required. - :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters 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. + can be migrated. Is either a CanMigrateParameters type or a IO[bytes] type. Required. + :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either CanMigrateResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.CanMigrateResult] @@ -1069,7 +942,7 @@ async def begin_can_migrate( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CanMigrateResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1081,20 +954,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.CanMigrateResult].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_can_migrate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/canMigrate" - } + return AsyncLROPoller[_models.CanMigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _migrate_initial( - self, resource_group_name: str, migration_parameters: Union[_models.MigrationParameters, IO], **kwargs: Any + self, + resource_group_name: str, + migration_parameters: Union[_models.MigrationParameters, IO[bytes]], + **kwargs: Any ) -> _models.MigrateResult: error_map = { 401: ClientAuthenticationError, @@ -1119,23 +993,22 @@ async def _migrate_initial( else: _json = self._serialize.body(migration_parameters, "MigrationParameters") - request = build_migrate_request( + _request = build_migrate_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._migrate_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1159,10 +1032,6 @@ async def _migrate_initial( return deserialized # type: ignore - _migrate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/migrate" - } - @overload async def begin_migrate( self, @@ -1182,14 +1051,6 @@ async def begin_migrate( :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 MigrateResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] @@ -1200,7 +1061,7 @@ async def begin_migrate( async def begin_migrate( self, resource_group_name: str, - migration_parameters: IO, + migration_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1211,18 +1072,10 @@ async def begin_migrate( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param migration_parameters: Properties needed to migrate the profile. Required. - :type migration_parameters: IO + :type migration_parameters: IO[bytes] :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 MigrateResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] @@ -1231,7 +1084,10 @@ async def begin_migrate( @distributed_trace_async async def begin_migrate( - self, resource_group_name: str, migration_parameters: Union[_models.MigrationParameters, IO], **kwargs: Any + self, + resource_group_name: str, + migration_parameters: Union[_models.MigrationParameters, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.MigrateResult]: """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be committed after this. @@ -1239,19 +1095,8 @@ async def begin_migrate( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param migration_parameters: Properties needed to migrate the profile. Is either a - MigrationParameters type or a IO type. Required. - :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters 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. + MigrationParameters type or a IO[bytes] type. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either MigrateResult or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.MigrateResult] @@ -1282,7 +1127,7 @@ async def begin_migrate( def get_long_running_output(pipeline_response): deserialized = self._deserialize("MigrateResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1294,17 +1139,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.MigrateResult].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_migrate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/migrate" - } + return AsyncLROPoller[_models.MigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _migration_commit_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, **kwargs: Any @@ -1323,21 +1166,20 @@ async def _migration_commit_initial( # pylint: disable=inconsistent-return-stat api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_migration_commit_request( + _request = build_migration_commit_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migration_commit_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1352,11 +1194,7 @@ async def _migration_commit_initial( # pylint: disable=inconsistent-return-stat response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, None, response_headers) - - _migration_commit_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/migrationCommit" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_migration_commit( @@ -1369,14 +1207,6 @@ async def begin_migration_commit( :param profile_name: Name of the CDN profile which is unique within the resource group. Required. :type profile_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: @@ -1403,7 +1233,7 @@ async def begin_migration_commit( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -1415,17 +1245,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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_migration_commit.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/migrationCommit" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.SsoUri: @@ -1440,7 +1266,6 @@ async def generate_sso_uri(self, resource_group_name: str, profile_name: str, ** :param profile_name: Name of the CDN profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SsoUri or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.SsoUri :raises ~azure.core.exceptions.HttpResponseError: @@ -1459,21 +1284,20 @@ async def generate_sso_uri(self, resource_group_name: str, profile_name: str, ** api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SsoUri] = kwargs.pop("cls", None) - request = build_generate_sso_uri_request( + _request = build_generate_sso_uri_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.generate_sso_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1486,13 +1310,9 @@ async def generate_sso_uri(self, resource_group_name: str, profile_name: str, ** deserialized = self._deserialize("SsoUri", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - generate_sso_uri.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/generateSsoUri" - } + return deserialized # type: ignore @distributed_trace_async async def list_supported_optimization_types( @@ -1506,7 +1326,6 @@ async def list_supported_optimization_types( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SupportedOptimizationTypesListResult or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.SupportedOptimizationTypesListResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1525,21 +1344,20 @@ async def list_supported_optimization_types( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SupportedOptimizationTypesListResult] = kwargs.pop("cls", None) - request = build_list_supported_optimization_types_request( + _request = build_list_supported_optimization_types_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_optimization_types.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1552,13 +1370,9 @@ async def list_supported_optimization_types( deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - list_supported_optimization_types.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getSupportedOptimizationTypes" - } + return deserialized # type: ignore @distributed_trace def list_resource_usage( @@ -1572,7 +1386,6 @@ def list_resource_usage( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceUsage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.ResourceUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -1594,17 +1407,16 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1616,13 +1428,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ResourceUsageListResult", pipeline_response) @@ -1632,11 +1444,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1648,7 +1460,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkResourceUsage" - } diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py index d6c74e3f581a..ed8847be9cbb 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_resource_usage_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -57,7 +57,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceUsage"]: """Check the quota and actual usage of the CDN profiles under the given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceUsage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.ResourceUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -79,15 +78,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ResourceUsage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -99,13 +97,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ResourceUsageListResult", pipeline_response) @@ -115,11 +113,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -131,5 +129,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkResourceUsage"} diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py index 37d29ba02847..59e6c34d3a4e 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_routes_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -77,7 +77,6 @@ def list_by_endpoint( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Route or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -99,18 +98,17 @@ def list_by_endpoint( def prepare_request(next_link=None): if not next_link: - request = build_list_by_endpoint_request( + _request = build_list_by_endpoint_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_endpoint.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -122,13 +120,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("RouteListResult", pipeline_response) @@ -138,11 +136,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -155,10 +153,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any @@ -176,7 +170,6 @@ async def get( :type endpoint_name: str :param route_name: Name of the routing rule. Required. :type route_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Route or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Route :raises ~azure.core.exceptions.HttpResponseError: @@ -195,23 +188,22 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Route] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, route_name=route_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -224,13 +216,9 @@ async def get( deserialized = self._deserialize("Route", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } + return deserialized # type: ignore async def _create_initial( self, @@ -238,7 +226,7 @@ async def _create_initial( profile_name: str, endpoint_name: str, route_name: str, - route: Union[_models.Route, IO], + route: Union[_models.Route, IO[bytes]], **kwargs: Any ) -> _models.Route: error_map = { @@ -264,7 +252,7 @@ async def _create_initial( else: _json = self._serialize.body(route, "Route") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -274,16 +262,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -310,10 +297,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } - @overload async def begin_create( self, @@ -344,14 +327,6 @@ async def begin_create( :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 Route or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -364,7 +339,7 @@ async def begin_create( profile_name: str, endpoint_name: str, route_name: str, - route: IO, + route: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -383,18 +358,10 @@ async def begin_create( :param route_name: Name of the routing rule. Required. :type route_name: str :param route: Route properties. Required. - :type route: IO + :type route: IO[bytes] :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 Route or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -407,7 +374,7 @@ async def begin_create( profile_name: str, endpoint_name: str, route_name: str, - route: Union[_models.Route, IO], + route: Union[_models.Route, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Route]: """Creates a new route with the specified route name under the specified subscription, resource @@ -423,19 +390,8 @@ async def begin_create( :type endpoint_name: str :param route_name: Name of the routing rule. Required. :type route_name: str - :param route: Route properties. Is either a Route type or a IO type. Required. - :type route: ~azure.mgmt.cdn.models.Route 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. + :param route: Route properties. Is either a Route type or a IO[bytes] type. Required. + :type route: ~azure.mgmt.cdn.models.Route or IO[bytes] :return: An instance of AsyncLROPoller that returns either Route or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -468,7 +424,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Route", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -481,17 +437,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Route].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } + return AsyncLROPoller[_models.Route]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -499,7 +453,7 @@ async def _update_initial( profile_name: str, endpoint_name: str, route_name: str, - route_update_properties: Union[_models.RouteUpdateParameters, IO], + route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Route: error_map = { @@ -525,7 +479,7 @@ async def _update_initial( else: _json = self._serialize.body(route_update_properties, "RouteUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -535,16 +489,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -568,10 +521,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } - @overload async def begin_update( self, @@ -602,14 +551,6 @@ async def begin_update( :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 Route or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -622,7 +563,7 @@ async def begin_update( profile_name: str, endpoint_name: str, route_name: str, - route_update_properties: IO, + route_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -641,18 +582,10 @@ async def begin_update( :param route_name: Name of the routing rule. Required. :type route_name: str :param route_update_properties: Route update properties. Required. - :type route_update_properties: IO + :type route_update_properties: IO[bytes] :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 Route or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -665,7 +598,7 @@ async def begin_update( profile_name: str, endpoint_name: str, route_name: str, - route_update_properties: Union[_models.RouteUpdateParameters, IO], + route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Route]: """Updates an existing route with the specified route name under the specified subscription, @@ -682,19 +615,8 @@ async def begin_update( :param route_name: Name of the routing rule. Required. :type route_name: str :param route_update_properties: Route update properties. Is either a RouteUpdateParameters type - or a IO type. Required. - :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters 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. + or a IO[bytes] type. Required. + :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either Route or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -727,7 +649,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Route", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -740,17 +662,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Route].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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } + return AsyncLROPoller[_models.Route]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any @@ -769,23 +689,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, route_name=route_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -800,11 +719,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -823,14 +738,6 @@ async def begin_delete( :type endpoint_name: str :param route_name: Name of the routing rule. Required. :type route_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: @@ -859,7 +766,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -871,14 +778,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py index a31c55e3703a..41884f7a7018 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rule_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -73,7 +73,6 @@ def list_by_profile( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RuleSet or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.RuleSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,17 +94,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,13 +115,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("RuleSetListResult", pipeline_response) @@ -133,11 +131,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +148,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any @@ -169,7 +163,6 @@ async def get( :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RuleSet or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.RuleSet :raises ~azure.core.exceptions.HttpResponseError: @@ -188,22 +181,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -216,13 +208,9 @@ async def get( deserialized = self._deserialize("RuleSet", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}" - } + return deserialized # type: ignore @distributed_trace_async async def create( @@ -238,7 +226,6 @@ async def create( :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RuleSet or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.RuleSet :raises ~azure.core.exceptions.HttpResponseError: @@ -257,22 +244,21 @@ async def create( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -293,10 +279,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}" - } - async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any ) -> None: @@ -314,22 +296,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -344,11 +325,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -365,14 +342,6 @@ async def begin_delete( :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. :type rule_set_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: @@ -400,7 +369,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -412,17 +381,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_resource_usage( @@ -438,7 +403,6 @@ def list_resource_usage( :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -460,18 +424,17 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -483,13 +446,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("UsagesListResult", pipeline_response) @@ -499,11 +462,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -515,7 +478,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/usages" - } diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py index cc52c5bbcf15..420bfd373e03 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_rules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -76,7 +76,6 @@ def list_by_rule_set( :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Rule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -98,18 +97,17 @@ def list_by_rule_set( def prepare_request(next_link=None): if not next_link: - request = build_list_by_rule_set_request( + _request = build_list_by_rule_set_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_rule_set.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -121,13 +119,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("RuleListResult", pipeline_response) @@ -137,11 +135,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -154,10 +152,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_rule_set.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any @@ -173,7 +167,6 @@ async def get( :type rule_set_name: str :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Rule :raises ~azure.core.exceptions.HttpResponseError: @@ -192,23 +185,22 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, rule_name=rule_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -221,13 +213,9 @@ async def get( deserialized = self._deserialize("Rule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } + return deserialized # type: ignore async def _create_initial( self, @@ -235,7 +223,7 @@ async def _create_initial( profile_name: str, rule_set_name: str, rule_name: str, - rule: Union[_models.Rule, IO], + rule: Union[_models.Rule, IO[bytes]], **kwargs: Any ) -> _models.Rule: error_map = { @@ -261,7 +249,7 @@ async def _create_initial( else: _json = self._serialize.body(rule, "Rule") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -271,16 +259,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -307,10 +294,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } - @overload async def begin_create( self, @@ -339,14 +322,6 @@ async def begin_create( :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 Rule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -359,7 +334,7 @@ async def begin_create( profile_name: str, rule_set_name: str, rule_name: str, - rule: IO, + rule: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -376,18 +351,10 @@ async def begin_create( :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_name: str :param rule: The delivery rule properties. Required. - :type rule: IO + :type rule: IO[bytes] :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 Rule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -400,7 +367,7 @@ async def begin_create( profile_name: str, rule_set_name: str, rule_name: str, - rule: Union[_models.Rule, IO], + rule: Union[_models.Rule, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Rule]: """Creates a new delivery rule within the specified rule set. @@ -414,19 +381,8 @@ async def begin_create( :type rule_set_name: str :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_name: str - :param rule: The delivery rule properties. Is either a Rule type or a IO type. Required. - :type rule: ~azure.mgmt.cdn.models.Rule 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. + :param rule: The delivery rule properties. Is either a Rule type or a IO[bytes] type. Required. + :type rule: ~azure.mgmt.cdn.models.Rule or IO[bytes] :return: An instance of AsyncLROPoller that returns either Rule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -459,7 +415,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Rule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -472,17 +428,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Rule].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } + return AsyncLROPoller[_models.Rule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, @@ -490,7 +444,7 @@ async def _update_initial( profile_name: str, rule_set_name: str, rule_name: str, - rule_update_properties: Union[_models.RuleUpdateParameters, IO], + rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Rule: error_map = { @@ -516,7 +470,7 @@ async def _update_initial( else: _json = self._serialize.body(rule_update_properties, "RuleUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -526,16 +480,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -559,10 +512,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } - @overload async def begin_update( self, @@ -591,14 +540,6 @@ async def begin_update( :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 Rule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -611,7 +552,7 @@ async def begin_update( profile_name: str, rule_set_name: str, rule_name: str, - rule_update_properties: IO, + rule_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -628,18 +569,10 @@ async def begin_update( :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_name: str :param rule_update_properties: Delivery rule properties. Required. - :type rule_update_properties: IO + :type rule_update_properties: IO[bytes] :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 Rule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -652,7 +585,7 @@ async def begin_update( profile_name: str, rule_set_name: str, rule_name: str, - rule_update_properties: Union[_models.RuleUpdateParameters, IO], + rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Rule]: """Updates an existing delivery rule within a rule set. @@ -667,19 +600,8 @@ async def begin_update( :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_name: str :param rule_update_properties: Delivery rule properties. Is either a RuleUpdateParameters type - or a IO type. Required. - :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters 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. + or a IO[bytes] type. Required. + :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters or IO[bytes] :return: An instance of AsyncLROPoller that returns either Rule or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -712,7 +634,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Rule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -725,17 +647,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Rule].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.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } + return AsyncLROPoller[_models.Rule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any @@ -754,23 +674,22 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, rule_name=rule_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -785,11 +704,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -806,14 +721,6 @@ async def begin_delete( :type rule_set_name: str :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_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: @@ -842,7 +749,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -854,14 +761,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py index abcd24de067b..b1fd8e71c21c 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_secrets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -73,7 +73,6 @@ def list_by_profile( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Secret or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.Secret] :raises ~azure.core.exceptions.HttpResponseError: @@ -95,17 +94,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -117,13 +115,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("SecretListResult", pipeline_response) @@ -133,11 +131,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -150,10 +148,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets" - } - @distributed_trace_async async def get(self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any) -> _models.Secret: """Gets an existing Secret within a profile. @@ -165,7 +159,6 @@ async def get(self, resource_group_name: str, profile_name: str, secret_name: st :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Secret or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Secret :raises ~azure.core.exceptions.HttpResponseError: @@ -184,22 +177,21 @@ async def get(self, resource_group_name: str, profile_name: str, secret_name: st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Secret] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, secret_name=secret_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -212,20 +204,16 @@ async def get(self, resource_group_name: str, profile_name: str, secret_name: st deserialized = self._deserialize("Secret", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, profile_name: str, secret_name: str, - secret: Union[_models.Secret, IO], + secret: Union[_models.Secret, IO[bytes]], **kwargs: Any ) -> _models.Secret: error_map = { @@ -251,7 +239,7 @@ async def _create_initial( else: _json = self._serialize.body(secret, "Secret") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, secret_name=secret_name, @@ -260,16 +248,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -296,10 +283,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}" - } - @overload async def begin_create( self, @@ -325,14 +308,6 @@ async def begin_create( :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 Secret or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Secret] @@ -345,7 +320,7 @@ async def begin_create( resource_group_name: str, profile_name: str, secret_name: str, - secret: IO, + secret: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -360,18 +335,10 @@ async def begin_create( :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str :param secret: The Secret properties. Required. - :type secret: IO + :type secret: IO[bytes] :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 Secret or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Secret] @@ -384,7 +351,7 @@ async def begin_create( resource_group_name: str, profile_name: str, secret_name: str, - secret: Union[_models.Secret, IO], + secret: Union[_models.Secret, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Secret]: """Creates a new Secret within the specified profile. @@ -396,19 +363,8 @@ async def begin_create( :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str - :param secret: The Secret properties. Is either a Secret type or a IO type. Required. - :type secret: ~azure.mgmt.cdn.models.Secret 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. + :param secret: The Secret properties. Is either a Secret type or a IO[bytes] type. Required. + :type secret: ~azure.mgmt.cdn.models.Secret or IO[bytes] :return: An instance of AsyncLROPoller that returns either Secret or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.Secret] @@ -441,7 +397,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Secret", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -454,17 +410,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Secret].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}" - } + return AsyncLROPoller[_models.Secret]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any @@ -483,22 +437,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, secret_name=secret_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -513,11 +466,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/secrets/{secretName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -532,14 +481,6 @@ async def begin_delete( :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_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: @@ -567,7 +508,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -579,14 +520,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/secrets/{secretName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py index a704a89fda48..5fb6e25102ed 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/aio/operations/_security_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -74,7 +74,6 @@ def list_by_profile( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SecurityPolicy or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.cdn.models.SecurityPolicy] :raises ~azure.core.exceptions.HttpResponseError: @@ -96,17 +95,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,13 +116,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("SecurityPolicyListResult", pipeline_response) @@ -134,11 +132,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,10 +149,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any @@ -168,7 +162,6 @@ async def get( :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SecurityPolicy or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.SecurityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -187,22 +180,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,20 +207,16 @@ async def get( deserialized = self._deserialize("SecurityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } + return deserialized # type: ignore async def _create_initial( self, resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy: Union[_models.SecurityPolicy, IO], + security_policy: Union[_models.SecurityPolicy, IO[bytes]], **kwargs: Any ) -> _models.SecurityPolicy: error_map = { @@ -254,7 +242,7 @@ async def _create_initial( else: _json = self._serialize.body(security_policy, "SecurityPolicy") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_name, @@ -263,16 +251,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -299,10 +286,6 @@ async def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } - @overload async def begin_create( self, @@ -328,14 +311,6 @@ async def begin_create( :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 SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -348,7 +323,7 @@ async def begin_create( resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy: IO, + security_policy: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -363,18 +338,10 @@ async def begin_create( :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str :param security_policy: The security policy properties. Required. - :type security_policy: IO + :type security_policy: IO[bytes] :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 SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -387,7 +354,7 @@ async def begin_create( resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy: Union[_models.SecurityPolicy, IO], + security_policy: Union[_models.SecurityPolicy, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SecurityPolicy]: """Creates a new security policy within the specified profile. @@ -399,20 +366,9 @@ async def begin_create( :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str - :param security_policy: The security policy properties. Is either a SecurityPolicy type or a IO - type. Required. - :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy 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. + :param security_policy: The security policy properties. Is either a SecurityPolicy type or a + IO[bytes] type. Required. + :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy or IO[bytes] :return: An instance of AsyncLROPoller that returns either SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -445,7 +401,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SecurityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -458,24 +414,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SecurityPolicy].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } + return AsyncLROPoller[_models.SecurityPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _patch_initial( self, resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO], + security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.SecurityPolicy: error_map = { @@ -501,7 +455,7 @@ async def _patch_initial( else: _json = self._serialize.body(security_policy_update_properties, "SecurityPolicyUpdateParameters") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_name, @@ -510,16 +464,15 @@ async def _patch_initial( content_type=content_type, json=_json, content=_content, - template_url=self._patch_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -543,10 +496,6 @@ async def _patch_initial( return deserialized # type: ignore - _patch_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } - @overload async def begin_patch( self, @@ -572,14 +521,6 @@ async def begin_patch( :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 SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -592,7 +533,7 @@ async def begin_patch( resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy_update_properties: IO, + security_policy_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -607,18 +548,10 @@ async def begin_patch( :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str :param security_policy_update_properties: Security policy update properties. Required. - :type security_policy_update_properties: IO + :type security_policy_update_properties: IO[bytes] :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 SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -631,7 +564,7 @@ async def begin_patch( resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO], + security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SecurityPolicy]: """Updates an existing security policy within a profile. @@ -644,20 +577,9 @@ async def begin_patch( :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str :param security_policy_update_properties: Security policy update properties. Is either a - SecurityPolicyUpdateParameters type or a IO type. Required. + SecurityPolicyUpdateParameters type or a IO[bytes] type. Required. :type security_policy_update_properties: ~azure.mgmt.cdn.models.SecurityPolicyUpdateParameters - 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. + or IO[bytes] :return: An instance of AsyncLROPoller that returns either SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -690,7 +612,7 @@ async def begin_patch( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SecurityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -703,17 +625,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.SecurityPolicy].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_patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } + return AsyncLROPoller[_models.SecurityPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any @@ -732,22 +652,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -762,11 +681,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -781,14 +696,6 @@ async def begin_delete( :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_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: @@ -816,7 +723,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -828,14 +735,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/__init__.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/__init__.py index 112aa1acb382..c82bb7b540c6 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/__init__.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/__init__.py @@ -168,6 +168,8 @@ from ._models_py3 import Profile from ._models_py3 import ProfileChangeSkuWafMapping from ._models_py3 import ProfileListResult +from ._models_py3 import ProfileLogScrubbing +from ._models_py3 import ProfileScrubbingRules from ._models_py3 import ProfileUpdateParameters from ._models_py3 import ProfileUpgradeParameters from ._models_py3 import ProxyResource @@ -338,6 +340,7 @@ from ._cdn_management_client_enums import ProbeProtocol from ._cdn_management_client_enums import ProfileProvisioningState from ._cdn_management_client_enums import ProfileResourceState +from ._cdn_management_client_enums import ProfileScrubbingState from ._cdn_management_client_enums import ProtocolType from ._cdn_management_client_enums import ProvisioningState from ._cdn_management_client_enums import QueryStringBehavior @@ -366,6 +369,9 @@ from ._cdn_management_client_enums import RuleCacheBehavior from ._cdn_management_client_enums import RuleIsCompressionEnabled from ._cdn_management_client_enums import RuleQueryStringCachingBehavior +from ._cdn_management_client_enums import ScrubbingRuleEntryMatchOperator +from ._cdn_management_client_enums import ScrubbingRuleEntryMatchVariable +from ._cdn_management_client_enums import ScrubbingRuleEntryState from ._cdn_management_client_enums import SecretType from ._cdn_management_client_enums import SecurityPolicyType from ._cdn_management_client_enums import ServerPortMatchConditionParametersTypeName @@ -567,6 +573,8 @@ "Profile", "ProfileChangeSkuWafMapping", "ProfileListResult", + "ProfileLogScrubbing", + "ProfileScrubbingRules", "ProfileUpdateParameters", "ProfileUpgradeParameters", "ProxyResource", @@ -736,6 +744,7 @@ "ProbeProtocol", "ProfileProvisioningState", "ProfileResourceState", + "ProfileScrubbingState", "ProtocolType", "ProvisioningState", "QueryStringBehavior", @@ -764,6 +773,9 @@ "RuleCacheBehavior", "RuleIsCompressionEnabled", "RuleQueryStringCachingBehavior", + "ScrubbingRuleEntryMatchOperator", + "ScrubbingRuleEntryMatchVariable", + "ScrubbingRuleEntryState", "SecretType", "SecurityPolicyType", "ServerPortMatchConditionParametersTypeName", diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py index f44da6ef7f27..d0164f2b6f7b 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_cdn_management_client_enums.py @@ -501,9 +501,8 @@ class MatchProcessingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): If not present, defaults to Continue. """ - CONTINUE = "Continue" - STOP = "Stop" CONTINUE_ENUM = "Continue" + STOP = "Stop" class MatchVariable(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -734,6 +733,13 @@ class ProfileResourceState(str, Enum, metaclass=CaseInsensitiveEnumMeta): ABORTING_MIGRATION = "AbortingMigration" +class ProfileScrubbingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the log scrubbing config. Default value is Enabled.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + class ProtocolType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Defines the TLS extension protocol that is used for secure delivery.""" @@ -979,6 +985,29 @@ class RuleQueryStringCachingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMet INCLUDE_SPECIFIED_QUERY_STRINGS = "IncludeSpecifiedQueryStrings" +class ScrubbingRuleEntryMatchOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """When matchVariable is a collection, operate on the selector to specify which elements in the + collection this rule applies to. + """ + + EQUALS_ANY = "EqualsAny" + + +class ScrubbingRuleEntryMatchVariable(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The variable to be scrubbed from the logs.""" + + REQUEST_IP_ADDRESS = "RequestIPAddress" + REQUEST_URI = "RequestUri" + QUERY_STRING_ARG_NAMES = "QueryStringArgNames" + + +class ScrubbingRuleEntryState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the state of a log scrubbing rule. Default value is enabled.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + class SecretType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of the secret resource.""" diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py index 40bf17abfeb4..e5fd01153680 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/models/_models_py3.py @@ -101,24 +101,6 @@ class ProxyResource(Resource): :vartype system_data: ~azure.mgmt.cdn.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 AFDDomain(ProxyResource): # pylint: disable=too-many-instance-attributes """Friendly domain name mapping to the endpoint hostname that the customer provides for branding @@ -237,7 +219,7 @@ def __init__( class AFDDomainHttpsParameters(_serialization.Model): """The JSON object that contains the properties to secure a domain. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar certificate_type: Defines the source of the SSL certificate. Required. Known values are: "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". @@ -407,7 +389,7 @@ class AFDDomainProperties(AFDDomainUpdatePropertiesParameters, AFDStatePropertie 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. + All required parameters must be populated in order to send to server. :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", "Updating", "Deleting", and "Creating". @@ -570,7 +552,7 @@ class TrackedResource(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. + All required parameters must be populated in order to send to server. :ivar id: Resource ID. :vartype id: str @@ -622,7 +604,7 @@ class AFDEndpoint(TrackedResource): # pylint: disable=too-many-instance-attribu 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. + All required parameters must be populated in order to send to server. :ivar id: Resource ID. :vartype id: str @@ -1885,7 +1867,7 @@ def __init__( class AfdPurgeParameters(_serialization.Model): """Parameters required for content purge. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar content_paths: The path to the content to be purged. Can describe a file path or a wild card directory. Required. @@ -2018,25 +2000,6 @@ class AzureFirstPartyManagedCertificate(Certificate): :vartype expiration_date: str """ - _validation = { - "subject": {"readonly": True}, - "expiration_date": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "subject": {"key": "subject", "type": "str"}, - "expiration_date": {"key": "expirationDate", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.SecretType"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of the secret resource. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :paramtype type: str or ~azure.mgmt.cdn.models.SecretType - """ - super().__init__(type=type, **kwargs) - class SecretParameters(_serialization.Model): """The json object containing secret parameters. @@ -2045,7 +2008,7 @@ class SecretParameters(_serialization.Model): AzureFirstPartyManagedCertificateParameters, CustomerCertificateParameters, ManagedCertificateParameters, UrlSigningKeyParameters - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type: The type of the secret resource. Required. Known values are: "UrlSigningKey", "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". @@ -2075,20 +2038,20 @@ def __init__(self, **kwargs: Any) -> None: self.type: Optional[str] = None -class AzureFirstPartyManagedCertificateParameters(SecretParameters): +class AzureFirstPartyManagedCertificateParameters(SecretParameters): # pylint: disable=name-too-long """Azure FirstParty Managed Certificate provided by other first party resource providers to enable HTTPS. 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. + All required parameters must be populated in order to send to server. :ivar type: The type of the secret resource. Required. Known values are: "UrlSigningKey", "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". :vartype type: str or ~azure.mgmt.cdn.models.SecretType :ivar secret_source: Resource reference to the Azure Key Vault certificate. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference :ivar subject: Subject name in the certificate. :vartype subject: str @@ -2213,7 +2176,7 @@ def __init__( class CacheExpirationActionParameters(_serialization.Model): """Defines the parameters for the cache expiration action. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleCacheExpirationActionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.CacheExpirationActionParametersTypeName @@ -2271,7 +2234,7 @@ def __init__( class CacheKeyQueryStringActionParameters(_serialization.Model): """Defines the parameters for the cache-key query string action. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleCacheKeyQueryStringBehaviorActionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.CacheKeyQueryStringActionParametersTypeName @@ -2319,7 +2282,7 @@ def __init__( class CanMigrateParameters(_serialization.Model): """Request body for CanMigrate operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar classic_resource_reference: Resource reference of the classic cdn profile or classic frontdoor that need to be migrated. Required. @@ -2393,7 +2356,7 @@ def __init__(self, *, errors: Optional[List["_models.MigrationErrorType"]] = Non class CdnCertificateSourceParameters(_serialization.Model): """Defines the parameters for using CDN managed certificate for securing custom domain. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "CdnCertificateSourceParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.CdnCertificateSourceParametersTypeName @@ -2457,7 +2420,7 @@ class CustomDomainHttpsParameters(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: UserManagedHttpsParameters, CdnManagedHttpsParameters - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar certificate_source: Defines the source of the SSL certificate. Required. Known values are: "AzureKeyVault" and "Cdn". @@ -2509,7 +2472,7 @@ def __init__( class CdnManagedHttpsParameters(CustomDomainHttpsParameters): """Defines the certificate source parameters using CDN managed certificate for enabling SSL. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar certificate_source: Defines the source of the SSL certificate. Required. Known values are: "AzureKeyVault" and "Cdn". @@ -2570,7 +2533,7 @@ class CdnWebApplicationFirewallPolicy(TrackedResource): # pylint: disable=too-m 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. + All required parameters must be populated in order to send to server. :ivar id: Resource ID. :vartype id: str @@ -2724,7 +2687,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: self.next_link = next_link -class CdnWebApplicationFirewallPolicyPatchParameters(_serialization.Model): +class CdnWebApplicationFirewallPolicyPatchParameters(_serialization.Model): # pylint: disable=name-too-long """Properties required to update a CdnWebApplicationFirewallPolicy. :ivar tags: CdnWebApplicationFirewallPolicy tags. @@ -2747,7 +2710,7 @@ def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> N class CheckEndpointNameAvailabilityInput(_serialization.Model): """Input of CheckNameAvailability API. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The resource name to validate. Required. :vartype name: str @@ -2843,7 +2806,7 @@ def __init__(self, **kwargs: Any) -> None: class CheckHostNameAvailabilityInput(_serialization.Model): """Input of CheckHostNameAvailability API. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar host_name: The host name to validate. Required. :vartype host_name: str @@ -2869,7 +2832,7 @@ def __init__(self, *, host_name: str, **kwargs: Any) -> None: class CheckNameAvailabilityInput(_serialization.Model): """Input of CheckNameAvailability API. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The resource name to validate. Required. :vartype name: str @@ -2965,7 +2928,7 @@ def __init__( class ClientPortMatchConditionParameters(_serialization.Model): """Defines the parameters for ClientPort match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleClientPortConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.ClientPortMatchConditionParametersTypeName @@ -3026,7 +2989,9 @@ def __init__( self.transforms = transforms -class Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems(_serialization.Model): +class Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems( + _serialization.Model +): # pylint: disable=name-too-long """Components18OrqelSchemasWafmetricsresponsePropertiesSeriesItemsPropertiesDataItems. :ivar date_time: @@ -3054,7 +3019,9 @@ def __init__( self.value = value -class Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems(_serialization.Model): +class Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems( + _serialization.Model +): # pylint: disable=name-too-long """Components1Gs0LlpSchemasMetricsresponsePropertiesSeriesItemsPropertiesDataItems. :ivar date_time: @@ -3082,7 +3049,9 @@ def __init__( self.value = value -class ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems(_serialization.Model): +class ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems( + _serialization.Model +): # pylint: disable=name-too-long """ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems. :ivar metric: @@ -3250,7 +3219,7 @@ def __init__( class CookiesMatchConditionParameters(_serialization.Model): """Defines the parameters for Cookies match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleCookiesConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.CookiesMatchConditionParametersTypeName @@ -3478,7 +3447,7 @@ class CustomerCertificate(Certificate): :vartype expiration_date: str :ivar secret_source: Resource reference to the Azure Key Vault certificate. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference :ivar secret_version: Certificate version. :vartype secret_version: str @@ -3527,7 +3496,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.cdn.models.SecretType :keyword secret_source: Resource reference to the Azure Key Vault certificate. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference :keyword secret_version: Certificate version. :paramtype secret_version: str @@ -3550,14 +3519,14 @@ class CustomerCertificateParameters(SecretParameters): 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. + All required parameters must be populated in order to send to server. :ivar type: The type of the secret resource. Required. Known values are: "UrlSigningKey", "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". :vartype type: str or ~azure.mgmt.cdn.models.SecretType :ivar secret_source: Resource reference to the Azure Key Vault certificate. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long Required. :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference :ivar secret_version: Version of the secret to be used. @@ -3609,7 +3578,7 @@ def __init__( """ :keyword secret_source: Resource reference to the Azure Key Vault certificate. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{certificateName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long Required. :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference :keyword secret_version: Version of the secret to be used. @@ -3634,7 +3603,7 @@ def __init__( class CustomRule(_serialization.Model): """Defines the common attributes for a custom rule that can be included in a waf policy. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: Defines the name of the custom rule. Required. :vartype name: str @@ -3722,7 +3691,7 @@ def __init__(self, *, rules: Optional[List["_models.CustomRule"]] = None, **kwar class DeepCreatedCustomDomain(_serialization.Model): """Custom domains created on the CDN endpoint. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: Custom domain name. Required. :vartype name: str @@ -3768,7 +3737,7 @@ class DeepCreatedOrigin(_serialization.Model): # pylint: disable=too-many-insta 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. + All required parameters must be populated in order to send to server. :ivar name: Origin name which must be unique within the endpoint. Required. :vartype name: str @@ -3911,7 +3880,7 @@ class DeepCreatedOriginGroup(_serialization.Model): """The origin group for CDN content which is added when creating a CDN endpoint. Traffic is sent to the origins within the origin group based on origin health. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: Origin group name which must be unique within the endpoint. Required. :vartype name: str @@ -3993,7 +3962,7 @@ def __init__( class DeliveryRule(_serialization.Model): """A rule that specifies a set of actions and conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: Name of the rule. :vartype name: str @@ -4060,7 +4029,7 @@ class DeliveryRuleAction(_serialization.Model): DeliveryRuleRouteConfigurationOverrideAction, UrlRedirectAction, UrlRewriteAction, UrlSigningAction - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the action for the delivery rule. Required. Known values are: "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", @@ -4100,7 +4069,7 @@ def __init__(self, **kwargs: Any) -> None: class DeliveryRuleCacheExpirationAction(DeliveryRuleAction): """Defines the cache expiration action for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the action for the delivery rule. Required. Known values are: "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", @@ -4134,7 +4103,7 @@ def __init__(self, *, parameters: "_models.CacheExpirationActionParameters", **k class DeliveryRuleCacheKeyQueryStringAction(DeliveryRuleAction): """Defines the cache-key query string action for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the action for the delivery rule. Required. Known values are: "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", @@ -4179,7 +4148,7 @@ class DeliveryRuleCondition(_serialization.Model): DeliveryRuleUrlFileExtensionCondition, DeliveryRuleUrlFileNameCondition, DeliveryRuleUrlPathCondition - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4229,7 +4198,7 @@ def __init__(self, **kwargs: Any) -> None: class DeliveryRuleClientPortCondition(DeliveryRuleCondition): """Defines the ClientPort condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4263,7 +4232,7 @@ def __init__(self, *, parameters: "_models.ClientPortMatchConditionParameters", class DeliveryRuleCookiesCondition(DeliveryRuleCondition): """Defines the Cookies condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4297,7 +4266,7 @@ def __init__(self, *, parameters: "_models.CookiesMatchConditionParameters", **k class DeliveryRuleHostNameCondition(DeliveryRuleCondition): """Defines the HostName condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4331,7 +4300,7 @@ def __init__(self, *, parameters: "_models.HostNameMatchConditionParameters", ** class DeliveryRuleHttpVersionCondition(DeliveryRuleCondition): """Defines the HttpVersion condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4365,7 +4334,7 @@ def __init__(self, *, parameters: "_models.HttpVersionMatchConditionParameters", class DeliveryRuleIsDeviceCondition(DeliveryRuleCondition): """Defines the IsDevice condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4399,7 +4368,7 @@ def __init__(self, *, parameters: "_models.IsDeviceMatchConditionParameters", ** class DeliveryRulePostArgsCondition(DeliveryRuleCondition): """Defines the PostArgs condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4433,7 +4402,7 @@ def __init__(self, *, parameters: "_models.PostArgsMatchConditionParameters", ** class DeliveryRuleQueryStringCondition(DeliveryRuleCondition): """Defines the QueryString condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4467,7 +4436,7 @@ def __init__(self, *, parameters: "_models.QueryStringMatchConditionParameters", class DeliveryRuleRemoteAddressCondition(DeliveryRuleCondition): """Defines the RemoteAddress condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4501,7 +4470,7 @@ def __init__(self, *, parameters: "_models.RemoteAddressMatchConditionParameters class DeliveryRuleRequestBodyCondition(DeliveryRuleCondition): """Defines the RequestBody condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4535,7 +4504,7 @@ def __init__(self, *, parameters: "_models.RequestBodyMatchConditionParameters", class DeliveryRuleRequestHeaderAction(DeliveryRuleAction): """Defines the request header action for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the action for the delivery rule. Required. Known values are: "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", @@ -4569,7 +4538,7 @@ def __init__(self, *, parameters: "_models.HeaderActionParameters", **kwargs: An class DeliveryRuleRequestHeaderCondition(DeliveryRuleCondition): """Defines the RequestHeader condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4603,7 +4572,7 @@ def __init__(self, *, parameters: "_models.RequestHeaderMatchConditionParameters class DeliveryRuleRequestMethodCondition(DeliveryRuleCondition): """Defines the RequestMethod condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4637,7 +4606,7 @@ def __init__(self, *, parameters: "_models.RequestMethodMatchConditionParameters class DeliveryRuleRequestSchemeCondition(DeliveryRuleCondition): """Defines the RequestScheme condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4671,7 +4640,7 @@ def __init__(self, *, parameters: "_models.RequestSchemeMatchConditionParameters class DeliveryRuleRequestUriCondition(DeliveryRuleCondition): """Defines the RequestUri condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4705,7 +4674,7 @@ def __init__(self, *, parameters: "_models.RequestUriMatchConditionParameters", class DeliveryRuleResponseHeaderAction(DeliveryRuleAction): """Defines the response header action for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the action for the delivery rule. Required. Known values are: "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", @@ -4736,11 +4705,11 @@ def __init__(self, *, parameters: "_models.HeaderActionParameters", **kwargs: An self.parameters = parameters -class DeliveryRuleRouteConfigurationOverrideAction(DeliveryRuleAction): +class DeliveryRuleRouteConfigurationOverrideAction(DeliveryRuleAction): # pylint: disable=name-too-long """Defines the route configuration override action for the delivery rule. Only applicable to Frontdoor Standard/Premium Profiles. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the action for the delivery rule. Required. Known values are: "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", @@ -4774,7 +4743,7 @@ def __init__(self, *, parameters: "_models.RouteConfigurationOverrideActionParam class DeliveryRuleServerPortCondition(DeliveryRuleCondition): """Defines the ServerPort condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4808,7 +4777,7 @@ def __init__(self, *, parameters: "_models.ServerPortMatchConditionParameters", class DeliveryRuleSocketAddrCondition(DeliveryRuleCondition): """Defines the SocketAddress condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4842,7 +4811,7 @@ def __init__(self, *, parameters: "_models.SocketAddrMatchConditionParameters", class DeliveryRuleSslProtocolCondition(DeliveryRuleCondition): """Defines the SslProtocol condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4876,7 +4845,7 @@ def __init__(self, *, parameters: "_models.SslProtocolMatchConditionParameters", class DeliveryRuleUrlFileExtensionCondition(DeliveryRuleCondition): """Defines the UrlFileExtension condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4910,7 +4879,7 @@ def __init__(self, *, parameters: "_models.UrlFileExtensionMatchConditionParamet class DeliveryRuleUrlFileNameCondition(DeliveryRuleCondition): """Defines the UrlFileName condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -4944,7 +4913,7 @@ def __init__(self, *, parameters: "_models.UrlFileNameMatchConditionParameters", class DeliveryRuleUrlPathCondition(DeliveryRuleCondition): """Defines the UrlPath condition for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the condition for the delivery rule. Required. Known values are: "RemoteAddress", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -5121,7 +5090,7 @@ class Endpoint(TrackedResource): # pylint: disable=too-many-instance-attributes 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. + All required parameters must be populated in order to send to server. :ivar id: Resource ID. :vartype id: str @@ -5574,7 +5543,7 @@ class EndpointProperties(EndpointPropertiesUpdateParameters): # pylint: disable 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. + All required parameters must be populated in order to send to server. :ivar origin_path: A directory path on the origin that CDN can use to retrieve content from, e.g. contoso.cloudapp.net/originpath. @@ -5790,10 +5759,10 @@ def __init__( self.provisioning_state = None -class EndpointPropertiesUpdateParametersDeliveryPolicy(_serialization.Model): +class EndpointPropertiesUpdateParametersDeliveryPolicy(_serialization.Model): # pylint: disable=name-too-long """A policy that specifies the delivery rules to be used for an endpoint. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar description: User-friendly description of the policy. :vartype description: str @@ -5824,7 +5793,9 @@ def __init__( self.rules = rules -class EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink(_serialization.Model): +class EndpointPropertiesUpdateParametersWebApplicationFirewallPolicyLink( + _serialization.Model +): # pylint: disable=name-too-long """Defines the Web Application Firewall policy for the endpoint (if applicable). :ivar id: Resource ID. @@ -6121,7 +6092,7 @@ def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs: A class GeoFilter(_serialization.Model): """Rules defining user's geo access within a CDN endpoint. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar relative_path: Relative path applicable to geo filter. (e.g. '/mypictures', '/mypicture/kitty.jpg', and etc.). Required. @@ -6174,7 +6145,7 @@ def __init__( class HeaderActionParameters(_serialization.Model): """Defines the parameters for the request header action. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleHeaderActionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.HeaderActionParametersTypeName @@ -6287,7 +6258,7 @@ def __init__( class HostNameMatchConditionParameters(_serialization.Model): """Defines the parameters for HostName match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleHostNameConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.HostNameMatchConditionParametersTypeName @@ -6382,7 +6353,7 @@ def __init__(self, *, begin: Optional[int] = None, end: Optional[int] = None, ** class HttpVersionMatchConditionParameters(_serialization.Model): """Defines the parameters for HttpVersion match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleHttpVersionConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.HttpVersionMatchConditionParametersTypeName @@ -6481,7 +6452,7 @@ def __init__( class IsDeviceMatchConditionParameters(_serialization.Model): """Defines the parameters for IsDevice match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleIsDeviceConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.IsDeviceMatchConditionParametersTypeName @@ -6543,7 +6514,7 @@ def __init__( class KeyVaultCertificateSourceParameters(_serialization.Model): """Describes the parameters for using a user's KeyVault certificate for securing custom domain. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "KeyVaultCertificateSourceParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.KeyVaultCertificateSourceParametersTypeName @@ -6639,7 +6610,7 @@ def __init__( class KeyVaultSigningKeyParameters(_serialization.Model): """Describes the parameters for using a user's KeyVault for URL Signing Key. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "KeyVaultSigningKeyParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.KeyVaultSigningKeyParametersTypeName @@ -6756,7 +6727,7 @@ def __init__( class LoadParameters(_serialization.Model): """Parameters required for content load. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar content_paths: The path to the content to be loaded. Path should be a relative file URL of the origin. Required. @@ -6841,32 +6812,13 @@ class ManagedCertificate(Certificate): :vartype expiration_date: str """ - _validation = { - "subject": {"readonly": True}, - "expiration_date": {"readonly": True}, - } - - _attribute_map = { - "type": {"key": "type", "type": "str"}, - "subject": {"key": "subject", "type": "str"}, - "expiration_date": {"key": "expirationDate", "type": "str"}, - } - - def __init__(self, *, type: Optional[Union[str, "_models.SecretType"]] = None, **kwargs: Any) -> None: - """ - :keyword type: The type of the secret resource. Known values are: "UrlSigningKey", - "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". - :paramtype type: str or ~azure.mgmt.cdn.models.SecretType - """ - super().__init__(type=type, **kwargs) - class ManagedCertificateParameters(SecretParameters): """Managed Certificate used for https. 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. + All required parameters must be populated in order to send to server. :ivar type: The type of the secret resource. Required. Known values are: "UrlSigningKey", "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". @@ -6961,7 +6913,7 @@ def __init__(self, **kwargs: Any) -> None: class ManagedRuleGroupOverride(_serialization.Model): """Defines a managed rule group override setting. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar rule_group_name: Describes the managed rule group within the rule set to override. Required. @@ -6999,7 +6951,7 @@ def __init__( class ManagedRuleOverride(_serialization.Model): """Defines a managed rule group override setting. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar rule_id: Identifier for the managed rule. Required. :vartype rule_id: str @@ -7048,7 +7000,7 @@ def __init__( class ManagedRuleSet(_serialization.Model): """Defines a managed rule set. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar rule_set_type: Defines the rule set type to use. Required. :vartype rule_set_type: str @@ -7219,7 +7171,7 @@ class ManagedServiceIdentity(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar principal_id: The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity. @@ -7233,7 +7185,7 @@ class ManagedServiceIdentity(_serialization.Model): :vartype type: str or ~azure.mgmt.cdn.models.ManagedServiceIdentityType :ivar user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :vartype user_assigned_identities: dict[str, ~azure.mgmt.cdn.models.UserAssignedIdentity] """ @@ -7265,7 +7217,7 @@ def __init__( :paramtype type: str or ~azure.mgmt.cdn.models.ManagedServiceIdentityType :keyword user_assigned_identities: The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: - '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. # pylint: disable=line-too-long The dictionary values can be empty objects ({}) in requests. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.cdn.models.UserAssignedIdentity] """ @@ -7279,7 +7231,7 @@ def __init__( class MatchCondition(_serialization.Model): """Define match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar match_variable: Match variable to compare against. Required. Known values are: "RemoteAddr", "SocketAddr", "RequestMethod", "RequestHeader", "RequestUri", "QueryString", @@ -7677,7 +7629,7 @@ def __init__(self, **kwargs: Any) -> None: class MigrationParameters(_serialization.Model): """Request body for Migrate operation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar sku: Sku for the migration. Required. :vartype sku: ~azure.mgmt.cdn.models.Sku @@ -8225,7 +8177,7 @@ def __init__( class OriginGroupOverrideAction(DeliveryRuleAction): """Defines the origin group override action for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the action for the delivery rule. Required. Known values are: "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", @@ -8259,7 +8211,7 @@ def __init__(self, *, parameters: "_models.OriginGroupOverrideActionParameters", class OriginGroupOverrideActionParameters(_serialization.Model): """Defines the parameters for the origin group override action. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleOriginGroupOverrideActionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.OriginGroupOverrideActionParametersTypeName @@ -9030,7 +8982,7 @@ def __init__( class PostArgsMatchConditionParameters(_serialization.Model): """Defines the parameters for PostArgs match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRulePostArgsConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.PostArgsMatchConditionParametersTypeName @@ -9103,7 +9055,7 @@ class Profile(TrackedResource): # pylint: disable=too-many-instance-attributes 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. + All required parameters must be populated in order to send to server. :ivar id: Resource ID. :vartype id: str @@ -9139,6 +9091,9 @@ class Profile(TrackedResource): # pylint: disable=too-many-instance-attributes :ivar origin_response_timeout_seconds: Send and receive timeout on forwarding request to the origin. When timeout is reached, the request fails and returns. :vartype origin_response_timeout_seconds: int + :ivar log_scrubbing: Defines rules that scrub sensitive fields in the Azure Front Door profile + logs. + :vartype log_scrubbing: ~azure.mgmt.cdn.models.ProfileLogScrubbing """ _validation = { @@ -9171,6 +9126,7 @@ class Profile(TrackedResource): # pylint: disable=too-many-instance-attributes "extended_properties": {"key": "properties.extendedProperties", "type": "{str}"}, "front_door_id": {"key": "properties.frontDoorId", "type": "str"}, "origin_response_timeout_seconds": {"key": "properties.originResponseTimeoutSeconds", "type": "int"}, + "log_scrubbing": {"key": "properties.logScrubbing", "type": "ProfileLogScrubbing"}, } def __init__( @@ -9181,6 +9137,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, origin_response_timeout_seconds: Optional[int] = None, + log_scrubbing: Optional["_models.ProfileLogScrubbing"] = None, **kwargs: Any ) -> None: """ @@ -9196,6 +9153,9 @@ def __init__( :keyword origin_response_timeout_seconds: Send and receive timeout on forwarding request to the origin. When timeout is reached, the request fails and returns. :paramtype origin_response_timeout_seconds: int + :keyword log_scrubbing: Defines rules that scrub sensitive fields in the Azure Front Door + profile logs. + :paramtype log_scrubbing: ~azure.mgmt.cdn.models.ProfileLogScrubbing """ super().__init__(location=location, tags=tags, **kwargs) self.sku = sku @@ -9206,12 +9166,13 @@ def __init__( self.extended_properties = None self.front_door_id = None self.origin_response_timeout_seconds = origin_response_timeout_seconds + self.log_scrubbing = log_scrubbing class ProfileChangeSkuWafMapping(_serialization.Model): """Parameters required for profile upgrade. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar security_policy_name: The security policy name. Required. :vartype security_policy_name: str @@ -9274,6 +9235,104 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: self.next_link = next_link +class ProfileLogScrubbing(_serialization.Model): + """Defines rules that scrub sensitive fields in the Azure Front Door profile logs. + + :ivar state: State of the log scrubbing config. Default value is Enabled. Known values are: + "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.cdn.models.ProfileScrubbingState + :ivar scrubbing_rules: List of log scrubbing rules applied to the Azure Front Door profile + logs. + :vartype scrubbing_rules: list[~azure.mgmt.cdn.models.ProfileScrubbingRules] + """ + + _attribute_map = { + "state": {"key": "state", "type": "str"}, + "scrubbing_rules": {"key": "scrubbingRules", "type": "[ProfileScrubbingRules]"}, + } + + def __init__( + self, + *, + state: Optional[Union[str, "_models.ProfileScrubbingState"]] = None, + scrubbing_rules: Optional[List["_models.ProfileScrubbingRules"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword state: State of the log scrubbing config. Default value is Enabled. Known values are: + "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.cdn.models.ProfileScrubbingState + :keyword scrubbing_rules: List of log scrubbing rules applied to the Azure Front Door profile + logs. + :paramtype scrubbing_rules: list[~azure.mgmt.cdn.models.ProfileScrubbingRules] + """ + super().__init__(**kwargs) + self.state = state + self.scrubbing_rules = scrubbing_rules + + +class ProfileScrubbingRules(_serialization.Model): + """Defines the contents of the log scrubbing rules. + + All required parameters must be populated in order to send to server. + + :ivar match_variable: The variable to be scrubbed from the logs. Required. Known values are: + "RequestIPAddress", "RequestUri", and "QueryStringArgNames". + :vartype match_variable: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryMatchVariable + :ivar selector_match_operator: When matchVariable is a collection, operate on the selector to + specify which elements in the collection this rule applies to. Required. "EqualsAny" + :vartype selector_match_operator: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryMatchOperator + :ivar selector: When matchVariable is a collection, operator used to specify which elements in + the collection this rule applies to. + :vartype selector: str + :ivar state: Defines the state of a log scrubbing rule. Default value is enabled. Known values + are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryState + """ + + _validation = { + "match_variable": {"required": True}, + "selector_match_operator": {"required": True}, + } + + _attribute_map = { + "match_variable": {"key": "matchVariable", "type": "str"}, + "selector_match_operator": {"key": "selectorMatchOperator", "type": "str"}, + "selector": {"key": "selector", "type": "str"}, + "state": {"key": "state", "type": "str"}, + } + + def __init__( + self, + *, + match_variable: Union[str, "_models.ScrubbingRuleEntryMatchVariable"], + selector_match_operator: Union[str, "_models.ScrubbingRuleEntryMatchOperator"], + selector: Optional[str] = None, + state: Optional[Union[str, "_models.ScrubbingRuleEntryState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword match_variable: The variable to be scrubbed from the logs. Required. Known values are: + "RequestIPAddress", "RequestUri", and "QueryStringArgNames". + :paramtype match_variable: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryMatchVariable + :keyword selector_match_operator: When matchVariable is a collection, operate on the selector + to specify which elements in the collection this rule applies to. Required. "EqualsAny" + :paramtype selector_match_operator: str or + ~azure.mgmt.cdn.models.ScrubbingRuleEntryMatchOperator + :keyword selector: When matchVariable is a collection, operator used to specify which elements + in the collection this rule applies to. + :paramtype selector: str + :keyword state: Defines the state of a log scrubbing rule. Default value is enabled. Known + values are: "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.cdn.models.ScrubbingRuleEntryState + """ + super().__init__(**kwargs) + self.match_variable = match_variable + self.selector_match_operator = selector_match_operator + self.selector = selector + self.state = state + + class ProfileUpdateParameters(_serialization.Model): """Properties required to update a profile. @@ -9284,6 +9343,8 @@ class ProfileUpdateParameters(_serialization.Model): :ivar origin_response_timeout_seconds: Send and receive timeout on forwarding request to the origin. When timeout is reached, the request fails and returns. :vartype origin_response_timeout_seconds: int + :ivar log_scrubbing: Defines rules to scrub sensitive fields in logs. + :vartype log_scrubbing: ~azure.mgmt.cdn.models.ProfileLogScrubbing """ _validation = { @@ -9294,6 +9355,7 @@ class ProfileUpdateParameters(_serialization.Model): "tags": {"key": "tags", "type": "{str}"}, "identity": {"key": "identity", "type": "ManagedServiceIdentity"}, "origin_response_timeout_seconds": {"key": "properties.originResponseTimeoutSeconds", "type": "int"}, + "log_scrubbing": {"key": "properties.logScrubbing", "type": "ProfileLogScrubbing"}, } def __init__( @@ -9302,6 +9364,7 @@ def __init__( tags: Optional[Dict[str, str]] = None, identity: Optional["_models.ManagedServiceIdentity"] = None, origin_response_timeout_seconds: Optional[int] = None, + log_scrubbing: Optional["_models.ProfileLogScrubbing"] = None, **kwargs: Any ) -> None: """ @@ -9312,17 +9375,20 @@ def __init__( :keyword origin_response_timeout_seconds: Send and receive timeout on forwarding request to the origin. When timeout is reached, the request fails and returns. :paramtype origin_response_timeout_seconds: int + :keyword log_scrubbing: Defines rules to scrub sensitive fields in logs. + :paramtype log_scrubbing: ~azure.mgmt.cdn.models.ProfileLogScrubbing """ super().__init__(**kwargs) self.tags = tags self.identity = identity self.origin_response_timeout_seconds = origin_response_timeout_seconds + self.log_scrubbing = log_scrubbing class ProfileUpgradeParameters(_serialization.Model): """Parameters required for profile upgrade. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar waf_mapping_list: Web Application Firewall (WAF) and security policy mapping for the profile upgrade. Required. @@ -9350,7 +9416,7 @@ def __init__(self, *, waf_mapping_list: List["_models.ProfileChangeSkuWafMapping class PurgeParameters(_serialization.Model): """Parameters required for content purge. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar content_paths: The path to the content to be purged. Can describe a file path or a wild card directory. Required. @@ -9378,7 +9444,7 @@ def __init__(self, *, content_paths: List[str], **kwargs: Any) -> None: class QueryStringMatchConditionParameters(_serialization.Model): """Defines the parameters for QueryString match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleQueryStringConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.QueryStringMatchConditionParametersTypeName @@ -9510,7 +9576,7 @@ def __init__( self.data = data -class RankingsResponseTablesPropertiesItemsItem(_serialization.Model): +class RankingsResponseTablesPropertiesItemsItem(_serialization.Model): # pylint: disable=name-too-long """RankingsResponseTablesPropertiesItemsItem. :ivar name: @@ -9543,7 +9609,7 @@ def __init__( self.metrics = metrics -class RankingsResponseTablesPropertiesItemsMetricsItem(_serialization.Model): +class RankingsResponseTablesPropertiesItemsMetricsItem(_serialization.Model): # pylint: disable=name-too-long """RankingsResponseTablesPropertiesItemsMetricsItem. :ivar metric: @@ -9585,7 +9651,7 @@ def __init__( class RateLimitRule(CustomRule): """Defines a rate limiting rule that can be included in a waf policy. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: Defines the name of the custom rule. Required. :vartype name: str @@ -9693,7 +9759,7 @@ def __init__(self, *, rules: Optional[List["_models.RateLimitRule"]] = None, **k class RemoteAddressMatchConditionParameters(_serialization.Model): """Defines the parameters for RemoteAddress match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleRemoteAddressConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.RemoteAddressMatchConditionParametersTypeName @@ -9760,7 +9826,7 @@ def __init__( class RequestBodyMatchConditionParameters(_serialization.Model): """Defines the parameters for RequestBody match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleRequestBodyConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.RequestBodyMatchConditionParametersTypeName @@ -9824,7 +9890,7 @@ def __init__( class RequestHeaderMatchConditionParameters(_serialization.Model): """Defines the parameters for RequestHeader match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleRequestHeaderConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.RequestHeaderMatchConditionParametersTypeName @@ -9896,7 +9962,7 @@ def __init__( class RequestMethodMatchConditionParameters(_serialization.Model): """Defines the parameters for RequestMethod match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleRequestMethodConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.RequestMethodMatchConditionParametersTypeName @@ -9959,7 +10025,7 @@ def __init__( class RequestSchemeMatchConditionParameters(_serialization.Model): """Defines the parameters for RequestScheme match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleRequestSchemeConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.RequestSchemeMatchConditionParametersTypeName @@ -10023,7 +10089,7 @@ def __init__( class RequestUriMatchConditionParameters(_serialization.Model): """Defines the parameters for RequestUri match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleRequestUriConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.RequestUriMatchConditionParametersTypeName @@ -10230,7 +10296,7 @@ def __init__( self.custom_domains = custom_domains -class ResourcesResponseEndpointsPropertiesItemsItem(_serialization.Model): +class ResourcesResponseEndpointsPropertiesItemsItem(_serialization.Model): # pylint: disable=name-too-long """ResourcesResponseEndpointsPropertiesItemsItem. :ivar id: @@ -10344,7 +10410,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: self.next_link = next_link -class ResponseBasedOriginErrorDetectionParameters(_serialization.Model): +class ResponseBasedOriginErrorDetectionParameters(_serialization.Model): # pylint: disable=name-too-long """The JSON object that contains the properties to determine origin health using real requests/responses. @@ -10548,10 +10614,10 @@ def __init__( self.deployment_status = None -class RouteConfigurationOverrideActionParameters(_serialization.Model): +class RouteConfigurationOverrideActionParameters(_serialization.Model): # pylint: disable=name-too-long """Defines the parameters for the route configuration override action. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleRouteConfigurationOverrideActionParameters" :vartype type_name: str or @@ -11041,7 +11107,7 @@ class Rule(ProxyResource): # pylint: disable=too-many-instance-attributes :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue", "Stop", and "Continue". + "Continue" and "Stop". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior :ivar provisioning_state: Provisioning status. Known values are: "Succeeded", "Failed", "Updating", "Deleting", and "Creating". @@ -11097,7 +11163,7 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue", "Stop", and "Continue". + "Continue" and "Stop". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__(**kwargs) @@ -11160,7 +11226,7 @@ class RuleUpdatePropertiesParameters(_serialization.Model): :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue", "Stop", and "Continue". + "Continue" and "Stop". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ @@ -11198,7 +11264,7 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue", "Stop", and "Continue". + "Continue" and "Stop". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__(**kwargs) @@ -11234,7 +11300,7 @@ class RuleProperties(RuleUpdatePropertiesParameters, AFDStateProperties): :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue", "Stop", and "Continue". + "Continue" and "Stop". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ @@ -11276,7 +11342,7 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue", "Stop", and "Continue". + "Continue" and "Stop". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__( @@ -11429,7 +11495,7 @@ class RuleUpdateParameters(_serialization.Model): :vartype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue", "Stop", and "Continue". + "Continue" and "Stop". :vartype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ @@ -11467,7 +11533,7 @@ def __init__( :paramtype actions: list[~azure.mgmt.cdn.models.DeliveryRuleAction] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue", "Stop", and "Continue". + "Continue" and "Stop". :paramtype match_processing_behavior: str or ~azure.mgmt.cdn.models.MatchProcessingBehavior """ super().__init__(**kwargs) @@ -11746,7 +11812,7 @@ class SecurityPolicyPropertiesParameters(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: SecurityPolicyWebApplicationFirewallParameters - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type: The type of the Security policy to create. Required. "WebApplicationFirewall" :vartype type: str or ~azure.mgmt.cdn.models.SecurityPolicyType @@ -11790,7 +11856,7 @@ def __init__( self.parameters = parameters -class SecurityPolicyWebApplicationFirewallAssociation(_serialization.Model): +class SecurityPolicyWebApplicationFirewallAssociation(_serialization.Model): # pylint: disable=name-too-long """settings for security policy patterns to match. :ivar domains: List of domains. @@ -11822,10 +11888,12 @@ def __init__( self.patterns_to_match = patterns_to_match -class SecurityPolicyWebApplicationFirewallParameters(SecurityPolicyPropertiesParameters): +class SecurityPolicyWebApplicationFirewallParameters( + SecurityPolicyPropertiesParameters +): # pylint: disable=name-too-long """The json object containing security policy waf parameters. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type: The type of the Security policy to create. Required. "WebApplicationFirewall" :vartype type: str or ~azure.mgmt.cdn.models.SecurityPolicyType @@ -11869,7 +11937,7 @@ def __init__( class ServerPortMatchConditionParameters(_serialization.Model): """Defines the parameters for ServerPort match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleServerPortConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.ServerPortMatchConditionParametersTypeName @@ -12073,7 +12141,7 @@ def __init__(self, *, name: Optional[Union[str, "_models.SkuName"]] = None, **kw class SocketAddrMatchConditionParameters(_serialization.Model): """Defines the parameters for SocketAddress match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleSocketAddrConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.SocketAddrMatchConditionParametersTypeName @@ -12135,7 +12203,7 @@ def __init__( class SslProtocolMatchConditionParameters(_serialization.Model): """Defines the parameters for SslProtocol match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleSslProtocolConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.SslProtocolMatchConditionParametersTypeName @@ -12305,7 +12373,7 @@ def __init__( class UrlFileExtensionMatchConditionParameters(_serialization.Model): """Defines the parameters for UrlFileExtension match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleUrlFileExtensionMatchConditionParameters" :vartype type_name: str or @@ -12371,7 +12439,7 @@ def __init__( class UrlFileNameMatchConditionParameters(_serialization.Model): """Defines the parameters for UrlFilename match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleUrlFilenameConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.UrlFileNameMatchConditionParametersTypeName @@ -12435,7 +12503,7 @@ def __init__( class UrlPathMatchConditionParameters(_serialization.Model): """Defines the parameters for UrlPath match conditions. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleUrlPathMatchConditionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.UrlPathMatchConditionParametersTypeName @@ -12499,7 +12567,7 @@ def __init__( class UrlRedirectAction(DeliveryRuleAction): """Defines the url redirect action for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the action for the delivery rule. Required. Known values are: "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", @@ -12533,7 +12601,7 @@ def __init__(self, *, parameters: "_models.UrlRedirectActionParameters", **kwarg class UrlRedirectActionParameters(_serialization.Model): """Defines the parameters for the url redirect action. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleUrlRedirectActionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.UrlRedirectActionParametersTypeName @@ -12623,7 +12691,7 @@ def __init__( class UrlRewriteAction(DeliveryRuleAction): """Defines the url rewrite action for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the action for the delivery rule. Required. Known values are: "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", @@ -12657,7 +12725,7 @@ def __init__(self, *, parameters: "_models.UrlRewriteActionParameters", **kwargs class UrlRewriteActionParameters(_serialization.Model): """Defines the parameters for the url rewrite action. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleUrlRewriteActionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.UrlRewriteActionParametersTypeName @@ -12715,7 +12783,7 @@ def __init__( class UrlSigningAction(DeliveryRuleAction): """Defines the url signing action for the delivery rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the action for the delivery rule. Required. Known values are: "CacheExpiration", "CacheKeyQueryString", "ModifyRequestHeader", "ModifyResponseHeader", @@ -12749,7 +12817,7 @@ def __init__(self, *, parameters: "_models.UrlSigningActionParameters", **kwargs class UrlSigningActionParameters(_serialization.Model): """Defines the parameters for the Url Signing action. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type_name: Required. "DeliveryRuleUrlSigningActionParameters" :vartype type_name: str or ~azure.mgmt.cdn.models.UrlSigningActionParametersTypeName @@ -12796,7 +12864,7 @@ def __init__( class UrlSigningKey(_serialization.Model): """Url signing key. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar key_id: Defines the customer defined key Id. This id will exist in the incoming request to indicate the key used to form the hash. Required. @@ -12835,7 +12903,7 @@ def __init__( class UrlSigningKeyParameters(SecretParameters): """Url signing key parameters. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar type: The type of the secret resource. Required. Known values are: "UrlSigningKey", "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". @@ -12845,7 +12913,7 @@ class UrlSigningKeyParameters(SecretParameters): :vartype key_id: str :ivar secret_source: Resource reference to the Azure Key Vault secret. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long Required. :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference :ivar secret_version: Version of the secret to be used. @@ -12879,7 +12947,7 @@ def __init__( :paramtype key_id: str :keyword secret_source: Resource reference to the Azure Key Vault secret. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long Required. :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference :keyword secret_version: Version of the secret to be used. @@ -12895,7 +12963,7 @@ def __init__( class UrlSigningParamIdentifier(_serialization.Model): """Defines how to identify a parameter for a specific purpose e.g. expires. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar param_indicator: Indicates the purpose of the parameter. Required. Known values are: "Expires", "KeyId", and "Signature". @@ -12934,7 +13002,7 @@ class Usage(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar id: Resource identifier. :vartype id: str @@ -13076,7 +13144,7 @@ def __init__(self, **kwargs: Any) -> None: class UserManagedHttpsParameters(CustomDomainHttpsParameters): """Defines the certificate source parameters using user's keyvault certificate for enabling SSL. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar certificate_source: Defines the source of the SSL certificate. Required. Known values are: "AzureKeyVault" and "Cdn". @@ -13137,7 +13205,7 @@ def __init__( class ValidateCustomDomainInput(_serialization.Model): """Input of the custom domain to be validated for DNS mapping. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar host_name: The host name of the custom domain. Must be a domain name. Required. :vartype host_name: str @@ -13196,7 +13264,7 @@ def __init__(self, **kwargs: Any) -> None: class ValidateProbeInput(_serialization.Model): """Input of the validate probe API. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar probe_url: The probe URL to validate. Required. :vartype probe_url: str @@ -13255,14 +13323,14 @@ def __init__(self, **kwargs: Any) -> None: class ValidateSecretInput(_serialization.Model): """Input of the secret to be validated. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar secret_type: The secret type. Required. Known values are: "UrlSigningKey", "CustomerCertificate", "ManagedCertificate", and "AzureFirstPartyManagedCertificate". :vartype secret_type: str or ~azure.mgmt.cdn.models.SecretType :ivar secret_source: Resource reference to the Azure Key Vault secret. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long Required. :vartype secret_source: ~azure.mgmt.cdn.models.ResourceReference :ivar secret_version: Secret version, if customer is using a specific version. @@ -13294,7 +13362,7 @@ def __init__( :paramtype secret_type: str or ~azure.mgmt.cdn.models.SecretType :keyword secret_source: Resource reference to the Azure Key Vault secret. Expected to be in format of - /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. + /subscriptions/{​​​​​​​​​subscriptionId}​​​​​​​​​/resourceGroups/{​​​​​​​​​resourceGroupName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/providers/Microsoft.KeyVault/vaults/{vaultName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​/secrets/{secretName}​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​. # pylint: disable=line-too-long Required. :paramtype secret_source: ~azure.mgmt.cdn.models.ResourceReference :keyword secret_version: Secret version, if customer is using a specific version. @@ -13458,7 +13526,7 @@ def __init__( self.data = data -class WafMetricsResponseSeriesPropertiesItemsItem(_serialization.Model): +class WafMetricsResponseSeriesPropertiesItemsItem(_serialization.Model): # pylint: disable=name-too-long """WafMetricsResponseSeriesPropertiesItemsItem. :ivar name: @@ -13562,7 +13630,7 @@ def __init__( :paramtype group_values: list[str] :keyword metrics: :paramtype metrics: - list[~azure.mgmt.cdn.models.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems] + list[~azure.mgmt.cdn.models.ComponentsKpo1PjSchemasWafrankingsresponsePropertiesDataItemsPropertiesMetricsItems] # pylint: disable=line-too-long """ super().__init__(**kwargs) self.group_values = group_values diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py index 91cc84f7faf1..780032971392 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_custom_domains_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +78,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +112,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -149,7 +149,7 @@ def build_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -186,7 +186,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -220,7 +220,7 @@ def build_refresh_validation_token_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -278,7 +278,6 @@ def list_by_profile( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AFDDomain or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -300,17 +299,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -322,13 +320,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("AFDDomainListResult", pipeline_response) @@ -338,11 +336,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,10 +353,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains" - } - @distributed_trace def get( self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any @@ -374,7 +368,6 @@ def get( :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. :type custom_domain_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AFDDomain or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.AFDDomain :raises ~azure.core.exceptions.HttpResponseError: @@ -393,22 +386,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDDomain] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -421,20 +413,16 @@ def get( deserialized = self._deserialize("AFDDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain: Union[_models.AFDDomain, IO], + custom_domain: Union[_models.AFDDomain, IO[bytes]], **kwargs: Any ) -> _models.AFDDomain: error_map = { @@ -460,7 +448,7 @@ def _create_initial( else: _json = self._serialize.body(custom_domain, "AFDDomain") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -469,16 +457,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -505,10 +492,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } - @overload def begin_create( self, @@ -535,14 +518,6 @@ def begin_create( :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 AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -554,7 +529,7 @@ def begin_create( resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain: IO, + custom_domain: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -570,18 +545,10 @@ def begin_create( Required. :type custom_domain_name: str :param custom_domain: Domain properties. Required. - :type custom_domain: IO + :type custom_domain: IO[bytes] :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 AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -593,7 +560,7 @@ def begin_create( resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain: Union[_models.AFDDomain, IO], + custom_domain: Union[_models.AFDDomain, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AFDDomain]: """Creates a new domain within the specified profile. @@ -606,19 +573,9 @@ def begin_create( :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. :type custom_domain_name: str - :param custom_domain: Domain properties. Is either a AFDDomain type or a IO type. Required. - :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain 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. + :param custom_domain: Domain properties. Is either a AFDDomain type or a IO[bytes] type. + Required. + :type custom_domain: ~azure.mgmt.cdn.models.AFDDomain or IO[bytes] :return: An instance of LROPoller that returns either AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -650,7 +607,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -662,24 +619,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AFDDomain].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } + return LROPoller[_models.AFDDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO], + custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AFDDomain: error_map = { @@ -705,7 +660,7 @@ def _update_initial( else: _json = self._serialize.body(custom_domain_update_properties, "AFDDomainUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, @@ -714,16 +669,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -747,10 +701,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } - @overload def begin_update( self, @@ -777,14 +727,6 @@ def begin_update( :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 AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -796,7 +738,7 @@ def begin_update( resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain_update_properties: IO, + custom_domain_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -812,18 +754,10 @@ def begin_update( Required. :type custom_domain_name: str :param custom_domain_update_properties: Domain properties. Required. - :type custom_domain_update_properties: IO + :type custom_domain_update_properties: IO[bytes] :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 AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -835,7 +769,7 @@ def begin_update( resource_group_name: str, profile_name: str, custom_domain_name: str, - custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO], + custom_domain_update_properties: Union[_models.AFDDomainUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AFDDomain]: """Updates an existing domain within a profile. @@ -849,19 +783,9 @@ def begin_update( Required. :type custom_domain_name: str :param custom_domain_update_properties: Domain properties. Is either a - AFDDomainUpdateParameters type or a IO type. Required. - :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters 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. + AFDDomainUpdateParameters type or a IO[bytes] type. Required. + :type custom_domain_update_properties: ~azure.mgmt.cdn.models.AFDDomainUpdateParameters or + IO[bytes] :return: An instance of LROPoller that returns either AFDDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -893,7 +817,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -905,17 +829,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AFDDomain].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.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } + return LROPoller[_models.AFDDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any @@ -934,22 +856,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -964,11 +885,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -985,14 +902,6 @@ def begin_delete( :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. :type custom_domain_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: @@ -1020,7 +929,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1031,17 +940,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/customDomains/{customDomainName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, custom_domain_name: str, **kwargs: Any @@ -1060,22 +965,21 @@ def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-st api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_refresh_validation_token_request( + _request = build_refresh_validation_token_request( resource_group_name=resource_group_name, profile_name=profile_name, custom_domain_name=custom_domain_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._refresh_validation_token_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1090,11 +994,7 @@ def _refresh_validation_token_initial( # pylint: disable=inconsistent-return-st response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, None, response_headers) - - _refresh_validation_token_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}/refreshValidationToken" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_refresh_validation_token( @@ -1110,14 +1010,6 @@ def begin_refresh_validation_token( :param custom_domain_name: Name of the domain under the profile which is unique globally. Required. :type custom_domain_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: @@ -1145,7 +1037,7 @@ def begin_refresh_validation_token( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1156,14 +1048,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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_refresh_validation_token.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/customDomains/{customDomainName}/refreshValidationToken" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py index afb0402a413f..39ec9832c5ab 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +78,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +112,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -149,7 +149,7 @@ def build_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -186,7 +186,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -220,7 +220,7 @@ def build_purge_content_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -257,7 +257,7 @@ def build_list_resource_usage_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -291,7 +291,7 @@ def build_validate_custom_domain_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -352,7 +352,6 @@ def list_by_profile( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AFDEndpoint or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDEndpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -374,17 +373,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -396,13 +394,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("AFDEndpointListResult", pipeline_response) @@ -412,11 +410,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -429,10 +427,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints" - } - @distributed_trace def get( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -448,7 +442,6 @@ def get( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AFDEndpoint or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.AFDEndpoint :raises ~azure.core.exceptions.HttpResponseError: @@ -467,22 +460,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDEndpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -495,20 +487,16 @@ def get( deserialized = self._deserialize("AFDEndpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: Union[_models.AFDEndpoint, IO], + endpoint: Union[_models.AFDEndpoint, IO[bytes]], **kwargs: Any ) -> _models.AFDEndpoint: error_map = { @@ -534,7 +522,7 @@ def _create_initial( else: _json = self._serialize.body(endpoint, "AFDEndpoint") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -543,16 +531,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -579,10 +566,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } - @overload def begin_create( self, @@ -610,14 +593,6 @@ def begin_create( :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 AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -630,7 +605,7 @@ def begin_create( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: IO, + endpoint: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -647,18 +622,10 @@ def begin_create( Required. :type endpoint_name: str :param endpoint: Endpoint properties. Required. - :type endpoint: IO + :type endpoint: IO[bytes] :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 AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -671,7 +638,7 @@ def begin_create( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: Union[_models.AFDEndpoint, IO], + endpoint: Union[_models.AFDEndpoint, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AFDEndpoint]: """Creates a new AzureFrontDoor endpoint with the specified endpoint name under the specified @@ -685,19 +652,9 @@ def begin_create( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :param endpoint: Endpoint properties. Is either a AFDEndpoint type or a IO type. Required. - :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint 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. + :param endpoint: Endpoint properties. Is either a AFDEndpoint type or a IO[bytes] type. + Required. + :type endpoint: ~azure.mgmt.cdn.models.AFDEndpoint or IO[bytes] :return: An instance of LROPoller that returns either AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -730,7 +687,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDEndpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -742,24 +699,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AFDEndpoint].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } + return LROPoller[_models.AFDEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO], + endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AFDEndpoint: error_map = { @@ -785,7 +740,7 @@ def _update_initial( else: _json = self._serialize.body(endpoint_update_properties, "AFDEndpointUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -794,16 +749,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -827,10 +781,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } - @overload def begin_update( self, @@ -860,14 +810,6 @@ def begin_update( :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 AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -880,7 +822,7 @@ def begin_update( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: IO, + endpoint_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -899,18 +841,10 @@ def begin_update( Required. :type endpoint_name: str :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: IO + :type endpoint_update_properties: IO[bytes] :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 AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -923,7 +857,7 @@ def begin_update( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO], + endpoint_update_properties: Union[_models.AFDEndpointUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AFDEndpoint]: """Updates an existing AzureFrontDoor endpoint with the specified endpoint name under the @@ -940,19 +874,9 @@ def begin_update( Required. :type endpoint_name: str :param endpoint_update_properties: Endpoint update properties. Is either a - AFDEndpointUpdateParameters type or a IO type. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters 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. + AFDEndpointUpdateParameters type or a IO[bytes] type. Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.AFDEndpointUpdateParameters or + IO[bytes] :return: An instance of LROPoller that returns either AFDEndpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDEndpoint] @@ -985,7 +909,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDEndpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -997,17 +921,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AFDEndpoint].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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } + return LROPoller[_models.AFDEndpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -1026,22 +948,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1056,11 +977,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -1077,14 +994,6 @@ def begin_delete( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_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: @@ -1112,7 +1021,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1123,24 +1032,20 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _purge_content_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, - contents: Union[_models.AfdPurgeParameters, IO], + contents: Union[_models.AfdPurgeParameters, IO[bytes]], **kwargs: Any ) -> None: error_map = { @@ -1166,7 +1071,7 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(contents, "AfdPurgeParameters") - request = build_purge_content_request( + _request = build_purge_content_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1175,16 +1080,15 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._purge_content_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1199,11 +1103,7 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, None, response_headers) - - _purge_content_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/purge" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload def begin_purge_content( @@ -1234,14 +1134,6 @@ def begin_purge_content( :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1253,7 +1145,7 @@ def begin_purge_content( resource_group_name: str, profile_name: str, endpoint_name: str, - contents: IO, + contents: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1272,18 +1164,10 @@ def begin_purge_content( Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Required. - :type contents: IO + :type contents: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1295,7 +1179,7 @@ def begin_purge_content( resource_group_name: str, profile_name: str, endpoint_name: str, - contents: Union[_models.AfdPurgeParameters, IO], + contents: Union[_models.AfdPurgeParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Removes a content from AzureFrontDoor. @@ -1311,19 +1195,8 @@ def begin_purge_content( :param contents: The list of paths to the content and the list of linked domains to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Is - either a AfdPurgeParameters type or a IO type. Required. - :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters 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. + either a AfdPurgeParameters type or a IO[bytes] type. Required. + :type contents: ~azure.mgmt.cdn.models.AfdPurgeParameters or IO[bytes] :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: @@ -1354,7 +1227,7 @@ def begin_purge_content( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1365,17 +1238,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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_purge_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/purge" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_resource_usage( @@ -1391,7 +1260,6 @@ def list_resource_usage( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -1413,18 +1281,17 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1436,13 +1303,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("UsagesListResult", pipeline_response) @@ -1452,11 +1319,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1469,10 +1336,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/usages" - } - @overload def validate_custom_domain( self, @@ -1500,7 +1363,6 @@ def validate_custom_domain( :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -1512,7 +1374,7 @@ def validate_custom_domain( resource_group_name: str, profile_name: str, endpoint_name: str, - custom_domain_properties: IO, + custom_domain_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1529,11 +1391,10 @@ def validate_custom_domain( Required. :type endpoint_name: str :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: IO + :type custom_domain_properties: IO[bytes] :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -1545,7 +1406,7 @@ def validate_custom_domain( resource_group_name: str, profile_name: str, endpoint_name: str, - custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO], + custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO[bytes]], **kwargs: Any ) -> _models.ValidateCustomDomainOutput: """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint @@ -1560,12 +1421,8 @@ def validate_custom_domain( Required. :type endpoint_name: str :param custom_domain_properties: Custom domain to be validated. Is either a - ValidateCustomDomainInput type or a IO type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput 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 + ValidateCustomDomainInput type or a IO[bytes] type. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or IO[bytes] :return: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -1593,7 +1450,7 @@ def validate_custom_domain( else: _json = self._serialize.body(custom_domain_properties, "ValidateCustomDomainInput") - request = build_validate_custom_domain_request( + _request = build_validate_custom_domain_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1602,16 +1459,15 @@ def validate_custom_domain( content_type=content_type, json=_json, content=_content, - template_url=self.validate_custom_domain.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1624,10 +1480,6 @@ def validate_custom_domain( deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate_custom_domain.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/validateCustomDomain" - } + return deserialized # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py index ac81758ffb26..81cdaaeab539 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origin_groups_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +78,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +112,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -149,7 +149,7 @@ def build_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -186,7 +186,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -220,7 +220,7 @@ def build_list_resource_usage_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -278,7 +278,6 @@ def list_by_profile( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDOriginGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -300,17 +299,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -322,13 +320,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("AFDOriginGroupListResult", pipeline_response) @@ -338,11 +336,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -355,10 +353,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups" - } - @distributed_trace def get( self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any @@ -373,7 +367,6 @@ def get( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AFDOriginGroup or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.AFDOriginGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -392,22 +385,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDOriginGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -420,20 +412,16 @@ def get( deserialized = self._deserialize("AFDOriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group: Union[_models.AFDOriginGroup, IO], + origin_group: Union[_models.AFDOriginGroup, IO[bytes]], **kwargs: Any ) -> _models.AFDOriginGroup: error_map = { @@ -459,7 +447,7 @@ def _create_initial( else: _json = self._serialize.body(origin_group, "AFDOriginGroup") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -468,16 +456,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -504,10 +491,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } - @overload def begin_create( self, @@ -534,14 +517,6 @@ def begin_create( :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 AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -554,7 +529,7 @@ def begin_create( resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group: IO, + origin_group: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -570,18 +545,10 @@ def begin_create( Required. :type origin_group_name: str :param origin_group: Origin group properties. Required. - :type origin_group: IO + :type origin_group: IO[bytes] :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 AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -594,7 +561,7 @@ def begin_create( resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group: Union[_models.AFDOriginGroup, IO], + origin_group: Union[_models.AFDOriginGroup, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AFDOriginGroup]: """Creates a new origin group within the specified profile. @@ -607,20 +574,9 @@ def begin_create( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_group_name: str - :param origin_group: Origin group properties. Is either a AFDOriginGroup type or a IO type. - Required. - :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup 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. + :param origin_group: Origin group properties. Is either a AFDOriginGroup type or a IO[bytes] + type. Required. + :type origin_group: ~azure.mgmt.cdn.models.AFDOriginGroup or IO[bytes] :return: An instance of LROPoller that returns either AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -653,7 +609,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDOriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -665,24 +621,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AFDOriginGroup].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } + return LROPoller[_models.AFDOriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO], + origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AFDOriginGroup: error_map = { @@ -708,7 +662,7 @@ def _update_initial( else: _json = self._serialize.body(origin_group_update_properties, "AFDOriginGroupUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -717,16 +671,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -750,10 +703,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } - @overload def begin_update( self, @@ -780,14 +729,6 @@ def begin_update( :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 AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -800,7 +741,7 @@ def begin_update( resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group_update_properties: IO, + origin_group_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -816,18 +757,10 @@ def begin_update( Required. :type origin_group_name: str :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: IO + :type origin_group_update_properties: IO[bytes] :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 AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -840,7 +773,7 @@ def begin_update( resource_group_name: str, profile_name: str, origin_group_name: str, - origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO], + origin_group_update_properties: Union[_models.AFDOriginGroupUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AFDOriginGroup]: """Updates an existing origin group within a profile. @@ -854,20 +787,9 @@ def begin_update( Required. :type origin_group_name: str :param origin_group_update_properties: Origin group properties. Is either a - AFDOriginGroupUpdateParameters type or a IO type. Required. + AFDOriginGroupUpdateParameters type or a IO[bytes] type. Required. :type origin_group_update_properties: ~azure.mgmt.cdn.models.AFDOriginGroupUpdateParameters 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. + IO[bytes] :return: An instance of LROPoller that returns either AFDOriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOriginGroup] @@ -900,7 +822,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDOriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -912,17 +834,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AFDOriginGroup].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.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } + return LROPoller[_models.AFDOriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, origin_group_name: str, **kwargs: Any @@ -941,22 +861,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -971,11 +890,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -991,14 +906,6 @@ def begin_delete( :param origin_group_name: Name of the origin group which is unique within the profile. Required. :type origin_group_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: @@ -1026,7 +933,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1037,17 +944,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/originGroups/{originGroupName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_resource_usage( @@ -1063,7 +966,6 @@ def list_resource_usage( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_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 Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -1085,18 +987,17 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1108,13 +1009,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("UsagesListResult", pipeline_response) @@ -1124,11 +1025,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1140,7 +1041,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/usages" - } diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py index b55e1a604a3a..fd5da5702708 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_origins_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_origin_group_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +124,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -167,7 +167,7 @@ def build_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -210,7 +210,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -272,7 +272,6 @@ def list_by_origin_group( :param origin_group_name: Name of the origin group which is unique within the profile. Required. :type origin_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 AFDOrigin or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.AFDOrigin] :raises ~azure.core.exceptions.HttpResponseError: @@ -294,18 +293,17 @@ def list_by_origin_group( def prepare_request(next_link=None): if not next_link: - request = build_list_by_origin_group_request( + _request = build_list_by_origin_group_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_origin_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -317,13 +315,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("AFDOriginListResult", pipeline_response) @@ -333,11 +331,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +348,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_origin_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins" - } - @distributed_trace def get( self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any @@ -370,7 +364,6 @@ def get( :type origin_group_name: str :param origin_name: Name of the origin which is unique within the profile. Required. :type origin_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: AFDOrigin or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.AFDOrigin :raises ~azure.core.exceptions.HttpResponseError: @@ -389,23 +382,22 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.AFDOrigin] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, origin_name=origin_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -418,13 +410,9 @@ def get( deserialized = self._deserialize("AFDOrigin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } + return deserialized # type: ignore def _create_initial( self, @@ -432,7 +420,7 @@ def _create_initial( profile_name: str, origin_group_name: str, origin_name: str, - origin: Union[_models.AFDOrigin, IO], + origin: Union[_models.AFDOrigin, IO[bytes]], **kwargs: Any ) -> _models.AFDOrigin: error_map = { @@ -458,7 +446,7 @@ def _create_initial( else: _json = self._serialize.body(origin, "AFDOrigin") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -468,16 +456,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -504,10 +491,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } - @overload def begin_create( self, @@ -537,14 +520,6 @@ def begin_create( :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 AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] :raises ~azure.core.exceptions.HttpResponseError: @@ -557,7 +532,7 @@ def begin_create( profile_name: str, origin_group_name: str, origin_name: str, - origin: IO, + origin: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -575,18 +550,10 @@ def begin_create( :param origin_name: Name of the origin that is unique within the profile. Required. :type origin_name: str :param origin: Origin properties. Required. - :type origin: IO + :type origin: IO[bytes] :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 AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] :raises ~azure.core.exceptions.HttpResponseError: @@ -599,7 +566,7 @@ def begin_create( profile_name: str, origin_group_name: str, origin_name: str, - origin: Union[_models.AFDOrigin, IO], + origin: Union[_models.AFDOrigin, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AFDOrigin]: """Creates a new origin within the specified origin group. @@ -614,19 +581,8 @@ def begin_create( :type origin_group_name: str :param origin_name: Name of the origin that is unique within the profile. Required. :type origin_name: str - :param origin: Origin properties. Is either a AFDOrigin type or a IO type. Required. - :type origin: ~azure.mgmt.cdn.models.AFDOrigin 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. + :param origin: Origin properties. Is either a AFDOrigin type or a IO[bytes] type. Required. + :type origin: ~azure.mgmt.cdn.models.AFDOrigin or IO[bytes] :return: An instance of LROPoller that returns either AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] :raises ~azure.core.exceptions.HttpResponseError: @@ -659,7 +615,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDOrigin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -671,17 +627,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AFDOrigin].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } + return LROPoller[_models.AFDOrigin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -689,7 +643,7 @@ def _update_initial( profile_name: str, origin_group_name: str, origin_name: str, - origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO], + origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.AFDOrigin: error_map = { @@ -715,7 +669,7 @@ def _update_initial( else: _json = self._serialize.body(origin_update_properties, "AFDOriginUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, @@ -725,16 +679,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -758,10 +711,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } - @overload def begin_update( self, @@ -791,14 +740,6 @@ def begin_update( :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 AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] :raises ~azure.core.exceptions.HttpResponseError: @@ -811,7 +752,7 @@ def begin_update( profile_name: str, origin_group_name: str, origin_name: str, - origin_update_properties: IO, + origin_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -829,18 +770,10 @@ def begin_update( :param origin_name: Name of the origin which is unique within the profile. Required. :type origin_name: str :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: IO + :type origin_update_properties: IO[bytes] :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 AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] :raises ~azure.core.exceptions.HttpResponseError: @@ -853,7 +786,7 @@ def begin_update( profile_name: str, origin_group_name: str, origin_name: str, - origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO], + origin_update_properties: Union[_models.AFDOriginUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.AFDOrigin]: """Updates an existing origin within an origin group. @@ -869,19 +802,8 @@ def begin_update( :param origin_name: Name of the origin which is unique within the profile. Required. :type origin_name: str :param origin_update_properties: Origin properties. Is either a AFDOriginUpdateParameters type - or a IO type. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters 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. + or a IO[bytes] type. Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.AFDOriginUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either AFDOrigin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.AFDOrigin] :raises ~azure.core.exceptions.HttpResponseError: @@ -914,7 +836,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("AFDOrigin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -926,17 +848,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.AFDOrigin].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.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } + return LROPoller[_models.AFDOrigin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, origin_group_name: str, origin_name: str, **kwargs: Any @@ -955,23 +875,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, origin_group_name=origin_group_name, origin_name=origin_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -986,11 +905,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -1008,14 +923,6 @@ def begin_delete( :type origin_group_name: str :param origin_name: Name of the origin which is unique within the profile. Required. :type origin_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: @@ -1044,7 +951,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1055,14 +962,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/originGroups/{originGroupName}/origins/{originName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py index fd8258f3ed09..f08fecb718cd 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_afd_profiles_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,13 +39,13 @@ _SERIALIZER.client_side_validation = False -def build_check_endpoint_name_availability_request( +def build_check_endpoint_name_availability_request( # pylint: disable=name-too-long resource_group_name: str, profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -83,7 +83,7 @@ def build_list_resource_usage_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,13 +110,13 @@ def build_list_resource_usage_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_host_name_availability_request( +def build_check_host_name_availability_request( # pylint: disable=name-too-long resource_group_name: str, profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -152,7 +152,7 @@ def build_validate_secret_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -190,7 +190,7 @@ def build_upgrade_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -265,7 +265,6 @@ def check_endpoint_name_availability( :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: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -276,7 +275,7 @@ def check_endpoint_name_availability( self, resource_group_name: str, profile_name: str, - check_endpoint_name_availability_input: IO, + check_endpoint_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -290,11 +289,10 @@ def check_endpoint_name_availability( unique within the resource group. Required. :type profile_name: str :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: IO + :type check_endpoint_name_availability_input: IO[bytes] :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: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -305,7 +303,7 @@ def check_endpoint_name_availability( self, resource_group_name: str, profile_name: str, - check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO], + check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO[bytes]], **kwargs: Any ) -> _models.CheckEndpointNameAvailabilityOutput: """Check the availability of an afdx endpoint name, and return the globally unique endpoint host @@ -317,13 +315,9 @@ def check_endpoint_name_availability( unique within the resource group. Required. :type profile_name: str :param check_endpoint_name_availability_input: Input to check. Is either a - CheckEndpointNameAvailabilityInput type or a IO type. Required. + CheckEndpointNameAvailabilityInput type or a IO[bytes] type. Required. :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput 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 + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or IO[bytes] :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -351,7 +345,7 @@ def check_endpoint_name_availability( else: _json = self._serialize.body(check_endpoint_name_availability_input, "CheckEndpointNameAvailabilityInput") - request = build_check_endpoint_name_availability_request( + _request = build_check_endpoint_name_availability_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -359,16 +353,15 @@ def check_endpoint_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_endpoint_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -381,13 +374,9 @@ def check_endpoint_name_availability( deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_endpoint_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkEndpointNameAvailability" - } + return deserialized # type: ignore @distributed_trace def list_resource_usage( @@ -400,7 +389,6 @@ def list_resource_usage( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -422,17 +410,16 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -444,13 +431,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("UsagesListResult", pipeline_response) @@ -460,11 +447,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -477,10 +464,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/usages" - } - @overload def check_host_name_availability( self, @@ -504,7 +487,6 @@ def check_host_name_availability( :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -515,7 +497,7 @@ def check_host_name_availability( self, resource_group_name: str, profile_name: str, - check_host_name_availability_input: IO, + check_host_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -529,11 +511,10 @@ def check_host_name_availability( which is unique within the resource group. Required. :type profile_name: str :param check_host_name_availability_input: Custom domain to be validated. Required. - :type check_host_name_availability_input: IO + :type check_host_name_availability_input: IO[bytes] :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -544,7 +525,7 @@ def check_host_name_availability( self, resource_group_name: str, profile_name: str, - check_host_name_availability_input: Union[_models.CheckHostNameAvailabilityInput, IO], + check_host_name_availability_input: Union[_models.CheckHostNameAvailabilityInput, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Validates the custom domain mapping to ensure it maps to the correct Azure Front Door endpoint @@ -556,13 +537,9 @@ def check_host_name_availability( which is unique within the resource group. Required. :type profile_name: str :param check_host_name_availability_input: Custom domain to be validated. Is either a - CheckHostNameAvailabilityInput type or a IO type. Required. + CheckHostNameAvailabilityInput type or a IO[bytes] type. Required. :type check_host_name_availability_input: ~azure.mgmt.cdn.models.CheckHostNameAvailabilityInput - 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 + or IO[bytes] :return: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -590,7 +567,7 @@ def check_host_name_availability( else: _json = self._serialize.body(check_host_name_availability_input, "CheckHostNameAvailabilityInput") - request = build_check_host_name_availability_request( + _request = build_check_host_name_availability_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -598,16 +575,15 @@ def check_host_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_host_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -620,13 +596,9 @@ def check_host_name_availability( deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_host_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkHostNameAvailability" - } + return deserialized # type: ignore @overload def validate_secret( @@ -650,7 +622,6 @@ def validate_secret( :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: ValidateSecretOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -661,7 +632,7 @@ def validate_secret( self, resource_group_name: str, profile_name: str, - validate_secret_input: IO, + validate_secret_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -674,11 +645,10 @@ def validate_secret( unique within the resource group. Required. :type profile_name: str :param validate_secret_input: The Secret source. Required. - :type validate_secret_input: IO + :type validate_secret_input: IO[bytes] :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: ValidateSecretOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -689,7 +659,7 @@ def validate_secret( self, resource_group_name: str, profile_name: str, - validate_secret_input: Union[_models.ValidateSecretInput, IO], + validate_secret_input: Union[_models.ValidateSecretInput, IO[bytes]], **kwargs: Any ) -> _models.ValidateSecretOutput: """Validate a Secret in the profile. @@ -699,13 +669,9 @@ def validate_secret( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium which is unique within the resource group. Required. :type profile_name: str - :param validate_secret_input: The Secret source. Is either a ValidateSecretInput type or a IO - type. Required. - :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput 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 + :param validate_secret_input: The Secret source. Is either a ValidateSecretInput type or a + IO[bytes] type. Required. + :type validate_secret_input: ~azure.mgmt.cdn.models.ValidateSecretInput or IO[bytes] :return: ValidateSecretOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateSecretOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -733,7 +699,7 @@ def validate_secret( else: _json = self._serialize.body(validate_secret_input, "ValidateSecretInput") - request = build_validate_secret_request( + _request = build_validate_secret_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -741,16 +707,15 @@ def validate_secret( content_type=content_type, json=_json, content=_content, - template_url=self.validate_secret.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -763,19 +728,15 @@ def validate_secret( deserialized = self._deserialize("ValidateSecretOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate_secret.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/validateSecret" - } + return deserialized # type: ignore def _upgrade_initial( self, resource_group_name: str, profile_name: str, - profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO], + profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], **kwargs: Any ) -> _models.Profile: error_map = { @@ -801,7 +762,7 @@ def _upgrade_initial( else: _json = self._serialize.body(profile_upgrade_parameters, "ProfileUpgradeParameters") - request = build_upgrade_request( + _request = build_upgrade_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -809,16 +770,15 @@ def _upgrade_initial( content_type=content_type, json=_json, content=_content, - template_url=self._upgrade_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -842,10 +802,6 @@ def _upgrade_initial( return deserialized # type: ignore - _upgrade_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/upgrade" - } - @overload def begin_upgrade( self, @@ -868,14 +824,6 @@ def begin_upgrade( :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -886,7 +834,7 @@ def begin_upgrade( self, resource_group_name: str, profile_name: str, - profile_upgrade_parameters: IO, + profile_upgrade_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -899,18 +847,10 @@ def begin_upgrade( unique within the resource group. Required. :type profile_name: str :param profile_upgrade_parameters: Profile upgrade input parameter. Required. - :type profile_upgrade_parameters: IO + :type profile_upgrade_parameters: IO[bytes] :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -921,7 +861,7 @@ def begin_upgrade( self, resource_group_name: str, profile_name: str, - profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO], + profile_upgrade_parameters: Union[_models.ProfileUpgradeParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Profile]: """Upgrade a profile from Standard_AzureFrontDoor to Premium_AzureFrontDoor. @@ -932,19 +872,8 @@ def begin_upgrade( unique within the resource group. Required. :type profile_name: str :param profile_upgrade_parameters: Profile upgrade input parameter. Is either a - ProfileUpgradeParameters type or a IO type. Required. - :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters 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. + ProfileUpgradeParameters type or a IO[bytes] type. Required. + :type profile_upgrade_parameters: ~azure.mgmt.cdn.models.ProfileUpgradeParameters or IO[bytes] :return: An instance of LROPoller that returns either Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -975,7 +904,7 @@ def begin_upgrade( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -987,14 +916,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Profile].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_upgrade.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/upgrade" - } + return LROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py index 009039d53364..8b639ca85902 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_cdn_management_client_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,13 +35,13 @@ _SERIALIZER.client_side_validation = False -def build_check_endpoint_name_availability_request( +def build_check_endpoint_name_availability_request( # pylint: disable=name-too-long resource_group_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -74,7 +74,7 @@ def build_check_name_availability_request(**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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -92,11 +92,13 @@ def build_check_name_availability_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_name_availability_with_subscription_request(subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_check_name_availability_with_subscription_request( # pylint: disable=name-too-long + 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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -123,7 +125,7 @@ def build_validate_probe_request(subscription_id: str, **kwargs: Any) -> HttpReq _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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -167,7 +169,6 @@ def check_endpoint_name_availability( :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: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -177,7 +178,7 @@ def check_endpoint_name_availability( def check_endpoint_name_availability( self, resource_group_name: str, - check_endpoint_name_availability_input: IO, + check_endpoint_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -188,11 +189,10 @@ def check_endpoint_name_availability( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param check_endpoint_name_availability_input: Input to check. Required. - :type check_endpoint_name_availability_input: IO + :type check_endpoint_name_availability_input: IO[bytes] :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: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -202,7 +202,7 @@ def check_endpoint_name_availability( def check_endpoint_name_availability( self, resource_group_name: str, - check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO], + check_endpoint_name_availability_input: Union[_models.CheckEndpointNameAvailabilityInput, IO[bytes]], **kwargs: Any ) -> _models.CheckEndpointNameAvailabilityOutput: """Check the availability of a resource name. This is needed for resources where name is globally @@ -211,13 +211,9 @@ def check_endpoint_name_availability( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param check_endpoint_name_availability_input: Input to check. Is either a - CheckEndpointNameAvailabilityInput type or a IO type. Required. + CheckEndpointNameAvailabilityInput type or a IO[bytes] type. Required. :type check_endpoint_name_availability_input: - ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput 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 + ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityInput or IO[bytes] :return: CheckEndpointNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckEndpointNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -245,23 +241,22 @@ def check_endpoint_name_availability( else: _json = self._serialize.body(check_endpoint_name_availability_input, "CheckEndpointNameAvailabilityInput") - request = build_check_endpoint_name_availability_request( + _request = build_check_endpoint_name_availability_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_endpoint_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -274,13 +269,9 @@ def check_endpoint_name_availability( deserialized = self._deserialize("CheckEndpointNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_endpoint_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/checkEndpointNameAvailability" - } + return deserialized # type: ignore @overload def check_name_availability( @@ -298,7 +289,6 @@ def check_name_availability( :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -306,17 +296,16 @@ def check_name_availability( @overload def check_name_availability( - self, check_name_availability_input: IO, *, content_type: str = "application/json", **kwargs: Any + self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a resource name. This is needed for resources where name is globally unique, such as a CDN endpoint. :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: IO + :type check_name_availability_input: IO[bytes] :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -324,18 +313,15 @@ def check_name_availability( @distributed_trace def check_name_availability( - self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO], **kwargs: Any + self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a resource name. This is needed for resources where name is globally unique, such as a CDN endpoint. :param check_name_availability_input: Input to check. Is either a CheckNameAvailabilityInput - type or a IO type. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput 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 + type or a IO[bytes] type. Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or + IO[bytes] :return: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -363,21 +349,20 @@ def check_name_availability( else: _json = self._serialize.body(check_name_availability_input, "CheckNameAvailabilityInput") - request = build_check_name_availability_request( + _request = build_check_name_availability_request( api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,14 +375,12 @@ def check_name_availability( deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability.metadata = {"url": "/providers/Microsoft.Cdn/checkNameAvailability"} + return deserialized # type: ignore @overload - def check_name_availability_with_subscription( + def check_name_availability_with_subscription( # pylint: disable=name-too-long self, check_name_availability_input: _models.CheckNameAvailabilityInput, *, @@ -412,44 +395,39 @@ def check_name_availability_with_subscription( :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def check_name_availability_with_subscription( - self, check_name_availability_input: IO, *, content_type: str = "application/json", **kwargs: Any + def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, check_name_availability_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a resource name. This is needed for resources where name is globally unique, such as a CDN endpoint. :param check_name_availability_input: Input to check. Required. - :type check_name_availability_input: IO + :type check_name_availability_input: IO[bytes] :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def check_name_availability_with_subscription( - self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO], **kwargs: Any + def check_name_availability_with_subscription( # pylint: disable=name-too-long + self, check_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a resource name. This is needed for resources where name is globally unique, such as a CDN endpoint. :param check_name_availability_input: Input to check. Is either a CheckNameAvailabilityInput - type or a IO type. Required. - :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput 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 + type or a IO[bytes] type. Required. + :type check_name_availability_input: ~azure.mgmt.cdn.models.CheckNameAvailabilityInput or + IO[bytes] :return: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -477,22 +455,21 @@ def check_name_availability_with_subscription( else: _json = self._serialize.body(check_name_availability_input, "CheckNameAvailabilityInput") - request = build_check_name_availability_with_subscription_request( + _request = build_check_name_availability_with_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check_name_availability_with_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -505,13 +482,9 @@ def check_name_availability_with_subscription( deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_name_availability_with_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkNameAvailability" - } + return deserialized # type: ignore @overload def validate_probe( @@ -526,7 +499,6 @@ def validate_probe( :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: ValidateProbeOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -534,18 +506,17 @@ def validate_probe( @overload def validate_probe( - self, validate_probe_input: IO, *, content_type: str = "application/json", **kwargs: Any + self, validate_probe_input: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.ValidateProbeOutput: """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to a file hosted on the origin server to help accelerate the delivery of dynamic content via the CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. :param validate_probe_input: Input to check. Required. - :type validate_probe_input: IO + :type validate_probe_input: IO[bytes] :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: ValidateProbeOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -553,19 +524,15 @@ def validate_probe( @distributed_trace def validate_probe( - self, validate_probe_input: Union[_models.ValidateProbeInput, IO], **kwargs: Any + self, validate_probe_input: Union[_models.ValidateProbeInput, IO[bytes]], **kwargs: Any ) -> _models.ValidateProbeOutput: """Check if the probe path is a valid path and the file can be accessed. Probe path is the path to a file hosted on the origin server to help accelerate the delivery of dynamic content via the CDN endpoint. This path is relative to the origin path specified in the endpoint configuration. - :param validate_probe_input: Input to check. Is either a ValidateProbeInput type or a IO type. - Required. - :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput 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 + :param validate_probe_input: Input to check. Is either a ValidateProbeInput type or a IO[bytes] + type. Required. + :type validate_probe_input: ~azure.mgmt.cdn.models.ValidateProbeInput or IO[bytes] :return: ValidateProbeOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateProbeOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -593,22 +560,21 @@ def validate_probe( else: _json = self._serialize.body(validate_probe_input, "ValidateProbeInput") - request = build_validate_probe_request( + _request = build_validate_probe_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.validate_probe.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -621,8 +587,6 @@ def validate_probe( deserialized = self._deserialize("ValidateProbeOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate_probe.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/validateProbe"} + return deserialized # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py index e15a88fc08c1..c4267008ac4d 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_custom_domains_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_endpoint_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +124,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -167,7 +167,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -207,7 +207,7 @@ def build_disable_custom_https_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -247,7 +247,7 @@ def build_enable_custom_https_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -312,7 +312,6 @@ def list_by_endpoint( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either CustomDomain or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.CustomDomain] :raises ~azure.core.exceptions.HttpResponseError: @@ -334,18 +333,17 @@ def list_by_endpoint( def prepare_request(next_link=None): if not next_link: - request = build_list_by_endpoint_request( + _request = build_list_by_endpoint_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_endpoint.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -357,13 +355,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("CustomDomainListResult", pipeline_response) @@ -373,11 +371,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,10 +388,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains" - } - @distributed_trace def get( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any @@ -410,7 +404,6 @@ def get( :type endpoint_name: str :param custom_domain_name: Name of the custom domain within an endpoint. Required. :type custom_domain_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CustomDomain or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CustomDomain :raises ~azure.core.exceptions.HttpResponseError: @@ -429,23 +422,22 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, custom_domain_name=custom_domain_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -458,13 +450,9 @@ def get( deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" - } + return deserialized # type: ignore def _create_initial( self, @@ -472,7 +460,7 @@ def _create_initial( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_properties: Union[_models.CustomDomainParameters, IO], + custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], **kwargs: Any ) -> _models.CustomDomain: error_map = { @@ -498,7 +486,7 @@ def _create_initial( else: _json = self._serialize.body(custom_domain_properties, "CustomDomainParameters") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -508,16 +496,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -544,10 +531,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" - } - @overload def begin_create( self, @@ -577,14 +560,6 @@ def begin_create( :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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -598,7 +573,7 @@ def begin_create( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_properties: IO, + custom_domain_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -616,18 +591,10 @@ def begin_create( :param custom_domain_name: Name of the custom domain within an endpoint. Required. :type custom_domain_name: str :param custom_domain_properties: Properties required to create a new custom domain. Required. - :type custom_domain_properties: IO + :type custom_domain_properties: IO[bytes] :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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -641,7 +608,7 @@ def begin_create( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_properties: Union[_models.CustomDomainParameters, IO], + custom_domain_properties: Union[_models.CustomDomainParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.CustomDomain]: """Creates a new custom domain within an endpoint. @@ -657,19 +624,8 @@ def begin_create( :param custom_domain_name: Name of the custom domain within an endpoint. Required. :type custom_domain_name: str :param custom_domain_properties: Properties required to create a new custom domain. Is either a - CustomDomainParameters type or a IO type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters 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. + CustomDomainParameters type or a IO[bytes] type. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.CustomDomainParameters or IO[bytes] :return: An instance of LROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -703,7 +659,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -713,17 +669,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CustomDomain].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" - } + return LROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any @@ -742,23 +696,22 @@ def _delete_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[Optional[_models.CustomDomain]] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, custom_domain_name=custom_domain_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -776,13 +729,9 @@ def _delete_initial( deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" - } + return deserialized # type: ignore @distributed_trace def begin_delete( @@ -800,14 +749,6 @@ def begin_delete( :type endpoint_name: str :param custom_domain_name: Name of the custom domain within an endpoint. Required. :type custom_domain_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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -842,7 +783,7 @@ def get_long_running_output(pipeline_response): deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -852,17 +793,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CustomDomain].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.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}" - } + return LROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _disable_custom_https_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any @@ -881,23 +820,22 @@ def _disable_custom_https_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CustomDomain] = kwargs.pop("cls", None) - request = build_disable_custom_https_request( + _request = build_disable_custom_https_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, custom_domain_name=custom_domain_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._disable_custom_https_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -921,10 +859,6 @@ def _disable_custom_https_initial( return deserialized # type: ignore - _disable_custom_https_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/disableCustomHttps" - } - @distributed_trace def begin_disable_custom_https( self, resource_group_name: str, profile_name: str, endpoint_name: str, custom_domain_name: str, **kwargs: Any @@ -941,14 +875,6 @@ def begin_disable_custom_https( :type endpoint_name: str :param custom_domain_name: Name of the custom domain within an endpoint. Required. :type custom_domain_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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -979,7 +905,7 @@ def begin_disable_custom_https( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -989,17 +915,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CustomDomain].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_disable_custom_https.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/disableCustomHttps" - } + return LROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _enable_custom_https_initial( self, @@ -1007,7 +931,7 @@ def _enable_custom_https_initial( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO]] = None, + custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO[bytes]]] = None, **kwargs: Any ) -> _models.CustomDomain: error_map = { @@ -1036,7 +960,7 @@ def _enable_custom_https_initial( else: _json = None - request = build_enable_custom_https_request( + _request = build_enable_custom_https_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1046,16 +970,15 @@ def _enable_custom_https_initial( content_type=content_type, json=_json, content=_content, - template_url=self._enable_custom_https_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1079,10 +1002,6 @@ def _enable_custom_https_initial( return deserialized # type: ignore - _enable_custom_https_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/enableCustomHttps" - } - @overload def begin_enable_custom_https( self, @@ -1114,14 +1033,6 @@ def begin_enable_custom_https( :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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -1135,7 +1046,7 @@ def begin_enable_custom_https( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_https_parameters: Optional[IO] = None, + custom_domain_https_parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1155,18 +1066,10 @@ def begin_enable_custom_https( :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the custom domain - using CDN managed certificate or user's own certificate. If not specified, enabling ssl uses CDN managed certificate by default. Default value is None. - :type custom_domain_https_parameters: IO + :type custom_domain_https_parameters: IO[bytes] :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 CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -1180,7 +1083,7 @@ def begin_enable_custom_https( profile_name: str, endpoint_name: str, custom_domain_name: str, - custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO]] = None, + custom_domain_https_parameters: Optional[Union[_models.CustomDomainHttpsParameters, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[_models.CustomDomain]: """Enable https delivery of the custom domain. @@ -1198,19 +1101,9 @@ def begin_enable_custom_https( :param custom_domain_https_parameters: The configuration specifying how to enable HTTPS for the custom domain - using CDN managed certificate or user's own certificate. If not specified, enabling ssl uses CDN managed certificate by default. Is either a CustomDomainHttpsParameters - type or a IO type. Default value is None. - :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters 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. + type or a IO[bytes] type. Default value is None. + :type custom_domain_https_parameters: ~azure.mgmt.cdn.models.CustomDomainHttpsParameters or + IO[bytes] :return: An instance of LROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CustomDomain] @@ -1244,7 +1137,7 @@ def begin_enable_custom_https( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1254,14 +1147,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CustomDomain].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_enable_custom_https.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/customDomains/{customDomainName}/enableCustomHttps" - } + return LROPoller[_models.CustomDomain]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py index 3476584d7147..e0c1485eb7ec 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_edge_nodes_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -40,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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +79,6 @@ def list(self, **kwargs: Any) -> Iterable["_models.EdgeNode"]: """Edgenodes are the global Point of Presence (POP) locations used to deliver CDN content to end users. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either EdgeNode or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.EdgeNode] :raises ~azure.core.exceptions.HttpResponseError: @@ -101,14 +100,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.EdgeNode"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -120,13 +118,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("EdgenodeResult", pipeline_response) @@ -136,11 +134,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -152,5 +150,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Cdn/edgenodes"} diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py index 4b99ac380ba2..01c8f64f14f7 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +78,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +112,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -149,7 +149,7 @@ def build_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -186,7 +186,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -220,7 +220,7 @@ def build_start_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -254,7 +254,7 @@ def build_stop_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -288,7 +288,7 @@ def build_purge_content_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -325,7 +325,7 @@ def build_load_content_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -362,7 +362,7 @@ def build_validate_custom_domain_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -399,7 +399,7 @@ def build_list_resource_usage_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -457,7 +457,6 @@ def list_by_profile( :param profile_name: Name of the CDN profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Endpoint or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Endpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -479,17 +478,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -501,13 +499,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("EndpointListResult", pipeline_response) @@ -517,11 +515,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -534,10 +532,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints" - } - @distributed_trace def get(self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any) -> _models.Endpoint: """Gets an existing CDN endpoint with the specified endpoint name under the specified @@ -551,7 +545,6 @@ def get(self, resource_group_name: str, profile_name: str, endpoint_name: str, * :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Endpoint or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Endpoint :raises ~azure.core.exceptions.HttpResponseError: @@ -570,22 +563,21 @@ def get(self, resource_group_name: str, profile_name: str, endpoint_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -598,20 +590,16 @@ def get(self, resource_group_name: str, profile_name: str, endpoint_name: str, * deserialized = self._deserialize("Endpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: Union[_models.Endpoint, IO], + endpoint: Union[_models.Endpoint, IO[bytes]], **kwargs: Any ) -> _models.Endpoint: error_map = { @@ -637,7 +625,7 @@ def _create_initial( else: _json = self._serialize.body(endpoint, "Endpoint") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -646,16 +634,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -682,10 +669,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } - @overload def begin_create( self, @@ -713,14 +696,6 @@ def begin_create( :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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -732,7 +707,7 @@ def begin_create( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: IO, + endpoint: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -749,18 +724,10 @@ def begin_create( Required. :type endpoint_name: str :param endpoint: Endpoint properties. Required. - :type endpoint: IO + :type endpoint: IO[bytes] :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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -772,7 +739,7 @@ def begin_create( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint: Union[_models.Endpoint, IO], + endpoint: Union[_models.Endpoint, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Endpoint]: """Creates a new CDN endpoint with the specified endpoint name under the specified subscription, @@ -786,19 +753,8 @@ def begin_create( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :param endpoint: Endpoint properties. Is either a Endpoint type or a IO type. Required. - :type endpoint: ~azure.mgmt.cdn.models.Endpoint 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. + :param endpoint: Endpoint properties. Is either a Endpoint type or a IO[bytes] type. Required. + :type endpoint: ~azure.mgmt.cdn.models.Endpoint or IO[bytes] :return: An instance of LROPoller that returns either Endpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -830,7 +786,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Endpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -840,24 +796,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Endpoint].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } + return LROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO], + endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Endpoint: error_map = { @@ -883,7 +837,7 @@ def _update_initial( else: _json = self._serialize.body(endpoint_update_properties, "EndpointUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -892,16 +846,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -925,10 +878,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } - @overload def begin_update( self, @@ -958,14 +907,6 @@ def begin_update( :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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -977,7 +918,7 @@ def begin_update( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: IO, + endpoint_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -996,18 +937,10 @@ def begin_update( Required. :type endpoint_name: str :param endpoint_update_properties: Endpoint update properties. Required. - :type endpoint_update_properties: IO + :type endpoint_update_properties: IO[bytes] :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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -1019,7 +952,7 @@ def begin_update( resource_group_name: str, profile_name: str, endpoint_name: str, - endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO], + endpoint_update_properties: Union[_models.EndpointUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Endpoint]: """Updates an existing CDN endpoint with the specified endpoint name under the specified @@ -1036,19 +969,8 @@ def begin_update( Required. :type endpoint_name: str :param endpoint_update_properties: Endpoint update properties. Is either a - EndpointUpdateParameters type or a IO type. Required. - :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters 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. + EndpointUpdateParameters type or a IO[bytes] type. Required. + :type endpoint_update_properties: ~azure.mgmt.cdn.models.EndpointUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either Endpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -1080,7 +1002,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Endpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1090,17 +1012,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Endpoint].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.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } + return LROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -1119,22 +1039,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1149,11 +1068,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -1170,14 +1085,6 @@ def begin_delete( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_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: @@ -1205,7 +1112,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1214,17 +1121,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/endpoints/{endpointName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _start_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -1243,22 +1146,21 @@ def _start_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1282,10 +1184,6 @@ def _start_initial( return deserialized # type: ignore - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/start" - } - @distributed_trace def begin_start( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -1300,14 +1198,6 @@ def begin_start( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -1336,7 +1226,7 @@ def begin_start( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Endpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1346,17 +1236,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Endpoint].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_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/start" - } + return LROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _stop_initial( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -1375,22 +1263,21 @@ def _stop_initial( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Endpoint] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1414,10 +1301,6 @@ def _stop_initial( return deserialized # type: ignore - _stop_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/stop" - } - @distributed_trace def begin_stop( self, resource_group_name: str, profile_name: str, endpoint_name: str, **kwargs: Any @@ -1432,14 +1315,6 @@ def begin_stop( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_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 Endpoint or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Endpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -1468,7 +1343,7 @@ def begin_stop( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Endpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1478,24 +1353,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Endpoint].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_stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/stop" - } + return LROPoller[_models.Endpoint]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _purge_content_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: Union[_models.PurgeParameters, IO], + content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any ) -> None: error_map = { @@ -1521,7 +1394,7 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(content_file_paths, "PurgeParameters") - request = build_purge_content_request( + _request = build_purge_content_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1530,16 +1403,15 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._purge_content_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1554,11 +1426,7 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, None, response_headers) - - _purge_content_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/purge" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload def begin_purge_content( @@ -1588,14 +1456,6 @@ def begin_purge_content( :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1607,7 +1467,7 @@ def begin_purge_content( resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: IO, + content_file_paths: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1625,18 +1485,10 @@ def begin_purge_content( :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Required. - :type content_file_paths: IO + :type content_file_paths: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1648,7 +1500,7 @@ def begin_purge_content( resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: Union[_models.PurgeParameters, IO], + content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Removes a content from CDN. @@ -1664,19 +1516,8 @@ def begin_purge_content( :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Is either a PurgeParameters - type or a IO type. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters 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. + type or a IO[bytes] type. Required. + :type content_file_paths: ~azure.mgmt.cdn.models.PurgeParameters or IO[bytes] :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: @@ -1707,7 +1548,7 @@ def begin_purge_content( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1716,24 +1557,20 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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_purge_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/purge" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _load_content_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: Union[_models.LoadParameters, IO], + content_file_paths: Union[_models.LoadParameters, IO[bytes]], **kwargs: Any ) -> None: error_map = { @@ -1759,7 +1596,7 @@ def _load_content_initial( # pylint: disable=inconsistent-return-statements else: _json = self._serialize.body(content_file_paths, "LoadParameters") - request = build_load_content_request( + _request = build_load_content_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -1768,16 +1605,15 @@ def _load_content_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._load_content_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1792,11 +1628,7 @@ def _load_content_initial( # pylint: disable=inconsistent-return-statements response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, None, response_headers) - - _load_content_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/load" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload def begin_load_content( @@ -1825,14 +1657,6 @@ def begin_load_content( :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1844,7 +1668,7 @@ def begin_load_content( resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: IO, + content_file_paths: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1861,18 +1685,10 @@ def begin_load_content( :type endpoint_name: str :param content_file_paths: The path to the content to be loaded. Path should be a full URL, e.g. ‘/pictures/city.png' which loads a single file. Required. - :type content_file_paths: IO + :type content_file_paths: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1884,7 +1700,7 @@ def begin_load_content( resource_group_name: str, profile_name: str, endpoint_name: str, - content_file_paths: Union[_models.LoadParameters, IO], + content_file_paths: Union[_models.LoadParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Pre-loads a content to CDN. Available for Verizon Profiles. @@ -1898,20 +1714,9 @@ def begin_load_content( Required. :type endpoint_name: str :param content_file_paths: The path to the content to be loaded. Path should be a full URL, - e.g. ‘/pictures/city.png' which loads a single file. Is either a LoadParameters type or a IO - type. Required. - :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters 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. + e.g. ‘/pictures/city.png' which loads a single file. Is either a LoadParameters type or a + IO[bytes] type. Required. + :type content_file_paths: ~azure.mgmt.cdn.models.LoadParameters or IO[bytes] :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: @@ -1942,7 +1747,7 @@ def begin_load_content( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1951,17 +1756,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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_load_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/load" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @overload def validate_custom_domain( @@ -1989,7 +1790,6 @@ def validate_custom_domain( :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -2001,7 +1801,7 @@ def validate_custom_domain( resource_group_name: str, profile_name: str, endpoint_name: str, - custom_domain_properties: IO, + custom_domain_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -2017,11 +1817,10 @@ def validate_custom_domain( Required. :type endpoint_name: str :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: IO + :type custom_domain_properties: IO[bytes] :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -2033,7 +1832,7 @@ def validate_custom_domain( resource_group_name: str, profile_name: str, endpoint_name: str, - custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO], + custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO[bytes]], **kwargs: Any ) -> _models.ValidateCustomDomainOutput: """Validates the custom domain mapping to ensure it maps to the correct CDN endpoint in DNS. @@ -2047,12 +1846,8 @@ def validate_custom_domain( Required. :type endpoint_name: str :param custom_domain_properties: Custom domain to be validated. Is either a - ValidateCustomDomainInput type or a IO type. Required. - :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput 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 + ValidateCustomDomainInput type or a IO[bytes] type. Required. + :type custom_domain_properties: ~azure.mgmt.cdn.models.ValidateCustomDomainInput or IO[bytes] :return: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -2080,7 +1875,7 @@ def validate_custom_domain( else: _json = self._serialize.body(custom_domain_properties, "ValidateCustomDomainInput") - request = build_validate_custom_domain_request( + _request = build_validate_custom_domain_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -2089,16 +1884,15 @@ def validate_custom_domain( content_type=content_type, json=_json, content=_content, - template_url=self.validate_custom_domain.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2111,13 +1905,9 @@ def validate_custom_domain( deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - validate_custom_domain.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/validateCustomDomain" - } + return deserialized # type: ignore @distributed_trace def list_resource_usage( @@ -2133,7 +1923,6 @@ def list_resource_usage( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceUsage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ResourceUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -2155,18 +1944,17 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -2178,13 +1966,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ResourceUsageListResult", pipeline_response) @@ -2194,11 +1982,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2210,7 +1998,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/checkResourceUsage" - } diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py index c487a8cd8004..ffd1a7d70ba4 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_log_analytics_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -54,7 +54,7 @@ def build_get_log_analytics_metrics_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -113,7 +113,7 @@ def build_get_log_analytics_rankings_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -149,13 +149,13 @@ def build_get_log_analytics_rankings_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_log_analytics_locations_request( +def build_get_log_analytics_locations_request( # pylint: disable=name-too-long resource_group_name: str, profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -182,13 +182,13 @@ def build_get_log_analytics_locations_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_log_analytics_resources_request( +def build_get_log_analytics_resources_request( # pylint: disable=name-too-long resource_group_name: str, profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -215,7 +215,7 @@ def build_get_log_analytics_resources_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_waf_log_analytics_metrics_request( +def build_get_waf_log_analytics_metrics_request( # pylint: disable=name-too-long resource_group_name: str, profile_name: str, subscription_id: str, @@ -232,7 +232,7 @@ def build_get_waf_log_analytics_metrics_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -269,7 +269,7 @@ def build_get_waf_log_analytics_metrics_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_waf_log_analytics_rankings_request( +def build_get_waf_log_analytics_rankings_request( # pylint: disable=name-too-long resource_group_name: str, profile_name: str, subscription_id: str, @@ -286,7 +286,7 @@ def build_get_waf_log_analytics_rankings_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -382,7 +382,6 @@ def get_log_analytics_metrics( :type continents: list[str] :param country_or_regions: Default value is None. :type country_or_regions: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response :return: MetricsResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.MetricsResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -401,7 +400,7 @@ def get_log_analytics_metrics( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MetricsResponse] = kwargs.pop("cls", None) - request = build_get_log_analytics_metrics_request( + _request = build_get_log_analytics_metrics_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -415,16 +414,15 @@ def get_log_analytics_metrics( continents=continents, country_or_regions=country_or_regions, api_version=api_version, - template_url=self.get_log_analytics_metrics.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -437,13 +435,9 @@ def get_log_analytics_metrics( deserialized = self._deserialize("MetricsResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_log_analytics_metrics.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsMetrics" - } + return deserialized # type: ignore @distributed_trace def get_log_analytics_rankings( @@ -477,7 +471,6 @@ def get_log_analytics_rankings( :type date_time_end: ~datetime.datetime :param custom_domains: Default value is None. :type custom_domains: list[str] - :keyword callable cls: A custom type or function that will be passed the direct response :return: RankingsResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.RankingsResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -496,7 +489,7 @@ def get_log_analytics_rankings( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RankingsResponse] = kwargs.pop("cls", None) - request = build_get_log_analytics_rankings_request( + _request = build_get_log_analytics_rankings_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -507,16 +500,15 @@ def get_log_analytics_rankings( date_time_end=date_time_end, custom_domains=custom_domains, api_version=api_version, - template_url=self.get_log_analytics_rankings.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -529,13 +521,9 @@ def get_log_analytics_rankings( deserialized = self._deserialize("RankingsResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_log_analytics_rankings.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsRankings" - } + return deserialized # type: ignore @distributed_trace def get_log_analytics_locations( @@ -548,7 +536,6 @@ def get_log_analytics_locations( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ContinentsResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ContinentsResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -567,21 +554,20 @@ def get_log_analytics_locations( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ContinentsResponse] = kwargs.pop("cls", None) - request = build_get_log_analytics_locations_request( + _request = build_get_log_analytics_locations_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_analytics_locations.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -594,13 +580,9 @@ def get_log_analytics_locations( deserialized = self._deserialize("ContinentsResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_log_analytics_locations.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsLocations" - } + return deserialized # type: ignore @distributed_trace def get_log_analytics_resources( @@ -613,7 +595,6 @@ def get_log_analytics_resources( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ResourcesResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.ResourcesResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -632,21 +613,20 @@ def get_log_analytics_resources( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ResourcesResponse] = kwargs.pop("cls", None) - request = build_get_log_analytics_resources_request( + _request = build_get_log_analytics_resources_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_log_analytics_resources.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -659,13 +639,9 @@ def get_log_analytics_resources( deserialized = self._deserialize("ResourcesResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_log_analytics_resources.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getLogAnalyticsResources" - } + return deserialized # type: ignore @distributed_trace def get_waf_log_analytics_metrics( @@ -702,7 +678,6 @@ def get_waf_log_analytics_metrics( :type group_by: list[str or ~azure.mgmt.cdn.models.WafRankingGroupBy] :param rule_types: Default value is None. :type rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] - :keyword callable cls: A custom type or function that will be passed the direct response :return: WafMetricsResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.WafMetricsResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -721,7 +696,7 @@ def get_waf_log_analytics_metrics( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WafMetricsResponse] = kwargs.pop("cls", None) - request = build_get_waf_log_analytics_metrics_request( + _request = build_get_waf_log_analytics_metrics_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -733,16 +708,15 @@ def get_waf_log_analytics_metrics( group_by=group_by, rule_types=rule_types, api_version=api_version, - template_url=self.get_waf_log_analytics_metrics.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -755,13 +729,9 @@ def get_waf_log_analytics_metrics( deserialized = self._deserialize("WafMetricsResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_waf_log_analytics_metrics.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsMetrics" - } + return deserialized # type: ignore @distributed_trace def get_waf_log_analytics_rankings( @@ -798,7 +768,6 @@ def get_waf_log_analytics_rankings( :type actions: list[str or ~azure.mgmt.cdn.models.WafAction] :param rule_types: Default value is None. :type rule_types: list[str or ~azure.mgmt.cdn.models.WafRuleType] - :keyword callable cls: A custom type or function that will be passed the direct response :return: WafRankingsResponse or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.WafRankingsResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -817,7 +786,7 @@ def get_waf_log_analytics_rankings( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.WafRankingsResponse] = kwargs.pop("cls", None) - request = build_get_waf_log_analytics_rankings_request( + _request = build_get_waf_log_analytics_rankings_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -829,16 +798,15 @@ def get_waf_log_analytics_rankings( actions=actions, rule_types=rule_types, api_version=api_version, - template_url=self.get_waf_log_analytics_rankings.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -851,10 +819,6 @@ def get_waf_log_analytics_rankings( deserialized = self._deserialize("WafRankingsResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_waf_log_analytics_rankings.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getWafLogAnalyticsRankings" - } + return deserialized # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py index 450b3804a3cf..a8cfc837fed2 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_managed_rule_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -40,7 +40,7 @@ def build_list_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-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 +86,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.ManagedRuleSetDefinition"]: """Lists all available managed rule sets. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ManagedRuleSetDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ManagedRuleSetDefinition] @@ -109,15 +108,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.ManagedRuleSetDefinition"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -129,13 +127,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ManagedRuleSetDefinitionList", pipeline_response) @@ -145,11 +143,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -161,7 +159,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/cdnWebApplicationFirewallManagedRuleSets" - } diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py index 0a325b720da9..183d22d5ab98 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -40,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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +78,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available CDN REST API 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) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Operation] :raises ~azure.core.exceptions.HttpResponseError: @@ -100,14 +99,13 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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 = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -119,13 +117,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("OperationsListResult", pipeline_response) @@ -135,11 +133,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,5 +149,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/providers/Microsoft.Cdn/operations"} diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py index a7b7d4a559ca..9ef3a1e48462 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origin_groups_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_endpoint_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +124,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -167,7 +167,7 @@ def build_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -210,7 +210,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -272,7 +272,6 @@ def list_by_endpoint( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OriginGroup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.OriginGroup] :raises ~azure.core.exceptions.HttpResponseError: @@ -294,18 +293,17 @@ def list_by_endpoint( def prepare_request(next_link=None): if not next_link: - request = build_list_by_endpoint_request( + _request = build_list_by_endpoint_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_endpoint.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -317,13 +315,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("OriginGroupListResult", pipeline_response) @@ -333,11 +331,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +348,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups" - } - @distributed_trace def get( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any @@ -371,7 +365,6 @@ def get( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_group_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: OriginGroup or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.OriginGroup :raises ~azure.core.exceptions.HttpResponseError: @@ -390,23 +383,22 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.OriginGroup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, origin_group_name=origin_group_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -419,13 +411,9 @@ def get( deserialized = self._deserialize("OriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } + return deserialized # type: ignore def _create_initial( self, @@ -433,7 +421,7 @@ def _create_initial( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group: Union[_models.OriginGroup, IO], + origin_group: Union[_models.OriginGroup, IO[bytes]], **kwargs: Any ) -> _models.OriginGroup: error_map = { @@ -459,7 +447,7 @@ def _create_initial( else: _json = self._serialize.body(origin_group, "OriginGroup") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -469,16 +457,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -505,10 +492,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } - @overload def begin_create( self, @@ -539,14 +522,6 @@ def begin_create( :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 OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -560,7 +535,7 @@ def begin_create( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group: IO, + origin_group: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -579,18 +554,10 @@ def begin_create( Required. :type origin_group_name: str :param origin_group: Origin group properties. Required. - :type origin_group: IO + :type origin_group: IO[bytes] :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 OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -604,7 +571,7 @@ def begin_create( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group: Union[_models.OriginGroup, IO], + origin_group: Union[_models.OriginGroup, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.OriginGroup]: """Creates a new origin group within the specified endpoint. @@ -620,20 +587,9 @@ def begin_create( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_group_name: str - :param origin_group: Origin group properties. Is either a OriginGroup type or a IO type. + :param origin_group: Origin group properties. Is either a OriginGroup type or a IO[bytes] type. Required. - :type origin_group: ~azure.mgmt.cdn.models.OriginGroup 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. + :type origin_group: ~azure.mgmt.cdn.models.OriginGroup or IO[bytes] :return: An instance of LROPoller that returns either OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -667,7 +623,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("OriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -677,17 +633,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OriginGroup].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } + return LROPoller[_models.OriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -695,7 +649,7 @@ def _update_initial( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO], + origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.OriginGroup: error_map = { @@ -721,7 +675,7 @@ def _update_initial( else: _json = self._serialize.body(origin_group_update_properties, "OriginGroupUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -731,16 +685,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -764,10 +717,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } - @overload def begin_update( self, @@ -798,14 +747,6 @@ def begin_update( :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 OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -819,7 +760,7 @@ def begin_update( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group_update_properties: IO, + origin_group_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -838,18 +779,10 @@ def begin_update( Required. :type origin_group_name: str :param origin_group_update_properties: Origin group properties. Required. - :type origin_group_update_properties: IO + :type origin_group_update_properties: IO[bytes] :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 OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -863,7 +796,7 @@ def begin_update( profile_name: str, endpoint_name: str, origin_group_name: str, - origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO], + origin_group_update_properties: Union[_models.OriginGroupUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.OriginGroup]: """Updates an existing origin group within an endpoint. @@ -880,19 +813,9 @@ def begin_update( Required. :type origin_group_name: str :param origin_group_update_properties: Origin group properties. Is either a - OriginGroupUpdateParameters type or a IO type. Required. - :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters 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. + OriginGroupUpdateParameters type or a IO[bytes] type. Required. + :type origin_group_update_properties: ~azure.mgmt.cdn.models.OriginGroupUpdateParameters or + IO[bytes] :return: An instance of LROPoller that returns either OriginGroup or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.OriginGroup] @@ -926,7 +849,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("OriginGroup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -936,17 +859,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.OriginGroup].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.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } + return LROPoller[_models.OriginGroup]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_group_name: str, **kwargs: Any @@ -965,23 +886,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, origin_group_name=origin_group_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -996,11 +916,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -1019,14 +935,6 @@ def begin_delete( :param origin_group_name: Name of the origin group which is unique within the endpoint. Required. :type origin_group_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: @@ -1055,7 +963,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1064,14 +972,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/endpoints/{endpointName}/originGroups/{originGroupName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py index 14567dd263bb..19dd676b5614 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_origins_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_endpoint_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +124,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -167,7 +167,7 @@ def build_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -210,7 +210,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -272,7 +272,6 @@ def list_by_endpoint( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Origin or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Origin] :raises ~azure.core.exceptions.HttpResponseError: @@ -294,18 +293,17 @@ def list_by_endpoint( def prepare_request(next_link=None): if not next_link: - request = build_list_by_endpoint_request( + _request = build_list_by_endpoint_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_endpoint.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -317,13 +315,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("OriginListResult", pipeline_response) @@ -333,11 +331,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +348,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins" - } - @distributed_trace def get( self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any @@ -370,7 +364,6 @@ def get( :type endpoint_name: str :param origin_name: Name of the origin which is unique within the endpoint. Required. :type origin_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Origin or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Origin :raises ~azure.core.exceptions.HttpResponseError: @@ -389,23 +382,22 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Origin] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, origin_name=origin_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -418,13 +410,9 @@ def get( deserialized = self._deserialize("Origin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } + return deserialized # type: ignore def _create_initial( self, @@ -432,7 +420,7 @@ def _create_initial( profile_name: str, endpoint_name: str, origin_name: str, - origin: Union[_models.Origin, IO], + origin: Union[_models.Origin, IO[bytes]], **kwargs: Any ) -> _models.Origin: error_map = { @@ -458,7 +446,7 @@ def _create_initial( else: _json = self._serialize.body(origin, "Origin") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -468,16 +456,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -504,10 +491,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } - @overload def begin_create( self, @@ -537,14 +520,6 @@ def begin_create( :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 Origin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] :raises ~azure.core.exceptions.HttpResponseError: @@ -557,7 +532,7 @@ def begin_create( profile_name: str, endpoint_name: str, origin_name: str, - origin: IO, + origin: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -575,18 +550,10 @@ def begin_create( :param origin_name: Name of the origin that is unique within the endpoint. Required. :type origin_name: str :param origin: Origin properties. Required. - :type origin: IO + :type origin: IO[bytes] :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 Origin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] :raises ~azure.core.exceptions.HttpResponseError: @@ -599,7 +566,7 @@ def begin_create( profile_name: str, endpoint_name: str, origin_name: str, - origin: Union[_models.Origin, IO], + origin: Union[_models.Origin, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Origin]: """Creates a new origin within the specified endpoint. @@ -614,19 +581,8 @@ def begin_create( :type endpoint_name: str :param origin_name: Name of the origin that is unique within the endpoint. Required. :type origin_name: str - :param origin: Origin properties. Is either a Origin type or a IO type. Required. - :type origin: ~azure.mgmt.cdn.models.Origin 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. + :param origin: Origin properties. Is either a Origin type or a IO[bytes] type. Required. + :type origin: ~azure.mgmt.cdn.models.Origin or IO[bytes] :return: An instance of LROPoller that returns either Origin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] :raises ~azure.core.exceptions.HttpResponseError: @@ -659,7 +615,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Origin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -669,17 +625,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Origin].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } + return LROPoller[_models.Origin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -687,7 +641,7 @@ def _update_initial( profile_name: str, endpoint_name: str, origin_name: str, - origin_update_properties: Union[_models.OriginUpdateParameters, IO], + origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Origin: error_map = { @@ -713,7 +667,7 @@ def _update_initial( else: _json = self._serialize.body(origin_update_properties, "OriginUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -723,16 +677,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -756,10 +709,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } - @overload def begin_update( self, @@ -789,14 +738,6 @@ def begin_update( :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 Origin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] :raises ~azure.core.exceptions.HttpResponseError: @@ -809,7 +750,7 @@ def begin_update( profile_name: str, endpoint_name: str, origin_name: str, - origin_update_properties: IO, + origin_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -827,18 +768,10 @@ def begin_update( :param origin_name: Name of the origin which is unique within the endpoint. Required. :type origin_name: str :param origin_update_properties: Origin properties. Required. - :type origin_update_properties: IO + :type origin_update_properties: IO[bytes] :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 Origin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] :raises ~azure.core.exceptions.HttpResponseError: @@ -851,7 +784,7 @@ def begin_update( profile_name: str, endpoint_name: str, origin_name: str, - origin_update_properties: Union[_models.OriginUpdateParameters, IO], + origin_update_properties: Union[_models.OriginUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Origin]: """Updates an existing origin within an endpoint. @@ -867,19 +800,8 @@ def begin_update( :param origin_name: Name of the origin which is unique within the endpoint. Required. :type origin_name: str :param origin_update_properties: Origin properties. Is either a OriginUpdateParameters type or - a IO type. Required. - :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters 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. + a IO[bytes] type. Required. + :type origin_update_properties: ~azure.mgmt.cdn.models.OriginUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either Origin or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Origin] :raises ~azure.core.exceptions.HttpResponseError: @@ -912,7 +834,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Origin", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -922,17 +844,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Origin].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.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } + return LROPoller[_models.Origin]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, origin_name: str, **kwargs: Any @@ -951,23 +871,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, origin_name=origin_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -982,11 +901,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -1004,14 +919,6 @@ def begin_delete( :type endpoint_name: str :param origin_name: Name of the origin which is unique within the endpoint. Required. :type origin_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: @@ -1040,7 +947,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1049,14 +956,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/endpoints/{endpointName}/origins/{originName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py index a8792e1b4e39..66b742af3e13 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -43,7 +43,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +78,7 @@ def build_get_request(resource_group_name: str, policy_name: str, subscription_i _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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -116,7 +116,7 @@ def build_create_or_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -157,7 +157,7 @@ def build_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -198,7 +198,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -255,7 +255,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cdn :param resource_group_name: Name of the Resource group within the Azure 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 CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] @@ -278,16 +277,15 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Cdn def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -299,13 +297,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("CdnWebApplicationFirewallPolicyList", pipeline_response) @@ -315,11 +313,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -332,10 +330,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies" - } - @distributed_trace def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _models.CdnWebApplicationFirewallPolicy: """Retrieve protection policy with specified name within a resource group. @@ -344,7 +338,6 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod :type resource_group_name: str :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. :type policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -363,21 +356,20 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.CdnWebApplicationFirewallPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, policy_name=policy_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -390,19 +382,15 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, policy_name: str, - cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO], + cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any ) -> _models.CdnWebApplicationFirewallPolicy: error_map = { @@ -428,7 +416,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(cdn_web_application_firewall_policy, "CdnWebApplicationFirewallPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, policy_name=policy_name, subscription_id=self._config.subscription_id, @@ -436,16 +424,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -472,10 +459,6 @@ def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } - @overload def begin_create_or_update( self, @@ -498,14 +481,6 @@ def begin_create_or_update( :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 CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] @@ -517,7 +492,7 @@ def begin_create_or_update( self, resource_group_name: str, policy_name: str, - cdn_web_application_firewall_policy: IO, + cdn_web_application_firewall_policy: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -529,18 +504,10 @@ def begin_create_or_update( :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. :type policy_name: str :param cdn_web_application_firewall_policy: Policy to be created. Required. - :type cdn_web_application_firewall_policy: IO + :type cdn_web_application_firewall_policy: IO[bytes] :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 CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] @@ -552,7 +519,7 @@ def begin_create_or_update( self, resource_group_name: str, policy_name: str, - cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO], + cdn_web_application_firewall_policy: Union[_models.CdnWebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: """Create or update policy with specified rule set name within a resource group. @@ -562,20 +529,9 @@ def begin_create_or_update( :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. :type policy_name: str :param cdn_web_application_firewall_policy: Policy to be created. Is either a - CdnWebApplicationFirewallPolicy type or a IO type. Required. + CdnWebApplicationFirewallPolicy type or a IO[bytes] type. Required. :type cdn_web_application_firewall_policy: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy 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. + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy or IO[bytes] :return: An instance of LROPoller that returns either CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] @@ -607,7 +563,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -617,24 +573,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CdnWebApplicationFirewallPolicy].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.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } + return LROPoller[_models.CdnWebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, policy_name: str, cdn_web_application_firewall_policy_patch_parameters: Union[ - _models.CdnWebApplicationFirewallPolicyPatchParameters, IO + _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] ], **kwargs: Any ) -> _models.CdnWebApplicationFirewallPolicy: @@ -663,7 +617,7 @@ def _update_initial( cdn_web_application_firewall_policy_patch_parameters, "CdnWebApplicationFirewallPolicyPatchParameters" ) - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, policy_name=policy_name, subscription_id=self._config.subscription_id, @@ -671,16 +625,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -704,10 +657,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } - @overload def begin_update( self, @@ -732,14 +681,6 @@ def begin_update( :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 CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] @@ -751,7 +692,7 @@ def begin_update( self, resource_group_name: str, policy_name: str, - cdn_web_application_firewall_policy_patch_parameters: IO, + cdn_web_application_firewall_policy_patch_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -765,18 +706,10 @@ def begin_update( :type policy_name: str :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy parameters to be patched. Required. - :type cdn_web_application_firewall_policy_patch_parameters: IO + :type cdn_web_application_firewall_policy_patch_parameters: IO[bytes] :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 CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] @@ -789,7 +722,7 @@ def begin_update( resource_group_name: str, policy_name: str, cdn_web_application_firewall_policy_patch_parameters: Union[ - _models.CdnWebApplicationFirewallPolicyPatchParameters, IO + _models.CdnWebApplicationFirewallPolicyPatchParameters, IO[bytes] ], **kwargs: Any ) -> LROPoller[_models.CdnWebApplicationFirewallPolicy]: @@ -802,20 +735,9 @@ def begin_update( :type policy_name: str :param cdn_web_application_firewall_policy_patch_parameters: CdnWebApplicationFirewallPolicy parameters to be patched. Is either a CdnWebApplicationFirewallPolicyPatchParameters type or a - IO type. Required. + IO[bytes] type. Required. :type cdn_web_application_firewall_policy_patch_parameters: - ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters 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. + ~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicyPatchParameters or IO[bytes] :return: An instance of LROPoller that returns either CdnWebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CdnWebApplicationFirewallPolicy] @@ -847,7 +769,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CdnWebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -857,17 +779,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CdnWebApplicationFirewallPolicy].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.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } + return LROPoller[_models.CdnWebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -879,7 +799,6 @@ def delete( # pylint: disable=inconsistent-return-statements :type resource_group_name: str :param policy_name: The name of the CdnWebApplicationFirewallPolicy. Required. :type policy_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: @@ -898,21 +817,20 @@ def delete( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, policy_name=policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -923,8 +841,4 @@ def delete( # pylint: disable=inconsistent-return-statements 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.Cdn/cdnWebApplicationFirewallPolicies/{policyName}" - } + return cls(pipeline_response, None, {}) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py index 544ad94c8097..0997b55f675d 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_profiles_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -43,7 +43,7 @@ def build_list_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +67,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -97,7 +97,7 @@ def build_get_request(resource_group_name: str, profile_name: str, subscription_ _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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -130,7 +130,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -166,7 +166,7 @@ def build_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -202,7 +202,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -233,7 +233,7 @@ def build_can_migrate_request(resource_group_name: str, subscription_id: str, ** _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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -266,7 +266,7 @@ def build_migrate_request(resource_group_name: str, subscription_id: str, **kwar _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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -301,7 +301,7 @@ def build_migration_commit_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -334,7 +334,7 @@ def build_generate_sso_uri_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -361,13 +361,13 @@ def build_generate_sso_uri_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_supported_optimization_types_request( +def build_list_supported_optimization_types_request( # pylint: disable=name-too-long resource_group_name: str, profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -400,7 +400,7 @@ def build_list_resource_usage_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -451,7 +451,6 @@ def list(self, **kwargs: Any) -> Iterable["_models.Profile"]: """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within an Azure subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Profile or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -473,15 +472,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Profile"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -493,13 +491,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ProfileListResult", pipeline_response) @@ -509,11 +507,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -526,8 +524,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/profiles"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Profile"]: """Lists all of the Azure Front Door Standard, Azure Front Door Premium, and CDN profiles within a @@ -535,7 +531,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: Name of the Resource group within the Azure 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 Profile or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -557,16 +552,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -578,13 +572,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ProfileListResult", pipeline_response) @@ -594,11 +588,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -611,10 +605,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles" - } - @distributed_trace def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.Profile: """Gets an Azure Front Door Standard or Azure Front Door Premium or CDN profile with the specified @@ -625,7 +615,6 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Profile or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Profile :raises ~azure.core.exceptions.HttpResponseError: @@ -644,21 +633,20 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Profile] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -671,16 +659,12 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" - } + return deserialized # type: ignore def _create_initial( - self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO], **kwargs: Any + self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO[bytes]], **kwargs: Any ) -> _models.Profile: error_map = { 401: ClientAuthenticationError, @@ -705,7 +689,7 @@ def _create_initial( else: _json = self._serialize.body(profile, "Profile") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -713,16 +697,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -749,10 +732,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" - } - @overload def begin_create( self, @@ -776,14 +755,6 @@ def begin_create( :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -794,7 +765,7 @@ def begin_create( self, resource_group_name: str, profile_name: str, - profile: IO, + profile: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -808,18 +779,10 @@ def begin_create( profile which is unique within the resource group. Required. :type profile_name: str :param profile: Profile properties needed to create a new profile. Required. - :type profile: IO + :type profile: IO[bytes] :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -827,7 +790,7 @@ def begin_create( @distributed_trace def begin_create( - self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO], **kwargs: Any + self, resource_group_name: str, profile_name: str, profile: Union[_models.Profile, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Profile]: """Creates a new Azure Front Door Standard or Azure Front Door Premium or CDN profile with a profile name under the specified subscription and resource group. @@ -838,19 +801,8 @@ def begin_create( profile which is unique within the resource group. Required. :type profile_name: str :param profile: Profile properties needed to create a new profile. Is either a Profile type or - a IO type. Required. - :type profile: ~azure.mgmt.cdn.models.Profile 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. + a IO[bytes] type. Required. + :type profile: ~azure.mgmt.cdn.models.Profile or IO[bytes] :return: An instance of LROPoller that returns either Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -881,7 +833,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -891,23 +843,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Profile].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" - } + return LROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, profile_name: str, - profile_update_parameters: Union[_models.ProfileUpdateParameters, IO], + profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Profile: error_map = { @@ -933,7 +883,7 @@ def _update_initial( else: _json = self._serialize.body(profile_update_parameters, "ProfileUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -941,16 +891,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -974,10 +923,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}" - } - @overload def begin_update( self, @@ -1002,14 +947,6 @@ def begin_update( :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -1020,7 +957,7 @@ def begin_update( self, resource_group_name: str, profile_name: str, - profile_update_parameters: IO, + profile_update_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1035,18 +972,10 @@ def begin_update( :type profile_name: str :param profile_update_parameters: Profile properties needed to update an existing profile. Required. - :type profile_update_parameters: IO + :type profile_update_parameters: IO[bytes] :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -1057,7 +986,7 @@ def begin_update( self, resource_group_name: str, profile_name: str, - profile_update_parameters: Union[_models.ProfileUpdateParameters, IO], + profile_update_parameters: Union[_models.ProfileUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Profile]: """Updates an existing Azure Front Door Standard or Azure Front Door Premium or CDN profile with @@ -1069,19 +998,8 @@ def begin_update( profile which is unique within the resource group. Required. :type profile_name: str :param profile_update_parameters: Profile properties needed to update an existing profile. Is - either a ProfileUpdateParameters type or a IO type. Required. - :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters 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. + either a ProfileUpdateParameters type or a IO[bytes] type. Required. + :type profile_update_parameters: ~azure.mgmt.cdn.models.ProfileUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -1112,7 +1030,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1122,17 +1040,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Profile].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.Cdn/profiles/{profileName}" - } + return LROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, **kwargs: Any @@ -1151,21 +1067,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1180,11 +1095,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1197,14 +1108,6 @@ def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: An :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile which is unique within the resource group. Required. :type profile_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: @@ -1231,7 +1134,7 @@ def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: An def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1240,20 +1143,19 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _can_migrate_initial( - self, resource_group_name: str, can_migrate_parameters: Union[_models.CanMigrateParameters, IO], **kwargs: Any + self, + resource_group_name: str, + can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], + **kwargs: Any ) -> Optional[_models.CanMigrateResult]: error_map = { 401: ClientAuthenticationError, @@ -1278,23 +1180,22 @@ def _can_migrate_initial( else: _json = self._serialize.body(can_migrate_parameters, "CanMigrateParameters") - request = build_can_migrate_request( + _request = build_can_migrate_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._can_migrate_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1313,13 +1214,9 @@ def _can_migrate_initial( response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _can_migrate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/canMigrate" - } + return deserialized # type: ignore @overload def begin_can_migrate( @@ -1340,14 +1237,6 @@ def begin_can_migrate( :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 CanMigrateResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] @@ -1358,7 +1247,7 @@ def begin_can_migrate( def begin_can_migrate( self, resource_group_name: str, - can_migrate_parameters: IO, + can_migrate_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1369,18 +1258,10 @@ def begin_can_migrate( :type resource_group_name: str :param can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor can be migrated. Required. - :type can_migrate_parameters: IO + :type can_migrate_parameters: IO[bytes] :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 CanMigrateResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] @@ -1389,26 +1270,18 @@ def begin_can_migrate( @distributed_trace def begin_can_migrate( - self, resource_group_name: str, can_migrate_parameters: Union[_models.CanMigrateParameters, IO], **kwargs: Any + self, + resource_group_name: str, + can_migrate_parameters: Union[_models.CanMigrateParameters, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.CanMigrateResult]: """Checks if CDN profile can be migrated to Azure Frontdoor(Standard/Premium) profile. :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param can_migrate_parameters: Properties needed to check if cdn profile or classic frontdoor - can be migrated. Is either a CanMigrateParameters type or a IO type. Required. - :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters 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. + can be migrated. Is either a CanMigrateParameters type or a IO[bytes] type. Required. + :type can_migrate_parameters: ~azure.mgmt.cdn.models.CanMigrateParameters or IO[bytes] :return: An instance of LROPoller that returns either CanMigrateResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.CanMigrateResult] @@ -1439,7 +1312,7 @@ def begin_can_migrate( def get_long_running_output(pipeline_response): deserialized = self._deserialize("CanMigrateResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1451,20 +1324,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.CanMigrateResult].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_can_migrate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/canMigrate" - } + return LROPoller[_models.CanMigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _migrate_initial( - self, resource_group_name: str, migration_parameters: Union[_models.MigrationParameters, IO], **kwargs: Any + self, + resource_group_name: str, + migration_parameters: Union[_models.MigrationParameters, IO[bytes]], + **kwargs: Any ) -> _models.MigrateResult: error_map = { 401: ClientAuthenticationError, @@ -1489,23 +1363,22 @@ def _migrate_initial( else: _json = self._serialize.body(migration_parameters, "MigrationParameters") - request = build_migrate_request( + _request = build_migrate_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self._migrate_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1529,10 +1402,6 @@ def _migrate_initial( return deserialized # type: ignore - _migrate_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/migrate" - } - @overload def begin_migrate( self, @@ -1552,14 +1421,6 @@ def begin_migrate( :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 MigrateResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] @@ -1570,7 +1431,7 @@ def begin_migrate( def begin_migrate( self, resource_group_name: str, - migration_parameters: IO, + migration_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -1581,18 +1442,10 @@ def begin_migrate( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param migration_parameters: Properties needed to migrate the profile. Required. - :type migration_parameters: IO + :type migration_parameters: IO[bytes] :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 MigrateResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] @@ -1601,7 +1454,10 @@ def begin_migrate( @distributed_trace def begin_migrate( - self, resource_group_name: str, migration_parameters: Union[_models.MigrationParameters, IO], **kwargs: Any + self, + resource_group_name: str, + migration_parameters: Union[_models.MigrationParameters, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.MigrateResult]: """Migrate the CDN profile to Azure Frontdoor(Standard/Premium) profile. The change need to be committed after this. @@ -1609,19 +1465,8 @@ def begin_migrate( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param migration_parameters: Properties needed to migrate the profile. Is either a - MigrationParameters type or a IO type. Required. - :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters 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. + MigrationParameters type or a IO[bytes] type. Required. + :type migration_parameters: ~azure.mgmt.cdn.models.MigrationParameters or IO[bytes] :return: An instance of LROPoller that returns either MigrateResult or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.MigrateResult] @@ -1652,7 +1497,7 @@ def begin_migrate( def get_long_running_output(pipeline_response): deserialized = self._deserialize("MigrateResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -1664,17 +1509,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.MigrateResult].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_migrate.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/migrate" - } + return LROPoller[_models.MigrateResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _migration_commit_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, **kwargs: Any @@ -1693,21 +1536,20 @@ def _migration_commit_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_migration_commit_request( + _request = build_migration_commit_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._migration_commit_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1722,11 +1564,7 @@ def _migration_commit_initial( # pylint: disable=inconsistent-return-statements response_headers["location"] = self._deserialize("str", response.headers.get("location")) if cls: - return cls(pipeline_response, None, response_headers) - - _migration_commit_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/migrationCommit" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_migration_commit(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1737,14 +1575,6 @@ def begin_migration_commit(self, resource_group_name: str, profile_name: str, ** :param profile_name: Name of the CDN profile which is unique within the resource group. Required. :type profile_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: @@ -1771,7 +1601,7 @@ def begin_migration_commit(self, resource_group_name: str, profile_name: str, ** def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1782,17 +1612,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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_migration_commit.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/migrationCommit" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.SsoUri: @@ -1807,7 +1633,6 @@ def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs :param profile_name: Name of the CDN profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SsoUri or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.SsoUri :raises ~azure.core.exceptions.HttpResponseError: @@ -1826,21 +1651,20 @@ def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SsoUri] = kwargs.pop("cls", None) - request = build_generate_sso_uri_request( + _request = build_generate_sso_uri_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.generate_sso_uri.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1853,13 +1677,9 @@ def generate_sso_uri(self, resource_group_name: str, profile_name: str, **kwargs deserialized = self._deserialize("SsoUri", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - generate_sso_uri.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/generateSsoUri" - } + return deserialized # type: ignore @distributed_trace def list_supported_optimization_types( @@ -1873,7 +1693,6 @@ def list_supported_optimization_types( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SupportedOptimizationTypesListResult or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.SupportedOptimizationTypesListResult :raises ~azure.core.exceptions.HttpResponseError: @@ -1892,21 +1711,20 @@ def list_supported_optimization_types( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SupportedOptimizationTypesListResult] = kwargs.pop("cls", None) - request = build_list_supported_optimization_types_request( + _request = build_list_supported_optimization_types_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_supported_optimization_types.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1919,13 +1737,9 @@ def list_supported_optimization_types( deserialized = self._deserialize("SupportedOptimizationTypesListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list_supported_optimization_types.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/getSupportedOptimizationTypes" - } + return deserialized # type: ignore @distributed_trace def list_resource_usage( @@ -1939,7 +1753,6 @@ def list_resource_usage( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium or CDN profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceUsage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ResourceUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -1961,17 +1774,16 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1983,13 +1795,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ResourceUsageListResult", pipeline_response) @@ -1999,11 +1811,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -2015,7 +1827,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/checkResourceUsage" - } diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py index 4f3afd191cb9..5b4b5c1ff2e1 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_resource_usage_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -40,7 +40,7 @@ def build_list_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +83,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.ResourceUsage"]: """Check the quota and actual usage of the CDN profiles under the given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ResourceUsage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.ResourceUsage] :raises ~azure.core.exceptions.HttpResponseError: @@ -105,15 +104,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.ResourceUsage"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -125,13 +123,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ResourceUsageListResult", pipeline_response) @@ -141,11 +139,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -157,5 +155,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Cdn/checkResourceUsage"} diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py index b32b6c93fb2d..1472a7498366 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_routes_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_endpoint_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +124,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -167,7 +167,7 @@ def build_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -210,7 +210,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -272,7 +272,6 @@ def list_by_endpoint( :param endpoint_name: Name of the endpoint under the profile which is unique globally. Required. :type endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Route or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -294,18 +293,17 @@ def list_by_endpoint( def prepare_request(next_link=None): if not next_link: - request = build_list_by_endpoint_request( + _request = build_list_by_endpoint_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_endpoint.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -317,13 +315,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("RouteListResult", pipeline_response) @@ -333,11 +331,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,10 +348,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_endpoint.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes" - } - @distributed_trace def get( self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any @@ -371,7 +365,6 @@ def get( :type endpoint_name: str :param route_name: Name of the routing rule. Required. :type route_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Route or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Route :raises ~azure.core.exceptions.HttpResponseError: @@ -390,23 +383,22 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Route] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, route_name=route_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -419,13 +411,9 @@ def get( deserialized = self._deserialize("Route", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } + return deserialized # type: ignore def _create_initial( self, @@ -433,7 +421,7 @@ def _create_initial( profile_name: str, endpoint_name: str, route_name: str, - route: Union[_models.Route, IO], + route: Union[_models.Route, IO[bytes]], **kwargs: Any ) -> _models.Route: error_map = { @@ -459,7 +447,7 @@ def _create_initial( else: _json = self._serialize.body(route, "Route") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -469,16 +457,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -505,10 +492,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } - @overload def begin_create( self, @@ -539,14 +522,6 @@ def begin_create( :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 Route or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -559,7 +534,7 @@ def begin_create( profile_name: str, endpoint_name: str, route_name: str, - route: IO, + route: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -578,18 +553,10 @@ def begin_create( :param route_name: Name of the routing rule. Required. :type route_name: str :param route: Route properties. Required. - :type route: IO + :type route: IO[bytes] :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 Route or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -602,7 +569,7 @@ def begin_create( profile_name: str, endpoint_name: str, route_name: str, - route: Union[_models.Route, IO], + route: Union[_models.Route, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Route]: """Creates a new route with the specified route name under the specified subscription, resource @@ -618,19 +585,8 @@ def begin_create( :type endpoint_name: str :param route_name: Name of the routing rule. Required. :type route_name: str - :param route: Route properties. Is either a Route type or a IO type. Required. - :type route: ~azure.mgmt.cdn.models.Route 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. + :param route: Route properties. Is either a Route type or a IO[bytes] type. Required. + :type route: ~azure.mgmt.cdn.models.Route or IO[bytes] :return: An instance of LROPoller that returns either Route or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -663,7 +619,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Route", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -675,17 +631,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Route].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } + return LROPoller[_models.Route]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -693,7 +647,7 @@ def _update_initial( profile_name: str, endpoint_name: str, route_name: str, - route_update_properties: Union[_models.RouteUpdateParameters, IO], + route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Route: error_map = { @@ -719,7 +673,7 @@ def _update_initial( else: _json = self._serialize.body(route_update_properties, "RouteUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, @@ -729,16 +683,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -762,10 +715,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } - @overload def begin_update( self, @@ -796,14 +745,6 @@ def begin_update( :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 Route or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -816,7 +757,7 @@ def begin_update( profile_name: str, endpoint_name: str, route_name: str, - route_update_properties: IO, + route_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -835,18 +776,10 @@ def begin_update( :param route_name: Name of the routing rule. Required. :type route_name: str :param route_update_properties: Route update properties. Required. - :type route_update_properties: IO + :type route_update_properties: IO[bytes] :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 Route or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -859,7 +792,7 @@ def begin_update( profile_name: str, endpoint_name: str, route_name: str, - route_update_properties: Union[_models.RouteUpdateParameters, IO], + route_update_properties: Union[_models.RouteUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Route]: """Updates an existing route with the specified route name under the specified subscription, @@ -876,19 +809,8 @@ def begin_update( :param route_name: Name of the routing rule. Required. :type route_name: str :param route_update_properties: Route update properties. Is either a RouteUpdateParameters type - or a IO type. Required. - :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters 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. + or a IO[bytes] type. Required. + :type route_update_properties: ~azure.mgmt.cdn.models.RouteUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either Route or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Route] :raises ~azure.core.exceptions.HttpResponseError: @@ -921,7 +843,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Route", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -933,17 +855,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Route].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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } + return LROPoller[_models.Route]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, endpoint_name: str, route_name: str, **kwargs: Any @@ -962,23 +882,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, endpoint_name=endpoint_name, route_name=route_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -993,11 +912,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -1016,14 +931,6 @@ def begin_delete( :type endpoint_name: str :param route_name: Name of the routing rule. Required. :type route_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: @@ -1052,7 +959,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1063,14 +970,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/afdEndpoints/{endpointName}/routes/{routeName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py index f714c7c27254..04771c92a8eb 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rule_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -44,7 +44,7 @@ def build_list_by_profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -77,7 +77,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -111,7 +111,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -145,7 +145,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -179,7 +179,7 @@ def build_list_resource_usage_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -237,7 +237,6 @@ def list_by_profile( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RuleSet or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.RuleSet] :raises ~azure.core.exceptions.HttpResponseError: @@ -259,17 +258,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -281,13 +279,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("RuleSetListResult", pipeline_response) @@ -297,11 +295,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -314,10 +312,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets" - } - @distributed_trace def get(self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any) -> _models.RuleSet: """Gets an existing AzureFrontDoor rule set with the specified rule set name under the specified @@ -331,7 +325,6 @@ def get(self, resource_group_name: str, profile_name: str, rule_set_name: str, * :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RuleSet or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.RuleSet :raises ~azure.core.exceptions.HttpResponseError: @@ -350,22 +343,21 @@ def get(self, resource_group_name: str, profile_name: str, rule_set_name: str, * api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -378,13 +370,9 @@ def get(self, resource_group_name: str, profile_name: str, rule_set_name: str, * deserialized = self._deserialize("RuleSet", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}" - } + return deserialized # type: ignore @distributed_trace def create(self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any) -> _models.RuleSet: @@ -398,7 +386,6 @@ def create(self, resource_group_name: str, profile_name: str, rule_set_name: str :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RuleSet or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.RuleSet :raises ~azure.core.exceptions.HttpResponseError: @@ -417,22 +404,21 @@ def create(self, resource_group_name: str, profile_name: str, rule_set_name: str api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.RuleSet] = kwargs.pop("cls", None) - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -453,10 +439,6 @@ def create(self, resource_group_name: str, profile_name: str, rule_set_name: str return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}" - } - def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, rule_set_name: str, **kwargs: Any ) -> None: @@ -474,22 +456,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -504,11 +485,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -525,14 +502,6 @@ def begin_delete( :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. :type rule_set_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: @@ -560,7 +529,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -571,17 +540,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def list_resource_usage( @@ -597,7 +562,6 @@ def list_resource_usage( :param rule_set_name: Name of the rule set under the profile which is unique globally. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Usage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Usage] :raises ~azure.core.exceptions.HttpResponseError: @@ -619,18 +583,17 @@ def list_resource_usage( def prepare_request(next_link=None): if not next_link: - request = build_list_resource_usage_request( + _request = build_list_resource_usage_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_resource_usage.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -642,13 +605,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("UsagesListResult", pipeline_response) @@ -658,11 +621,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -674,7 +637,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_resource_usage.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/usages" - } diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py index 20299ed5169b..81b284fe983d 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_rules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_rule_set_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +79,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -114,7 +114,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -152,7 +152,7 @@ def build_update_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -190,7 +190,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -251,7 +251,6 @@ def list_by_rule_set( :type profile_name: str :param rule_set_name: Name of the rule set under the profile. Required. :type rule_set_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Rule or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -273,18 +272,17 @@ def list_by_rule_set( def prepare_request(next_link=None): if not next_link: - request = build_list_by_rule_set_request( + _request = build_list_by_rule_set_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_rule_set.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -296,13 +294,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("RuleListResult", pipeline_response) @@ -312,11 +310,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -329,10 +327,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_rule_set.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules" - } - @distributed_trace def get( self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any @@ -348,7 +342,6 @@ def get( :type rule_set_name: str :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Rule or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Rule :raises ~azure.core.exceptions.HttpResponseError: @@ -367,23 +360,22 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Rule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, rule_name=rule_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -396,13 +388,9 @@ def get( deserialized = self._deserialize("Rule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } + return deserialized # type: ignore def _create_initial( self, @@ -410,7 +398,7 @@ def _create_initial( profile_name: str, rule_set_name: str, rule_name: str, - rule: Union[_models.Rule, IO], + rule: Union[_models.Rule, IO[bytes]], **kwargs: Any ) -> _models.Rule: error_map = { @@ -436,7 +424,7 @@ def _create_initial( else: _json = self._serialize.body(rule, "Rule") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -446,16 +434,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -482,10 +469,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } - @overload def begin_create( self, @@ -514,14 +497,6 @@ def begin_create( :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 Rule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -534,7 +509,7 @@ def begin_create( profile_name: str, rule_set_name: str, rule_name: str, - rule: IO, + rule: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -551,18 +526,10 @@ def begin_create( :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_name: str :param rule: The delivery rule properties. Required. - :type rule: IO + :type rule: IO[bytes] :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 Rule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -575,7 +542,7 @@ def begin_create( profile_name: str, rule_set_name: str, rule_name: str, - rule: Union[_models.Rule, IO], + rule: Union[_models.Rule, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Rule]: """Creates a new delivery rule within the specified rule set. @@ -589,19 +556,8 @@ def begin_create( :type rule_set_name: str :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_name: str - :param rule: The delivery rule properties. Is either a Rule type or a IO type. Required. - :type rule: ~azure.mgmt.cdn.models.Rule 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. + :param rule: The delivery rule properties. Is either a Rule type or a IO[bytes] type. Required. + :type rule: ~azure.mgmt.cdn.models.Rule or IO[bytes] :return: An instance of LROPoller that returns either Rule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -634,7 +590,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Rule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -646,17 +602,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Rule].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } + return LROPoller[_models.Rule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, @@ -664,7 +618,7 @@ def _update_initial( profile_name: str, rule_set_name: str, rule_name: str, - rule_update_properties: Union[_models.RuleUpdateParameters, IO], + rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.Rule: error_map = { @@ -690,7 +644,7 @@ def _update_initial( else: _json = self._serialize.body(rule_update_properties, "RuleUpdateParameters") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, @@ -700,16 +654,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -733,10 +686,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } - @overload def begin_update( self, @@ -765,14 +714,6 @@ def begin_update( :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 Rule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -785,7 +726,7 @@ def begin_update( profile_name: str, rule_set_name: str, rule_name: str, - rule_update_properties: IO, + rule_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -802,18 +743,10 @@ def begin_update( :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_name: str :param rule_update_properties: Delivery rule properties. Required. - :type rule_update_properties: IO + :type rule_update_properties: IO[bytes] :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 Rule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -826,7 +759,7 @@ def begin_update( profile_name: str, rule_set_name: str, rule_name: str, - rule_update_properties: Union[_models.RuleUpdateParameters, IO], + rule_update_properties: Union[_models.RuleUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Rule]: """Updates an existing delivery rule within a rule set. @@ -841,19 +774,8 @@ def begin_update( :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_name: str :param rule_update_properties: Delivery rule properties. Is either a RuleUpdateParameters type - or a IO type. Required. - :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters 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. + or a IO[bytes] type. Required. + :type rule_update_properties: ~azure.mgmt.cdn.models.RuleUpdateParameters or IO[bytes] :return: An instance of LROPoller that returns either Rule or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Rule] :raises ~azure.core.exceptions.HttpResponseError: @@ -886,7 +808,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Rule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -898,17 +820,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Rule].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.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } + return LROPoller[_models.Rule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, rule_set_name: str, rule_name: str, **kwargs: Any @@ -927,23 +847,22 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, rule_set_name=rule_set_name, rule_name=rule_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -958,11 +877,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -979,14 +894,6 @@ def begin_delete( :type rule_set_name: str :param rule_name: Name of the delivery rule which is unique within the endpoint. Required. :type rule_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: @@ -1015,7 +922,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1026,14 +933,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/ruleSets/{ruleSetName}/rules/{ruleName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py index bf81cf87d8ec..0152a8451731 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_secrets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +78,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +112,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -149,7 +149,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -205,7 +205,6 @@ def list_by_profile(self, resource_group_name: str, profile_name: str, **kwargs: :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Secret or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.Secret] :raises ~azure.core.exceptions.HttpResponseError: @@ -227,17 +226,16 @@ def list_by_profile(self, resource_group_name: str, profile_name: str, **kwargs: def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -249,13 +247,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("SecretListResult", pipeline_response) @@ -265,11 +263,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -282,10 +280,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets" - } - @distributed_trace def get(self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any) -> _models.Secret: """Gets an existing Secret within a profile. @@ -297,7 +291,6 @@ def get(self, resource_group_name: str, profile_name: str, secret_name: str, **k :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Secret or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.Secret :raises ~azure.core.exceptions.HttpResponseError: @@ -316,22 +309,21 @@ def get(self, resource_group_name: str, profile_name: str, secret_name: str, **k api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Secret] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, secret_name=secret_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -344,20 +336,16 @@ def get(self, resource_group_name: str, profile_name: str, secret_name: str, **k deserialized = self._deserialize("Secret", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, profile_name: str, secret_name: str, - secret: Union[_models.Secret, IO], + secret: Union[_models.Secret, IO[bytes]], **kwargs: Any ) -> _models.Secret: error_map = { @@ -383,7 +371,7 @@ def _create_initial( else: _json = self._serialize.body(secret, "Secret") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, secret_name=secret_name, @@ -392,16 +380,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -428,10 +415,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}" - } - @overload def begin_create( self, @@ -457,14 +440,6 @@ def begin_create( :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 Secret or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Secret] :raises ~azure.core.exceptions.HttpResponseError: @@ -476,7 +451,7 @@ def begin_create( resource_group_name: str, profile_name: str, secret_name: str, - secret: IO, + secret: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -491,18 +466,10 @@ def begin_create( :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str :param secret: The Secret properties. Required. - :type secret: IO + :type secret: IO[bytes] :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 Secret or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Secret] :raises ~azure.core.exceptions.HttpResponseError: @@ -514,7 +481,7 @@ def begin_create( resource_group_name: str, profile_name: str, secret_name: str, - secret: Union[_models.Secret, IO], + secret: Union[_models.Secret, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Secret]: """Creates a new Secret within the specified profile. @@ -526,19 +493,8 @@ def begin_create( :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_name: str - :param secret: The Secret properties. Is either a Secret type or a IO type. Required. - :type secret: ~azure.mgmt.cdn.models.Secret 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. + :param secret: The Secret properties. Is either a Secret type or a IO[bytes] type. Required. + :type secret: ~azure.mgmt.cdn.models.Secret or IO[bytes] :return: An instance of LROPoller that returns either Secret or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.Secret] :raises ~azure.core.exceptions.HttpResponseError: @@ -570,7 +526,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Secret", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -582,17 +538,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Secret].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/secrets/{secretName}" - } + return LROPoller[_models.Secret]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, secret_name: str, **kwargs: Any @@ -611,22 +565,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, secret_name=secret_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -641,11 +594,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/secrets/{secretName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -660,14 +609,6 @@ def begin_delete( :type profile_name: str :param secret_name: Name of the Secret under the profile. Required. :type secret_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: @@ -695,7 +636,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -706,14 +647,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/secrets/{secretName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py index 4673ff303578..34be1e8228f9 100644 --- a/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py +++ b/sdk/cdn/azure-mgmt-cdn/azure/mgmt/cdn/operations/_security_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_profile_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +78,7 @@ def build_get_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -112,7 +112,7 @@ def build_create_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -149,7 +149,7 @@ def build_patch_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -186,7 +186,7 @@ def build_delete_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-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -244,7 +244,6 @@ def list_by_profile( :param profile_name: Name of the Azure Front Door Standard or Azure Front Door Premium profile which is unique within the resource group. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either SecurityPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.cdn.models.SecurityPolicy] :raises ~azure.core.exceptions.HttpResponseError: @@ -266,17 +265,16 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -288,13 +286,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("SecurityPolicyListResult", pipeline_response) @@ -304,11 +302,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -321,10 +319,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies" - } - @distributed_trace def get( self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any @@ -338,7 +332,6 @@ def get( :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: SecurityPolicy or the result of cls(response) :rtype: ~azure.mgmt.cdn.models.SecurityPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -357,22 +350,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.SecurityPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -385,20 +377,16 @@ def get( deserialized = self._deserialize("SecurityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } + return deserialized # type: ignore def _create_initial( self, resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy: Union[_models.SecurityPolicy, IO], + security_policy: Union[_models.SecurityPolicy, IO[bytes]], **kwargs: Any ) -> _models.SecurityPolicy: error_map = { @@ -424,7 +412,7 @@ def _create_initial( else: _json = self._serialize.body(security_policy, "SecurityPolicy") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_name, @@ -433,16 +421,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -469,10 +456,6 @@ def _create_initial( return deserialized # type: ignore - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } - @overload def begin_create( self, @@ -498,14 +481,6 @@ def begin_create( :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 SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -518,7 +493,7 @@ def begin_create( resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy: IO, + security_policy: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -533,18 +508,10 @@ def begin_create( :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str :param security_policy: The security policy properties. Required. - :type security_policy: IO + :type security_policy: IO[bytes] :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 SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -557,7 +524,7 @@ def begin_create( resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy: Union[_models.SecurityPolicy, IO], + security_policy: Union[_models.SecurityPolicy, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SecurityPolicy]: """Creates a new security policy within the specified profile. @@ -569,20 +536,9 @@ def begin_create( :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str - :param security_policy: The security policy properties. Is either a SecurityPolicy type or a IO - type. Required. - :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy 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. + :param security_policy: The security policy properties. Is either a SecurityPolicy type or a + IO[bytes] type. Required. + :type security_policy: ~azure.mgmt.cdn.models.SecurityPolicy or IO[bytes] :return: An instance of LROPoller that returns either SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -615,7 +571,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SecurityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -627,24 +583,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SecurityPolicy].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } + return LROPoller[_models.SecurityPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _patch_initial( self, resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO], + security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], **kwargs: Any ) -> _models.SecurityPolicy: error_map = { @@ -670,7 +624,7 @@ def _patch_initial( else: _json = self._serialize.body(security_policy_update_properties, "SecurityPolicyUpdateParameters") - request = build_patch_request( + _request = build_patch_request( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_name, @@ -679,16 +633,15 @@ def _patch_initial( content_type=content_type, json=_json, content=_content, - template_url=self._patch_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -712,10 +665,6 @@ def _patch_initial( return deserialized # type: ignore - _patch_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } - @overload def begin_patch( self, @@ -741,14 +690,6 @@ def begin_patch( :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 SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -761,7 +702,7 @@ def begin_patch( resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy_update_properties: IO, + security_policy_update_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -776,18 +717,10 @@ def begin_patch( :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str :param security_policy_update_properties: Security policy update properties. Required. - :type security_policy_update_properties: IO + :type security_policy_update_properties: IO[bytes] :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 SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -800,7 +733,7 @@ def begin_patch( resource_group_name: str, profile_name: str, security_policy_name: str, - security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO], + security_policy_update_properties: Union[_models.SecurityPolicyUpdateParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SecurityPolicy]: """Updates an existing security policy within a profile. @@ -813,20 +746,9 @@ def begin_patch( :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_name: str :param security_policy_update_properties: Security policy update properties. Is either a - SecurityPolicyUpdateParameters type or a IO type. Required. + SecurityPolicyUpdateParameters type or a IO[bytes] type. Required. :type security_policy_update_properties: ~azure.mgmt.cdn.models.SecurityPolicyUpdateParameters - 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. + or IO[bytes] :return: An instance of LROPoller that returns either SecurityPolicy or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.cdn.models.SecurityPolicy] @@ -859,7 +781,7 @@ def begin_patch( def get_long_running_output(pipeline_response): deserialized = self._deserialize("SecurityPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -871,17 +793,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.SecurityPolicy].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_patch.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } + return LROPoller[_models.SecurityPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, security_policy_name: str, **kwargs: Any @@ -900,22 +820,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, security_policy_name=security_policy_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -930,11 +849,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -949,14 +864,6 @@ def begin_delete( :type profile_name: str :param security_policy_name: Name of the security policy under the profile. Required. :type security_policy_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: @@ -984,7 +891,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -995,14 +902,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Cdn/profiles/{profileName}/securityPolicies/{securityPolicyName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_create.py index fa6395ea5f0f..232c2e014f9f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -44,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDCustomDomains_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_delete.py index 6505cac26a2c..cdde1ccd7199 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDCustomDomains_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_get.py index 06a3a0e6eba6..c529ac66adb1 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDCustomDomains_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_list_by_profile.py index f078178580dd..9838f20f9aa9 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_list_by_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDCustomDomains_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_refresh_validation_token.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_refresh_validation_token.py index 268eedb647e1..14687b97d07d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_refresh_validation_token.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_refresh_validation_token.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDCustomDomains_RefreshValidationToken.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_RefreshValidationToken.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_update.py index 75b75f15d28a..383d3fee790e 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_custom_domains_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -43,6 +46,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDCustomDomains_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_create.py index 64231376b1f3..6c47e4ba6e73 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -42,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDEndpoints_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_delete.py index d144c87a9398..2d4f28011117 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDEndpoints_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py index fff1c94b2ad5..eca25cfe859c 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDEndpoints_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_by_profile.py index 2d91b13c1129..b678db5bb2db 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_by_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDEndpoints_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_resource_usage.py index 8dc7f49025da..656ee738021c 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_list_resource_usage.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDEndpoints_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_purge_content.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_purge_content.py index 26702ef272b4..aebb6dbb77e8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_purge_content.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_purge_content.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +40,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDEndpoints_PurgeContent.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_PurgeContent.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_update.py index 036bfec598f7..f84366b6e02e 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDEndpoints_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_validate_custom_domain.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_validate_custom_domain.py index c5c40ea09632..37fd7a89af3f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_validate_custom_domain.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_endpoints_validate_custom_domain.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDEndpoints_ValidateCustomDomain.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_ValidateCustomDomain.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_create.py index 6b5b69190459..5f1a41348821 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -53,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDOriginGroups_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_delete.py index 03bd89b6aff8..79952a91120c 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDOriginGroups_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_get.py index e7c258c214c7..606b8be50db8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDOriginGroups_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_by_profile.py index aec67d1a806e..de8a9f7f5725 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_by_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDOriginGroups_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_resource_usage.py index f8de8aec8390..0297a249bcdb 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_list_resource_usage.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDOriginGroups_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_update.py index 771ab8fffb2f..0a17f8587bb0 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origin_groups_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -53,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDOriginGroups_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py index fc98e195c658..c42baa3cadc9 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -47,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDOrigins_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py index e4388e376e74..d8e79eddaa4a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDOrigins_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py index 792c61858a8d..4216fff73b9d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDOrigins_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_list_by_origin_group.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_list_by_origin_group.py index a9a5da807de7..8aca66fa1ea7 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_list_by_origin_group.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_list_by_origin_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDOrigins_ListByOriginGroup.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_ListByOriginGroup.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py index 691f9761ac12..ffdd1c9eb0c4 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_origins_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -46,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDOrigins_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_endpoint_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_endpoint_name_availability.py index b0de61c629aa..3cd89e63f42a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_endpoint_name_availability.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_endpoint_name_availability.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -41,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDProfiles_CheckEndpointNameAvailability.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_CheckEndpointNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_host_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_host_name_availability.py index 3a4f7c70ecf6..0c58ab223c3d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_host_name_availability.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_check_host_name_availability.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDProfiles_CheckHostNameAvailability.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_CheckHostNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_list_resource_usage.py index 8a3c7d93a9ba..7d952f353b0f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_list_resource_usage.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDProfiles_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_upgrade.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_upgrade.py index f9620e1342a7..183a03ed50d9 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_upgrade.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_upgrade.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -46,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDProfiles_Upgrade.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_Upgrade.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_validate_secret.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_validate_secret.py index 5d9fcf5e03b3..66b34e4ba7d8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_validate_secret.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/afd_profiles_validate_secret.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -42,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/AFDProfiles_ValidateSecret.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_ValidateSecret.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_endpoint_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_endpoint_name_availability.py index eff40ca4bf64..e674cea2011f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_endpoint_name_availability.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_endpoint_name_availability.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/CheckEndpointNameAvailability.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CheckEndpointNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability.py index df6de4195977..ef2972396a83 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -35,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/CheckNameAvailability.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability_with_subscription.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability_with_subscription.py index 547741a92442..dafc98d6dee6 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability_with_subscription.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/check_name_availability_with_subscription.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -35,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/CheckNameAvailabilityWithSubscription.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CheckNameAvailabilityWithSubscription.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_create.py index e6382132190c..7f0e634b4aa4 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -39,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/CustomDomains_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_delete.py index f9c3385a76ac..7861318578bd 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/CustomDomains_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_disable_custom_https.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_disable_custom_https.py index 0d33897052fc..f9194bef7069 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_disable_custom_https.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_disable_custom_https.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/CustomDomains_DisableCustomHttps.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_DisableCustomHttps.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_byoc.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_byoc.py index 110c0a67094e..4f88e220d426 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_byoc.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_byoc.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/CustomDomains_EnableCustomHttpsUsingBYOC.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_EnableCustomHttpsUsingBYOC.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_cdn_managed_certificate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_cdn_managed_certificate.py index 0faf7b473da4..c62b5e115f17 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_cdn_managed_certificate.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_enable_custom_https_using_cdn_managed_certificate.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/CustomDomains_EnableCustomHttpsUsingCDNManagedCertificate.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_EnableCustomHttpsUsingCDNManagedCertificate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py index fad1235f9c32..09b7e305b0e2 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/CustomDomains_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_list_by_endpoint.py index 13f196a03b80..13a26666662b 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_list_by_endpoint.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/custom_domains_list_by_endpoint.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/CustomDomains_ListByEndpoint.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py index 40e4f5356bf6..c7e2062ae372 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/edge_nodes_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/EdgeNodes_List.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/EdgeNodes_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py index c0bdd9170d5a..9168c89ae5a4 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -153,6 +156,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Endpoints_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py index 2b502bc52e7b..39a54278d76d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Endpoints_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py index 08338765c9bf..301f9f733c6a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Endpoints_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_by_profile.py index a3e76ee90852..f5461c728bc4 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_by_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Endpoints_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_resource_usage.py index f4fb4f2adacd..405675b567fe 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_list_resource_usage.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Endpoints_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_load_content.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_load_content.py index 3d824cc886e2..1cf246f15099 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_load_content.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_load_content.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +40,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Endpoints_LoadContent.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_LoadContent.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_purge_content.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_purge_content.py index 7d8bcab6fe3e..57adb262b0fa 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_purge_content.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_purge_content.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +40,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Endpoints_PurgeContent.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_PurgeContent.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py index 17da60b2ddc6..87f3f2134ca8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_start.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Endpoints_Start.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Start.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py index d085a2f393e6..d8ec097a2211 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_stop.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Endpoints_Stop.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Stop.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py index 5566b23e8aa9..828459ba88ef 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Endpoints_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_validate_custom_domain.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_validate_custom_domain.py index 4bea9fc5dc75..af88a31d15c6 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_validate_custom_domain.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/endpoints_validate_custom_domain.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Endpoints_ValidateCustomDomain.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_ValidateCustomDomain.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_locations.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_locations.py index 396b85057426..3a8bd6124731 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_locations.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_locations.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/LogAnalytics_GetLogAnalyticsLocations.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsLocations.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_metrics.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_metrics.py index e733695c48e5..99792edff08a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_metrics.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_metrics.py @@ -6,11 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime import isodate +from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -44,6 +50,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/LogAnalytics_GetLogAnalyticsMetrics.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsMetrics.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_rankings.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_rankings.py index 7911f82042b9..1b476cdd4515 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_rankings.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_rankings.py @@ -6,11 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime import isodate +from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -43,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/LogAnalytics_GetLogAnalyticsRankings.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsRankings.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_resources.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_resources.py index 66a565efaf12..ba65e42c3cef 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_resources.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_log_analytics_resources.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/LogAnalytics_GetLogAnalyticsResources.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsResources.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_metrics.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_metrics.py index 1e6c5c700c22..bd7f9b3079db 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_metrics.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_metrics.py @@ -6,11 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime import isodate +from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -42,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/LogAnalytics_GetWafLogAnalyticsMetrics.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetWafLogAnalyticsMetrics.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_rankings.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_rankings.py index 36ff61107cb3..d6c05717d1e6 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_rankings.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/log_analytics_get_waf_log_analytics_rankings.py @@ -6,11 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime import isodate +from typing import List, TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -43,6 +49,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/LogAnalytics_GetWafLogAnalyticsRankings.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetWafLogAnalyticsRankings.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py index d2c4314fde2d..60380404b906 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/operations_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Operations_List.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Operations_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_create.py index 339e989c45f3..8fc8ae01c77a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -57,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/OriginGroups_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_delete.py index d03ad85f22aa..16263ab85319 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/OriginGroups_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py index 2e92b682b1de..e0e64c28f83d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/OriginGroups_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_list_by_endpoint.py index 0aa0e55bf907..59a0711ca5a5 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_list_by_endpoint.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_list_by_endpoint.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/OriginGroups_ListByEndpoint.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_update.py index a80bdd682ba7..9ca87890ab2c 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origin_groups_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -53,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/OriginGroups_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py index 27900a861075..df360fce2549 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -52,6 +55,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Origins_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py index c36840990848..2e0262ae7112 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Origins_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py index cf77f18a233f..babb5673bbf7 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Origins_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_list_by_endpoint.py index 3fe8360cbda9..9841934192fd 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_list_by_endpoint.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_list_by_endpoint.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Origins_ListByEndpoint.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py index c4023d1d05e9..048a05562201 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/origins_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -49,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Origins_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_can_migrate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_can_migrate.py index ed386fa7b2f2..61208bef63d0 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_can_migrate.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_can_migrate.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -40,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_CanMigrate.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_CanMigrate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py index 19e2350b7c4a..139587290691 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py index 60cb6946eb34..e15c08f6a878 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_generate_sso_uri.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_generate_sso_uri.py index 7c6b60c9370b..ccbc01208071 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_generate_sso_uri.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_generate_sso_uri.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_GenerateSsoUri.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_GenerateSsoUri.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py index afa7f63fee59..172c69425889 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py index 4add99bf2ae8..d14470182ced 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_List.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_by_resource_group.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_by_resource_group.py index e5ed0520f27f..b97c6fa4f15c 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_by_resource_group.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_ListByResourceGroup.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_ListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_resource_usage.py index c675bd803d14..b4d07330bcbe 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_resource_usage.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_supported_optimization_types.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_supported_optimization_types.py index 515e0efd5fe9..2f16d6104d98 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_supported_optimization_types.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_list_supported_optimization_types.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_ListSupportedOptimizationTypes.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_ListSupportedOptimizationTypes.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py index c372b688383f..ff448f96f765 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migrate.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -42,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_Migrate.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Migrate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_commit.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_commit.py index b22da8916298..39880c2a7040 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_commit.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_migration_commit.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_MigrationCommit.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_MigrationCommit.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py index 5c6d3c38610d..7a77aa5cf83a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/profiles_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Profiles_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/resource_usage_list.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/resource_usage_list.py index c3d76c9c682f..f13ebbc36df5 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/resource_usage_list.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/resource_usage_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/ResourceUsage_List.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/ResourceUsage_List.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py index 8cbf91526366..ac4b9aac1942 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -70,6 +73,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Routes_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py index 641429034752..005a5640be13 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Routes_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py index 31e18d413b51..97d3bbb4ffed 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Routes_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_list_by_endpoint.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_list_by_endpoint.py index 21623cfa6e8e..975bbf16c82e 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_list_by_endpoint.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_list_by_endpoint.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Routes_ListByEndpoint.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_ListByEndpoint.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py index d19596662563..2e1431b0c52d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/routes_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -69,6 +72,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Routes_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py index e10d67313823..e3c4d5ab619a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_create.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/RuleSets_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py index d26f39b416e5..129ba69060cb 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/RuleSets_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py index b994c4330f23..4108b7daa08e 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/RuleSets_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_by_profile.py index 8bdfdac3c609..30b1fd7b2c27 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_by_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/RuleSets_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_resource_usage.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_resource_usage.py index 502c03ddd3c4..310c77ba4f71 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_resource_usage.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rule_sets_list_resource_usage.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/RuleSets_ListResourceUsage.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_ListResourceUsage.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py index 4a5c09b5750e..07e893135dd6 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -65,6 +68,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Rules_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py index 2056decc1f93..bae4e0fabfe8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Rules_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py index 36664316f57e..2e2505d9f09f 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Rules_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_list_by_rule_set.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_list_by_rule_set.py index 12da638f70d2..f096b56e948a 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_list_by_rule_set.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_list_by_rule_set.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Rules_ListByRuleSet.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_ListByRuleSet.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py index 2aafce7790ba..ab1eb23507e3 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/rules_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -54,6 +57,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Rules_Update.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Update.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py index e3ed807ce669..ce98279c2883 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -49,6 +52,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Secrets_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py index c46e8d4722ce..247d04c46c71 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Secrets_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py index 3c012ee66b10..18e6df120ff9 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Secrets_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_list_by_profile.py index 01dcf4635796..a23988e572f4 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/secrets_list_by_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/Secrets_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_create.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_create.py index 49c6295930cc..007ffa21a147 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_create.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -60,6 +63,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/SecurityPolicies_Create.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Create.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_delete.py index b58993383969..53a393cf71b8 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/SecurityPolicies_Delete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Delete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_get.py index eaedf2278c3b..9ffd420f9622 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/SecurityPolicies_Get.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Get.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_list_by_profile.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_list_by_profile.py index eb6a6cacd682..a73aab33dff3 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_list_by_profile.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_list_by_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/SecurityPolicies_ListByProfile.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_ListByProfile.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_patch.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_patch.py index 54c670801cc7..9bc7789afd81 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_patch.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/security_policies_patch.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -60,6 +63,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/SecurityPolicies_Patch.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Patch.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py index 15ef4da097fa..eb0e8b8c8ad5 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/validate_probe.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -35,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/ValidateProbe.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/ValidateProbe.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_managed_rule_sets.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_managed_rule_sets.py index d148f719d780..8d0ee8e8fcb0 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_managed_rule_sets.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_managed_rule_sets.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/WafListManagedRuleSets.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafListManagedRuleSets.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py index 46d111044022..94470f323fe4 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_list_policies.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/WafListPolicies.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafListPolicies.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py index 84e950028707..0478923b8574 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_patch_policy.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/WafPatchPolicy.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPatchPolicy.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_create_or_update.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_create_or_update.py index 5f8238aff193..63b8ee7c267d 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_create_or_update.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_create_or_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -122,6 +125,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/WafPolicyCreateOrUpdate.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py index 0dd91e351b55..c0b10e7d8496 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -35,6 +36,6 @@ def main(): ) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/WafPolicyDelete.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyDelete.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py index b9fcfd734459..eecc00b102f2 100644 --- a/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py +++ b/sdk/cdn/azure-mgmt-cdn/generated_samples/waf_policy_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.cdn import CdnManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2023-05-01/examples/WafPolicyGet.json +# x-ms-original-file: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyGet.json if __name__ == "__main__": main() diff --git a/sdk/cdn/azure-mgmt-cdn/setup.py b/sdk/cdn/azure-mgmt-cdn/setup.py index fcaddbd2a9d4..c0f0a3ca2878 100644 --- a/sdk/cdn/azure-mgmt-cdn/setup.py +++ b/sdk/cdn/azure-mgmt-cdn/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, @@ -74,10 +74,9 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7", + python_requires=">=3.8", ) diff --git a/sdk/cdn/azure-mgmt-cdn/tests/test_cli_mgmt_cdn.py b/sdk/cdn/azure-mgmt-cdn/tests/disable_test_cli_mgmt_cdn.py similarity index 100% rename from sdk/cdn/azure-mgmt-cdn/tests/test_cli_mgmt_cdn.py rename to sdk/cdn/azure-mgmt-cdn/tests/disable_test_cli_mgmt_cdn.py diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/assets.json b/sdk/cognitivelanguage/azure-ai-language-questionanswering/assets.json index 3966f00debec..017b86b554e5 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/assets.json +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/cognitivelanguage/azure-ai-language-questionanswering", - "Tag": "python/cognitivelanguage/azure-ai-language-questionanswering_bc3330c503" + "Tag": "python/cognitivelanguage/azure-ai-language-questionanswering_1f7e05ddea" } diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_operations/_patch.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_operations/_patch.py index 92309e39559e..bd34dd7e9987 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_operations/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_operations/_patch.py @@ -216,7 +216,11 @@ def get_answers( # pylint: disable=arguments-differ # pylint ignore b/c with overloads we need to doc ALL the params in the impl for them to show up in docs # pylint: disable=docstring-keyword-should-match-keyword-only,docstring-missing-param,docstring-should-be-keyword @distributed_trace - def get_answers(self, *args: AnswersOptions, **kwargs: Any) -> AnswersResult: + def get_answers( # pyright: ignore[reportIncompatibleMethodOverride] + self, + *args: AnswersOptions, + **kwargs: Any + ) -> AnswersResult: """Answers the specified question using your knowledge base. :param options: Positional only. POST body of the request. Provide either `options`, OR @@ -302,7 +306,11 @@ def get_answers_from_text( # pylint: disable=arguments-differ """ @distributed_trace - def get_answers_from_text(self, *args: AnswersFromTextOptions, **kwargs: Any) -> AnswersFromTextResult: + def get_answers_from_text( # pyright: ignore[reportIncompatibleMethodOverride] + self, + *args: AnswersFromTextOptions, + **kwargs: Any + ) -> AnswersFromTextResult: """Answers the specified question using the provided text in the body. :param options: Positional only. POST body of the request. Provide either `options`, OR diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py index 6114b9cc4ec0..0c8d68c2fef6 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase.py @@ -248,7 +248,7 @@ def test_query_knowledgebase_with_answerspan(self, recorded_test, qna_creds): assert prompt.qna_id assert prompt.display_text - + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_query_knowledgebase_with_dictparams(self, recorded_test, qna_creds): client = QuestionAnsweringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"])) query_params = { @@ -276,6 +276,7 @@ def test_query_knowledgebase_with_dictparams(self, recorded_test, qna_creds): assert len(confident_answers) == 1 assert confident_answers[0].source == "surface-book-user-guide-EN.pdf" + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_query_knowledgebase_overload(self, recorded_test, qna_creds): client = QuestionAnsweringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"])) with client: @@ -298,6 +299,7 @@ def test_query_knowledgebase_overload(self, recorded_test, qna_creds): assert len(confident_answers) == 1 assert confident_answers[0].source == "surface-book-user-guide-EN.pdf" + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_query_knowledgebase_with_followup(self, recorded_test, qna_creds): client = QuestionAnsweringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"])) with client: diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py index 4ef64a9ba691..251aa22a0565 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_query_knowledgebase_async.py @@ -253,6 +253,7 @@ async def test_query_knowledgebase_with_answerspan(self, recorded_test, qna_cred assert prompt.qna_id assert prompt.display_text + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") @pytest.mark.asyncio async def test_query_knowledgebase_with_dictparams(self, recorded_test, qna_creds): client = QuestionAnsweringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"])) @@ -281,6 +282,7 @@ async def test_query_knowledgebase_with_dictparams(self, recorded_test, qna_cred assert len(confident_answers) == 1 assert confident_answers[0].source == "surface-book-user-guide-EN.pdf" + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") @pytest.mark.asyncio async def test_query_knowledgebase_overload(self, recorded_test, qna_creds): client = QuestionAnsweringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"])) @@ -304,6 +306,7 @@ async def test_query_knowledgebase_overload(self, recorded_test, qna_creds): assert len(confident_answers) == 1 assert confident_answers[0].source == "surface-book-user-guide-EN.pdf" + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") @pytest.mark.asyncio async def test_query_knowledgebase_with_followup(self, recorded_test, qna_creds): client = QuestionAnsweringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"])) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_update_knowledge_sources.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_update_knowledge_sources.py index 48c09c41b238..a7320a71e466 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_update_knowledge_sources.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_update_knowledge_sources.py @@ -3,6 +3,7 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ +import pytest from azure.ai.language.questionanswering.authoring import AuthoringClient from azure.core.credentials import AzureKeyCredential @@ -12,6 +13,7 @@ class TestSourcesQnasSynonyms(QuestionAnsweringTestCase): + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_add_source(self, recorded_test, qna_creds): client = AuthoringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"])) diff --git a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_update_knowledge_sources_async.py b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_update_knowledge_sources_async.py index c8f5feded6cc..4b6373afbcf4 100644 --- a/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_update_knowledge_sources_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-questionanswering/tests/test_update_knowledge_sources_async.py @@ -14,6 +14,7 @@ class TestSourcesQnasSynonymsAsync(QuestionAnsweringTestCase): + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") @pytest.mark.asyncio async def test_add_source(self, recorded_test, qna_creds): client = AuthoringClient(qna_creds["qna_endpoint"], AzureKeyCredential(qna_creds["qna_key"])) diff --git a/sdk/commerce/azure-mgmt-commerce/pyproject.toml b/sdk/commerce/azure-mgmt-commerce/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/commerce/azure-mgmt-commerce/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/communication/azure-communication-chat/CHANGELOG.md b/sdk/communication/azure-communication-chat/CHANGELOG.md index cba571549c5d..c18eb9b4224b 100644 --- a/sdk/communication/azure-communication-chat/CHANGELOG.md +++ b/sdk/communication/azure-communication-chat/CHANGELOG.md @@ -1,18 +1,12 @@ # Release History -## 1.3.0 (Unreleased) +## 1.3.0 (2024-04-10) ### Features Added - Updated `chat_attachment.attachment_type`to include type `file` to support ACS users to recieve files shared by Teams user. - Added support for a new communication identifier `MicrosoftTeamsAppIdentifier`. -### Breaking Changes - -### Bugs Fixed - -### Other Changes - ## 1.2.0 (2023-12-04) ### Features Added diff --git a/sdk/communication/azure-communication-jobrouter/CHANGELOG.md b/sdk/communication/azure-communication-jobrouter/CHANGELOG.md index f4f2475e7145..08e01dbe13fe 100644 --- a/sdk/communication/azure-communication-jobrouter/CHANGELOG.md +++ b/sdk/communication/azure-communication-jobrouter/CHANGELOG.md @@ -1,5 +1,16 @@ # Release History -## 1.1.0b1 (Unreleased) + +## 1.1.0b2 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + +## 1.1.0b1 (2024-04-12) This is the beta release of Azure Communication Job Router Python SDK. For more information, please see the [README][read_me]. diff --git a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_version.py b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_version.py index a1f432eddc4e..f6cd39818b76 100644 --- a/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_version.py +++ b/sdk/communication/azure-communication-jobrouter/azure/communication/jobrouter/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0b1" +VERSION = "1.1.0b2" diff --git a/sdk/communication/azure-communication-networktraversal/CHANGELOG.md b/sdk/communication/azure-communication-networktraversal/CHANGELOG.md index 255028b5002b..8837e5118e7c 100644 --- a/sdk/communication/azure-communication-networktraversal/CHANGELOG.md +++ b/sdk/communication/azure-communication-networktraversal/CHANGELOG.md @@ -1,13 +1,12 @@ # Release History -## 1.1.0b2 (Unreleased) +## 1.1.0b2 (2024-04-10) ### Features Added - Added the ability specify the API version by an optional `api_version` keyword parameter. ### Breaking Changes - -### Bugs Fixed +- Please note, this package is no longer being maintained after 03/31/2024. ### Other Changes Python 3.6 is no longer supported. Please use Python version 3.7 or later. For more details, please read our page on [Azure SDK for Python version support policy](https://github.com/Azure/azure-sdk-for-python/wiki/Azure-SDKs-Python-version-support-policy). diff --git a/sdk/communication/azure-communication-networktraversal/README.md b/sdk/communication/azure-communication-networktraversal/README.md index 8e2133164fec..9d8bcd5dc19d 100644 --- a/sdk/communication/azure-communication-networktraversal/README.md +++ b/sdk/communication/azure-communication-networktraversal/README.md @@ -1,5 +1,7 @@ # Azure Communication Network Traversal Package client library for Python +**Please note, this package has been deprecated and will no longer be maintained after 03/31/2024.** + Azure Communication Network Traversal is managing TURN credentials for Azure Communication Services. It will provide TURN credentials to a user. @@ -11,22 +13,7 @@ It will provide TURN credentials to a user. _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ # Getting started - -### Prerequisites - -- Python 3.7 or later is required to use this package. -- You must have an [Azure subscription](https://azure.microsoft.com/free/) -- A deployed Communication Services resource. You can use the [Azure Portal](https://docs.microsoft.com/azure/communication-services/quickstarts/create-communication-resource?tabs=windows&pivots=platform-azp) or the [Azure PowerShell](https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice) to set it up. - -### Install the package - -Install the Azure Communication Identity client library for Python with [pip](https://pypi.org/project/pip/): -Install the Azure Communication Relay Client library for Python with [pip](https://pypi.org/project/pip/): - -```bash -pip install azure-communication-identity -pip install azure-communication-networktraversal -``` +Please note, this package has been deprecated and will no longer be maintained after 03/31/2024. # Key concepts @@ -141,4 +128,4 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. -[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md +[azure_core]: https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/core/azure-core/README.md \ No newline at end of file diff --git a/sdk/communication/azure-communication-networktraversal/setup.py b/sdk/communication/azure-communication-networktraversal/setup.py index 578425379ff8..6023241a3839 100644 --- a/sdk/communication/azure-communication-networktraversal/setup.py +++ b/sdk/communication/azure-communication-networktraversal/setup.py @@ -45,7 +45,7 @@ license='MIT License', # ensure that the development status reflects the status of your package classifiers=[ - "Development Status :: 4 - Beta", + "Development Status :: 7 - Inactive", 'Programming Language :: Python', "Programming Language :: Python :: 3 :: Only", diff --git a/sdk/communication/azure-communication-rooms/CHANGELOG.md b/sdk/communication/azure-communication-rooms/CHANGELOG.md index f9239bb7ee03..46bf3572a6a8 100644 --- a/sdk/communication/azure-communication-rooms/CHANGELOG.md +++ b/sdk/communication/azure-communication-rooms/CHANGELOG.md @@ -1,14 +1,11 @@ # Release History -## 1.1.0b2 (Unreleased) +## 1.1.0 (2024-04-15) +- General Availability version of PSTN dial-out capability feature. ### Features Added - Added support for a new communication identifier `MicrosoftTeamsAppIdentifier`. -### Breaking Changes - -### Bugs Fixed - ### Other Changes - The `MicrosoftBotIdentifier` and `MicrosoftBotProperties` have been deprecated. diff --git a/sdk/communication/azure-communication-rooms/README.md b/sdk/communication/azure-communication-rooms/README.md index 247e4cd000b2..f591d39d6558 100644 --- a/sdk/communication/azure-communication-rooms/README.md +++ b/sdk/communication/azure-communication-rooms/README.md @@ -49,7 +49,7 @@ valid_from if they are missing. The default for`valid_from` is current date time ### Create a room To create a room, call the `create_room` function from `RoomsClient`. The `valid_from`, `valid_until`, and `participants` arguments are all optional. -Starting in 1.1.0b1 release, ACS Rooms supports PSTN Dial-Out feature. To create room with PSTN Dial-Out property, call `create_room` function and set `pstn_dial_out_enabled` to either true or false. If `pstn_dial_out_enabled` is not provided, then the default value for `pstn_dial_out_enabled` is false. +Starting in 1.1.0 release, ACS Rooms supports PSTN Dial-Out feature. To create room with PSTN Dial-Out property, call `create_room` function and set `pstn_dial_out_enabled` to either true or false. If `pstn_dial_out_enabled` is not provided, then the default value for `pstn_dial_out_enabled` is false. ```python from azure.core.exceptions import HttpResponseError @@ -83,7 +83,7 @@ except HttpResponseError as ex: ``` ### Update a room The `valid_from` and `valid_until` properties of a created room can be updated by calling the `update_room` function from `RoomsClient`. -Starting in 1.1.0b1 release, ACS Rooms supports PSTN Dial-Out feature. To update a room with PSTN Dial-Out property, call `update_room` and set `pstn_dial_out_enabled` to either true or false. If `pstn_dial_out_enabled` is not provided, then there is no changes to PstnDialOutEnabled property in the room. +Starting in 1.1.0 release, ACS Rooms supports PSTN Dial-Out feature. To update a room with PSTN Dial-Out property, call `update_room` and set `pstn_dial_out_enabled` to either true or false. If `pstn_dial_out_enabled` is not provided, then there is no changes to PstnDialOutEnabled property in the room. ```python try: diff --git a/sdk/communication/azure-communication-rooms/assets.json b/sdk/communication/azure-communication-rooms/assets.json index 8c5673ea1e26..cbc996f28d15 100644 --- a/sdk/communication/azure-communication-rooms/assets.json +++ b/sdk/communication/azure-communication-rooms/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/communication/azure-communication-rooms", - "Tag": "python/communication/azure-communication-rooms_3b00bd4436" + "Tag": "python/communication/azure-communication-rooms_8232264a76" } diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_api_versions.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_api_versions.py index 74a68dc67ea0..ed828e445956 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_api_versions.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_api_versions.py @@ -8,6 +8,6 @@ class ApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): V2023_06_14 = "2023-06-14" - V2023_10_30_PREVIEW = "2023-10-30-preview" + V2024_04_15 = "2024-04-15" -DEFAULT_VERSION = ApiVersion.V2023_10_30_PREVIEW +DEFAULT_VERSION = ApiVersion.V2024_04_15 diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/__init__.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/__init__.py index fd646d867d42..3b2f1e1ffe83 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/__init__.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.7.6) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.13.7) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_client.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_client.py index 129e768ec37a..f8170363e8d6 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_client.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_client.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.7.6) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.13.7) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -8,6 +8,7 @@ from typing import Any from azure.core import PipelineClient +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from ._configuration import AzureCommunicationRoomsServiceConfiguration @@ -24,8 +25,8 @@ class AzureCommunicationRoomsService: # pylint: disable=client-accepts-api-vers :vartype participants: azure.communication.rooms.operations.ParticipantsOperations :param endpoint: The endpoint of the Azure Communication resource. Required. :type endpoint: str - :keyword api_version: Api Version. Default value is "2023-10-30-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-04-15". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ @@ -34,7 +35,24 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential ) -> None: _endpoint = "{endpoint}" self._config = AzureCommunicationRoomsServiceConfiguration(endpoint=endpoint, **kwargs) - self._client: PipelineClient = PipelineClient(base_url=_endpoint, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs) self._serialize = Serializer() self._deserialize = Deserializer() @@ -42,7 +60,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self.rooms = RoomsOperations(self._client, self._config, self._serialize, self._deserialize) self.participants = ParticipantsOperations(self._client, self._config, self._serialize, self._deserialize) - def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -66,7 +84,7 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_configuration.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_configuration.py index ade6e4b5507d..bd75c423f194 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_configuration.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_configuration.py @@ -1,20 +1,17 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.7.6) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.13.7) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any -from azure.core.configuration import Configuration from azure.core.pipeline import policies VERSION = "unknown" -class AzureCommunicationRoomsServiceConfiguration( # pylint: disable=too-many-instance-attributes,name-too-long - Configuration -): +class AzureCommunicationRoomsServiceConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AzureCommunicationRoomsService. Note that all parameters used to create this instance are saved as instance @@ -22,14 +19,13 @@ class AzureCommunicationRoomsServiceConfiguration( # pylint: disable=too-many-i :param endpoint: The endpoint of the Azure Communication resource. Required. :type endpoint: str - :keyword api_version: Api Version. Default value is "2023-10-30-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-04-15". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, **kwargs: Any) -> None: - super(AzureCommunicationRoomsServiceConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-10-30-preview") + api_version: str = kwargs.pop("api_version", "2024-04-15") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -37,6 +33,7 @@ def __init__(self, endpoint: str, **kwargs: Any) -> None: self.endpoint = endpoint self.api_version = api_version kwargs.setdefault("sdk_moniker", "communication-rooms/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -45,7 +42,7 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_serialization.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_serialization.py index 9f3e29b11388..2f781d740827 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_serialization.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,7 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -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: @@ -295,7 +288,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[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__) @@ -340,7 +333,7 @@ def _create_xml_node(cls): 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: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +344,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +383,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +408,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +438,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -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 @@ -668,7 +661,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -710,7 +703,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -730,7 +723,6 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) - # https://github.com/Azure/autorest.python/issues/2063 output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") @@ -746,7 +738,7 @@ def query(self, name, data, data_type, **kwargs): :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 + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -755,7 +747,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return 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) @@ -806,7 +798,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -826,7 +818,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -995,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) @@ -1172,10 +1164,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1211,7 +1203,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1232,7 +1223,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1373,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, @@ -1393,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 @@ -1446,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) @@ -1483,7 +1473,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1517,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 @@ -1580,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 @@ -1654,7 +1644,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1702,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: @@ -1759,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"]: @@ -1810,7 +1800,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1864,10 +1853,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1895,7 +1884,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1947,7 +1936,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1984,7 +1973,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -2000,9 +1989,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/__init__.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/__init__.py index fd646d867d42..3b2f1e1ffe83 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/__init__.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.7.6) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.13.7) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/_client.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/_client.py index 35b7e525d02a..5fe9ee7977c8 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/_client.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/_client.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.7.6) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.13.7) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- @@ -8,6 +8,7 @@ from typing import Any, Awaitable from azure.core import AsyncPipelineClient +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from .._serialization import Deserializer, Serializer @@ -24,8 +25,8 @@ class AzureCommunicationRoomsService: # pylint: disable=client-accepts-api-vers :vartype participants: azure.communication.rooms.aio.operations.ParticipantsOperations :param endpoint: The endpoint of the Azure Communication resource. Required. :type endpoint: str - :keyword api_version: Api Version. Default value is "2023-10-30-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-04-15". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ @@ -34,7 +35,24 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential ) -> None: _endpoint = "{endpoint}" self._config = AzureCommunicationRoomsServiceConfiguration(endpoint=endpoint, **kwargs) - self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncPipelineClient = AsyncPipelineClient(base_url=_endpoint, policies=_policies, **kwargs) self._serialize = Serializer() self._deserialize = Deserializer() @@ -42,7 +60,9 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential self.rooms = RoomsOperations(self._client, self._config, self._serialize, self._deserialize) self.participants = ParticipantsOperations(self._client, self._config, self._serialize, self._deserialize) - def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -66,7 +86,7 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHt } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/_configuration.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/_configuration.py index 8b31c532f305..d16cdcc0d1ea 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/_configuration.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/_configuration.py @@ -1,20 +1,17 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.7.6) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.13.7) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from typing import Any -from azure.core.configuration import Configuration from azure.core.pipeline import policies VERSION = "unknown" -class AzureCommunicationRoomsServiceConfiguration( # pylint: disable=too-many-instance-attributes,name-too-long - Configuration -): +class AzureCommunicationRoomsServiceConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for AzureCommunicationRoomsService. Note that all parameters used to create this instance are saved as instance @@ -22,14 +19,13 @@ class AzureCommunicationRoomsServiceConfiguration( # pylint: disable=too-many-i :param endpoint: The endpoint of the Azure Communication resource. Required. :type endpoint: str - :keyword api_version: Api Version. Default value is "2023-10-30-preview". Note that overriding - this default value may result in unsupported behavior. + :keyword api_version: Api Version. Default value is "2024-04-15". Note that overriding this + default value may result in unsupported behavior. :paramtype api_version: str """ def __init__(self, endpoint: str, **kwargs: Any) -> None: - super(AzureCommunicationRoomsServiceConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-10-30-preview") + api_version: str = kwargs.pop("api_version", "2024-04-15") if endpoint is None: raise ValueError("Parameter 'endpoint' must not be None.") @@ -37,6 +33,7 @@ def __init__(self, endpoint: str, **kwargs: Any) -> None: self.endpoint = endpoint self.api_version = api_version kwargs.setdefault("sdk_moniker", "communication-rooms/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -45,7 +42,7 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/operations/__init__.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/operations/__init__.py index 8ccd48ceb310..66faef91bac1 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/operations/__init__.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/operations/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.7.6) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.13.7) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/operations/_operations.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/operations/_operations.py index 5144471085b9..8de5fc317794 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/operations/_operations.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/aio/operations/_operations.py @@ -1,7 +1,7 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.7.6) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.13.7) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- from io import IOBase @@ -62,6 +62,7 @@ def __init__(self, *args, **kwargs) -> None: @overload async def create(self, create_room_request: JSON, *, content_type: str = "application/json", **kwargs: Any) -> JSON: + # pylint: disable=line-too-long """Creates a new room. Creates a new room. @@ -119,13 +120,16 @@ async def create(self, create_room_request: JSON, *, content_type: str = "applic """ @overload - async def create(self, create_room_request: IO, *, content_type: str = "application/json", **kwargs: Any) -> JSON: + async def create( + self, create_room_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> JSON: + # pylint: disable=line-too-long """Creates a new room. Creates a new room. :param create_room_request: The create room request body. Required. - :type create_room_request: IO + :type create_room_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -156,17 +160,15 @@ async def create(self, create_room_request: IO, *, content_type: str = "applicat """ @distributed_trace_async - async def create(self, create_room_request: Union[JSON, IO], **kwargs: Any) -> JSON: + async def create(self, create_room_request: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long """Creates a new room. Creates a new room. - :param create_room_request: The create room request body. Is either a JSON type or a IO type. - Required. - :type create_room_request: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str + :param create_room_request: The create room request body. Is either a JSON type or a IO[bytes] + type. Required. + :type create_room_request: JSON or IO[bytes] :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -235,7 +237,7 @@ async def create(self, create_room_request: Union[JSON, IO], **kwargs: Any) -> J else: _json = create_room_request - request = build_rooms_create_request( + _request = build_rooms_create_request( content_type=content_type, api_version=self._config.api_version, json=_json, @@ -246,11 +248,11 @@ async def create(self, create_room_request: Union[JSON, IO], **kwargs: Any) -> J path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -267,12 +269,13 @@ async def create(self, create_room_request: Union[JSON, IO], **kwargs: Any) -> J deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable[JSON]: + # pylint: disable=line-too-long """Retrieves all created rooms. Retrieves all created rooms. @@ -318,7 +321,7 @@ def list(self, **kwargs: Any) -> AsyncIterable[JSON]: def prepare_request(next_link=None): if not next_link: - request = build_rooms_list_request( + _request = build_rooms_list_request( api_version=self._config.api_version, headers=_headers, params=_params, @@ -328,7 +331,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -340,7 +343,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -348,9 +351,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -360,11 +363,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -380,6 +383,7 @@ async def get_next(next_link=None): @distributed_trace_async async def get(self, room_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long """Retrieves an existing room by id. Retrieves an existing room by id. @@ -424,7 +428,7 @@ async def get(self, room_id: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_rooms_get_request( + _request = build_rooms_get_request( room_id=room_id, api_version=self._config.api_version, headers=_headers, @@ -433,11 +437,11 @@ async def get(self, room_id: str, **kwargs: Any) -> JSON: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -454,9 +458,9 @@ async def get(self, room_id: str, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @overload async def update( @@ -467,6 +471,7 @@ async def update( content_type: str = "application/merge-patch+json", **kwargs: Any ) -> JSON: + # pylint: disable=line-too-long """Update a room with given changes. Update a room with given changes. @@ -521,11 +526,12 @@ async def update( async def update( self, room_id: str, - update_room_request: IO, + update_room_request: IO[bytes], *, content_type: str = "application/merge-patch+json", **kwargs: Any ) -> JSON: + # pylint: disable=line-too-long """Update a room with given changes. Update a room with given changes. @@ -533,7 +539,7 @@ async def update( :param room_id: The id of the room requested. Required. :type room_id: str :param update_room_request: The update room request. Required. - :type update_room_request: IO + :type update_room_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -564,19 +570,17 @@ async def update( """ @distributed_trace_async - async def update(self, room_id: str, update_room_request: Union[JSON, IO], **kwargs: Any) -> JSON: + async def update(self, room_id: str, update_room_request: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long """Update a room with given changes. Update a room with given changes. :param room_id: The id of the room requested. Required. :type room_id: str - :param update_room_request: The update room request. Is either a JSON type or a IO type. + :param update_room_request: The update room request. Is either a JSON type or a IO[bytes] type. Required. - :type update_room_request: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: - 'application/merge-patch+json'. Default value is None. - :paramtype content_type: str + :type update_room_request: JSON or IO[bytes] :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -637,7 +641,7 @@ async def update(self, room_id: str, update_room_request: Union[JSON, IO], **kwa else: _json = update_room_request - request = build_rooms_update_request( + _request = build_rooms_update_request( room_id=room_id, content_type=content_type, api_version=self._config.api_version, @@ -649,11 +653,11 @@ async def update(self, room_id: str, update_room_request: Union[JSON, IO], **kwa path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -670,9 +674,9 @@ async def update(self, room_id: str, update_room_request: Union[JSON, IO], **kwa deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace_async async def delete(self, room_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements @@ -699,7 +703,7 @@ async def delete(self, room_id: str, **kwargs: Any) -> None: # pylint: disable= cls: ClsType[None] = kwargs.pop("cls", None) - request = build_rooms_delete_request( + _request = build_rooms_delete_request( room_id=room_id, api_version=self._config.api_version, headers=_headers, @@ -708,11 +712,11 @@ async def delete(self, room_id: str, **kwargs: Any) -> None: # pylint: disable= path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -724,7 +728,7 @@ async def delete(self, room_id: str, **kwargs: Any) -> None: # pylint: disable= raise HttpResponseError(response=response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore class ParticipantsOperations: @@ -746,6 +750,7 @@ def __init__(self, *args, **kwargs) -> None: @distributed_trace def list(self, room_id: str, **kwargs: Any) -> AsyncIterable[JSON]: + # pylint: disable=line-too-long """Get participants in a room. Get participants in a room. @@ -786,7 +791,7 @@ def list(self, room_id: str, **kwargs: Any) -> AsyncIterable[JSON]: def prepare_request(next_link=None): if not next_link: - request = build_participants_list_request( + _request = build_participants_list_request( room_id=room_id, api_version=self._config.api_version, headers=_headers, @@ -797,7 +802,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -809,7 +814,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -817,9 +822,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -829,11 +834,11 @@ async def extract_data(pipeline_response): return deserialized.get("nextLink") or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -856,6 +861,7 @@ async def update( content_type: str = "application/merge-patch+json", **kwargs: Any ) -> JSON: + # pylint: disable=line-too-long """Update participants in a room. Update participants in a room. @@ -890,7 +896,7 @@ async def update( async def update( self, room_id: str, - update_participants_request: IO, + update_participants_request: IO[bytes], *, content_type: str = "application/merge-patch+json", **kwargs: Any @@ -902,7 +908,7 @@ async def update( :param room_id: The id of the room to update the participants in. Required. :type room_id: str :param update_participants_request: An updated set of participants of the room. Required. - :type update_participants_request: IO + :type update_participants_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -912,7 +918,8 @@ async def update( """ @distributed_trace_async - async def update(self, room_id: str, update_participants_request: Union[JSON, IO], **kwargs: Any) -> JSON: + async def update(self, room_id: str, update_participants_request: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long """Update participants in a room. Update participants in a room. @@ -920,11 +927,8 @@ async def update(self, room_id: str, update_participants_request: Union[JSON, IO :param room_id: The id of the room to update the participants in. Required. :type room_id: str :param update_participants_request: An updated set of participants of the room. Is either a - JSON type or a IO type. Required. - :type update_participants_request: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: - 'application/merge-patch+json'. Default value is None. - :paramtype content_type: str + JSON type or a IO[bytes] type. Required. + :type update_participants_request: JSON or IO[bytes] :return: JSON :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -965,7 +969,7 @@ async def update(self, room_id: str, update_participants_request: Union[JSON, IO else: _json = update_participants_request - request = build_participants_update_request( + _request = build_participants_update_request( room_id=room_id, content_type=content_type, api_version=self._config.api_version, @@ -977,11 +981,11 @@ async def update(self, room_id: str, update_participants_request: Union[JSON, IO path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -998,6 +1002,6 @@ async def update(self, room_id: str, update_participants_request: Union[JSON, IO deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/operations/__init__.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/operations/__init__.py index 8ccd48ceb310..66faef91bac1 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/operations/__init__.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/operations/__init__.py @@ -1,6 +1,6 @@ # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.7.6) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.13.7) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/operations/_operations.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/operations/_operations.py index 7a5571e61bf3..d19bf6b0f157 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/operations/_operations.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_generated/operations/_operations.py @@ -1,7 +1,7 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- -# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.7.6) +# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.7, generator: @autorest/python@6.13.7) # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime @@ -44,7 +44,7 @@ def build_rooms_create_request(**kwargs: Any) -> HttpRequest: _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-30-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -57,7 +57,9 @@ def build_rooms_create_request(**kwargs: Any) -> HttpRequest: if "Repeatability-Request-ID" not in _headers: _headers["Repeatability-Request-ID"] = str(uuid.uuid4()) if "Repeatability-First-Sent" not in _headers: - _headers["Repeatability-First-Sent"] = _SERIALIZER.serialize_data(datetime.datetime.now(), "rfc-1123") + _headers["Repeatability-First-Sent"] = _SERIALIZER.serialize_data( + datetime.datetime.now(datetime.timezone.utc), "rfc-1123" + ) if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -69,7 +71,7 @@ def build_rooms_list_request(**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-30-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +90,7 @@ def build_rooms_get_request(room_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-30-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -113,7 +115,7 @@ def build_rooms_update_request(room_id: str, **kwargs: Any) -> HttpRequest: _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-30-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -139,7 +141,7 @@ def build_rooms_delete_request(room_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-30-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -163,7 +165,7 @@ def build_participants_list_request(room_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-30-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -188,7 +190,7 @@ def build_participants_update_request(room_id: str, **kwargs: Any) -> HttpReques _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-30-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-04-15")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -229,6 +231,7 @@ def __init__(self, *args, **kwargs): @overload def create(self, create_room_request: JSON, *, content_type: str = "application/json", **kwargs: Any) -> JSON: + # pylint: disable=line-too-long """Creates a new room. Creates a new room. @@ -286,13 +289,14 @@ def create(self, create_room_request: JSON, *, content_type: str = "application/ """ @overload - def create(self, create_room_request: IO, *, content_type: str = "application/json", **kwargs: Any) -> JSON: + def create(self, create_room_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any) -> JSON: + # pylint: disable=line-too-long """Creates a new room. Creates a new room. :param create_room_request: The create room request body. Required. - :type create_room_request: IO + :type create_room_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str @@ -323,17 +327,15 @@ def create(self, create_room_request: IO, *, content_type: str = "application/js """ @distributed_trace - def create(self, create_room_request: Union[JSON, IO], **kwargs: Any) -> JSON: + def create(self, create_room_request: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long """Creates a new room. Creates a new room. - :param create_room_request: The create room request body. Is either a JSON type or a IO type. - Required. - :type create_room_request: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: 'application/json'. - Default value is None. - :paramtype content_type: str + :param create_room_request: The create room request body. Is either a JSON type or a IO[bytes] + type. Required. + :type create_room_request: JSON or IO[bytes] :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -402,7 +404,7 @@ def create(self, create_room_request: Union[JSON, IO], **kwargs: Any) -> JSON: else: _json = create_room_request - request = build_rooms_create_request( + _request = build_rooms_create_request( content_type=content_type, api_version=self._config.api_version, json=_json, @@ -413,11 +415,11 @@ def create(self, create_room_request: Union[JSON, IO], **kwargs: Any) -> JSON: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -434,12 +436,13 @@ def create(self, create_room_request: Union[JSON, IO], **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace def list(self, **kwargs: Any) -> Iterable[JSON]: + # pylint: disable=line-too-long """Retrieves all created rooms. Retrieves all created rooms. @@ -485,7 +488,7 @@ def list(self, **kwargs: Any) -> Iterable[JSON]: def prepare_request(next_link=None): if not next_link: - request = build_rooms_list_request( + _request = build_rooms_list_request( api_version=self._config.api_version, headers=_headers, params=_params, @@ -495,7 +498,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -507,7 +510,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -515,9 +518,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -527,11 +530,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -547,6 +550,7 @@ def get_next(next_link=None): @distributed_trace def get(self, room_id: str, **kwargs: Any) -> JSON: + # pylint: disable=line-too-long """Retrieves an existing room by id. Retrieves an existing room by id. @@ -591,7 +595,7 @@ def get(self, room_id: str, **kwargs: Any) -> JSON: cls: ClsType[JSON] = kwargs.pop("cls", None) - request = build_rooms_get_request( + _request = build_rooms_get_request( room_id=room_id, api_version=self._config.api_version, headers=_headers, @@ -600,11 +604,11 @@ def get(self, room_id: str, **kwargs: Any) -> JSON: path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -621,9 +625,9 @@ def get(self, room_id: str, **kwargs: Any) -> JSON: deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @overload def update( @@ -634,6 +638,7 @@ def update( content_type: str = "application/merge-patch+json", **kwargs: Any ) -> JSON: + # pylint: disable=line-too-long """Update a room with given changes. Update a room with given changes. @@ -688,11 +693,12 @@ def update( def update( self, room_id: str, - update_room_request: IO, + update_room_request: IO[bytes], *, content_type: str = "application/merge-patch+json", **kwargs: Any ) -> JSON: + # pylint: disable=line-too-long """Update a room with given changes. Update a room with given changes. @@ -700,7 +706,7 @@ def update( :param room_id: The id of the room requested. Required. :type room_id: str :param update_room_request: The update room request. Required. - :type update_room_request: IO + :type update_room_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -731,19 +737,17 @@ def update( """ @distributed_trace - def update(self, room_id: str, update_room_request: Union[JSON, IO], **kwargs: Any) -> JSON: + def update(self, room_id: str, update_room_request: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long """Update a room with given changes. Update a room with given changes. :param room_id: The id of the room requested. Required. :type room_id: str - :param update_room_request: The update room request. Is either a JSON type or a IO type. + :param update_room_request: The update room request. Is either a JSON type or a IO[bytes] type. Required. - :type update_room_request: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: - 'application/merge-patch+json'. Default value is None. - :paramtype content_type: str + :type update_room_request: JSON or IO[bytes] :return: JSON object :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -804,7 +808,7 @@ def update(self, room_id: str, update_room_request: Union[JSON, IO], **kwargs: A else: _json = update_room_request - request = build_rooms_update_request( + _request = build_rooms_update_request( room_id=room_id, content_type=content_type, api_version=self._config.api_version, @@ -816,11 +820,11 @@ def update(self, room_id: str, update_room_request: Union[JSON, IO], **kwargs: A path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -837,9 +841,9 @@ def update(self, room_id: str, update_room_request: Union[JSON, IO], **kwargs: A deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore @distributed_trace def delete(self, room_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements @@ -866,7 +870,7 @@ def delete(self, room_id: str, **kwargs: Any) -> None: # pylint: disable=incons cls: ClsType[None] = kwargs.pop("cls", None) - request = build_rooms_delete_request( + _request = build_rooms_delete_request( room_id=room_id, api_version=self._config.api_version, headers=_headers, @@ -875,11 +879,11 @@ def delete(self, room_id: str, **kwargs: Any) -> None: # pylint: disable=incons path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -891,7 +895,7 @@ def delete(self, room_id: str, **kwargs: Any) -> None: # pylint: disable=incons raise HttpResponseError(response=response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore class ParticipantsOperations: @@ -913,6 +917,7 @@ def __init__(self, *args, **kwargs): @distributed_trace def list(self, room_id: str, **kwargs: Any) -> Iterable[JSON]: + # pylint: disable=line-too-long """Get participants in a room. Get participants in a room. @@ -953,7 +958,7 @@ def list(self, room_id: str, **kwargs: Any) -> Iterable[JSON]: def prepare_request(next_link=None): if not next_link: - request = build_participants_list_request( + _request = build_participants_list_request( room_id=room_id, api_version=self._config.api_version, headers=_headers, @@ -964,7 +969,7 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) else: # make call to next link with the client's api-version @@ -976,7 +981,7 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _request = HttpRequest( "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params ) path_format_arguments = { @@ -984,9 +989,9 @@ def prepare_request(next_link=None): "self._config.endpoint", self._config.endpoint, "str", skip_quote=True ), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return request + return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() @@ -996,11 +1001,11 @@ def extract_data(pipeline_response): return deserialized.get("nextLink") or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1023,6 +1028,7 @@ def update( content_type: str = "application/merge-patch+json", **kwargs: Any ) -> JSON: + # pylint: disable=line-too-long """Update participants in a room. Update participants in a room. @@ -1057,7 +1063,7 @@ def update( def update( self, room_id: str, - update_participants_request: IO, + update_participants_request: IO[bytes], *, content_type: str = "application/merge-patch+json", **kwargs: Any @@ -1069,7 +1075,7 @@ def update( :param room_id: The id of the room to update the participants in. Required. :type room_id: str :param update_participants_request: An updated set of participants of the room. Required. - :type update_participants_request: IO + :type update_participants_request: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". :paramtype content_type: str @@ -1079,7 +1085,8 @@ def update( """ @distributed_trace - def update(self, room_id: str, update_participants_request: Union[JSON, IO], **kwargs: Any) -> JSON: + def update(self, room_id: str, update_participants_request: Union[JSON, IO[bytes]], **kwargs: Any) -> JSON: + # pylint: disable=line-too-long """Update participants in a room. Update participants in a room. @@ -1087,11 +1094,8 @@ def update(self, room_id: str, update_participants_request: Union[JSON, IO], **k :param room_id: The id of the room to update the participants in. Required. :type room_id: str :param update_participants_request: An updated set of participants of the room. Is either a - JSON type or a IO type. Required. - :type update_participants_request: JSON or IO - :keyword content_type: Body Parameter content-type. Known values are: - 'application/merge-patch+json'. Default value is None. - :paramtype content_type: str + JSON type or a IO[bytes] type. Required. + :type update_participants_request: JSON or IO[bytes] :return: JSON :rtype: JSON :raises ~azure.core.exceptions.HttpResponseError: @@ -1132,7 +1136,7 @@ def update(self, room_id: str, update_participants_request: Union[JSON, IO], **k else: _json = update_participants_request - request = build_participants_update_request( + _request = build_participants_update_request( room_id=room_id, content_type=content_type, api_version=self._config.api_version, @@ -1144,11 +1148,11 @@ def update(self, room_id: str, update_participants_request: Union[JSON, IO], **k path_format_arguments = { "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), } - request.url = self._client.format_url(request.url, **path_format_arguments) + _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1165,6 +1169,6 @@ def update(self, room_id: str, update_participants_request: Union[JSON, IO], **k deserialized = None if cls: - return cls(pipeline_response, cast(JSON, deserialized), {}) + return cls(pipeline_response, cast(JSON, deserialized), {}) # type: ignore - return cast(JSON, deserialized) + return cast(JSON, deserialized) # type: ignore diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_rooms_client.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_rooms_client.py index 396fd2a022a6..9a0b0f0ca35f 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_rooms_client.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_rooms_client.py @@ -35,7 +35,7 @@ class RoomsClient(object): param Union[TokenCredential, AzureKeyCredential] credential: The access key we use to authenticate against the service. :keyword api_version: Azure Communication Rooms API version. - Default value is "2023-10-30-preview". + Default value is "2024-04-15". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str """ diff --git a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_version.py b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_version.py index 412327e24fc3..0e9eb783481e 100644 --- a/sdk/communication/azure-communication-rooms/azure/communication/rooms/_version.py +++ b/sdk/communication/azure-communication-rooms/azure/communication/rooms/_version.py @@ -4,6 +4,6 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "1.1.0b2" +VERSION = "1.1.0" SDK_MONIKER = "communication-rooms/{}".format(VERSION) # type: str diff --git a/sdk/communication/azure-communication-rooms/setup.py b/sdk/communication/azure-communication-rooms/setup.py index bc98da3b7631..c11634dc2c7a 100644 --- a/sdk/communication/azure-communication-rooms/setup.py +++ b/sdk/communication/azure-communication-rooms/setup.py @@ -65,8 +65,8 @@ ] ), install_requires=[ - "azure-core>=1.24.0", - "msrest>=0.7.1", + "azure-core>=1.29.0", + "isodate>=0.6.1", ], python_requires=">=3.8", include_package_data=True, diff --git a/sdk/communication/azure-communication-rooms/swagger/README.md b/sdk/communication/azure-communication-rooms/swagger/README.md index 9f11f266d0f0..9a04f0b8da2c 100644 --- a/sdk/communication/azure-communication-rooms/swagger/README.md +++ b/sdk/communication/azure-communication-rooms/swagger/README.md @@ -26,7 +26,7 @@ python: ```yaml title: Azure Communication Rooms Service require: - - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/c01954913cf229486cb3091072e807c277ebc322/specification/communication/data-plane/Rooms/readme.md + - https://raw.githubusercontent.com/Azure/azure-rest-api-specs/91813ca7a287fe944262e992413ce4d51d987276/specification/communication/data-plane/Rooms/readme.md output-folder: ../azure/communication/rooms/_generated namespace: azure.communication.rooms package-name: azure-communication-rooms diff --git a/sdk/communication/azure-mgmt-communication/pyproject.toml b/sdk/communication/azure-mgmt-communication/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/communication/azure-mgmt-communication/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/confidentialledger/azure-mgmt-confidentialledger/pyproject.toml b/sdk/confidentialledger/azure-mgmt-confidentialledger/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/confidentialledger/azure-mgmt-confidentialledger/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/core/azure-core/azure/core/pipeline/_base.py b/sdk/core/azure-core/azure/core/pipeline/_base.py index 025cb5df6f74..85947b547f5e 100644 --- a/sdk/core/azure-core/azure/core/pipeline/_base.py +++ b/sdk/core/azure-core/azure/core/pipeline/_base.py @@ -87,8 +87,7 @@ def send(self, request: PipelineRequest[HTTPRequestType]) -> PipelineResponse[HT except Exception: # pylint: disable=broad-except _await_result(self._policy.on_exception, request) raise - else: - _await_result(self._policy.on_response, request, response) + _await_result(self._policy.on_response, request, response) return response diff --git a/sdk/core/azure-core/azure/core/pipeline/_base_async.py b/sdk/core/azure-core/azure/core/pipeline/_base_async.py index c12e1be4ce4a..946acfc1d10c 100644 --- a/sdk/core/azure-core/azure/core/pipeline/_base_async.py +++ b/sdk/core/azure-core/azure/core/pipeline/_base_async.py @@ -70,8 +70,7 @@ async def send( except Exception: # pylint: disable=broad-except await _await_result(self._policy.on_exception, request) raise - else: - await _await_result(self._policy.on_response, request, response) + await _await_result(self._policy.on_response, request, response) return response diff --git a/sdk/core/azure-core/azure/core/pipeline/policies/_authentication.py b/sdk/core/azure-core/azure/core/pipeline/policies/_authentication.py index 1a78be3cfbc1..608b544dfc06 100644 --- a/sdk/core/azure-core/azure/core/pipeline/policies/_authentication.py +++ b/sdk/core/azure-core/azure/core/pipeline/policies/_authentication.py @@ -124,26 +124,26 @@ def send(self, request: PipelineRequest[HTTPRequestType]) -> PipelineResponse[HT self.on_request(request) try: response = self.next.send(request) - self.on_response(request, response) except Exception: # pylint:disable=broad-except self.on_exception(request) raise - else: - if response.http_response.status_code == 401: - self._token = None # any cached token is invalid - if "WWW-Authenticate" in response.http_response.headers: - request_authorized = self.on_challenge(request, response) - if request_authorized: - # if we receive a challenge response, we retrieve a new token - # which matches the new target. In this case, we don't want to remove - # token from the request so clear the 'insecure_domain_change' tag - request.context.options.pop("insecure_domain_change", False) - try: - response = self.next.send(request) - self.on_response(request, response) - except Exception: # pylint:disable=broad-except - self.on_exception(request) - raise + + self.on_response(request, response) + if response.http_response.status_code == 401: + self._token = None # any cached token is invalid + if "WWW-Authenticate" in response.http_response.headers: + request_authorized = self.on_challenge(request, response) + if request_authorized: + # if we receive a challenge response, we retrieve a new token + # which matches the new target. In this case, we don't want to remove + # token from the request so clear the 'insecure_domain_change' tag + request.context.options.pop("insecure_domain_change", False) + try: + response = self.next.send(request) + self.on_response(request, response) + except Exception: # pylint:disable=broad-except + self.on_exception(request) + raise return response diff --git a/sdk/core/azure-core/azure/core/pipeline/policies/_authentication_async.py b/sdk/core/azure-core/azure/core/pipeline/policies/_authentication_async.py index 57e8b08a7692..f0abbcebd430 100644 --- a/sdk/core/azure-core/azure/core/pipeline/policies/_authentication_async.py +++ b/sdk/core/azure-core/azure/core/pipeline/policies/_authentication_async.py @@ -102,8 +102,7 @@ async def send( except Exception: # pylint:disable=broad-except await await_result(self.on_exception, request) raise - else: - await await_result(self.on_response, request, response) + await await_result(self.on_response, request, response) if response.http_response.status_code == 401: self._token = None # any cached token is invalid @@ -119,8 +118,7 @@ async def send( except Exception: # pylint:disable=broad-except await await_result(self.on_exception, request) raise - else: - await await_result(self.on_response, request, response) + await await_result(self.on_response, request, response) return response diff --git a/sdk/core/azure-core/azure/core/tracing/decorator.py b/sdk/core/azure-core/azure/core/tracing/decorator.py index aee70d03e5b1..347a9c9adae7 100644 --- a/sdk/core/azure-core/azure/core/tracing/decorator.py +++ b/sdk/core/azure-core/azure/core/tracing/decorator.py @@ -27,12 +27,14 @@ import functools -from typing import Callable, Any, TypeVar, overload, Optional +from typing import Callable, Any, TypeVar, overload, Optional, Mapping, TYPE_CHECKING from typing_extensions import ParamSpec from .common import change_context, get_function_and_class_name from . import SpanKind as _SpanKind from ..settings import settings +if TYPE_CHECKING: + from azure.core.tracing import SpanKind P = ParamSpec("P") T = TypeVar("T") @@ -44,28 +46,42 @@ def distributed_trace(__func: Callable[P, T]) -> Callable[P, T]: @overload -def distributed_trace( # pylint:disable=function-redefined - **kwargs: Any, # pylint:disable=unused-argument +def distributed_trace( + *, + name_of_span: Optional[str] = None, + kind: Optional["SpanKind"] = None, + tracing_attributes: Optional[Mapping[str, Any]] = None, + **kwargs: Any, ) -> Callable[[Callable[P, T]], Callable[P, T]]: pass def distributed_trace( - __func: Optional[Callable[P, T]] = None, **kwargs: Any -) -> Any: # pylint:disable=function-redefined + __func: Optional[Callable[P, T]] = None, # pylint: disable=unused-argument + *, + name_of_span: Optional[str] = None, + kind: Optional["SpanKind"] = None, + tracing_attributes: Optional[Mapping[str, Any]] = None, + **kwargs: Any, +) -> Any: """Decorator to apply to function to get traced automatically. Span will use the func name or "name_of_span". - :param callable func: A function to decorate + :param callable __func: A function to decorate :keyword name_of_span: The span name to replace func name if necessary :paramtype name_of_span: str :keyword kind: The kind of the span. INTERNAL by default. :paramtype kind: ~azure.core.tracing.SpanKind + :keyword tracing_attributes: Attributes to add to the span. + :paramtype tracing_attributes: Mapping[str, Any] or None + :return: The decorated function + :rtype: Any """ - name_of_span = kwargs.pop("name_of_span", None) - tracing_attributes = kwargs.pop("tracing_attributes", {}) - kind = kwargs.pop("kind", _SpanKind.INTERNAL) + if tracing_attributes is None: + tracing_attributes = {} + if kind is None: + kind = _SpanKind.INTERNAL def decorator(func: Callable[P, T]) -> Callable[P, T]: @functools.wraps(func) diff --git a/sdk/core/azure-core/azure/core/tracing/decorator_async.py b/sdk/core/azure-core/azure/core/tracing/decorator_async.py index 6d7d543cde2f..4909724a39fc 100644 --- a/sdk/core/azure-core/azure/core/tracing/decorator_async.py +++ b/sdk/core/azure-core/azure/core/tracing/decorator_async.py @@ -27,12 +27,15 @@ import functools -from typing import Awaitable, Callable, Any, TypeVar, overload, Optional +from typing import Awaitable, Callable, Any, TypeVar, overload, Optional, Mapping, TYPE_CHECKING from typing_extensions import ParamSpec from .common import change_context, get_function_and_class_name from . import SpanKind as _SpanKind from ..settings import settings +if TYPE_CHECKING: + from azure.core.tracing import SpanKind + P = ParamSpec("P") T = TypeVar("T") @@ -43,28 +46,42 @@ def distributed_trace_async(__func: Callable[P, Awaitable[T]]) -> Callable[P, Aw @overload -def distributed_trace_async( # pylint:disable=function-redefined - **kwargs: Any, # pylint:disable=unused-argument +def distributed_trace_async( + *, + name_of_span: Optional[str] = None, + kind: Optional["SpanKind"] = None, + tracing_attributes: Optional[Mapping[str, Any]] = None, + **kwargs: Any, ) -> Callable[[Callable[P, Awaitable[T]]], Callable[P, Awaitable[T]]]: pass -def distributed_trace_async( # pylint:disable=function-redefined - __func: Optional[Callable[P, Awaitable[T]]] = None, **kwargs: Any +def distributed_trace_async( + __func: Optional[Callable[P, Awaitable[T]]] = None, # pylint: disable=unused-argument + *, + name_of_span: Optional[str] = None, + kind: Optional["SpanKind"] = None, + tracing_attributes: Optional[Mapping[str, Any]] = None, + **kwargs: Any, ) -> Any: """Decorator to apply to function to get traced automatically. Span will use the func name or "name_of_span". - :param callable func: A function to decorate + :param callable __func: A function to decorate :keyword name_of_span: The span name to replace func name if necessary :paramtype name_of_span: str :keyword kind: The kind of the span. INTERNAL by default. :paramtype kind: ~azure.core.tracing.SpanKind + :keyword tracing_attributes: Attributes to add to the span. + :paramtype tracing_attributes: Mapping[str, Any] or None + :return: The decorated function + :rtype: Any """ - name_of_span = kwargs.pop("name_of_span", None) - tracing_attributes = kwargs.pop("tracing_attributes", {}) - kind = kwargs.pop("kind", _SpanKind.INTERNAL) + if tracing_attributes is None: + tracing_attributes = {} + if kind is None: + kind = _SpanKind.INTERNAL def decorator(func: Callable[P, Awaitable[T]]) -> Callable[P, Awaitable[T]]: @functools.wraps(func) diff --git a/sdk/core/azure-core/tests/async_tests/test_rest_http_response_async.py b/sdk/core/azure-core/tests/async_tests/test_rest_http_response_async.py index d59b3ea44faf..243d41e3160c 100644 --- a/sdk/core/azure-core/tests/async_tests/test_rest_http_response_async.py +++ b/sdk/core/azure-core/tests/async_tests/test_rest_http_response_async.py @@ -271,32 +271,32 @@ async def test_text_and_encoding(send_request): assert response.encoding == "utf-16" -# @pytest.mark.asyncio -# async def test_multipart_encode_non_seekable_filelike(send_request): -# """ -# Test that special readable but non-seekable filelike objects are supported, -# at the cost of reading them into memory at most once. -# """ - -# class IteratorIO(io.IOBase): -# def __init__(self, iterator): -# self._iterator = iterator - -# def read(self, *args): -# return b"".join(self._iterator) - -# def data(): -# yield b"Hello" -# yield b"World" - -# fileobj = IteratorIO(data()) -# files = {"file": fileobj} -# request = HttpRequest( -# "POST", -# "/multipart/non-seekable-filelike", -# files=files, -# ) -# await send_request(request) +@pytest.mark.asyncio +async def test_multipart_encode_non_seekable_filelike(send_request): + """ + Test that special readable but non-seekable filelike objects are supported, + at the cost of reading them into memory at most once. + """ + + class IteratorIO(io.IOBase): + def __init__(self, iterator): + self._iterator = iterator + + def read(self, *args): + return b"".join(self._iterator) + + def data(): + yield b"Hello" + yield b"World" + + fileobj = IteratorIO(data()) + files = {"file": fileobj} + request = HttpRequest( + "POST", + "/multipart/non-seekable-filelike", + files=files, + ) + await send_request(request) def test_initialize_response_abc(): diff --git a/sdk/core/azure-core/tests/testserver_tests/coretestserver/coretestserver/test_routes/multipart.py b/sdk/core/azure-core/tests/testserver_tests/coretestserver/coretestserver/test_routes/multipart.py index dd7e6b05862e..0433dcc3b8ef 100644 --- a/sdk/core/azure-core/tests/testserver_tests/coretestserver/coretestserver/test_routes/multipart.py +++ b/sdk/core/azure-core/tests/testserver_tests/coretestserver/coretestserver/test_routes/multipart.py @@ -25,12 +25,10 @@ def basic(): assert_with_message("content type", multipart_header_start, request.content_type[: len(multipart_header_start)]) if request.files: # aiohttp - assert_with_message("content length", 228, request.content_length) assert_with_message("num files", 1, len(request.files)) assert_with_message("has file named fileContent", True, bool(request.files.get("fileContent"))) file_content = request.files["fileContent"] assert_with_message("file content type", "application/octet-stream", file_content.content_type) - assert_with_message("file content length", 14, file_content.content_length) assert_with_message("filename", "fileContent", file_content.filename) assert_with_message( "has content disposition header", True, bool(file_content.headers.get("Content-Disposition")) @@ -42,7 +40,6 @@ def basic(): ) elif request.form: # requests - assert_with_message("content length", 184, request.content_length) assert_with_message("fileContent", "", request.form["fileContent"]) else: return Response(status=400) # should be either of these @@ -58,7 +55,6 @@ def data_and_files(): assert_with_message("message", "Hello, world!", request.form["message"]) file_content = request.files["fileContent"] assert_with_message("file content type", "application/octet-stream", file_content.content_type) - assert_with_message("file content length", 14, file_content.content_length) assert_with_message("filename", "fileContent", file_content.filename) assert_with_message( "has content disposition header", True, bool(file_content.headers.get("Content-Disposition")) @@ -93,17 +89,15 @@ def non_seekable_filelike(): # aiohttp len_files = len(request.files) assert_with_message("num files", 1, len_files) - # assert_with_message("content length", 258, request.content_length) assert_with_message("num files", 1, len(request.files)) assert_with_message("has file named file", True, bool(request.files.get("file"))) file = request.files["file"] assert_with_message("file content type", "application/octet-stream", file.content_type) - assert_with_message("file content length", 14, file.content_length) assert_with_message("filename", "file", file.filename) assert_with_message("has content disposition header", True, bool(file.headers.get("Content-Disposition"))) assert_with_message( "content disposition", - 'form-data; name="fileContent"; filename="fileContent"; filename*=utf-8\'\'fileContent', + 'form-data; name="file"; filename="file"', file.headers["Content-Disposition"], ) elif request.form: diff --git a/sdk/core/corehttp/corehttp/runtime/policies/_authentication.py b/sdk/core/corehttp/corehttp/runtime/policies/_authentication.py index 1e961ecda683..e658eed33b94 100644 --- a/sdk/core/corehttp/corehttp/runtime/policies/_authentication.py +++ b/sdk/core/corehttp/corehttp/runtime/policies/_authentication.py @@ -116,22 +116,22 @@ def send(self, request: PipelineRequest[HTTPRequestType]) -> PipelineResponse[HT self.on_request(request) try: response = self.next.send(request) - self.on_response(request, response) except Exception: # pylint:disable=broad-except self.on_exception(request) raise - else: - if response.http_response.status_code == 401: - self._token = None # any cached token is invalid - if "WWW-Authenticate" in response.http_response.headers: - request_authorized = self.on_challenge(request, response) - if request_authorized: - try: - response = self.next.send(request) - self.on_response(request, response) - except Exception: # pylint:disable=broad-except - self.on_exception(request) - raise + + self.on_response(request, response) + if response.http_response.status_code == 401: + self._token = None # any cached token is invalid + if "WWW-Authenticate" in response.http_response.headers: + request_authorized = self.on_challenge(request, response) + if request_authorized: + try: + response = self.next.send(request) + self.on_response(request, response) + except Exception: # pylint:disable=broad-except + self.on_exception(request) + raise return response diff --git a/sdk/core/corehttp/corehttp/runtime/policies/_authentication_async.py b/sdk/core/corehttp/corehttp/runtime/policies/_authentication_async.py index e4a3e73872d0..c19e7c025ef0 100644 --- a/sdk/core/corehttp/corehttp/runtime/policies/_authentication_async.py +++ b/sdk/core/corehttp/corehttp/runtime/policies/_authentication_async.py @@ -91,8 +91,7 @@ async def send( except Exception: # pylint:disable=broad-except await await_result(self.on_exception, request) raise - else: - await await_result(self.on_response, request, response) + await await_result(self.on_response, request, response) if response.http_response.status_code == 401: self._token = None # any cached token is invalid @@ -104,8 +103,7 @@ async def send( except Exception: # pylint:disable=broad-except await await_result(self.on_exception, request) raise - else: - await await_result(self.on_response, request, response) + await await_result(self.on_response, request, response) return response diff --git a/sdk/core/corehttp/tests/async_tests/test_rest_http_response_async.py b/sdk/core/corehttp/tests/async_tests/test_rest_http_response_async.py index 050699356796..4f6b9d78ea28 100644 --- a/sdk/core/corehttp/tests/async_tests/test_rest_http_response_async.py +++ b/sdk/core/corehttp/tests/async_tests/test_rest_http_response_async.py @@ -252,33 +252,33 @@ async def test_text_and_encoding(send_request, transport): assert response.encoding == "utf-16" -# @pytest.mark.asyncio -# @pytest.mark.parametrize("transport", ASYNC_TRANSPORTS) -# async def test_multipart_encode_non_seekable_filelike(send_request, transport): -# """ -# Test that special readable but non-seekable filelike objects are supported, -# at the cost of reading them into memory at most once. -# """ - -# class IteratorIO(io.IOBase): -# def __init__(self, iterator): -# self._iterator = iterator - -# def read(self, *args): -# return b"".join(self._iterator) - -# def data(): -# yield b"Hello" -# yield b"World" - -# fileobj = IteratorIO(data()) -# files = {"file": fileobj} -# request = HttpRequest( -# "POST", -# "/multipart/non-seekable-filelike", -# files=files, -# ) -# await send_request(request, transport()) +@pytest.mark.asyncio +@pytest.mark.parametrize("transport", ASYNC_TRANSPORTS) +async def test_multipart_encode_non_seekable_filelike(send_request, transport): + """ + Test that special readable but non-seekable filelike objects are supported, + at the cost of reading them into memory at most once. + """ + + class IteratorIO(io.IOBase): + def __init__(self, iterator): + self._iterator = iterator + + def read(self, *args): + return b"".join(self._iterator) + + def data(): + yield b"Hello" + yield b"World" + + fileobj = IteratorIO(data()) + files = {"file": fileobj} + request = HttpRequest( + "POST", + "/multipart/non-seekable-filelike", + files=files, + ) + await send_request(request, transport()) def test_initialize_response_abc(): diff --git a/sdk/core/corehttp/tests/testserver_tests/coretestserver/coretestserver/test_routes/multipart.py b/sdk/core/corehttp/tests/testserver_tests/coretestserver/coretestserver/test_routes/multipart.py index c6f86ceb5996..f0841c04052a 100644 --- a/sdk/core/corehttp/tests/testserver_tests/coretestserver/coretestserver/test_routes/multipart.py +++ b/sdk/core/corehttp/tests/testserver_tests/coretestserver/coretestserver/test_routes/multipart.py @@ -25,12 +25,10 @@ def basic(): assert_with_message("content type", multipart_header_start, request.content_type[: len(multipart_header_start)]) if request.files: # aiohttp - assert_with_message("content length", 228, request.content_length) assert_with_message("num files", 1, len(request.files)) assert_with_message("has file named fileContent", True, bool(request.files.get("fileContent"))) file_content = request.files["fileContent"] assert_with_message("file content type", "application/octet-stream", file_content.content_type) - assert_with_message("file content length", 14, file_content.content_length) assert_with_message("filename", "fileContent", file_content.filename) assert_with_message( "has content disposition header", True, bool(file_content.headers.get("Content-Disposition")) @@ -42,7 +40,6 @@ def basic(): ) elif request.form: # requests - assert_with_message("content length", 184, request.content_length) assert_with_message("fileContent", "", request.form["fileContent"]) else: return Response(status=400) # should be either of these @@ -58,7 +55,6 @@ def data_and_files(): assert_with_message("message", "Hello, world!", request.form["message"]) file_content = request.files["fileContent"] assert_with_message("file content type", "application/octet-stream", file_content.content_type) - assert_with_message("file content length", 14, file_content.content_length) assert_with_message("filename", "fileContent", file_content.filename) assert_with_message( "has content disposition header", True, bool(file_content.headers.get("Content-Disposition")) @@ -93,17 +89,15 @@ def non_seekable_filelike(): # aiohttp len_files = len(request.files) assert_with_message("num files", 1, len_files) - # assert_with_message("content length", 258, request.content_length) assert_with_message("num files", 1, len(request.files)) assert_with_message("has file named file", True, bool(request.files.get("file"))) file = request.files["file"] assert_with_message("file content type", "application/octet-stream", file.content_type) - assert_with_message("file content length", 14, file.content_length) assert_with_message("filename", "file", file.filename) assert_with_message("has content disposition header", True, bool(file.headers.get("Content-Disposition"))) assert_with_message( "content disposition", - 'form-data; name="fileContent"; filename="fileContent"; filename*=utf-8\'\'fileContent', + 'form-data; name="file"; filename="file"', file.headers["Content-Disposition"], ) elif request.form: diff --git a/sdk/cosmos/azure-cosmos/CHANGELOG.md b/sdk/cosmos/azure-cosmos/CHANGELOG.md index 4017eee05c8a..d91e8da83519 100644 --- a/sdk/cosmos/azure-cosmos/CHANGELOG.md +++ b/sdk/cosmos/azure-cosmos/CHANGELOG.md @@ -3,10 +3,14 @@ ### 4.6.1 (Unreleased) #### Features Added +* Added support for using the start time option for change feed query API. See [PR 35090](https://github.com/Azure/azure-sdk-for-python/pull/35090) #### Breaking Changes #### Bugs Fixed +* Fixed a bug where change feed query in Async client was not returning all pages due to case-sensitive response headers. See [PR 35090](https://github.com/Azure/azure-sdk-for-python/pull/35090) +* Fixed a bug when a retryable exception occurs in the first page of a query execution causing query to return 0 results. See [PR 35090](https://github.com/Azure/azure-sdk-for-python/pull/35090). + #### Other Changes diff --git a/sdk/cosmos/azure-cosmos/README.md b/sdk/cosmos/azure-cosmos/README.md index 4bd8666c682b..ad7873639e31 100644 --- a/sdk/cosmos/azure-cosmos/README.md +++ b/sdk/cosmos/azure-cosmos/README.md @@ -158,7 +158,6 @@ Currently, the features below are **not supported**. For alternatives options, c 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 * Cross-partition ORDER BY for mixed types * Enabling diagnostics for async query-type methods @@ -176,7 +175,7 @@ Streamable queries like `SELECT * FROM WHERE` *do* support continuation tokens. Typically, you can use [Azure Portal](https://portal.azure.com/), [Azure Cosmos DB Resource Provider REST API](https://docs.microsoft.com/rest/api/cosmos-db-resource-provider), [Azure CLI](https://docs.microsoft.com/cli/azure/azure-cli-reference-for-cosmos-db) or [PowerShell](https://docs.microsoft.com/azure/cosmos-db/manage-with-powershell) for the control plane unsupported limitations. ### Using The Async Client as a Workaround to Bulk -While the SDK supports transactional batch, support for bulk requests is not yet implemented in the Python SDK. You can use the async client along with this [concurrency sample][concurrency_sample] we have developed as a reference for a possible workaround. +While the SDK supports transactional batch, support for bulk requests is not yet implemented in the Python SDK. You can use the async client along with this [concurrency sample][cosmos_concurrency_sample] we have developed as a reference for a possible workaround. >[WARNING] > Using the asynchronous client for concurrent operations like shown in this sample will consume a lot of RUs very fast. We **strongly recommend** testing this out against the cosmos emulator first to verify your code works well and avoid incurring charges. diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/_base.py b/sdk/cosmos/azure-cosmos/azure/cosmos/_base.py index f8ab0ca15961..a7daecae060c 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/_base.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/_base.py @@ -291,8 +291,12 @@ def GetHeaders( # pylint: disable=too-many-statements,too-many-branches if_none_match_value = options["continuation"] elif options.get("isStartFromBeginning") and not options["isStartFromBeginning"]: if_none_match_value = "*" + elif options.get("startTime"): + start_time = options.get("startTime") + headers[http_constants.HttpHeaders.IfModified_since] = start_time if if_none_match_value: headers[http_constants.HttpHeaders.IfNoneMatch] = if_none_match_value + headers[http_constants.HttpHeaders.AIM] = http_constants.HttpHeaders.IncrementalFeedHeaderValue else: if options.get("continuation"): diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/aio/base_execution_context.py b/sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/aio/base_execution_context.py index 3f52e342d641..4ccef73388de 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/aio/base_execution_context.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/aio/base_execution_context.py @@ -56,7 +56,18 @@ def _get_initial_continuation(self): return None def _has_more_pages(self): - return not self._has_started or self._continuation + return not self._has_finished + + async def _ensure(self): + if not self._has_more_pages(): + return + + if not self._buffer: + results = await self._fetch_next_block() + self._buffer.extend(results) + + if not self._buffer: + self._has_finished = True async def fetch_next_block(self): """Returns a block of results with respecting retry policy. @@ -67,17 +78,10 @@ async def fetch_next_block(self): :return: List of results. :rtype: list """ - if not self._has_more_pages(): - return [] - - if self._buffer: - # if there is anything in the buffer returns that - res = list(self._buffer) - self._buffer.clear() - return res - - # fetches the next block - return await self._fetch_next_block() + await self._ensure() + res = list(self._buffer) + self._buffer.clear() + return res async def _fetch_next_block(self): raise NotImplementedError @@ -96,13 +100,7 @@ async def __anext__(self): :rtype: dict :raises StopAsyncIteration: If no more result is left. """ - if self._has_finished: - raise StopAsyncIteration - - if not self._buffer: - - results = await self.fetch_next_block() - self._buffer.extend(results) + await self._ensure() if not self._buffer: raise StopAsyncIteration @@ -117,21 +115,27 @@ async def _fetch_items_helper_no_retries(self, fetch_function): :rtype: list """ fetched_items = [] - # Continues pages till finds a non-empty page or all results are exhausted + new_options = copy.deepcopy(self._options) while self._continuation or not self._has_started: - if not self._has_started: - self._has_started = True - new_options = copy.deepcopy(self._options) + # Check if this is first fetch for read from specific time change feed. + # For read specific time the first fetch will return empty even if we have more pages. + is_s_time_first_fetch = self._is_change_feed and self._options.get("startTime") and not self._has_started + new_options["continuation"] = self._continuation + response_headers = {} (fetched_items, response_headers) = await fetch_function(new_options) + if not self._has_started: + self._has_started = True + continuation_key = http_constants.HttpHeaders.Continuation # Use Etag as continuation token for change feed queries. if self._is_change_feed: continuation_key = http_constants.HttpHeaders.ETag # In change feed queries, the continuation token is always populated. The hasNext() test is whether # there is any items in the response or not. - if not self._is_change_feed or fetched_items: + # No initial fetch for start time change feed, so we need to pass continuation token for first fetch + if not self._is_change_feed or fetched_items or is_s_time_first_fetch: self._continuation = response_headers.get(continuation_key) else: self._continuation = None diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/base_execution_context.py b/sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/base_execution_context.py index f0769f6caf25..fbbb5fdc5f12 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/base_execution_context.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/_execution_context/base_execution_context.py @@ -54,7 +54,18 @@ def _get_initial_continuation(self): return None def _has_more_pages(self): - return not self._has_started or self._continuation + return not self._has_finished + + def _ensure(self): + if not self._has_more_pages(): + return + + if not self._buffer: + results = self._fetch_next_block() + self._buffer.extend(results) + + if not self._buffer: + self._has_finished = True def fetch_next_block(self): """Returns a block of results with respecting retry policy. @@ -65,17 +76,10 @@ def fetch_next_block(self): :return: List of results. :rtype: list """ - if not self._has_more_pages(): - return [] - - if self._buffer: - # if there is anything in the buffer returns that - res = list(self._buffer) - self._buffer.clear() - return res - - # fetches the next block - return self._fetch_next_block() + self._ensure() + res = list(self._buffer) + self._buffer.clear() + return res def _fetch_next_block(self): raise NotImplementedError @@ -94,13 +98,7 @@ def __next__(self): :rtype: dict :raises StopIteration: If no more result is left. """ - if self._has_finished: - raise StopIteration - - if not self._buffer: - - results = self.fetch_next_block() - self._buffer.extend(results) + self._ensure() if not self._buffer: raise StopIteration @@ -115,21 +113,26 @@ def _fetch_items_helper_no_retries(self, fetch_function): :rtype: list """ fetched_items = [] - # Continues pages till finds a non-empty page or all results are exhausted + new_options = copy.deepcopy(self._options) while self._continuation or not self._has_started: + # Check if this is first fetch for read from specific time change feed. + # For read specific time the first fetch will return empty even if we have more pages. + is_s_time_first_fetch = self._is_change_feed and self._options.get("startTime") and not self._has_started if not self._has_started: self._has_started = True - new_options = copy.deepcopy(self._options) new_options["continuation"] = self._continuation + response_headers = {} (fetched_items, response_headers) = fetch_function(new_options) + continuation_key = http_constants.HttpHeaders.Continuation # Use Etag as continuation token for change feed queries. if self._is_change_feed: continuation_key = http_constants.HttpHeaders.ETag # In change feed queries, the continuation token is always populated. The hasNext() test is whether # there is any items in the response or not. - if not self._is_change_feed or fetched_items: + # For start time however we get no initial results, so we need to pass continuation token + if not self._is_change_feed or fetched_items or is_s_time_first_fetch: self._continuation = response_headers.get(continuation_key) else: self._continuation = None diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/_synchronized_request.py b/sdk/cosmos/azure-cosmos/azure/cosmos/_synchronized_request.py index 7dea1f2abec4..5663b8aa9faa 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/_synchronized_request.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/_synchronized_request.py @@ -21,7 +21,7 @@ """Synchronized request in the Azure Cosmos database service. """ - +import copy import json import time @@ -139,7 +139,7 @@ def _Request(global_endpoint_manager, request_params, connection_policy, pipelin ) response = response.http_response - headers = dict(response.headers) + headers = copy.copy(response.headers) data = response.body() if data: diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_asynchronous_request.py b/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_asynchronous_request.py index a3e8b25a823c..176b33807ddd 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_asynchronous_request.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_asynchronous_request.py @@ -21,7 +21,7 @@ """Asynchronous request in the Azure Cosmos database service. """ - +import copy import json import time @@ -107,7 +107,7 @@ async def _Request(global_endpoint_manager, request_params, connection_policy, p ) response = response.http_response - headers = dict(response.headers) + headers = copy.copy(response.headers) data = response.body() if data: diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py b/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py index eebd6c552c64..0bb123fd0de2 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/aio/_container.py @@ -21,7 +21,7 @@ """Create, read, update and delete items in the Azure Cosmos DB SQL API service. """ - +from datetime import datetime, timezone from typing import Any, Dict, Mapping, Optional, Sequence, Type, Union, List, Tuple, cast from typing_extensions import Literal @@ -476,6 +476,7 @@ def query_items_change_feed( *, partition_key_range_id: Optional[str] = None, is_start_from_beginning: bool = False, + start_time: Optional[datetime] = None, continuation: Optional[str] = None, max_item_count: Optional[int] = None, partition_key: Optional[PartitionKeyType] = None, @@ -486,6 +487,8 @@ def query_items_change_feed( :keyword bool is_start_from_beginning: Get whether change feed should start from beginning (true) or from current (false). By default, it's start from current (false). + :keyword datetime start_time: Specifies a point of time to start change feed. Start time in + '%a, %d %b %Y %H:%M:%S GMT' format. Converts datetime to UTC regardless of timezone. :keyword str partition_key_range_id: ChangeFeed requests can be executed against specific partition key ranges. This is used to process the change feed in parallel across multiple consumers. :keyword str continuation: e_tag value to be used as continuation for reading change feed. @@ -505,6 +508,8 @@ def query_items_change_feed( kwargs['priority'] = priority feed_options = _build_options(kwargs) feed_options["isStartFromBeginning"] = is_start_from_beginning + if start_time is not None and is_start_from_beginning is False and isinstance(start_time, datetime): + feed_options["startTime"] = start_time.astimezone(timezone.utc).strftime('%a, %d %b %Y %H:%M:%S GMT') if partition_key_range_id is not None: feed_options["partitionKeyRangeId"] = partition_key_range_id if partition_key is not None: diff --git a/sdk/cosmos/azure-cosmos/azure/cosmos/container.py b/sdk/cosmos/azure-cosmos/azure/cosmos/container.py index 1262d96c7327..b2cdd8a3d942 100644 --- a/sdk/cosmos/azure-cosmos/azure/cosmos/container.py +++ b/sdk/cosmos/azure-cosmos/azure/cosmos/container.py @@ -21,7 +21,7 @@ """Create, read, update and delete items in the Azure Cosmos DB SQL API service. """ - +from datetime import datetime, timezone import warnings from typing import Any, Dict, List, Optional, Sequence, Union, Tuple, Mapping, Type, cast from typing_extensions import Literal @@ -307,6 +307,7 @@ def query_items_change_feed( self, partition_key_range_id: Optional[str] = None, is_start_from_beginning: bool = False, + start_time: Optional[datetime] = None, continuation: Optional[str] = None, max_item_count: Optional[int] = None, *, @@ -320,6 +321,8 @@ def query_items_change_feed( This is used to process the change feed in parallel across multiple consumers. :param bool is_start_from_beginning: Get whether change feed should start from beginning (true) or from current (false). By default, it's start from current (false). + :param datetime start_time: Specifies a point of time to start change feed. Start time in + '%a, %d %b %Y %H:%M:%S GMT' format. Converts datetime to UTC regardless of timezone. :param max_item_count: Max number of items to be returned in the enumeration operation. :param str continuation: e_tag value to be used as continuation for reading change feed. :param int max_item_count: Max number of items to be returned in the enumeration operation. @@ -342,6 +345,8 @@ def query_items_change_feed( feed_options["partitionKey"] = self._set_partition_key(partition_key) if is_start_from_beginning is not None: feed_options["isStartFromBeginning"] = is_start_from_beginning + if start_time is not None and is_start_from_beginning is False and isinstance(start_time, datetime): + feed_options["startTime"] = start_time.astimezone(timezone.utc).strftime('%a, %d %b %Y %H:%M:%S GMT') if max_item_count is not None: feed_options["maxItemCount"] = max_item_count if continuation is not None: diff --git a/sdk/cosmos/azure-cosmos/samples/change_feed_management.py b/sdk/cosmos/azure-cosmos/samples/change_feed_management.py index a4d7eeed5945..f5e854406764 100644 --- a/sdk/cosmos/azure-cosmos/samples/change_feed_management.py +++ b/sdk/cosmos/azure-cosmos/samples/change_feed_management.py @@ -3,6 +3,8 @@ # Licensed under the MIT License. See LICENSE.txt in the project root for # license information. # ------------------------------------------------------------------------- +from datetime import datetime, timezone + import azure.cosmos.documents as documents import azure.cosmos.cosmos_client as cosmos_client import azure.cosmos.exceptions as exceptions @@ -35,12 +37,12 @@ def create_items(container, size): for i in range(1, size): c = str(uuid.uuid4()) item_definition = {'id': 'item' + c, - 'address': {'street': '1 Microsoft Way'+c, - 'city': 'Redmond'+c, - 'state': 'WA', - 'zip code': 98052 - } - } + 'address': {'street': '1 Microsoft Way' + c, + 'city': 'Redmond' + c, + 'state': 'WA', + 'zip code': 98052 + } + } created_item = container.create_item(body=item_definition) @@ -58,6 +60,19 @@ def read_change_feed(container): print('\nFinished reading all the change feed\n') +def read_change_feed_with_start_time(container, start_time): + time = start_time.strftime('%a, %d %b %Y %H:%M:%S GMT') + print('\nReading Change Feed from start time of {}\n'.format(time)) + + # You can read change feed from a specific time. + # You must pass in a datetime object for the start_time field. + response = container.query_items_change_feed(start_time=start_time) + for doc in response: + print(doc) + + print('\nFinished reading all the change feed from start time of {}\n'.format(time)) + + def run_sample(): client = cosmos_client.CosmosClient(HOST, {'masterKey': MASTER_KEY}) try: @@ -78,8 +93,16 @@ def run_sample(): except exceptions.CosmosResourceExistsError: raise RuntimeError("Container with id '{}' already exists".format(CONTAINER_ID)) + # Create items create_items(container, 100) + # Timestamp post item creations + timestamp = datetime.now(timezone.utc) + # Create more items after time stamp + create_items(container, 50) + # Read change feed from beginning read_change_feed(container) + # Read Change Feed from timestamp + read_change_feed_with_start_time(container, timestamp) # cleanup database after sample try: diff --git a/sdk/cosmos/azure-cosmos/samples/change_feed_management_async.py b/sdk/cosmos/azure-cosmos/samples/change_feed_management_async.py index 869aa028da1f..9ea66d4ebcda 100644 --- a/sdk/cosmos/azure-cosmos/samples/change_feed_management_async.py +++ b/sdk/cosmos/azure-cosmos/samples/change_feed_management_async.py @@ -3,6 +3,8 @@ # Licensed under the MIT License. See LICENSE.txt in the project root for # license information. # ------------------------------------------------------------------------- +from datetime import datetime, timezone + from azure.cosmos.aio import CosmosClient import azure.cosmos.exceptions as exceptions import azure.cosmos.documents as documents @@ -36,12 +38,12 @@ async def create_items(container, size): for i in range(1, size): c = str(uuid.uuid4()) item_definition = {'id': 'item' + c, - 'address': {'street': '1 Microsoft Way'+c, - 'city': 'Redmond'+c, - 'state': 'WA', - 'zip code': 98052 - } - } + 'address': {'street': '1 Microsoft Way' + c, + 'city': 'Redmond' + c, + 'state': 'WA', + 'zip code': 98052 + } + } await container.create_item(body=item_definition) @@ -63,6 +65,19 @@ async def read_change_feed(container): print('\nFinished reading all the change feed\n') +async def read_change_feed_with_start_time(container, start_time): + time = start_time.strftime('%a, %d %b %Y %H:%M:%S GMT') + print('\nReading Change Feed from start time of {}\n'.format(time)) + + # You can read change feed from a specific time. + # You must pass in a datetime object for the start_time field. + response = container.query_items_change_feed(start_time=start_time) + async for doc in response: + print(doc) + + print('\nFinished reading all the change feed from start time of {}\n'.format(time)) + + async def run_sample(): async with CosmosClient(HOST, MASTER_KEY) as client: try: @@ -83,8 +98,16 @@ async def run_sample(): except exceptions.CosmosResourceExistsError: raise RuntimeError("Container with id '{}' already exists".format(CONTAINER_ID)) + # Create items await create_items(container, 100) + # Timestamp post item creations + timestamp = datetime.now(timezone.utc) + # Create more items after time stamp + await create_items(container, 50) + # Read change feed from beginning await read_change_feed(container) + # Read Change Feed from timestamp + await read_change_feed_with_start_time(container, timestamp) # cleanup database after sample try: diff --git a/sdk/cosmos/azure-cosmos/test/test_query.py b/sdk/cosmos/azure-cosmos/test/test_query.py index 4d1acfee34c0..2d65006b7deb 100644 --- a/sdk/cosmos/azure-cosmos/test/test_query.py +++ b/sdk/cosmos/azure-cosmos/test/test_query.py @@ -3,7 +3,8 @@ import unittest import uuid - +from datetime import datetime, timedelta, timezone +from time import sleep import pytest import azure.cosmos._retry_utility as retry_utility @@ -278,6 +279,71 @@ def test_query_change_feed_with_pk_range_id(self): self.assertEqual(len(iter_list), 0) self.created_db.delete_container(created_collection.id) + def test_query_change_feed_with_start_time(self): + created_collection = self.created_db.create_container_if_not_exists("query_change_feed_start_time_test", + PartitionKey(path="/pk")) + batchSize = 50 + + def round_time(): + utc_now = datetime.now(timezone.utc) + return utc_now - timedelta(microseconds=utc_now.microsecond) + def create_random_items(container, batch_size): + for _ in range(batch_size): + # Generate a Random partition key + partition_key = 'pk' + str(uuid.uuid4()) + + # Generate a random item + item = { + 'id': 'item' + str(uuid.uuid4()), + 'partitionKey': partition_key, + 'content': 'This is some random content', + } + + try: + # Create the item in the container + container.upsert_item(item) + except exceptions.CosmosHttpResponseError as e: + self.fail(e) + + # Create first batch of random items + create_random_items(created_collection, batchSize) + + # wait for 1 second and record the time, then wait another second + sleep(1) + start_time = round_time() + not_utc_time = datetime.now() + sleep(1) + + # now create another batch of items + create_random_items(created_collection, batchSize) + + # now query change feed based on start time + change_feed_iter = list(created_collection.query_items_change_feed(start_time=start_time)) + totalCount = len(change_feed_iter) + + # now check if the number of items that were changed match the batch size + self.assertEqual(totalCount, batchSize) + + # negative test: pass in a valid time in the future + future_time = start_time + timedelta(hours=1) + change_feed_iter = list(created_collection.query_items_change_feed(start_time=future_time)) + totalCount = len(change_feed_iter) + # A future time should return 0 + self.assertEqual(totalCount, 0) + + # test a date that is not utc, will be converted to utc by sdk + change_feed_iter = list(created_collection.query_items_change_feed(start_time=not_utc_time)) + totalCount = len(change_feed_iter) + # Should equal batch size + self.assertEqual(totalCount, batchSize) + + # test an invalid value, will ignore start time option + invalid_time = "Invalid value" + change_feed_iter = list(created_collection.query_items_change_feed(start_time=invalid_time)) + totalCount = len(change_feed_iter) + # Should not equal batch size + self.assertNotEqual(totalCount, batchSize) + def test_populate_query_metrics(self): created_collection = self.created_db.create_container("query_metrics_test", PartitionKey(path="/pk")) diff --git a/sdk/cosmos/azure-cosmos/test/test_query_async.py b/sdk/cosmos/azure-cosmos/test/test_query_async.py index 3258de2343b1..61b8f413645c 100644 --- a/sdk/cosmos/azure-cosmos/test/test_query_async.py +++ b/sdk/cosmos/azure-cosmos/test/test_query_async.py @@ -1,8 +1,10 @@ # The MIT License (MIT) # Copyright (c) Microsoft Corporation. All rights reserved. - +import asyncio import unittest import uuid +from asyncio import sleep, gather +from datetime import datetime, timedelta, timezone import pytest @@ -14,6 +16,7 @@ from azure.cosmos.aio import CosmosClient, DatabaseProxy, ContainerProxy from azure.cosmos.documents import _DistinctType from azure.cosmos.partition_key import PartitionKey +from azure.cosmos._retry_options import RetryOptions @pytest.mark.cosmosEmulator @@ -316,8 +319,76 @@ async def test_query_change_feed_with_pk_range_id_async(self): iter_list = [item async for item in query_iterable] assert len(iter_list) == 0 + @pytest.mark.asyncio + async def test_query_change_feed_with_start_time(self): + created_collection = await self.created_db.create_container_if_not_exists("query_change_feed_start_time_test", + PartitionKey(path="/pk")) + batchSize = 50 + + def round_time(): + utc_now = datetime.now(timezone.utc) + return utc_now - timedelta(microseconds=utc_now.microsecond) + + async def create_random_items(container, batch_size): + for _ in range(batch_size): + # Generate a Random partition key + partition_key = 'pk' + str(uuid.uuid4()) + + # Generate a random item + item = { + 'id': 'item' + str(uuid.uuid4()), + 'partitionKey': partition_key, + 'content': 'This is some random content', + } + + try: + # Create the item in the container + await container.upsert_item(item) + except exceptions.CosmosHttpResponseError as e: + pytest.fail(e) + + # Create first batch of random items + await create_random_items(created_collection, batchSize) + + # wait for 1 second and record the time, then wait another second + await sleep(1) + start_time = round_time() + not_utc_time = datetime.now() + await sleep(1) + + # now create another batch of items + await create_random_items(created_collection, batchSize) + + # now query change feed based on start time + change_feed_iter = [i async for i in created_collection.query_items_change_feed(start_time=start_time)] + totalCount = len(change_feed_iter) + + # now check if the number of items that were changed match the batch size + assert totalCount == batchSize + + # negative test: pass in a valid time in the future + future_time = start_time + timedelta(hours=1) + change_feed_iter = [i async for i in created_collection.query_items_change_feed(start_time=future_time)] + totalCount = len(change_feed_iter) + # A future time should return 0 + assert totalCount == 0 + + # test a date that is not utc, will be converted to utc by sdk + change_feed_iter = [i async for i in created_collection.query_items_change_feed(start_time=not_utc_time)] + totalCount = len(change_feed_iter) + # Should equal batch size + assert totalCount == batchSize + + # test an invalid value, will ignore start time option + invalid_time = "Invalid value" + change_feed_iter = [i async for i in created_collection.query_items_change_feed(start_time=invalid_time)] + totalCount = len(change_feed_iter) + # Should not equal batch size + assert totalCount != batchSize + await self.created_db.delete_container(created_collection.id) + @pytest.mark.asyncio async def test_populate_query_metrics_async(self): created_collection = await self.created_db.create_container( "query_metrics_test" + str(uuid.uuid4()), @@ -809,6 +880,58 @@ async def test_computed_properties_query(self): partition_key="test")] assert len(queried_items) == 0 + async def test_cosmos_query_retryable_error_async(self): + async def query_items(database): + # Tests to make sure 429 exception is surfaced when retries run out in the first page of a query. + try: + container = await database.create_container( + id="query_retryable_error_test", partition_key=PartitionKey(path="/pk"), offer_throughput=400 + ) + except exceptions.CosmosResourceExistsError: + container = database.get_container_client("query_retryable_error_test") + query = "SELECT * FROM c" + try: + query_iterable = [d async for d in container.query_items(query, max_item_count=10)] + if len(query_iterable) == 0: + # Query should not return empty if it has items to query on a retryable exception is raised + pytest.fail("Expected 429 Exception.") + except exceptions.CosmosHttpResponseError as ex: + # A retryable exception should be surfaced when retries run out + assert ex.status_code == 429 + + created_collection = await self.created_db.create_container_if_not_exists("query_retryable_error_test", + PartitionKey(path="/pk")) + # Created items to query + for _ in range(150): + # Generate a Random partition key + partition_key = 'pk' + str(uuid.uuid4()) + + # Generate a random item + item = { + 'id': 'item' + str(uuid.uuid4()), + 'partitionKey': partition_key, + 'content': 'This is some random content', + } + + try: + # Create the item in the container + await created_collection.upsert_item(item) + except exceptions.CosmosHttpResponseError as e: + pytest.fail(e) + # Set retry options to fail much more easily to avoid too much concurrency + retry_options = RetryOptions(max_retry_attempt_count=1, + fixed_retry_interval_in_milliseconds=1, max_wait_time_in_seconds=1) + old_retry = self.client.client_connection.connection_policy.RetryOptions + self.client.client_connection.connection_policy.RetryOptions = retry_options + created_collection = await self.created_db.create_container_if_not_exists("query_retryable_error_test", + PartitionKey(path="/pk")) + # Force a 429 exception by having multiple concurrent queries. + num_queries = 4 + await gather(*[query_items(self.created_db) for _ in range(num_queries)]) + + self.client.client_connection.connection_policy.RetryOptions = old_retry + await self.created_db.delete_container(created_collection.id) + if __name__ == '__main__': unittest.main() diff --git a/sdk/customproviders/azure-mgmt-customproviders/pyproject.toml b/sdk/customproviders/azure-mgmt-customproviders/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/customproviders/azure-mgmt-customproviders/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/datashare/azure-mgmt-datashare/pyproject.toml b/sdk/datashare/azure-mgmt-datashare/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/datashare/azure-mgmt-datashare/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/defendereasm/azure-mgmt-defendereasm/pyproject.toml b/sdk/defendereasm/azure-mgmt-defendereasm/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/defendereasm/azure-mgmt-defendereasm/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/deviceupdate/azure-mgmt-deviceupdate/pyproject.toml b/sdk/deviceupdate/azure-mgmt-deviceupdate/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/deviceupdate/azure-mgmt-deviceupdate/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/assets.json b/sdk/documentintelligence/azure-ai-documentintelligence/assets.json index 727a23fffd27..e9423371da54 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/assets.json +++ b/sdk/documentintelligence/azure-ai-documentintelligence/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/documentintelligence/azure-ai-documentintelligence", - "Tag": "python/documentintelligence/azure-ai-documentintelligence_a54f07ab98" + "Tag": "python/documentintelligence/azure-ai-documentintelligence_d341ce7992" } diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/tests/conftest.py b/sdk/documentintelligence/azure-ai-documentintelligence/tests/conftest.py index 5af1d15c2f8f..d1e3c5cebfc2 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/tests/conftest.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/tests/conftest.py @@ -23,26 +23,6 @@ def add_sanitizers(test_proxy): add_remove_header_sanitizer(headers="Ocp-Apim-Subscription-Key") add_general_regex_sanitizer(value="fakeendpoint", regex="(?<=\\/\\/)[a-z-]+(?=\\.cognitiveservices\\.azure\\.com)") add_oauth_response_sanitizer() - add_body_key_sanitizer( - json_path="urlSource", - value="blob_sas_url", - regex="(?<=\\/\\/)[a-z-]+(?=\\.blob\\.core\\.windows\\.net)(.*)$", - ) - add_body_key_sanitizer( - json_path="azureBlobSource.containerUrl", - value="blob_sas_url", - regex="(?<=\\/\\/)[a-z-]+(?=\\.blob\\.core\\.windows\\.net)(.*)$", - ) - add_body_key_sanitizer( - json_path="source", - value="blob_sas_url", - regex="(?<=\\/\\/)[a-z-]+(?=\\.blob\\.core\\.windows\\.net)(.*)$", - ) - add_body_key_sanitizer( - json_path="accessToken", - value="redacted", - regex="([0-9a-f-]{36})", - ) add_body_key_sanitizer( json_path="targetResourceId", value="/path/to/resource/id", diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/tests/test_dac_analyze_custom_model.py b/sdk/documentintelligence/azure-ai-documentintelligence/tests/test_dac_analyze_custom_model.py index 6cd606522bc7..7556c0e71a7a 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/tests/test_dac_analyze_custom_model.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/tests/test_dac_analyze_custom_model.py @@ -57,6 +57,7 @@ def test_analyze_document_empty_model_id(self, **kwargs): client.begin_analyze_document(model_id="", analyze_request=b"xx") assert "Resource not found" in str(e.value) + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") @DocumentIntelligencePreparer() @recorded_by_proxy def test_analyze_document_empty_model_id_from_url(self, **kwargs): diff --git a/sdk/documentintelligence/azure-ai-documentintelligence/tests/test_dac_analyze_custom_model_async.py b/sdk/documentintelligence/azure-ai-documentintelligence/tests/test_dac_analyze_custom_model_async.py index afc8f9815099..165b10626f43 100644 --- a/sdk/documentintelligence/azure-ai-documentintelligence/tests/test_dac_analyze_custom_model_async.py +++ b/sdk/documentintelligence/azure-ai-documentintelligence/tests/test_dac_analyze_custom_model_async.py @@ -67,6 +67,7 @@ async def test_analyze_document_empty_model_id(self, **kwargs): ) assert "Resource not found" in str(e.value) + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") @DocumentIntelligencePreparer() @recorded_by_proxy_async async def test_analyze_document_empty_model_id_from_url(self, **kwargs): diff --git a/sdk/edgeorder/azure-mgmt-edgeorder/pyproject.toml b/sdk/edgeorder/azure-mgmt-edgeorder/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/edgeorder/azure-mgmt-edgeorder/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/education/azure-mgmt-education/pyproject.toml b/sdk/education/azure-mgmt-education/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/education/azure-mgmt-education/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/eventgrid/azure-eventgrid/CHANGELOG.md b/sdk/eventgrid/azure-eventgrid/CHANGELOG.md index a8c8df91615b..ef1aeefa75ad 100644 --- a/sdk/eventgrid/azure-eventgrid/CHANGELOG.md +++ b/sdk/eventgrid/azure-eventgrid/CHANGELOG.md @@ -1,6 +1,16 @@ # Release History -## 4.19.0 (Unreleased) +## 4.19.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + +## 4.19.0 (2024-04-10) ### Features Added @@ -10,8 +20,6 @@ - Fixed a bug where the Api Version was being hardcoded to `2018-01-01` on any request sent to the service. -### Other Changes - ## 4.18.0 (2024-03-12) ### Features Added diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py index 0081e67dc50e..bb1644791288 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_event_mappings.py @@ -56,6 +56,10 @@ class SystemEventNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): IoTHubDeviceCreatedEventName = 'Microsoft.Devices.DeviceCreated' # Aliases end here + AcsAdvancedMessageDeliveryStatusUpdatedEventName = 'Microsoft.Communication.AdvancedMessageDeliveryStatusUpdated' + + AcsAdvancedMessageReceivedEventName = 'Microsoft.Communication.AdvancedMessageReceived' + AcsChatMessageDeletedEventName = 'Microsoft.Communication.ChatMessageDeleted' AcsChatMessageDeletedInThreadEventName = 'Microsoft.Communication.ChatMessageDeletedInThread' @@ -94,10 +98,6 @@ class SystemEventNames(str, Enum, metaclass=CaseInsensitiveEnumMeta): AcsIncomingCallEventName = 'Microsoft.Communication.IncomingCall' - AcsMessageDeliveryStatusUpdatedEventName = 'Microsoft.Communication.AdvancedMessageDeliveryStatusUpdated' - - AcsMessageReceivedEventName = 'Microsoft.Communication.AdvancedMessageReceived' - AcsRecordingFileStatusUpdatedEventName = 'Microsoft.Communication.RecordingFileStatusUpdated' AcsRouterJobCancelledEventName = 'Microsoft.Communication.RouterJobCancelled' diff --git a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_version.py b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_version.py index 576475d23301..5834df1ac978 100644 --- a/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_version.py +++ b/sdk/eventgrid/azure-eventgrid/azure/eventgrid/_version.py @@ -9,4 +9,4 @@ # regenerated. # -------------------------------------------------------------------------- -VERSION = "4.19.0" +VERSION = "4.19.1" diff --git a/sdk/eventgrid/azure-eventgrid/swagger/_constants.py b/sdk/eventgrid/azure-eventgrid/swagger/_constants.py index 91b4a02b40ea..c6a89faa3626 100644 --- a/sdk/eventgrid/azure-eventgrid/swagger/_constants.py +++ b/sdk/eventgrid/azure-eventgrid/swagger/_constants.py @@ -68,3 +68,5 @@ 'EventGridMQTTClientEventData', 'AppConfigurationSnapshotEventData', 'HealthResourcesResourceEventData', 'AcsRouterJobEventData', 'AcsRouterWorkerEventData', 'AcsRouterEventData', 'AvsClusterEventData', 'AvsPrivateCloudEventData', 'AvsScriptExecutionEventData', "AcsMessageEventData" ] + +NAMING_CHANGES = ["AcsMessageDeliveryStatusUpdatedEventName", "AcsMessageReceivedEventName"] diff --git a/sdk/eventgrid/azure-eventgrid/swagger/postprocess_eventnames.py b/sdk/eventgrid/azure-eventgrid/swagger/postprocess_eventnames.py index ed1631718d31..5e96e2c8cd62 100644 --- a/sdk/eventgrid/azure-eventgrid/swagger/postprocess_eventnames.py +++ b/sdk/eventgrid/azure-eventgrid/swagger/postprocess_eventnames.py @@ -4,7 +4,7 @@ import sys from urllib.request import urlopen from azure.eventgrid._generated import models -from _constants import files, backward_compat, additional_events, EXCEPTIONS +from _constants import files, backward_compat, additional_events, EXCEPTIONS, NAMING_CHANGES def extract(definitions): if not definitions: @@ -13,6 +13,8 @@ def extract(definitions): for event in definitions: if event.endswith('Data') and event not in EXCEPTIONS: key, txt = "Name".join(event.rsplit('Data', 1)), definitions[event]['description'] + if key in NAMING_CHANGES: + key = key.replace("Acs", "AcsAdvanced") try: val = re.findall("Microsoft.[a-zA-Z]+.[a-zA-Z]+.[a-zA-Z]+", txt) if " event" in val[0]: diff --git a/sdk/eventhub/azure-eventhub-checkpointstoretable/pyproject.toml b/sdk/eventhub/azure-eventhub-checkpointstoretable/pyproject.toml index b55425f8865e..b3a5b0d1edf7 100644 --- a/sdk/eventhub/azure-eventhub-checkpointstoretable/pyproject.toml +++ b/sdk/eventhub/azure-eventhub-checkpointstoretable/pyproject.toml @@ -3,4 +3,5 @@ mypy = false pyright = false type_check_samples = false verifytypes = false -pylint = false \ No newline at end of file +pylint = false +strict_sphinx = true diff --git a/sdk/eventhub/azure-eventhub/CHANGELOG.md b/sdk/eventhub/azure-eventhub/CHANGELOG.md index 8f0912164eb9..f942dbcaace1 100644 --- a/sdk/eventhub/azure-eventhub/CHANGELOG.md +++ b/sdk/eventhub/azure-eventhub/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 5.11.7 (Unreleased) +## 5.11.8 (Unreleased) ### Features Added @@ -8,6 +8,12 @@ ### Bugs Fixed +### Other Changes + +## 5.11.7 (2024-04-10) + +### Bugs Fixed + - Fixed a bug where using `EventHubProducerClient` in buffered mode could potentially drop a buffered message without actually sending it. ([#34712](https://github.com/Azure/azure-sdk-for-python/pull/34712)) ### Other Changes diff --git a/sdk/eventhub/azure-eventhub/azure/eventhub/_version.py b/sdk/eventhub/azure-eventhub/azure/eventhub/_version.py index 4ffd61897d07..8ce6c0056b9f 100644 --- a/sdk/eventhub/azure-eventhub/azure/eventhub/_version.py +++ b/sdk/eventhub/azure-eventhub/azure/eventhub/_version.py @@ -3,4 +3,4 @@ # Licensed under the MIT License. # ------------------------------------ -VERSION = "5.11.7" +VERSION = "5.11.8" diff --git a/sdk/extendedlocation/azure-mgmt-extendedlocation/pyproject.toml b/sdk/extendedlocation/azure-mgmt-extendedlocation/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/extendedlocation/azure-mgmt-extendedlocation/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/fluidrelay/azure-mgmt-fluidrelay/pyproject.toml b/sdk/fluidrelay/azure-mgmt-fluidrelay/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/fluidrelay/azure-mgmt-fluidrelay/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md b/sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md index 279fcdfe41cb..a40c7ef60dc8 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md +++ b/sdk/formrecognizer/azure-ai-formrecognizer/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 3.3.4 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + ## 3.3.3 (2024-04-09) ### Other Changes diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/assets.json b/sdk/formrecognizer/azure-ai-formrecognizer/assets.json index b0d0b3f8368c..b7eb4b2bf3b5 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/assets.json +++ b/sdk/formrecognizer/azure-ai-formrecognizer/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/formrecognizer/azure-ai-formrecognizer", - "Tag": "python/formrecognizer/azure-ai-formrecognizer_9918a968ae" + "Tag": "python/formrecognizer/azure-ai-formrecognizer_ec714f4765" } diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_version.py b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_version.py index 9ffefecbe6ba..62bb2a061e2e 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_version.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/azure/ai/formrecognizer/_version.py @@ -3,4 +3,4 @@ # Licensed under the MIT License. # ------------------------------------ -VERSION = "3.3.3" +VERSION = "3.3.4" diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/async_samples/sample_analyze_addon_barcodes_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/async_samples/sample_analyze_addon_barcodes_async.py index 48574b2a1d2f..a5616221cbf9 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/async_samples/sample_analyze_addon_barcodes_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/async_samples/sample_analyze_addon_barcodes_async.py @@ -84,7 +84,7 @@ async def analyze_barcodes(): # Specify which add-on capabilities to enable. with open(path_to_sample_documents, "rb") as f: poller = await document_analysis_client.begin_analyze_document( - "prebuilt-layout", document=f, features=[AnalysisFeature.barcode/QR code] + "prebuilt-layout", document=f, features=[AnalysisFeature.BARCODES] ) result = await poller.result() diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/async_samples/sample_send_request_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/async_samples/sample_send_request_async.py index 0107d570426b..88eec8f27491 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/async_samples/sample_send_request_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/async_samples/sample_send_request_async.py @@ -35,53 +35,52 @@ async def sample_send_request(): endpoint=endpoint, credential=AzureKeyCredential(key) ) - # The `send_request` method can send custom HTTP requests that share the client's existing pipeline, - # while adding convenience for endpoint construction and service API versioning. - # Now let's use the `send_request` method to make a resource details fetching request. - # The URL of the request can be relative (your endpoint is the default base URL), - # and the API version of your client will automatically be used for the request. - request = HttpRequest(method="GET", url="info") async with client: + # The `send_request` method can send custom HTTP requests that share the client's existing pipeline, + # while adding convenience for endpoint construction and service API versioning. + # Now let's use the `send_request` method to make a resource details fetching request. + # The URL of the request can be relative (your endpoint is the default base URL), + # and the API version of your client will automatically be used for the request. + request = HttpRequest(method="GET", url="info") response = await client.send_request(request) - response.raise_for_status() - response_body = response.json() - print( - f"Our resource has {response_body['customDocumentModels']['count']} custom models, " - f"and we can have at most {response_body['customDocumentModels']['limit']} custom models." - f"The quota limit for custom neural document models is {response_body['customNeuralDocumentModelBuilds']['quota']} and the resource has" - f"used {response_body['customNeuralDocumentModelBuilds']['used']}. The resource quota will reset on {response_body['customNeuralDocumentModelBuilds']['quotaResetDateTime']}" - ) + response.raise_for_status() + response_body = response.json() + print( + f"Our resource has {response_body['customDocumentModels']['count']} custom models, " + f"and we can have at most {response_body['customDocumentModels']['limit']} custom models." + f"The quota limit for custom neural document models is {response_body['customNeuralDocumentModelBuilds']['quota']} and the resource has" + f"used {response_body['customNeuralDocumentModelBuilds']['used']}. The resource quota will reset on {response_body['customNeuralDocumentModelBuilds']['quotaResetDateTime']}" + ) - # pass with absolute url and override the API version - request = HttpRequest(method="GET", url=f"{endpoint}/formrecognizer/info?api-version=2022-08-31") - async with client: + # pass with absolute url and override the API version + request = HttpRequest(method="GET", url=f"{endpoint}/formrecognizer/info?api-version=2022-08-31") response = await client.send_request(request) - response.raise_for_status() - response_body = response.json() - print( - f"Our resource has {response_body['customDocumentModels']['count']} custom models, " - f"and we can have at most {response_body['customDocumentModels']['limit']} custom models." - f"The quota limit for custom neural document models is {response_body['customNeuralDocumentModelBuilds']['quota']} and the resource has" - f"used {response_body['customNeuralDocumentModelBuilds']['used']}. The resource quota will reset on {response_body['customNeuralDocumentModelBuilds']['quotaResetDateTime']}" - ) + response.raise_for_status() + response_body = response.json() + print( + f"Our resource has {response_body['customDocumentModels']['count']} custom models, " + f"and we can have at most {response_body['customDocumentModels']['limit']} custom models." + ) - # override the API version to v2.1 - request = HttpRequest(method="GET", url="v2.1/custom/models?op=summary") - async with client: + # override the API version to v2.1 + request = HttpRequest(method="GET", url="v2.1/custom/models?op=summary") response = await client.send_request(request) - response.raise_for_status() - response_body = response.json() - print(f"Our account has {response_body['summary']['count']} custom models, " - f"and we can have at most {response_body['summary']['limit']} custom models.") + response.raise_for_status() + response_body = response.json() + print( + f"Our account has {response_body['summary']['count']} custom models, " + f"and we can have at most {response_body['summary']['limit']} custom models." + ) - # pass with absolute url and override the API version to v2.1 - request = HttpRequest(method="GET", url=f"{endpoint}/formrecognizer/v2.1/custom/models?op=summary") - async with client: + # pass with absolute url and override the API version to v2.1 + request = HttpRequest(method="GET", url=f"{endpoint}/formrecognizer/v2.1/custom/models?op=summary") response = await client.send_request(request) - response.raise_for_status() - response_body = response.json() - print(f"Our account has {response_body['summary']['count']} custom models, " - f"and we can have at most {response_body['summary']['limit']} custom models.") + response.raise_for_status() + response_body = response.json() + print( + f"Our account has {response_body['summary']['count']} custom models, " + f"and we can have at most {response_body['summary']['limit']} custom models." + ) async def sample_send_request_v2(): @@ -92,42 +91,44 @@ async def sample_send_request_v2(): client = FormTrainingClient( endpoint=endpoint, credential=AzureKeyCredential(key) ) - - # The `send_request` method can send custom HTTP requests that share the client's existing pipeline, - # while adding convenience for endpoint construction and service API versioning. - # Now let's use the `send_request` method to make a resource details fetching request. - # The URL of the request can be relative (your endpoint is the default base URL), - # and the API version of your client will automatically be used for the request. - request = HttpRequest(method="GET", url="custom/models?op=summary") + async with client: + # The `send_request` method can send custom HTTP requests that share the client's existing pipeline, + # while adding convenience for endpoint construction and service API versioning. + # Now let's use the `send_request` method to make a resource details fetching request. + # The URL of the request can be relative (your endpoint is the default base URL), + # and the API version of your client will automatically be used for the request. + request = HttpRequest(method="GET", url="custom/models?op=summary") response = await client.send_request(request) - response.raise_for_status() - response_body = response.json() - print(f"Our account has {response_body['summary']['count']} custom models, " - f"and we can have at most {response_body['summary']['limit']} custom models.") + response.raise_for_status() + response_body = response.json() + print( + f"Our account has {response_body['summary']['count']} custom models, " + f"and we can have at most {response_body['summary']['limit']} custom models." + ) - # pass with absolute url and override the API version - request = HttpRequest(method="GET", url=f"{endpoint}/formrecognizer/v2.0/custom/models?op=summary") - async with client: + # pass with absolute url and override the API version + request = HttpRequest(method="GET", url=f"{endpoint}/formrecognizer/v2.0/custom/models?op=summary") response = await client.send_request(request) - response.raise_for_status() - response_body = response.json() - print(f"Our account has {response_body['summary']['count']} custom models, " - f"and we can have at most {response_body['summary']['limit']} custom models.") + response.raise_for_status() + response_body = response.json() + print( + f"Our account has {response_body['summary']['count']} custom models, " + f"and we can have at most {response_body['summary']['limit']} custom models." + ) - # override the API version to 2023-07-31 - # can only override the API version to 2022-08-31 or later with absolute url - request = HttpRequest(method="GET", url=f"{endpoint}/formrecognizer/info?api-version=2023-07-31") - async with client: + # override the API version to 2023-07-31 + # can only override the API version to 2022-08-31 or later with absolute url + request = HttpRequest(method="GET", url=f"{endpoint}/formrecognizer/info?api-version=2023-07-31") response = await client.send_request(request) - response.raise_for_status() - response_body = response.json() - print( - f"Our resource has {response_body['customDocumentModels']['count']} custom models, " - f"and we can have at most {response_body['customDocumentModels']['limit']} custom models." - f"The quota limit for custom neural document models is {response_body['customNeuralDocumentModelBuilds']['quota']} and the resource has" - f"used {response_body['customNeuralDocumentModelBuilds']['used']}. The resource quota will reset on {response_body['customNeuralDocumentModelBuilds']['quotaResetDateTime']}" - ) + response.raise_for_status() + response_body = response.json() + print( + f"Our resource has {response_body['customDocumentModels']['count']} custom models, " + f"and we can have at most {response_body['customDocumentModels']['limit']} custom models." + f"The quota limit for custom neural document models is {response_body['customNeuralDocumentModelBuilds']['quota']} and the resource has" + f"used {response_body['customNeuralDocumentModelBuilds']['used']}. The resource quota will reset on {response_body['customNeuralDocumentModelBuilds']['quotaResetDateTime']}" + ) async def main(): diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/sample_send_request.py b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/sample_send_request.py index 91999e50dc1c..2fd54ca24f13 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/sample_send_request.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/samples/v3.2_and_later/sample_send_request.py @@ -58,8 +58,6 @@ def sample_send_request(): print( f"Our resource has {response_body['customDocumentModels']['count']} custom models, " f"and we can have at most {response_body['customDocumentModels']['limit']} custom models." - f"The quota limit for custom neural document models is {response_body['customNeuralDocumentModelBuilds']['quota']} and the resource has" - f"used {response_body['customNeuralDocumentModelBuilds']['used']}. The resource quota will reset on {response_body['customNeuralDocumentModelBuilds']['quotaResetDateTime']}" ) # override the API version to v2.1 @@ -67,16 +65,20 @@ def sample_send_request(): response = client.send_request(request) response.raise_for_status() response_body = response.json() - print(f"Our account has {response_body['summary']['count']} custom models, " - f"and we can have at most {response_body['summary']['limit']} custom models.") + print( + f"Our account has {response_body['summary']['count']} custom models, " + f"and we can have at most {response_body['summary']['limit']} custom models." + ) # pass with absolute url and override the API version to v2.1 request = HttpRequest(method="GET", url=f"{endpoint}/formrecognizer/v2.1/custom/models?op=summary") response = client.send_request(request) response.raise_for_status() response_body = response.json() - print(f"Our account has {response_body['summary']['count']} custom models, " - f"and we can have at most {response_body['summary']['limit']} custom models.") + print( + f"Our account has {response_body['summary']['count']} custom models, " + f"and we can have at most {response_body['summary']['limit']} custom models." + ) def sample_send_request_v2(): @@ -97,16 +99,20 @@ def sample_send_request_v2(): response = client.send_request(request) response.raise_for_status() response_body = response.json() - print(f"Our account has {response_body['summary']['count']} custom models, " - f"and we can have at most {response_body['summary']['limit']} custom models.") + print( + f"Our account has {response_body['summary']['count']} custom models, " + f"and we can have at most {response_body['summary']['limit']} custom models." + ) # pass with absolute url and override the API version request = HttpRequest(method="GET", url=f"{endpoint}/formrecognizer/v2.0/custom/models?op=summary") response = client.send_request(request) response.raise_for_status() response_body = response.json() - print(f"Our account has {response_body['summary']['count']} custom models, " - f"and we can have at most {response_body['summary']['limit']} custom models.") + print( + f"Our account has {response_body['summary']['count']} custom models, " + f"and we can have at most {response_body['summary']['limit']} custom models." + ) # override the API version to 2023-07-31 request = HttpRequest(method="GET", url=f"{endpoint}/formrecognizer/info?api-version=2023-07-31") diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py b/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py index de46a48517f4..8412e70744f9 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/tests/conftest.py @@ -27,26 +27,6 @@ def add_sanitizers(test_proxy): regex="(?<=\\/\\/)[a-z-]+(?=\\.cognitiveservices\\.azure\\.com)" ) add_oauth_response_sanitizer() - add_body_key_sanitizer( - json_path="urlSource", - value="blob_sas_url", - regex="(?<=\\/\\/)[a-z-]+(?=\\.blob\\.core\\.windows\\.net)(.*)$", - ) - add_body_key_sanitizer( - json_path="azureBlobSource.containerUrl", - value="blob_sas_url", - regex="(?<=\\/\\/)[a-z-]+(?=\\.blob\\.core\\.windows\\.net)(.*)$", - ) - add_body_key_sanitizer( - json_path="source", - value="blob_sas_url", - regex="(?<=\\/\\/)[a-z-]+(?=\\.blob\\.core\\.windows\\.net)(.*)$", - ) - add_body_key_sanitizer( - json_path="accessToken", - value="redacted", - regex="([0-9a-f-]{36})", - ) add_body_key_sanitizer( json_path="targetResourceId", value="/path/to/resource/id", diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_send_request.py b/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_send_request.py index 73a5b9feb19f..2efb4459f4db 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_send_request.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_send_request.py @@ -22,6 +22,8 @@ class TestSendRequest(FormRecognizerTest): @recorded_by_proxy def test_get_resource_details(self, client, **kwargs): set_bodiless_matcher() + resource_details = client.get_resource_details() + request = HttpRequest( method="GET", url="info", @@ -31,8 +33,8 @@ def test_get_resource_details(self, client, **kwargs): received_info1 = result.json() assert received_info1 assert received_info1["customDocumentModels"] - assert received_info1["customDocumentModels"]["count"] == 0 - assert received_info1["customDocumentModels"]["limit"] == 250 + assert received_info1["customDocumentModels"]["count"] == resource_details.custom_document_models.count + assert received_info1["customDocumentModels"]["limit"] == resource_details.custom_document_models.limit request = HttpRequest( method="GET", @@ -43,7 +45,7 @@ def test_get_resource_details(self, client, **kwargs): received_info2 = result.json() assert received_info2["customDocumentModels"]["count"] == received_info1["customDocumentModels"]["count"] assert received_info2["customDocumentModels"]["limit"] == received_info1["customDocumentModels"]["limit"] - + # test with absolute url request = HttpRequest( method="GET", @@ -54,7 +56,7 @@ def test_get_resource_details(self, client, **kwargs): received_info3 = result.json() assert received_info3["customDocumentModels"]["count"] == received_info1["customDocumentModels"]["count"] assert received_info3["customDocumentModels"]["limit"] == received_info1["customDocumentModels"]["limit"] - + # test with v2 API version request = HttpRequest( method="GET", @@ -64,9 +66,9 @@ def test_get_resource_details(self, client, **kwargs): result = client.send_request(request) received_info4 = result.json() assert received_info4 - assert received_info4["summary"]["count"] == 0 - assert received_info4["summary"]["limit"] - + assert received_info4["summary"]["count"] == resource_details.custom_document_models.count + assert received_info4["summary"]["limit"] == resource_details.custom_document_models.limit + # test with v2 API version with absolute url request = HttpRequest( method="GET", @@ -83,6 +85,8 @@ def test_get_resource_details(self, client, **kwargs): @recorded_by_proxy def test_get_account_properties_v2(self, client): set_bodiless_matcher() + account_properties = client.get_account_properties() + request = HttpRequest( method="GET", url="custom/models?op=summary", @@ -92,9 +96,9 @@ def test_get_account_properties_v2(self, client): received_info1 = result.json() assert received_info1 assert received_info1["summary"] - assert received_info1["summary"]["count"] == 0 - assert received_info1["summary"]["limit"] == 250 - + assert received_info1["summary"]["count"] == account_properties.custom_model_count + assert received_info1["summary"]["limit"] == account_properties.custom_model_limit + # test with absolute url request = HttpRequest( method="GET", @@ -105,7 +109,7 @@ def test_get_account_properties_v2(self, client): received_info3 = result.json() assert received_info3["summary"]["count"] == received_info1["summary"]["count"] assert received_info3["summary"]["limit"] == received_info1["summary"]["limit"] - + # relative URLs can't override the API version on 2.x clients request = HttpRequest( method="GET", @@ -116,7 +120,7 @@ def test_get_account_properties_v2(self, client): received_info4 = result.json() assert received_info4["error"]["code"] == "404" assert received_info4["error"]["message"] == "Resource not found" - + # test with v2 API version with absolute url request = HttpRequest( method="GET", @@ -126,5 +130,5 @@ def test_get_account_properties_v2(self, client): result = client.send_request(request) received_info5 = result.json() assert received_info5 - assert received_info5["customDocumentModels"]["count"] == 0 - assert received_info5["customDocumentModels"]["limit"] == 250 + assert received_info5["customDocumentModels"]["count"] == account_properties.custom_model_count + assert received_info5["customDocumentModels"]["limit"] == account_properties.custom_model_limit diff --git a/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_send_request_async.py b/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_send_request_async.py index 2db0c7be194b..c0dd7dc925c1 100644 --- a/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_send_request_async.py +++ b/sdk/formrecognizer/azure-ai-formrecognizer/tests/test_send_request_async.py @@ -17,13 +17,14 @@ class TestSendRequestAsync(AsyncFormRecognizerTest): - @FormRecognizerPreparer() @DocumentModelAdministrationClientPreparer() @recorded_by_proxy_async async def test_get_resource_details(self, client, **kwargs): set_bodiless_matcher() async with client: + resource_details = await client.get_resource_details() + request = HttpRequest( method="GET", url="info", @@ -33,8 +34,8 @@ async def test_get_resource_details(self, client, **kwargs): received_info1 = result.json() assert received_info1 assert received_info1["customDocumentModels"] - assert received_info1["customDocumentModels"]["count"] == 0 - assert received_info1["customDocumentModels"]["limit"] == 250 + assert received_info1["customDocumentModels"]["count"] == resource_details.custom_document_models.count + assert received_info1["customDocumentModels"]["limit"] == resource_details.custom_document_models.limit request = HttpRequest( method="GET", @@ -66,9 +67,9 @@ async def test_get_resource_details(self, client, **kwargs): result = await client.send_request(request) received_info4 = result.json() assert received_info4 - assert received_info4["summary"]["count"] == 0 - assert received_info4["summary"]["limit"] == 250 - + assert received_info4["summary"]["count"] == resource_details.custom_document_models.count + assert received_info4["summary"]["limit"] == resource_details.custom_document_models.limit + # test with v2 API version with absolute url request = HttpRequest( method="GET", @@ -86,6 +87,8 @@ async def test_get_resource_details(self, client, **kwargs): async def test_get_account_properties_v2(self, client): set_bodiless_matcher() async with client: + account_properties = await client.get_account_properties() + request = HttpRequest( method="GET", url="custom/models?op=summary", @@ -95,9 +98,9 @@ async def test_get_account_properties_v2(self, client): received_info1 = result.json() assert received_info1 assert received_info1["summary"] - assert received_info1["summary"]["count"] == 0 - assert received_info1["summary"]["limit"] == 250 - + assert received_info1["summary"]["count"] == account_properties.custom_model_count + assert received_info1["summary"]["limit"] == account_properties.custom_model_limit + # test with absolute url request = HttpRequest( method="GET", @@ -108,7 +111,7 @@ async def test_get_account_properties_v2(self, client): received_info3 = result.json() assert received_info3["summary"]["count"] == received_info1["summary"]["count"] assert received_info3["summary"]["limit"] == received_info1["summary"]["limit"] - + # relative URLs can't override the API version on 2.x clients request = HttpRequest( method="GET", @@ -119,7 +122,7 @@ async def test_get_account_properties_v2(self, client): received_info4 = result.json() assert received_info4["error"]["code"] == "404" assert received_info4["error"]["message"] == "Resource not found" - + # test with v2 API version with absolute url request = HttpRequest( method="GET", @@ -129,5 +132,5 @@ async def test_get_account_properties_v2(self, client): result = await client.send_request(request) received_info5 = result.json() assert received_info5 - assert received_info5["customDocumentModels"]["count"] == 0 - assert received_info5["customDocumentModels"]["limit"] == 250 + assert received_info5["customDocumentModels"]["count"] == account_properties.custom_model_count + assert received_info5["customDocumentModels"]["limit"] == account_properties.custom_model_limit diff --git a/sdk/graphservices/azure-mgmt-graphservices/pyproject.toml b/sdk/graphservices/azure-mgmt-graphservices/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/graphservices/azure-mgmt-graphservices/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/pyproject.toml b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/hardwaresecuritymodules/azure-mgmt-hardwaresecuritymodules/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/pyproject.toml b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/hybridkubernetes/azure-mgmt-hybridkubernetes/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/identity/azure-identity-broker/CHANGELOG.md b/sdk/identity/azure-identity-broker/CHANGELOG.md index 7ede23f32d9a..63799795bd10 100644 --- a/sdk/identity/azure-identity-broker/CHANGELOG.md +++ b/sdk/identity/azure-identity-broker/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 1.1.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + ## 1.1.0 (2024-04-09) ### Features Added diff --git a/sdk/identity/azure-identity-broker/azure/identity/broker/_version.py b/sdk/identity/azure-identity-broker/azure/identity/broker/_version.py index 6587dc75afd5..8307d096a03f 100644 --- a/sdk/identity/azure-identity-broker/azure/identity/broker/_version.py +++ b/sdk/identity/azure-identity-broker/azure/identity/broker/_version.py @@ -2,4 +2,4 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ -VERSION = "1.1.0" +VERSION = "1.1.1" diff --git a/sdk/identity/azure-identity/CHANGELOG.md b/sdk/identity/azure-identity/CHANGELOG.md index 6c549911b647..0a03c8d61622 100644 --- a/sdk/identity/azure-identity/CHANGELOG.md +++ b/sdk/identity/azure-identity/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 1.16.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + ## 1.16.0 (2024-04-09) ### Other Changes diff --git a/sdk/identity/azure-identity/azure/identity/_version.py b/sdk/identity/azure-identity/azure/identity/_version.py index d6b2b365a466..b47d22c5d31a 100644 --- a/sdk/identity/azure-identity/azure/identity/_version.py +++ b/sdk/identity/azure-identity/azure/identity/_version.py @@ -2,4 +2,4 @@ # Copyright (c) Microsoft Corporation. # Licensed under the MIT License. # ------------------------------------ -VERSION = "1.16.0" +VERSION = "1.16.1" diff --git a/sdk/identity/azure-identity/tests/test_multi_tenant_auth.py b/sdk/identity/azure-identity/tests/test_multi_tenant_auth.py index c4771b47cfea..2c5d8c385bfe 100644 --- a/sdk/identity/azure-identity/tests/test_multi_tenant_auth.py +++ b/sdk/identity/azure-identity/tests/test_multi_tenant_auth.py @@ -21,6 +21,7 @@ def _send_request(self, credential: ClientSecretCredential) -> HttpResponse: response = client.send_request(request) return response + @pytest.mark.live_test_only @pytest.mark.skipif( is_live() and not os.environ.get("AZURE_IDENTITY_MULTI_TENANT_CLIENT_ID"), reason="Multi-tenant envvars not configured.", diff --git a/sdk/identity/azure-identity/tests/test_multi_tenant_auth_async.py b/sdk/identity/azure-identity/tests/test_multi_tenant_auth_async.py index 08a777e5aeef..c6ca05477760 100644 --- a/sdk/identity/azure-identity/tests/test_multi_tenant_auth_async.py +++ b/sdk/identity/azure-identity/tests/test_multi_tenant_auth_async.py @@ -22,6 +22,7 @@ async def _send_request(self, credential: ClientSecretCredential) -> HttpRespons return response @pytest.mark.asyncio + @pytest.mark.live_test_only @pytest.mark.skipif( is_live() and not os.environ.get("AZURE_IDENTITY_MULTI_TENANT_CLIENT_ID"), reason="Multi-tenant envvars not configured.", diff --git a/sdk/iotfirmwaredefense/azure-mgmt-iotfirmwaredefense/pyproject.toml b/sdk/iotfirmwaredefense/azure-mgmt-iotfirmwaredefense/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/iotfirmwaredefense/azure-mgmt-iotfirmwaredefense/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/iothub/azure-mgmt-iotcentral/pyproject.toml b/sdk/iothub/azure-mgmt-iotcentral/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/iothub/azure-mgmt-iotcentral/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/keyvault/azure-keyvault-administration/CHANGELOG.md b/sdk/keyvault/azure-keyvault-administration/CHANGELOG.md index b15e0dd4e9fd..b1548c770172 100644 --- a/sdk/keyvault/azure-keyvault-administration/CHANGELOG.md +++ b/sdk/keyvault/azure-keyvault-administration/CHANGELOG.md @@ -7,6 +7,8 @@ ### Breaking Changes ### Bugs Fixed +- Typing errors from using Key Vault clients as context managers have been fixed + ([#34744](https://github.com/Azure/azure-sdk-for-python/issues/34744)) ### Other Changes diff --git a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_access_control_client.py b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_access_control_client.py index 7802b9ff458b..24bc8e0fbb7d 100644 --- a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_access_control_client.py +++ b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_access_control_client.py @@ -248,3 +248,7 @@ def list_role_definitions( cls=lambda result: [KeyVaultRoleDefinition._from_generated(d) for d in result], **kwargs ) + + def __enter__(self) -> "KeyVaultAccessControlClient": + self._client.__enter__() + return self diff --git a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_backup_client.py b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_backup_client.py index 9a9e76701cfb..1c3cabca5fbe 100644 --- a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_backup_client.py +++ b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_backup_client.py @@ -247,3 +247,7 @@ def begin_restore(self, folder_url: str, *args: str, **kwargs: Any) -> LROPoller polling=polling, **kwargs, ) + + def __enter__(self) -> "KeyVaultBackupClient": + self._client.__enter__() + return self diff --git a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_settings_client.py b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_settings_client.py index fda25fafbad0..8328052949af 100644 --- a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_settings_client.py +++ b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/_settings_client.py @@ -82,3 +82,7 @@ def update_setting(self, setting: KeyVaultSetting, **kwargs: Any) -> KeyVaultSet **kwargs ) return KeyVaultSetting._from_generated(result) + + def __enter__(self) -> "KeyVaultSettingsClient": + self._client.__enter__() + return self diff --git a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_access_control_client.py b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_access_control_client.py index 9a432070b226..fd3e206176ed 100644 --- a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_access_control_client.py +++ b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_access_control_client.py @@ -249,3 +249,7 @@ def list_role_definitions( cls=lambda result: [KeyVaultRoleDefinition._from_generated(d) for d in result], **kwargs ) + + async def __aenter__(self) -> "KeyVaultAccessControlClient": + await self._client.__aenter__() + return self diff --git a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_backup_client.py b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_backup_client.py index 539ef027f7c5..9ba403fdb0bf 100644 --- a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_backup_client.py +++ b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_backup_client.py @@ -244,3 +244,7 @@ async def begin_restore(self, folder_url: str, *args: str, **kwargs: Any) -> Asy polling=polling, **kwargs, ) + + async def __aenter__(self) -> "KeyVaultBackupClient": + await self._client.__aenter__() + return self diff --git a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_settings_client.py b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_settings_client.py index 73729dd33af8..67b71815ce53 100644 --- a/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_settings_client.py +++ b/sdk/keyvault/azure-keyvault-administration/azure/keyvault/administration/aio/_settings_client.py @@ -85,3 +85,7 @@ async def update_setting(self, setting: KeyVaultSetting, **kwargs: Any) -> KeyVa **kwargs ) return KeyVaultSetting._from_generated(result) + + async def __aenter__(self) -> "KeyVaultSettingsClient": + await self._client.__aenter__() + return self diff --git a/sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md b/sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md index c76d62fea30c..4f5d35eebc76 100644 --- a/sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md +++ b/sdk/keyvault/azure-keyvault-certificates/CHANGELOG.md @@ -7,6 +7,8 @@ ### Breaking Changes ### Bugs Fixed +- Typing errors from using Key Vault clients as context managers have been fixed + ([#34744](https://github.com/Azure/azure-sdk-for-python/issues/34744)) ### Other Changes diff --git a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_client.py b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_client.py index 464e789207c3..919c2594a172 100644 --- a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_client.py +++ b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/_client.py @@ -1041,3 +1041,7 @@ def list_properties_of_issuers(self, **kwargs: Any) -> ItemPaged[IssuerPropertie cls=lambda objs: [IssuerProperties._from_issuer_item(issuer_item=x) for x in objs], **kwargs ) + + def __enter__(self) -> "CertificateClient": + self._client.__enter__() + return self diff --git a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/aio/_client.py b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/aio/_client.py index e9cea65b3801..f238a57be60b 100644 --- a/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/aio/_client.py +++ b/sdk/keyvault/azure-keyvault-certificates/azure/keyvault/certificates/aio/_client.py @@ -1046,3 +1046,7 @@ def list_properties_of_issuers(self, **kwargs: Any) -> AsyncItemPaged[IssuerProp cls=lambda objs: [IssuerProperties._from_issuer_item(x) for x in objs], **kwargs ) + + async def __aenter__(self) -> "CertificateClient": + await self._client.__aenter__() + return self diff --git a/sdk/keyvault/azure-keyvault-keys/CHANGELOG.md b/sdk/keyvault/azure-keyvault-keys/CHANGELOG.md index 5b926aaf562b..a77229c31057 100644 --- a/sdk/keyvault/azure-keyvault-keys/CHANGELOG.md +++ b/sdk/keyvault/azure-keyvault-keys/CHANGELOG.md @@ -7,6 +7,8 @@ ### Breaking Changes ### Bugs Fixed +- Typing errors from using Key Vault clients as context managers have been fixed + ([#34744](https://github.com/Azure/azure-sdk-for-python/issues/34744)) ### Other Changes diff --git a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_client.py b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_client.py index 61803b1f43ac..f014eb66df32 100644 --- a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_client.py +++ b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/_client.py @@ -874,3 +874,7 @@ def update_key_rotation_policy( vault_base_url=self._vault_url, key_name=key_name, key_rotation_policy=new_policy ) return KeyRotationPolicy._from_generated(result) + + def __enter__(self) -> "KeyClient": + self._client.__enter__() + return self diff --git a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/aio/_client.py b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/aio/_client.py index 6e06b8843da5..2b4da3a51ae5 100644 --- a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/aio/_client.py +++ b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/aio/_client.py @@ -878,3 +878,7 @@ async def update_key_rotation_policy( vault_base_url=self._vault_url, key_name=key_name, key_rotation_policy=new_policy ) return KeyRotationPolicy._from_generated(result) + + async def __aenter__(self) -> "KeyClient": + await self._client.__aenter__() + return self diff --git a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/crypto/_client.py b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/crypto/_client.py index e6cbd6b91984..56585ae8861d 100644 --- a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/crypto/_client.py +++ b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/crypto/_client.py @@ -560,3 +560,7 @@ def verify(self, algorithm: SignatureAlgorithm, digest: bytes, signature: bytes, ) return VerifyResult(key_id=self.key_id, algorithm=algorithm, is_valid=operation_result.value) + + def __enter__(self) -> "CryptographyClient": + self._client.__enter__() + return self diff --git a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/crypto/aio/_client.py b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/crypto/aio/_client.py index 79f11fe5e47f..3ebf3f8f2a38 100644 --- a/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/crypto/aio/_client.py +++ b/sdk/keyvault/azure-keyvault-keys/azure/keyvault/keys/crypto/aio/_client.py @@ -482,3 +482,7 @@ async def verify( ) return VerifyResult(key_id=self.key_id, algorithm=algorithm, is_valid=operation_result.value) + + async def __aenter__(self) -> "CryptographyClient": + await self._client.__aenter__() + return self diff --git a/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md b/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md index 841726789a08..cd0f99964eb9 100644 --- a/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md +++ b/sdk/keyvault/azure-keyvault-secrets/CHANGELOG.md @@ -7,6 +7,8 @@ ### Breaking Changes ### Bugs Fixed +- Typing errors from using Key Vault clients as context managers have been fixed + ([#34744](https://github.com/Azure/azure-sdk-for-python/issues/34744)) ### Other Changes diff --git a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_client.py b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_client.py index 4f5723556725..00ddafb81e1c 100644 --- a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_client.py +++ b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/_client.py @@ -464,3 +464,7 @@ def begin_recover_deleted_secret(self, name: str, **kwargs: Any) -> LROPoller[Se interval=polling_interval, ) return KeyVaultOperationPoller(polling_method) + + def __enter__(self) -> "SecretClient": + self._client.__enter__() + return self diff --git a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/aio/_client.py b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/aio/_client.py index 3e31953ab934..de2a1316ead4 100644 --- a/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/aio/_client.py +++ b/sdk/keyvault/azure-keyvault-secrets/azure/keyvault/secrets/aio/_client.py @@ -439,3 +439,7 @@ async def recover_deleted_secret(self, name: str, **kwargs: Any) -> SecretProper await polling_method.run() return polling_method.resource() + + async def __aenter__(self) -> "SecretClient": + await self._client.__aenter__() + return self diff --git a/sdk/keyvault/azure-keyvault-secrets/tests/test_samples_secrets_async.py b/sdk/keyvault/azure-keyvault-secrets/tests/test_samples_secrets_async.py index c3abc10f9061..a8f566e3be2e 100644 --- a/sdk/keyvault/azure-keyvault-secrets/tests/test_samples_secrets_async.py +++ b/sdk/keyvault/azure-keyvault-secrets/tests/test_samples_secrets_async.py @@ -109,8 +109,6 @@ async def test_example_secret_crud_operations(self, client, **kwargs): @AsyncSecretsClientPreparer() @recorded_by_proxy_async async def test_example_secret_list_operations(self, client, **kwargs): - if not is_live(): - set_custom_default_matcher(excluded_headers="Authorization") secret_client = client async with secret_client: for i in range(7): diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/CHANGELOG.md b/sdk/largeinstance/azure-mgmt-largeinstance/CHANGELOG.md new file mode 100644 index 000000000000..238ce7d92cbe --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 1.0.0b1 (2024-04-15) + +* Initial Release diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/LICENSE b/sdk/largeinstance/azure-mgmt-largeinstance/LICENSE new file mode 100644 index 000000000000..b2f52a2bad4e --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) Microsoft Corporation. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/MANIFEST.in b/sdk/largeinstance/azure-mgmt-largeinstance/MANIFEST.in new file mode 100644 index 000000000000..2cf490173f6e --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/MANIFEST.in @@ -0,0 +1,8 @@ +include _meta.json +recursive-include tests *.py *.json +recursive-include samples *.py *.md +include *.md +include azure/__init__.py +include azure/mgmt/__init__.py +include LICENSE +include azure/mgmt/largeinstance/py.typed diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/README.md b/sdk/largeinstance/azure-mgmt-largeinstance/README.md new file mode 100644 index 000000000000..900efbd3cbd7 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/README.md @@ -0,0 +1,61 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure Largeinstance Management Client Library. +This package has been tested with Python 3.8+. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + +## _Disclaimer_ + +_Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For more information and questions, please refer to https://github.com/Azure/azure-sdk-for-python/issues/20691_ + +## Getting started + +### Prerequisites + +- Python 3.8+ is required to use this package. +- [Azure subscription](https://azure.microsoft.com/free/) + +### Install the package + +```bash +pip install azure-mgmt-largeinstance +pip install azure-identity +``` + +### Authentication + +By default, [Azure Active Directory](https://aka.ms/awps/aad) token authentication depends on correct configure of following environment variables. + +- `AZURE_CLIENT_ID` for Azure client ID. +- `AZURE_TENANT_ID` for Azure tenant ID. +- `AZURE_CLIENT_SECRET` for Azure client secret. + +In addition, Azure subscription ID can be configured via environment variable `AZURE_SUBSCRIPTION_ID`. + +With above configuration, client can be authenticated by following code: + +```python +from azure.identity import DefaultAzureCredential +from azure.mgmt.largeinstance import LargeInstanceMgmtClient +import os + +sub_id = os.getenv("AZURE_SUBSCRIPTION_ID") +client = LargeInstanceMgmtClient(credential=DefaultAzureCredential(), subscription_id=sub_id) +``` + +## Examples + +Code samples for this package can be found at: +- [Search Largeinstance Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com +- [Azure Python Mgmt SDK Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +## Troubleshooting + +## Next steps + +## Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/_meta.json b/sdk/largeinstance/azure-mgmt-largeinstance/_meta.json new file mode 100644 index 000000000000..09dbf3047d00 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/_meta.json @@ -0,0 +1,11 @@ +{ + "commit": "db6282dd0d04c5f13375e98e88b09d04c2009ae8", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.7", + "use": [ + "@autorest/python@6.13.7", + "@autorest/modelerfour@4.27.0" + ], + "autorest_command": "autorest specification/azurelargeinstance/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.13.7 --use=@autorest/modelerfour@4.27.0 --version=3.9.7 --version-tolerant=False", + "readme": "specification/azurelargeinstance/resource-manager/readme.md" +} \ No newline at end of file diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/__init__.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/__init__.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/__init__.py new file mode 100644 index 000000000000..8db66d3d0f0f --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/__init__.py @@ -0,0 +1 @@ +__path__ = __import__("pkgutil").extend_path(__path__, __name__) diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/__init__.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/__init__.py new file mode 100644 index 000000000000..64d4c3b93695 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/__init__.py @@ -0,0 +1,26 @@ +# 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 ._large_instance_mgmt_client import LargeInstanceMgmtClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "LargeInstanceMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_configuration.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_configuration.py new file mode 100644 index 000000000000..7b1881353e85 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_configuration.py @@ -0,0 +1,65 @@ +# 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 typing import Any, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class LargeInstanceMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for LargeInstanceMgmtClient. + + 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: 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 "2023-07-20-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: + api_version: str = kwargs.pop("api_version", "2023-07-20-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-largeinstance/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_large_instance_mgmt_client.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_large_instance_mgmt_client.py new file mode 100644 index 000000000000..94e9a8a059d6 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_large_instance_mgmt_client.py @@ -0,0 +1,122 @@ +# 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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy + +from . import models as _models +from ._configuration import LargeInstanceMgmtClientConfiguration +from ._serialization import Deserializer, Serializer +from .operations import AzureLargeInstanceOperations, AzureLargeStorageInstanceOperations, Operations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class LargeInstanceMgmtClient: # pylint: disable=client-accepts-api-version-keyword + """The AzureLargeInstance Management client. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.largeinstance.operations.Operations + :ivar azure_large_instance: AzureLargeInstanceOperations operations + :vartype azure_large_instance: azure.mgmt.largeinstance.operations.AzureLargeInstanceOperations + :ivar azure_large_storage_instance: AzureLargeStorageInstanceOperations operations + :vartype azure_large_storage_instance: + azure.mgmt.largeinstance.operations.AzureLargeStorageInstanceOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :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 "2023-07-20-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. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = LargeInstanceMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + 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.azure_large_instance = AzureLargeInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.azure_large_storage_instance = AzureLargeStorageInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + def close(self) -> None: + self._client.close() + + def __enter__(self) -> "LargeInstanceMgmtClient": + self._client.__enter__() + return self + + def __exit__(self, *exc_details: Any) -> None: + self._client.__exit__(*exc_details) diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_patch.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_serialization.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_serialization.py new file mode 100644 index 000000000000..2f781d740827 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_serialization.py @@ -0,0 +1,1998 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file +# pyright: reportUnnecessaryTypeIgnoreComment=false + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +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 +import xml.etree.ElementTree as ET + +import isodate # type: ignore + +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +ModelType = TypeVar("ModelType", bound="Model") +JSON = MutableMapping[str, Any] + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + 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. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError as err: + # It might be because the server has an issue, and returned JSON with + # content-type XML.... + # So let's try a JSON load, and if it's still broken + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # The function hack is because Py2.7 messes up with exception + # context otherwise. + _LOGGER.critical("Wasn't XML not JSON, failing") + raise DeserializationError("XML is invalid") from err + raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + 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 + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset # type: ignore +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? None: + self.additional_properties: Optional[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__) + elif k in self._validation and self._validation[k].get("readonly", False): + _LOGGER.warning("Readonly attribute %s will be ignored in class %s", k, self.__class__) + else: + setattr(self, k, kwargs[k]) + + 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: Any) -> bool: + """Compare objects by comparing all attributes.""" + return not self.__eq__(other) + + def __str__(self) -> str: + return str(self.__dict__) + + @classmethod + def enable_additional_properties_sending(cls) -> None: + cls._attribute_map["additional_properties"] = {"key": "", "type": "{object}"} + + @classmethod + def is_xml_model(cls) -> bool: + try: + cls._xml_map # type: ignore + except AttributeError: + return False + return True + + @classmethod + def _create_xml_node(cls): + """Create XML node.""" + try: + 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: bool = False, **kwargs: Any) -> JSON: + """Return the JSON that would be sent to server from this model. + + This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param bool keep_readonly: If you want to serialize the readonly attributes + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore + + 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: + + .. code::python + + def my_key_transformer(key, attr_desc, value): + return key + + Key is the attribute name used in Python. Attr_desc + is a dict of metadata. Currently contains 'type' with the + msrest type and 'key' with the RestAPI encoded key. + Value is the current value in this object. + + The string returned will be used to serialize the key. + If the return type is a list, this is considered hierarchical + result dict. + + See the three examples in this file: + + - attribute_transformer + - full_restapi_key_transformer + - last_restapi_key_transformer + + If you want XML serialization, you can pass the kwargs is_xml=True. + + :param function key_transformer: A key transformer function. + :returns: A dict JSON compatible object + :rtype: dict + """ + serializer = Serializer(self._infer_class_models()) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore + + @classmethod + def _infer_class_models(cls): + try: + str_models = cls.__module__.rsplit(".", 1)[0] + models = sys.modules[str_models] + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + if cls.__name__ not in client_models: + raise ValueError("Not Autorest generated code") + except Exception: + # Assume it's not Autorest generated (tests?). Add ourselves as dependencies. + client_models = {cls.__name__: cls} + return client_models + + @classmethod + 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. + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + 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 + extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor + and last_rest_key_case_insensitive_extractor) + + :param dict data: A dict using RestAPI structure + :param str content_type: JSON by default, set application/xml if XML. + :returns: An instance of this model + :raises: DeserializationError if something went wrong + """ + deserializer = Deserializer(cls._infer_class_models()) + deserializer.key_extractors = ( # type: ignore + [ # type: ignore + attribute_key_case_insensitive_extractor, + rest_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + if key_extractors is None + else key_extractors + ) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore + + @classmethod + def _flatten_subtype(cls, key, objects): + if "_subtype_map" not in cls.__dict__: + return {} + result = dict(cls._subtype_map[key]) + for valuetype in cls._subtype_map[key].values(): + result.update(objects[valuetype]._flatten_subtype(key, objects)) + return result + + @classmethod + def _classify(cls, response, objects): + """Check the class _subtype_map for any child classes. + We want to ignore any inherited _subtype_maps. + Remove the polymorphic key from the initial data. + """ + for subtype_key in cls.__dict__.get("_subtype_map", {}).keys(): + subtype_value = None + + if not isinstance(response, ET.Element): + rest_api_response_key = cls._get_rest_key_parts(subtype_key)[-1] + subtype_value = response.pop(rest_api_response_key, None) or response.pop(subtype_key, None) + else: + subtype_value = xml_key_extractor(subtype_key, cls._attribute_map[subtype_key], response) + if subtype_value: + # Try to match base class. Can be class name only + # (bug to fix in Autorest to support x-ms-discriminator-name) + if cls.__name__ == subtype_value: + return cls + flatten_mapping_type = cls._flatten_subtype(subtype_key, objects) + try: + return objects[flatten_mapping_type[subtype_value]] # type: ignore + except KeyError: + _LOGGER.warning( + "Subtype value %s has no mapping, use base class %s.", + subtype_value, + cls.__name__, + ) + break + else: + _LOGGER.warning("Discriminator %s is absent or null, use base class %s.", subtype_key, cls.__name__) + break + return cls + + @classmethod + def _get_rest_key_parts(cls, attr_key): + """Get the RestAPI key of this attr, split it and decode part + :param str attr_key: Attribute key must be in attribute_map. + :returns: A list of RestAPI part + :rtype: list + """ + rest_split_key = _FLATTEN.split(cls._attribute_map[attr_key]["key"]) + return [_decode_attribute_map_key(key_part) for key_part in rest_split_key] + + +def _decode_attribute_map_key(key): + """This decode a key in an _attribute_map to the actual key we want to look at + inside the received data. + + :param str key: A key string from the generated code + """ + return key.replace("\\.", ".") + + +class Serializer(object): + """Request object model serializer.""" + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + _xml_basic_types_serializers = {"bool": lambda x: str(x).lower()} + days = {0: "Mon", 1: "Tue", 2: "Wed", 3: "Thu", 4: "Fri", 5: "Sat", 6: "Sun"} + months = { + 1: "Jan", + 2: "Feb", + 3: "Mar", + 4: "Apr", + 5: "May", + 6: "Jun", + 7: "Jul", + 8: "Aug", + 9: "Sep", + 10: "Oct", + 11: "Nov", + 12: "Dec", + } + validation = { + "min_length": lambda x, y: len(x) < y, + "max_length": lambda x, y: len(x) > y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes: Optional[Mapping[str, type]] = None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies: Dict[str, type] = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + 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) # type: ignore + continue + if xml_desc.get("text", False): + serialized.text = new_attr # type: ignore + continue + if isinstance(new_attr, list): + 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", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + 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 = str(new_attr) + serialized.append(local_node) # type: ignore + else: # JSON + for k in reversed(keys): # type: ignore + new_attr = {k: new_attr} + + _new_attr = new_attr + _serialized = serialized + for k in keys: # type: ignore + if k not in _serialized: + _serialized.update(_new_attr) # type: ignore + _new_attr = _new_attr[k] # type: ignore + _serialized = _serialized[k] + 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)) + raise SerializationError(msg) from err + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + 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: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ # type: ignore + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise SerializationError("Unable to build a model: " + str(err)) from err + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :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, list + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # 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] + do_quote = not kwargs.get("skip_quote", False) + return 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) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data is CoreNull: + return None + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **kwargs) + + except (ValueError, TypeError) as err: + msg = "Unable to serialize value: {!r} as type: {!r}." + raise SerializationError(msg.format(data, data_type)) from err + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): # type: ignore + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + 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): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + 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) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError as err: + if isinstance(err, SerializationError): + raise + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + 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 str: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) # type: ignore + return result + except ValueError: + 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}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise SerializationError(msg) from err + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise TypeError(msg) from err + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in 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 + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_data) + if working_data is None: + # If at any point while following flatten JSON path see None, it means + # that all properties under are None as well + return None + key = ".".join(dict_keys[1:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + 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) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # 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) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + 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]] = None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, str): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + 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"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + 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 # type: ignore + raise DeserializationError(msg) from err + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + 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 deserialize. + """ + if target is None: + return None, None + + if isinstance(target, str): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + 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 + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deserialize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + if hasattr(raw_data, "_content_consumed"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text, raw_data.headers) + + 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 + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) # type: ignore + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_type) + + except (ValueError, TypeError, AttributeError) as err: + msg = "Unable to deserialize response data." + msg += " Data: {}, {}".format(data, data_type) + raise DeserializationError(msg) from err + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, str): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, str): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): # type: ignore + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + data = data.value + if isinstance(data, int): + # Workaround. We might consider remove it in the future. + try: + return list(enum_obj.__members__.values())[data] + except IndexError: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) # type: ignore + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) # type: ignore + attr = attr + padding # type: ignore + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(str(attr)) # type: ignore + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise DeserializationError(msg) from err + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) # type: ignore + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise DeserializationError(msg) from err + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + 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=0, defaultday=0) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + 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) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + 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)) + ) + if not date_obj.tzinfo: + date_obj = date_obj.astimezone(tz=TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to rfc datetime object." + raise DeserializationError(msg) from err + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() # type: ignore + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise DeserializationError(msg) from err + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) # type: ignore + try: + attr = int(attr) + date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) + except ValueError as err: + msg = "Cannot deserialize to unix datetime object." + raise DeserializationError(msg) from err + else: + return date_obj diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_vendor.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_vendor.py new file mode 100644 index 000000000000..0dafe0e287ff --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_vendor.py @@ -0,0 +1,16 @@ +# -------------------------------------------------------------------------- +# 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.core.pipeline.transport import HttpRequest + + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_version.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/__init__.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/__init__.py new file mode 100644 index 000000000000..f941516e8c1e --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/__init__.py @@ -0,0 +1,23 @@ +# 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 ._large_instance_mgmt_client import LargeInstanceMgmtClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "LargeInstanceMgmtClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/_configuration.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/_configuration.py new file mode 100644 index 000000000000..9d91180130fc --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/_configuration.py @@ -0,0 +1,65 @@ +# 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 typing import Any, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class LargeInstanceMgmtClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long + """Configuration for LargeInstanceMgmtClient. + + 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: 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 "2023-07-20-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: + api_version: str = kwargs.pop("api_version", "2023-07-20-preview") + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-largeinstance/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) + self._configure(**kwargs) + + 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) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/_large_instance_mgmt_client.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/_large_instance_mgmt_client.py new file mode 100644 index 000000000000..e22a168ebccb --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/_large_instance_mgmt_client.py @@ -0,0 +1,125 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.pipeline import policies +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy + +from .. import models as _models +from .._serialization import Deserializer, Serializer +from ._configuration import LargeInstanceMgmtClientConfiguration +from .operations import AzureLargeInstanceOperations, AzureLargeStorageInstanceOperations, Operations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class LargeInstanceMgmtClient: # pylint: disable=client-accepts-api-version-keyword + """The AzureLargeInstance Management client. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.largeinstance.aio.operations.Operations + :ivar azure_large_instance: AzureLargeInstanceOperations operations + :vartype azure_large_instance: + azure.mgmt.largeinstance.aio.operations.AzureLargeInstanceOperations + :ivar azure_large_storage_instance: AzureLargeStorageInstanceOperations operations + :vartype azure_large_storage_instance: + azure.mgmt.largeinstance.aio.operations.AzureLargeStorageInstanceOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :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 "2023-07-20-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. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = LargeInstanceMgmtClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) + + 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.azure_large_instance = AzureLargeInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.azure_large_storage_instance = AzureLargeStorageInstanceOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "LargeInstanceMgmtClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details: Any) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/_patch.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/__init__.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/__init__.py new file mode 100644 index 000000000000..9b4f2bf7ab5c --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/__init__.py @@ -0,0 +1,23 @@ +# 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 ._operations import Operations +from ._azure_large_instance_operations import AzureLargeInstanceOperations +from ._azure_large_storage_instance_operations import AzureLargeStorageInstanceOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "AzureLargeInstanceOperations", + "AzureLargeStorageInstanceOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_azure_large_instance_operations.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_azure_large_instance_operations.py new file mode 100644 index 000000000000..f83cd5caa565 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_azure_large_instance_operations.py @@ -0,0 +1,864 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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._azure_large_instance_operations import ( + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_restart_request, + build_shutdown_request, + build_start_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AzureLargeInstanceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.largeinstance.aio.LargeInstanceMgmtClient`'s + :attr:`azure_large_instance` 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") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AzureLargeInstance"]: + """Gets a list of Azure Large Instances in the specified subscription. The + operations returns various properties of each Azure Large Instance. + + :return: An iterator like instance of either AzureLargeInstance or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.largeinstance.models.AzureLargeInstance] + :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.AzureLargeInstanceListResult] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeInstanceListResult", 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) + + 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) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AzureLargeInstance"]: + """Gets a list of Azure Large Instances in the specified subscription and resource + group. The operations returns various properties of each Azure Large Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either AzureLargeInstance or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.largeinstance.models.AzureLargeInstance] + :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.AzureLargeInstanceListResult] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeInstanceListResult", 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) + + 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) + + @distributed_trace_async + async def get( + self, resource_group_name: str, azure_large_instance_name: str, **kwargs: Any + ) -> _models.AzureLargeInstance: + """Gets an Azure Large Instance for the specified subscription, resource group, + and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :return: AzureLargeInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeInstance + :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.AzureLargeInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + azure_large_instance_name: str, + properties: _models.AzureLargeInstanceTagsUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureLargeInstance: + """Patches the Tags field of an Azure Large Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.largeinstance.models.AzureLargeInstanceTagsUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureLargeInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + azure_large_instance_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureLargeInstance: + """Patches the Tags field of an Azure Large Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureLargeInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + azure_large_instance_name: str, + properties: Union[_models.AzureLargeInstanceTagsUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.AzureLargeInstance: + """Patches the Tags field of an Azure Large Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param properties: The resource properties to be updated. Is either a + AzureLargeInstanceTagsUpdate type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.largeinstance.models.AzureLargeInstanceTagsUpdate or IO[bytes] + :return: AzureLargeInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeInstance + :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.AzureLargeInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "AzureLargeInstanceTagsUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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("AzureLargeInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + async def _restart_initial( + self, + resource_group_name: str, + azure_large_instance_name: str, + force_parameter: Optional[Union[_models.ForceState, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + 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[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(force_parameter, (IOBase, bytes)): + _content = force_parameter + else: + if force_parameter is not None: + _json = self._serialize.body(force_parameter, "ForceState") + else: + _json = None + + _request = build_restart_request( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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, 202]: + 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 = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + async def begin_restart( + self, + resource_group_name: str, + azure_large_instance_name: str, + force_parameter: Optional[_models.ForceState] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """The operation to restart an Azure Large Instance (only for compute instances). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param force_parameter: When set to 'active', this parameter empowers the server with the + ability to forcefully terminate and halt any existing processes that may be running on the + server. Default value is None. + :type force_parameter: ~azure.mgmt.largeinstance.models.ForceState + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.largeinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restart( + self, + resource_group_name: str, + azure_large_instance_name: str, + force_parameter: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """The operation to restart an Azure Large Instance (only for compute instances). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param force_parameter: When set to 'active', this parameter empowers the server with the + ability to forcefully terminate and halt any existing processes that may be running on the + server. Default value is None. + :type force_parameter: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.largeinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restart( + self, + resource_group_name: str, + azure_large_instance_name: str, + force_parameter: Optional[Union[_models.ForceState, IO[bytes]]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """The operation to restart an Azure Large Instance (only for compute instances). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param force_parameter: When set to 'active', this parameter empowers the server with the + ability to forcefully terminate and halt any existing processes that may be running on the + server. Is either a ForceState type or a IO[bytes] type. Default value is None. + :type force_parameter: ~azure.mgmt.largeinstance.models.ForceState or IO[bytes] + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.largeinstance.models.OperationStatusResult] + :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.OperationStatusResult] = 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._restart_initial( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + force_parameter=force_parameter, + 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("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + 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[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _shutdown_initial( + self, resource_group_name: str, azure_large_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + 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[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + _request = build_shutdown_request( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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, 202]: + 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 = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_shutdown( + self, resource_group_name: str, azure_large_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """The operation to shutdown an Azure Large Instance (only for compute instances). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.largeinstance.models.OperationStatusResult] + :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.OperationStatusResult] = 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._shutdown_initial( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_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): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + 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[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + async def _start_initial( + self, resource_group_name: str, azure_large_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + 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[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + _request = build_start_request( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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, 202]: + 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 = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def begin_start( + self, resource_group_name: str, azure_large_instance_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.OperationStatusResult]: + """The operation to start an Azure Large Instance (only for compute instances). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :return: An instance of AsyncLROPoller that returns either OperationStatusResult or the result + of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.largeinstance.models.OperationStatusResult] + :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.OperationStatusResult] = 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._start_initial( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_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): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + 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[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_azure_large_storage_instance_operations.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_azure_large_storage_instance_operations.py new file mode 100644 index 000000000000..3364785c97aa --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_azure_large_storage_instance_operations.py @@ -0,0 +1,423 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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, 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.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 ... import models as _models +from ..._vendor import _convert_request +from ...operations._azure_large_storage_instance_operations import ( + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_update_request, +) + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class AzureLargeStorageInstanceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.largeinstance.aio.LargeInstanceMgmtClient`'s + :attr:`azure_large_storage_instance` 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") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.AzureLargeStorageInstance"]: + """Gets a list of AzureLargeStorageInstances in the specified subscription. The + operations returns various properties of each Azure LargeStorage instance. + + :return: An iterator like instance of either AzureLargeStorageInstance or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.largeinstance.models.AzureLargeStorageInstance] + :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.AzureLargeStorageInstanceListResult] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeStorageInstanceListResult", 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) + + 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) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.AzureLargeStorageInstance"]: + """Gets a list of AzureLargeStorageInstances in the specified subscription and + resource group. The operations returns various properties of each Azure + LargeStorage instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either AzureLargeStorageInstance or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.largeinstance.models.AzureLargeStorageInstance] + :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.AzureLargeStorageInstanceListResult] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeStorageInstanceListResult", 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) + + 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) + + @distributed_trace_async + async def get( + self, resource_group_name: str, azure_large_storage_instance_name: str, **kwargs: Any + ) -> _models.AzureLargeStorageInstance: + """Gets an Azure Large Storage instance for the specified subscription, resource + group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_storage_instance_name: Name of the AzureLargeStorageInstance. Required. + :type azure_large_storage_instance_name: str + :return: AzureLargeStorageInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstance + :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.AzureLargeStorageInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + azure_large_storage_instance_name=azure_large_storage_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeStorageInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + azure_large_storage_instance_name: str, + properties: _models.AzureLargeStorageInstanceTagsUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureLargeStorageInstance: + """Patches the Tags field of a Azure Large Storage Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_storage_instance_name: Name of the AzureLargeStorageInstance. Required. + :type azure_large_storage_instance_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstanceTagsUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureLargeStorageInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + azure_large_storage_instance_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureLargeStorageInstance: + """Patches the Tags field of a Azure Large Storage Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_storage_instance_name: Name of the AzureLargeStorageInstance. Required. + :type azure_large_storage_instance_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureLargeStorageInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + azure_large_storage_instance_name: str, + properties: Union[_models.AzureLargeStorageInstanceTagsUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.AzureLargeStorageInstance: + """Patches the Tags field of a Azure Large Storage Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_storage_instance_name: Name of the AzureLargeStorageInstance. Required. + :type azure_large_storage_instance_name: str + :param properties: The resource properties to be updated. Is either a + AzureLargeStorageInstanceTagsUpdate type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstanceTagsUpdate or + IO[bytes] + :return: AzureLargeStorageInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstance + :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.AzureLargeStorageInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "AzureLargeStorageInstanceTagsUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + azure_large_storage_instance_name=azure_large_storage_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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("AzureLargeStorageInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_operations.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_operations.py new file mode 100644 index 000000000000..2c5b4d14b97b --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_operations.py @@ -0,0 +1,129 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +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.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 ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.largeinstance.aio.LargeInstanceMgmtClient`'s + :attr:`operations` 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") + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.largeinstance.models.Operation] + :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.OperationListResult] = 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( + api_version=api_version, + 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("OperationListResult", 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) + + 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) diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_patch.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/__init__.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/__init__.py new file mode 100644 index 000000000000..65bab839e49f --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/__init__.py @@ -0,0 +1,93 @@ +# 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 ._models_py3 import AzureLargeInstance +from ._models_py3 import AzureLargeInstanceListResult +from ._models_py3 import AzureLargeInstanceProperties +from ._models_py3 import AzureLargeInstanceTagsUpdate +from ._models_py3 import AzureLargeStorageInstance +from ._models_py3 import AzureLargeStorageInstanceListResult +from ._models_py3 import AzureLargeStorageInstanceProperties +from ._models_py3 import AzureLargeStorageInstanceTagsUpdate +from ._models_py3 import Disk +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import ForceState +from ._models_py3 import HardwareProfile +from ._models_py3 import IpAddress +from ._models_py3 import NetworkProfile +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import OperationStatusResult +from ._models_py3 import OsProfile +from ._models_py3 import Resource +from ._models_py3 import StorageBillingProperties +from ._models_py3 import StorageProfile +from ._models_py3 import StorageProperties +from ._models_py3 import SystemData +from ._models_py3 import Tags +from ._models_py3 import TrackedResource + +from ._large_instance_mgmt_client_enums import ActionType +from ._large_instance_mgmt_client_enums import AzureLargeInstanceForcePowerState +from ._large_instance_mgmt_client_enums import AzureLargeInstanceHardwareTypeNamesEnum +from ._large_instance_mgmt_client_enums import AzureLargeInstancePowerStateEnum +from ._large_instance_mgmt_client_enums import AzureLargeInstanceProvisioningStatesEnum +from ._large_instance_mgmt_client_enums import AzureLargeInstanceSizeNamesEnum +from ._large_instance_mgmt_client_enums import CreatedByType +from ._large_instance_mgmt_client_enums import Origin +from ._large_instance_mgmt_client_enums import ProvisioningState +from ._large_instance_mgmt_client_enums import Versions +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AzureLargeInstance", + "AzureLargeInstanceListResult", + "AzureLargeInstanceProperties", + "AzureLargeInstanceTagsUpdate", + "AzureLargeStorageInstance", + "AzureLargeStorageInstanceListResult", + "AzureLargeStorageInstanceProperties", + "AzureLargeStorageInstanceTagsUpdate", + "Disk", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "ForceState", + "HardwareProfile", + "IpAddress", + "NetworkProfile", + "Operation", + "OperationDisplay", + "OperationListResult", + "OperationStatusResult", + "OsProfile", + "Resource", + "StorageBillingProperties", + "StorageProfile", + "StorageProperties", + "SystemData", + "Tags", + "TrackedResource", + "ActionType", + "AzureLargeInstanceForcePowerState", + "AzureLargeInstanceHardwareTypeNamesEnum", + "AzureLargeInstancePowerStateEnum", + "AzureLargeInstanceProvisioningStatesEnum", + "AzureLargeInstanceSizeNamesEnum", + "CreatedByType", + "Origin", + "ProvisioningState", + "Versions", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/_large_instance_mgmt_client_enums.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/_large_instance_mgmt_client_enums.py new file mode 100644 index 000000000000..fadb85cee7a3 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/_large_instance_mgmt_client_enums.py @@ -0,0 +1,256 @@ +# 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 ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" + + INTERNAL = "Internal" + + +class AzureLargeInstanceForcePowerState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of two possible values to determine if the ALI instance restart operation should + forcefully terminate and halt any existing processes that may be running on the server or not. + """ + + ACTIVE = "active" + """Active means that the restart operation will terminate and halt existing processes that may be + running on the server""" + INACTIVE = "inactive" + """Inactive means that the restart operation will not terminate and halt existing processes that + may be running on the server""" + + +class AzureLargeInstanceHardwareTypeNamesEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of the hardware options (vendor and/or their product name) for an Azure Large Instance.""" + + CISCO_UCS = "Cisco_UCS" + """Hardware type of UCS from vendor Cisco""" + HPE = "HPE" + """Hardware type of HPE from vendor Hewlett Packard Enterprise""" + SDFLEX = "SDFLEX" + """Hardware type of SDFLEX""" + + +class AzureLargeInstancePowerStateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Power states that an Azure Large Instance can be in.""" + + STARTING = "starting" + """Starting means that the Azure Large Instance resource is turning on.""" + STARTED = "started" + """Started means that the Azure Large Instance resource has been powered on.""" + STOPPING = "stopping" + """Stopping means that the Azure Large Instance resource is shutting down.""" + STOPPED = "stopped" + """Stopped means that the Azure Large Instance resource has shut down.""" + RESTARTING = "restarting" + """Restarting means that the Azure Large Instance resource is restarting.""" + UNKNOWN = "unknown" + """Unknown means that the state of the Azure Large Instance is unknown.""" + + +class AzureLargeInstanceProvisioningStatesEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning states that an Azure Large Instance can be in.""" + + ACCEPTED = "Accepted" + """Accepted means Azure Large Instance resource provisioning has been accepted.""" + CREATING = "Creating" + """Creating means Azure Large Instance resource is being created.""" + UPDATING = "Updating" + """Updating means an existing Azure Large Instance resource is being updated""" + FAILED = "Failed" + """Failed means Azure Large Instance resource is in failed state""" + SUCCEEDED = "Succeeded" + """Succeeded means Azure Large Instance resource creation succeeded during last create/update""" + DELETING = "Deleting" + """Deleting means Azure Large Instance resource is in the process of being deleted""" + MIGRATING = "Migrating" + """Migrating means Azure Large Instance resource is being migrated from one subscription or + resource group to another""" + CANCELED = "Canceled" + """Cancelled Azure Large Instance resource operation has been cancelled""" + + +class AzureLargeInstanceSizeNamesEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum of available model types (each of which have their own storage / memory sizes) for an + Azure Large Instance type. See + https://docs.microsoft.com/azure/sap/large-instances/hana-available-skus. + """ + + S72_M = "S72m" + """Type I class SKU that can't be purchased anymore""" + S144_M = "S144m" + """Type I class SKU that can't be purchased anymore""" + S72 = "S72" + """Type I class SKU that can't be purchased anymore""" + S144 = "S144" + """Type I class SKU that can't be purchased anymore""" + S192 = "S192" + """Type I class SKU that can't be purchased anymore""" + S192_M = "S192m" + """Type I class SKU that can't be purchased anymore""" + S192_XM = "S192xm" + """Type I class SKU that can't be purchased anymore""" + S96 = "S96" + """2 sockets, 96 CPU threads, 48 CPU cores, 768 GB total memory, 768 GB DRAM, 3.0 TB storage, + Cisco_UCS hardware type""" + S112 = "S112" + """No longer offered or used.""" + S224 = "S224" + """4 sockets, 224 CPU threads, 112 CPU cores, 3 TB total memory, 3 TB DRAM, 6.3 TB storage, + Cisco_UCS hardware type""" + S224_M = "S224m" + """4 sockets, 224 CPU threads, 112 CPU cores, 6 TB total memory, 6 TB DRAM, 10.5 TB storage, + Cisco_UCS hardware type""" + S224_OM = "S224om" + """4 sockets, 224 CPU threads, 112 CPU cores, 6 TB total memory, 3 TB DRAM, 3 TB memory optane, + 10.5 TB storage, Cisco_UCS hardware type""" + S224_OO = "S224oo" + """4 sockets, 224 CPU threads, 112 CPU cores, 4.5 TB total memory, 1.5 TB DRAM, 3 TB memory + optane, 8.4 TB storage, Cisco_UCS hardware type""" + S224_OOM = "S224oom" + """4 sockets, 224 CPU threads, 112 CPU cores, 9 TB total memory, 3 TB DRAM, 6 TB memory optane, + 14.8 TB storage, Cisco_UCS hardware type""" + S224_OOO = "S224ooo" + """4 sockets, 224 CPU threads, 112 CPU cores, 7.5TB total memory, 1.5 TB DRAM, 6 TB memory optane, + 12.7 TB storage, Cisco_UCS hardware type""" + S224_SE = "S224se" + """4 sockets, 448 CPU threads, 6 TB total memory, SDFLEX hardware type""" + S384 = "S384" + """8 sockets, 384 CPU threads, 192 CPU cores, 4 TB total memory, 4 TB DRAM, 16 TB storage, + HPEMc990x hardware type""" + S384_M = "S384m" + """8 sockets, 384 CPU threads, 192 CPU cores, 6 TB total memory, 6 TB DRAM, 18 TB storage, + HPEMc990x hardware type""" + S384_XM = "S384xm" + """8 sockets, 384 CPU threads, 192 CPU cores, 8 TB total memory, 8 TB DRAM, 22 TB storage, + HPEMc990x hardware type""" + S384_XXM = "S384xxm" + """8 sockets, 384 CPU threads, 12 TB total memory, HPEMc990x hardware type""" + S448 = "S448" + """8 sockets, 448 CPU threads, 224 CPU cores, 6 TB total memory, 6 TB DRAM, 10.5 TB storage, + SDFLEX hardware type""" + S448_M = "S448m" + """8 sockets, 448 CPU threads, 224 CPU cores, 12 TB total memory, 12 TB DRAM, 18.9 TB storage, + SDFLEX hardware type""" + S448_OM = "S448om" + """8 sockets, 448 CPU threads, 224 CPU cores, 12 TB total memory, 6 TB DRAM, 6 TB memory optane, + 18.9 TB storage, SDFLEX hardware type""" + S448_OO = "S448oo" + """8 sockets, 448 CPU threads, 224 CPU cores, 9 TB total memory, 3 TB DRAM, 6 TB memory optane, + 14.8 TB storage, SDFLEX hardware type""" + S448_OOM = "S448oom" + """8 sockets, 448 CPU threads, 224 CPU cores, 18 TB total memory, 6 TB DRAM, 12 memory optane, + 27.4 TB storage, SDFLEX hardware type""" + S448_OOO = "S448ooo" + """8 sockets, 448 CPU threads, 224 CPU cores, 15 TB total memory, 3 TB DRAM, 12 memory optane, + 23.2 TB storage, SDFLEX hardware type""" + S448_SE = "S448se" + """8 sockets, 448 CPU threads, 12 TB total memory, SDFLEX hardware type""" + S576_M = "S576m" + """12 sockets, 576 CPU threads, 288 CPU cores, 12 TB total memory, 12 TB DRAM, 28 TB storage, + HPEMc990x hardware type""" + S576_XM = "S576xm" + """12 sockets, 576 CPU threads, 288 CPU cores, 18 TB total memory, HPEMc990x hardware type""" + S672 = "S672" + """12 sockets, 672 CPU threads, 336 CPU cores, 9 TB total memory, 9 TB DRAM, 14.7 TB storage, + SDFLEX hardware type""" + S672_M = "S672m" + """12 sockets, 672 CPU threads, 336 CPU cores, 18 TB total memory, 18 TB DRAM, 27.4 TB storage, + SDFLEX hardware type""" + S672_OM = "S672om" + """12 sockets, 672 CPU threads, 336 CPU cores, 18 TB total memory, 9 TB DRAM, 9 TB memory optane, + 27.4 TB storage, SDFLEX hardware type""" + S672_OO = "S672oo" + """12 sockets, 672 CPU threads, 336 CPU cores, 13.5 TB total memory, 4.5 TB DRAM, 9 TB memory + optane, 21.1 TB storage, SDFLEX hardware type""" + S672_OOM = "S672oom" + """12 sockets, 672 CPU threads, 336 CPU cores, 27 TB total memory, 9 TB DRAM, 18 TB memory optane, + 40 TB storage, SDFLEX hardware type""" + S672_OOO = "S672ooo" + """12 sockets, 672 CPU threads, 336 CPU cores, 22.5 TB total memory, 4.5 TB DRAM, 18 TB memory + optane, 33.7 TB storage, SDFLEX hardware type""" + S768 = "S768" + """No longer offered or used.""" + S768_M = "S768m" + """16 sockets, 768 CPU threads, 384 CPU cores, 16 TB total memory, 16 TB DRAM, 36 TB storage, + HPEMc990x hardware type""" + S768_XM = "S768xm" + """16 sockets, 768 CPU threads, 384 CPU cores, 24 TB total memory, 24 TB DRAM, 56 TB storage, + HPEMc990x hardware type""" + S896 = "S896" + """16 sockets, 896 CPU threads, 448 CPU cores, 12 TB total memory, 12 TB DRAM, 18.9 TB storage, + SDFLEX hardware type""" + S896_M = "S896m" + """16 sockets, 896 CPU threads, 448 CPU cores, 24 TB total memory, 24 TB DRAM, 35.8 TB storage, + SDFLEX hardware type""" + S896_OM = "S896om" + """16 sockets, 896 CPU threads, 448 CPU cores, 24 TB total memory, 12 TB DRAM, 12 TB memory + optane, 35.8 TB storage, SDFLEX hardware type""" + S896_OO = "S896oo" + """16 sockets, 896 CPU threads, 448 CPU cores, 18 TB total memory, 6 TB DRAM, 12 TB memory + optane, 27.4 TB storage, SDFLEX hardware type""" + S896_OOM = "S896oom" + """16 sockets, 896 CPU threads, 448 CPU cores, 36 TB total memory, 12 TB DRAM, 24 TB memory + optane, 52.7 TB storage, SDFLEX hardware type""" + S896_OOO = "S896ooo" + """16 sockets, 896 CPU threads, 448 CPU cores, 30 TB total memory, 6 TB DRAM, 24 TB memory optane, + 44.3 TB storage, SDFLEX hardware type""" + S960_M = "S960m" + """20 sockets, 960 CPU threads, 480 CPU cores, 20 TB total memory, 20 TB DRAM, 46 TB storage, + HPEMc990x hardware type""" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit + logs UX. Default value is "user,system". + """ + + USER = "user" + SYSTEM = "system" + USER_SYSTEM = "user,system" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An enum of possible operation states for an AzureLargeStorageInstances.""" + + ACCEPTED = "Accepted" + """Accepted means ARM resource has been accepted.""" + CREATING = "Creating" + """Creating means ARM resource is being created.""" + UPDATING = "Updating" + """Updating means an existing ARM resource is being updated""" + FAILED = "Failed" + """Failed means resource is in failed state""" + SUCCEEDED = "Succeeded" + """Succeeded means resource creation succeeded during last create/update""" + DELETING = "Deleting" + """Deleting means resource is in the process of being deleted""" + CANCELED = "Canceled" + """Cancelled means resource operation has been cancelled""" + MIGRATING = "Migrating" + """Migrating means resource is being migrated from one subscription or resource group to another""" + + +class Versions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Azure Large Instance api versions.""" + + V2023_07_20_PREVIEW = "2023-07-20-preview" + """Azure Large Instance api version 2023-07-20-preview.""" diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/_models_py3.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/_models_py3.py new file mode 100644 index 000000000000..24f90585bb4f --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/_models_py3.py @@ -0,0 +1,1192 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + +import datetime +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from .. import _serialization + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models + + +class Resource(_serialization.Model): + """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: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :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.largeinstance.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) + self.id = None + self.name = None + self.type = None + self.system_data = None + + +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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :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.largeinstance.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 AzureLargeInstance(TrackedResource): + """Azure Large Instance info on Azure (ARM properties and AzureLargeInstance + properties). + + 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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :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.largeinstance.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 properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.largeinstance.models.AzureLargeInstanceProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "AzureLargeInstanceProperties"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.AzureLargeInstanceProperties"] = 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 properties: The resource-specific properties for this resource. + :paramtype properties: ~azure.mgmt.largeinstance.models.AzureLargeInstanceProperties + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class AzureLargeInstanceListResult(_serialization.Model): + """The response of a AzureLargeInstance list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The AzureLargeInstance items on this page. Required. + :vartype value: list[~azure.mgmt.largeinstance.models.AzureLargeInstance] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AzureLargeInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.AzureLargeInstance"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The AzureLargeInstance items on this page. Required. + :paramtype value: list[~azure.mgmt.largeinstance.models.AzureLargeInstance] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AzureLargeInstanceProperties(_serialization.Model): + """Describes the properties of an Azure Large Instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar hardware_profile: Specifies the hardware settings for the Azure Large Instance. + :vartype hardware_profile: ~azure.mgmt.largeinstance.models.HardwareProfile + :ivar storage_profile: Specifies the storage settings for the Azure Large Instance disks. + :vartype storage_profile: ~azure.mgmt.largeinstance.models.StorageProfile + :ivar os_profile: Specifies the operating system settings for the Azure Large Instance. + :vartype os_profile: ~azure.mgmt.largeinstance.models.OsProfile + :ivar network_profile: Specifies the network settings for the Azure Large Instance. + :vartype network_profile: ~azure.mgmt.largeinstance.models.NetworkProfile + :ivar azure_large_instance_id: Specifies the Azure Large Instance unique ID. + :vartype azure_large_instance_id: str + :ivar power_state: Resource power state. Known values are: "starting", "started", "stopping", + "stopped", "restarting", and "unknown". + :vartype power_state: str or ~azure.mgmt.largeinstance.models.AzureLargeInstancePowerStateEnum + :ivar proximity_placement_group: Resource proximity placement group. + :vartype proximity_placement_group: str + :ivar hw_revision: Hardware revision of an Azure Large Instance. + :vartype hw_revision: str + :ivar partner_node_id: ARM ID of another AzureLargeInstance that will share a network with this + AzureLargeInstance. + :vartype partner_node_id: str + :ivar provisioning_state: State of provisioning of the AzureLargeInstance. Known values are: + "Accepted", "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating", and + "Canceled". + :vartype provisioning_state: str or + ~azure.mgmt.largeinstance.models.AzureLargeInstanceProvisioningStatesEnum + """ + + _validation = { + "azure_large_instance_id": {"readonly": True}, + "power_state": {"readonly": True}, + "proximity_placement_group": {"readonly": True}, + "hw_revision": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "hardware_profile": {"key": "hardwareProfile", "type": "HardwareProfile"}, + "storage_profile": {"key": "storageProfile", "type": "StorageProfile"}, + "os_profile": {"key": "osProfile", "type": "OsProfile"}, + "network_profile": {"key": "networkProfile", "type": "NetworkProfile"}, + "azure_large_instance_id": {"key": "azureLargeInstanceId", "type": "str"}, + "power_state": {"key": "powerState", "type": "str"}, + "proximity_placement_group": {"key": "proximityPlacementGroup", "type": "str"}, + "hw_revision": {"key": "hwRevision", "type": "str"}, + "partner_node_id": {"key": "partnerNodeId", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + hardware_profile: Optional["_models.HardwareProfile"] = None, + storage_profile: Optional["_models.StorageProfile"] = None, + os_profile: Optional["_models.OsProfile"] = None, + network_profile: Optional["_models.NetworkProfile"] = None, + partner_node_id: Optional[str] = None, + **kwargs: Any + ) -> None: + """ + :keyword hardware_profile: Specifies the hardware settings for the Azure Large Instance. + :paramtype hardware_profile: ~azure.mgmt.largeinstance.models.HardwareProfile + :keyword storage_profile: Specifies the storage settings for the Azure Large Instance disks. + :paramtype storage_profile: ~azure.mgmt.largeinstance.models.StorageProfile + :keyword os_profile: Specifies the operating system settings for the Azure Large Instance. + :paramtype os_profile: ~azure.mgmt.largeinstance.models.OsProfile + :keyword network_profile: Specifies the network settings for the Azure Large Instance. + :paramtype network_profile: ~azure.mgmt.largeinstance.models.NetworkProfile + :keyword partner_node_id: ARM ID of another AzureLargeInstance that will share a network with + this + AzureLargeInstance. + :paramtype partner_node_id: str + """ + super().__init__(**kwargs) + self.hardware_profile = hardware_profile + self.storage_profile = storage_profile + self.os_profile = os_profile + self.network_profile = network_profile + self.azure_large_instance_id = None + self.power_state = None + self.proximity_placement_group = None + self.hw_revision = None + self.partner_node_id = partner_node_id + self.provisioning_state = None + + +class AzureLargeInstanceTagsUpdate(_serialization.Model): + """The type used for updating tags in AzureLargeInstance resources. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class AzureLargeStorageInstance(TrackedResource): + """AzureLargeStorageInstance info on Azure (ARM properties and + AzureLargeStorageInstance properties). + + 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 server. + + :ivar id: Fully qualified resource ID for the resource. E.g. + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long + :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.largeinstance.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 properties: The resource-specific properties for this resource. + :vartype properties: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstanceProperties + """ + + _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"}, + "properties": {"key": "properties", "type": "AzureLargeStorageInstanceProperties"}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + properties: Optional["_models.AzureLargeStorageInstanceProperties"] = 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 properties: The resource-specific properties for this resource. + :paramtype properties: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstanceProperties + """ + super().__init__(tags=tags, location=location, **kwargs) + self.properties = properties + + +class AzureLargeStorageInstanceListResult(_serialization.Model): + """The response of a AzureLargeStorageInstance list operation. + + All required parameters must be populated in order to send to server. + + :ivar value: The AzureLargeStorageInstance items on this page. Required. + :vartype value: list[~azure.mgmt.largeinstance.models.AzureLargeStorageInstance] + :ivar next_link: The link to the next page of items. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[AzureLargeStorageInstance]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__( + self, *, value: List["_models.AzureLargeStorageInstance"], next_link: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword value: The AzureLargeStorageInstance items on this page. Required. + :paramtype value: list[~azure.mgmt.largeinstance.models.AzureLargeStorageInstance] + :keyword next_link: The link to the next page of items. + :paramtype next_link: str + """ + super().__init__(**kwargs) + self.value = value + self.next_link = next_link + + +class AzureLargeStorageInstanceProperties(_serialization.Model): + """Describes the properties of an AzureLargeStorageInstance. + + :ivar azure_large_storage_instance_unique_identifier: Specifies the AzureLargeStorageInstance + unique ID. + :vartype azure_large_storage_instance_unique_identifier: str + :ivar storage_properties: Specifies the storage properties for the AzureLargeStorage instance. + :vartype storage_properties: ~azure.mgmt.largeinstance.models.StorageProperties + """ + + _attribute_map = { + "azure_large_storage_instance_unique_identifier": { + "key": "azureLargeStorageInstanceUniqueIdentifier", + "type": "str", + }, + "storage_properties": {"key": "storageProperties", "type": "StorageProperties"}, + } + + def __init__( + self, + *, + azure_large_storage_instance_unique_identifier: Optional[str] = None, + storage_properties: Optional["_models.StorageProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword azure_large_storage_instance_unique_identifier: Specifies the + AzureLargeStorageInstance unique ID. + :paramtype azure_large_storage_instance_unique_identifier: str + :keyword storage_properties: Specifies the storage properties for the AzureLargeStorage + instance. + :paramtype storage_properties: ~azure.mgmt.largeinstance.models.StorageProperties + """ + super().__init__(**kwargs) + self.azure_large_storage_instance_unique_identifier = azure_large_storage_instance_unique_identifier + self.storage_properties = storage_properties + + +class AzureLargeStorageInstanceTagsUpdate(_serialization.Model): + """The type used for updating tags in AzureLargeStorageInstance resources. + + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class Disk(_serialization.Model): + """Specifies the disk information fo the Azure Large Instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The disk name. + :vartype name: str + :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. + :vartype disk_size_gb: int + :ivar lun: Specifies the logical unit number of the data disk. This value is used to + identify data disks within the VM and therefore must be unique for each data + disk attached to a VM. + :vartype lun: int + """ + + _validation = { + "lun": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "disk_size_gb": {"key": "diskSizeGB", "type": "int"}, + "lun": {"key": "lun", "type": "int"}, + } + + def __init__(self, *, name: Optional[str] = None, disk_size_gb: Optional[int] = None, **kwargs: Any) -> None: + """ + :keyword name: The disk name. + :paramtype name: str + :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. + :paramtype disk_size_gb: int + """ + super().__init__(**kwargs) + self.name = name + self.disk_size_gb = disk_size_gb + self.lun = None + + +class ErrorAdditionalInfo(_serialization.Model): + """The resource management error additional info. + + 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 = { + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, + } + + 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.largeinstance.models.ErrorDetail] + :ivar additional_info: The error additional info. + :vartype additional_info: list[~azure.mgmt.largeinstance.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.largeinstance.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.largeinstance.models.ErrorDetail + """ + super().__init__(**kwargs) + self.error = error + + +class ForceState(_serialization.Model): + """The active state empowers the server with the ability to forcefully terminate + and halt any existing processes that may be running on the server. + + :ivar force_state: Whether to force restart by shutting all processes. Known values are: + "active" and "inactive". + :vartype force_state: str or ~azure.mgmt.largeinstance.models.AzureLargeInstanceForcePowerState + """ + + _attribute_map = { + "force_state": {"key": "forceState", "type": "str"}, + } + + def __init__( + self, *, force_state: Optional[Union[str, "_models.AzureLargeInstanceForcePowerState"]] = None, **kwargs: Any + ) -> None: + """ + :keyword force_state: Whether to force restart by shutting all processes. Known values are: + "active" and "inactive". + :paramtype force_state: str or + ~azure.mgmt.largeinstance.models.AzureLargeInstanceForcePowerState + """ + super().__init__(**kwargs) + self.force_state = force_state + + +class HardwareProfile(_serialization.Model): + """Specifies the hardware settings for the Azure Large Instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar hardware_type: Name of the hardware type (vendor and/or their product name). Known values + are: "Cisco_UCS", "HPE", and "SDFLEX". + :vartype hardware_type: str or + ~azure.mgmt.largeinstance.models.AzureLargeInstanceHardwareTypeNamesEnum + :ivar azure_large_instance_size: Specifies the Azure Large Instance SKU. Known values are: + "S72m", "S144m", "S72", "S144", "S192", "S192m", "S192xm", "S96", "S112", "S224", "S224m", + "S224om", "S224oo", "S224oom", "S224ooo", "S224se", "S384", "S384m", "S384xm", "S384xxm", + "S448", "S448m", "S448om", "S448oo", "S448oom", "S448ooo", "S448se", "S576m", "S576xm", "S672", + "S672m", "S672om", "S672oo", "S672oom", "S672ooo", "S768", "S768m", "S768xm", "S896", "S896m", + "S896om", "S896oo", "S896oom", "S896ooo", and "S960m". + :vartype azure_large_instance_size: str or + ~azure.mgmt.largeinstance.models.AzureLargeInstanceSizeNamesEnum + """ + + _validation = { + "hardware_type": {"readonly": True}, + "azure_large_instance_size": {"readonly": True}, + } + + _attribute_map = { + "hardware_type": {"key": "hardwareType", "type": "str"}, + "azure_large_instance_size": {"key": "azureLargeInstanceSize", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.hardware_type = None + self.azure_large_instance_size = None + + +class IpAddress(_serialization.Model): + """Specifies the IP address of the network interface. + + :ivar ip_address: Specifies the IP address of the network interface. + :vartype ip_address: str + """ + + _attribute_map = { + "ip_address": {"key": "ipAddress", "type": "str"}, + } + + def __init__(self, *, ip_address: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword ip_address: Specifies the IP address of the network interface. + :paramtype ip_address: str + """ + super().__init__(**kwargs) + self.ip_address = ip_address + + +class NetworkProfile(_serialization.Model): + """Specifies the network settings for the Azure Large Instance disks. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar network_interfaces: Specifies the network interfaces for the Azure Large Instance. + :vartype network_interfaces: list[~azure.mgmt.largeinstance.models.IpAddress] + :ivar circuit_id: Specifies the circuit id for connecting to express route. + :vartype circuit_id: str + """ + + _validation = { + "circuit_id": {"readonly": True}, + } + + _attribute_map = { + "network_interfaces": {"key": "networkInterfaces", "type": "[IpAddress]"}, + "circuit_id": {"key": "circuitId", "type": "str"}, + } + + def __init__(self, *, network_interfaces: Optional[List["_models.IpAddress"]] = None, **kwargs: Any) -> None: + """ + :keyword network_interfaces: Specifies the network interfaces for the Azure Large Instance. + :paramtype network_interfaces: list[~azure.mgmt.largeinstance.models.IpAddress] + """ + super().__init__(**kwargs) + self.network_interfaces = network_interfaces + self.circuit_id = None + + +class Operation(_serialization.Model): + """Details of a REST API operation, returned from the Resource Provider Operations API. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation, as per Resource-Based Access Control (RBAC). Examples: + "Microsoft.Compute/virtualMachines/write", "Microsoft.Compute/virtualMachines/capture/action". + :vartype name: str + :ivar is_data_action: Whether the operation applies to data-plane. This is "true" for + data-plane operations and "false" for ARM/control-plane operations. + :vartype is_data_action: bool + :ivar display: Localized display information for this particular operation. + :vartype display: ~azure.mgmt.largeinstance.models.OperationDisplay + :ivar origin: The intended executor of the operation; as in Resource Based Access Control + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.largeinstance.models.Origin + :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.largeinstance.models.ActionType + """ + + _validation = { + "name": {"readonly": True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + "action_type": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "action_type": {"key": "actionType", "type": "str"}, + } + + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs: Any) -> None: + """ + :keyword display: Localized display information for this particular operation. + :paramtype display: ~azure.mgmt.largeinstance.models.OperationDisplay + """ + super().__init__(**kwargs) + self.name = None + self.is_data_action = None + self.display = display + self.origin = None + self.action_type = None + + +class OperationDisplay(_serialization.Model): + """Localized display information for this particular operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: The localized friendly form of the resource provider name, e.g. "Microsoft + Monitoring Insights" or "Microsoft Compute". + :vartype provider: str + :ivar resource: The localized friendly name of the resource type related to this operation. + E.g. "Virtual Machines" or "Job Schedule Collections". + :vartype resource: str + :ivar operation: The concise, localized friendly name for the operation; suitable for + dropdowns. E.g. "Create or Update Virtual Machine", "Restart Virtual Machine". + :vartype operation: str + :ivar description: The short, localized friendly description of the operation; suitable for + tool tips and detailed views. + :vartype description: str + """ + + _validation = { + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs: Any) -> None: + """ """ + super().__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(_serialization.Model): + """A list of REST API operations supported by an Azure Resource Provider. It contains an 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 value: List of operations supported by the resource provider. + :vartype value: list[~azure.mgmt.largeinstance.models.Operation] + :ivar next_link: URL to get the next set of operation list results (if there are any). + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "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 OperationStatusResult(_serialization.Model): + """The current status of an async operation. + + 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 server. + + :ivar id: Fully qualified ID for the async operation. + :vartype id: str + :ivar resource_id: Fully qualified ID of the resource against which the original async + operation was started. + :vartype resource_id: str + :ivar name: Name of the async operation. + :vartype name: str + :ivar status: Operation status. Required. + :vartype status: str + :ivar percent_complete: Percent of the operation that is complete. + :vartype percent_complete: float + :ivar start_time: The start time of the operation. + :vartype start_time: ~datetime.datetime + :ivar end_time: The end time of the operation. + :vartype end_time: ~datetime.datetime + :ivar operations: The operations list. + :vartype operations: list[~azure.mgmt.largeinstance.models.OperationStatusResult] + :ivar error: If present, details of the operation error. + :vartype error: ~azure.mgmt.largeinstance.models.ErrorDetail + """ + + _validation = { + "resource_id": {"readonly": True}, + "status": {"required": True}, + "percent_complete": {"maximum": 100, "minimum": 0}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "status": {"key": "status", "type": "str"}, + "percent_complete": {"key": "percentComplete", "type": "float"}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "end_time": {"key": "endTime", "type": "iso-8601"}, + "operations": {"key": "operations", "type": "[OperationStatusResult]"}, + "error": {"key": "error", "type": "ErrorDetail"}, + } + + def __init__( + self, + *, + status: str, + id: Optional[str] = None, # pylint: disable=redefined-builtin + name: Optional[str] = None, + percent_complete: Optional[float] = None, + start_time: Optional[datetime.datetime] = None, + end_time: Optional[datetime.datetime] = None, + operations: Optional[List["_models.OperationStatusResult"]] = None, + error: Optional["_models.ErrorDetail"] = None, + **kwargs: Any + ) -> None: + """ + :keyword id: Fully qualified ID for the async operation. + :paramtype id: str + :keyword name: Name of the async operation. + :paramtype name: str + :keyword status: Operation status. Required. + :paramtype status: str + :keyword percent_complete: Percent of the operation that is complete. + :paramtype percent_complete: float + :keyword start_time: The start time of the operation. + :paramtype start_time: ~datetime.datetime + :keyword end_time: The end time of the operation. + :paramtype end_time: ~datetime.datetime + :keyword operations: The operations list. + :paramtype operations: list[~azure.mgmt.largeinstance.models.OperationStatusResult] + :keyword error: If present, details of the operation error. + :paramtype error: ~azure.mgmt.largeinstance.models.ErrorDetail + """ + super().__init__(**kwargs) + self.id = id + self.resource_id = None + self.name = name + self.status = status + self.percent_complete = percent_complete + self.start_time = start_time + self.end_time = end_time + self.operations = operations + self.error = error + + +class OsProfile(_serialization.Model): + """Specifies the operating system settings for the Azure Large Instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar computer_name: Specifies the host OS name of the Azure Large Instance. + :vartype computer_name: str + :ivar os_type: This property allows you to specify the type of the OS. + :vartype os_type: str + :ivar version: Specifies version of operating system. + :vartype version: str + :ivar ssh_public_key: Specifies the SSH public key used to access the operating system. + :vartype ssh_public_key: str + """ + + _validation = { + "os_type": {"readonly": True}, + "version": {"readonly": True}, + } + + _attribute_map = { + "computer_name": {"key": "computerName", "type": "str"}, + "os_type": {"key": "osType", "type": "str"}, + "version": {"key": "version", "type": "str"}, + "ssh_public_key": {"key": "sshPublicKey", "type": "str"}, + } + + def __init__( + self, *, computer_name: Optional[str] = None, ssh_public_key: Optional[str] = None, **kwargs: Any + ) -> None: + """ + :keyword computer_name: Specifies the host OS name of the Azure Large Instance. + :paramtype computer_name: str + :keyword ssh_public_key: Specifies the SSH public key used to access the operating system. + :paramtype ssh_public_key: str + """ + super().__init__(**kwargs) + self.computer_name = computer_name + self.os_type = None + self.version = None + self.ssh_public_key = ssh_public_key + + +class StorageBillingProperties(_serialization.Model): + """Describes the billing related details of the AzureLargeStorageInstance. + + :ivar billing_mode: the billing mode for the storage instance. + :vartype billing_mode: str + :ivar sku: the SKU type that is provisioned. + :vartype sku: str + """ + + _attribute_map = { + "billing_mode": {"key": "billingMode", "type": "str"}, + "sku": {"key": "sku", "type": "str"}, + } + + def __init__(self, *, billing_mode: Optional[str] = None, sku: Optional[str] = None, **kwargs: Any) -> None: + """ + :keyword billing_mode: the billing mode for the storage instance. + :paramtype billing_mode: str + :keyword sku: the SKU type that is provisioned. + :paramtype sku: str + """ + super().__init__(**kwargs) + self.billing_mode = billing_mode + self.sku = sku + + +class StorageProfile(_serialization.Model): + """Specifies the storage settings for the Azure Large Instance disks. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar nfs_ip_address: IP Address to connect to storage. + :vartype nfs_ip_address: str + :ivar os_disks: Specifies information about the operating system disk used by Azure Large + Instance. + :vartype os_disks: list[~azure.mgmt.largeinstance.models.Disk] + """ + + _validation = { + "nfs_ip_address": {"readonly": True}, + } + + _attribute_map = { + "nfs_ip_address": {"key": "nfsIpAddress", "type": "str"}, + "os_disks": {"key": "osDisks", "type": "[Disk]"}, + } + + def __init__(self, *, os_disks: Optional[List["_models.Disk"]] = None, **kwargs: Any) -> None: + """ + :keyword os_disks: Specifies information about the operating system disk used by Azure Large + Instance. + :paramtype os_disks: list[~azure.mgmt.largeinstance.models.Disk] + """ + super().__init__(**kwargs) + self.nfs_ip_address = None + self.os_disks = os_disks + + +class StorageProperties(_serialization.Model): + """described the storage properties of the azure large storage instance. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provisioning_state: State of provisioning of the AzureLargeStorageInstance. Known values + are: "Accepted", "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Canceled", and + "Migrating". + :vartype provisioning_state: str or ~azure.mgmt.largeinstance.models.ProvisioningState + :ivar offering_type: the offering type for which the resource is getting provisioned. + :vartype offering_type: str + :ivar storage_type: the storage protocol for which the resource is getting provisioned. + :vartype storage_type: str + :ivar generation: the kind of storage instance. + :vartype generation: str + :ivar hardware_type: the hardware type of the storage instance. Known values are: "Cisco_UCS", + "HPE", and "SDFLEX". + :vartype hardware_type: str or + ~azure.mgmt.largeinstance.models.AzureLargeInstanceHardwareTypeNamesEnum + :ivar workload_type: the workload for which the resource is getting provisioned. + :vartype workload_type: str + :ivar storage_billing_properties: the billing related information for the resource. + :vartype storage_billing_properties: ~azure.mgmt.largeinstance.models.StorageBillingProperties + """ + + _validation = { + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "offering_type": {"key": "offeringType", "type": "str"}, + "storage_type": {"key": "storageType", "type": "str"}, + "generation": {"key": "generation", "type": "str"}, + "hardware_type": {"key": "hardwareType", "type": "str"}, + "workload_type": {"key": "workloadType", "type": "str"}, + "storage_billing_properties": {"key": "storageBillingProperties", "type": "StorageBillingProperties"}, + } + + def __init__( + self, + *, + offering_type: Optional[str] = None, + storage_type: Optional[str] = None, + generation: Optional[str] = None, + hardware_type: Optional[Union[str, "_models.AzureLargeInstanceHardwareTypeNamesEnum"]] = None, + workload_type: Optional[str] = None, + storage_billing_properties: Optional["_models.StorageBillingProperties"] = None, + **kwargs: Any + ) -> None: + """ + :keyword offering_type: the offering type for which the resource is getting provisioned. + :paramtype offering_type: str + :keyword storage_type: the storage protocol for which the resource is getting provisioned. + :paramtype storage_type: str + :keyword generation: the kind of storage instance. + :paramtype generation: str + :keyword hardware_type: the hardware type of the storage instance. Known values are: + "Cisco_UCS", "HPE", and "SDFLEX". + :paramtype hardware_type: str or + ~azure.mgmt.largeinstance.models.AzureLargeInstanceHardwareTypeNamesEnum + :keyword workload_type: the workload for which the resource is getting provisioned. + :paramtype workload_type: str + :keyword storage_billing_properties: the billing related information for the resource. + :paramtype storage_billing_properties: + ~azure.mgmt.largeinstance.models.StorageBillingProperties + """ + super().__init__(**kwargs) + self.provisioning_state = None + self.offering_type = offering_type + self.storage_type = storage_type + self.generation = generation + self.hardware_type = hardware_type + self.workload_type = workload_type + self.storage_billing_properties = storage_billing_properties + + +class SystemData(_serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :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.largeinstance.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.largeinstance.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + "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, + *, + 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 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.largeinstance.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.largeinstance.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super().__init__(**kwargs) + 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 Tags(_serialization.Model): + """Tags field of the AzureLargeInstance instance. + + :ivar tags: Tags field of the AzureLargeInstance instance. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs: Any) -> None: + """ + :keyword tags: Tags field of the AzureLargeInstance instance. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/_patch.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/__init__.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/__init__.py new file mode 100644 index 000000000000..9b4f2bf7ab5c --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/__init__.py @@ -0,0 +1,23 @@ +# 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 ._operations import Operations +from ._azure_large_instance_operations import AzureLargeInstanceOperations +from ._azure_large_storage_instance_operations import AzureLargeStorageInstanceOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "AzureLargeInstanceOperations", + "AzureLargeStorageInstanceOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_azure_large_instance_operations.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_azure_large_instance_operations.py new file mode 100644 index 000000000000..a64e1f2f371d --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_azure_large_instance_operations.py @@ -0,0 +1,1086 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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_list_by_subscription_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-20-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.AzureLargeInstance/azureLargeInstances" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _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_by_resource_group_request(resource_group_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-07-20-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeInstances", + ) # 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 + ), + } + + _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_request( + resource_group_name: str, azure_large_instance_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-07-20-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeInstances/{azureLargeInstanceName}", + ) # 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 + ), + "azureLargeInstanceName": _SERIALIZER.url( + "azure_large_instance_name", azure_large_instance_name, "str", pattern=r".*" + ), + } + + _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_update_request( + resource_group_name: str, azure_large_instance_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-07-20-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.AzureLargeInstance/azureLargeInstances/{azureLargeInstanceName}", + ) # 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 + ), + "azureLargeInstanceName": _SERIALIZER.url( + "azure_large_instance_name", azure_large_instance_name, "str", pattern=r".*" + ), + } + + _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restart_request( + resource_group_name: str, azure_large_instance_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-07-20-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.AzureLargeInstance/azureLargeInstances/{azureLargeInstanceName}/restart", + ) # 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 + ), + "azureLargeInstanceName": _SERIALIZER.url( + "azure_large_instance_name", azure_large_instance_name, "str", pattern=r".*" + ), + } + + _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="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_shutdown_request( + resource_group_name: str, azure_large_instance_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-07-20-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeInstances/{azureLargeInstanceName}/shutdown", + ) # 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 + ), + "azureLargeInstanceName": _SERIALIZER.url( + "azure_large_instance_name", azure_large_instance_name, "str", pattern=r".*" + ), + } + + _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) + + +def build_start_request( + resource_group_name: str, azure_large_instance_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-07-20-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeInstances/{azureLargeInstanceName}/start", + ) # 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 + ), + "azureLargeInstanceName": _SERIALIZER.url( + "azure_large_instance_name", azure_large_instance_name, "str", pattern=r".*" + ), + } + + _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 AzureLargeInstanceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.largeinstance.LargeInstanceMgmtClient`'s + :attr:`azure_large_instance` 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") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AzureLargeInstance"]: + """Gets a list of Azure Large Instances in the specified subscription. The + operations returns various properties of each Azure Large Instance. + + :return: An iterator like instance of either AzureLargeInstance or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.largeinstance.models.AzureLargeInstance] + :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.AzureLargeInstanceListResult] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeInstanceListResult", 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) + + 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) + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.AzureLargeInstance"]: + """Gets a list of Azure Large Instances in the specified subscription and resource + group. The operations returns various properties of each Azure Large Instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either AzureLargeInstance or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.largeinstance.models.AzureLargeInstance] + :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.AzureLargeInstanceListResult] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeInstanceListResult", 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) + + 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) + + @distributed_trace + def get( + self, resource_group_name: str, azure_large_instance_name: str, **kwargs: Any + ) -> _models.AzureLargeInstance: + """Gets an Azure Large Instance for the specified subscription, resource group, + and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :return: AzureLargeInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeInstance + :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.AzureLargeInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + azure_large_instance_name: str, + properties: _models.AzureLargeInstanceTagsUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureLargeInstance: + """Patches the Tags field of an Azure Large Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.largeinstance.models.AzureLargeInstanceTagsUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureLargeInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + azure_large_instance_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureLargeInstance: + """Patches the Tags field of an Azure Large Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureLargeInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + azure_large_instance_name: str, + properties: Union[_models.AzureLargeInstanceTagsUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.AzureLargeInstance: + """Patches the Tags field of an Azure Large Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param properties: The resource properties to be updated. Is either a + AzureLargeInstanceTagsUpdate type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.largeinstance.models.AzureLargeInstanceTagsUpdate or IO[bytes] + :return: AzureLargeInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeInstance + :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.AzureLargeInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "AzureLargeInstanceTagsUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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("AzureLargeInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + def _restart_initial( + self, + resource_group_name: str, + azure_large_instance_name: str, + force_parameter: Optional[Union[_models.ForceState, IO[bytes]]] = None, + **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + 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[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(force_parameter, (IOBase, bytes)): + _content = force_parameter + else: + if force_parameter is not None: + _json = self._serialize.body(force_parameter, "ForceState") + else: + _json = None + + _request = build_restart_request( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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, 202]: + 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 = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @overload + def begin_restart( + self, + resource_group_name: str, + azure_large_instance_name: str, + force_parameter: Optional[_models.ForceState] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """The operation to restart an Azure Large Instance (only for compute instances). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param force_parameter: When set to 'active', this parameter empowers the server with the + ability to forcefully terminate and halt any existing processes that may be running on the + server. Default value is None. + :type force_parameter: ~azure.mgmt.largeinstance.models.ForceState + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.largeinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restart( + self, + resource_group_name: str, + azure_large_instance_name: str, + force_parameter: Optional[IO[bytes]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """The operation to restart an Azure Large Instance (only for compute instances). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param force_parameter: When set to 'active', this parameter empowers the server with the + ability to forcefully terminate and halt any existing processes that may be running on the + server. Default value is None. + :type force_parameter: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.largeinstance.models.OperationStatusResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restart( + self, + resource_group_name: str, + azure_large_instance_name: str, + force_parameter: Optional[Union[_models.ForceState, IO[bytes]]] = None, + **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """The operation to restart an Azure Large Instance (only for compute instances). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :param force_parameter: When set to 'active', this parameter empowers the server with the + ability to forcefully terminate and halt any existing processes that may be running on the + server. Is either a ForceState type or a IO[bytes] type. Default value is None. + :type force_parameter: ~azure.mgmt.largeinstance.models.ForceState or IO[bytes] + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.largeinstance.models.OperationStatusResult] + :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.OperationStatusResult] = 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._restart_initial( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + force_parameter=force_parameter, + 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("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + 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[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _shutdown_initial( + self, resource_group_name: str, azure_large_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + 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[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + _request = build_shutdown_request( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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, 202]: + 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 = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_shutdown( + self, resource_group_name: str, azure_large_instance_name: str, **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """The operation to shutdown an Azure Large Instance (only for compute instances). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.largeinstance.models.OperationStatusResult] + :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.OperationStatusResult] = 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._shutdown_initial( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_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): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + 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[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + def _start_initial( + self, resource_group_name: str, azure_large_instance_name: str, **kwargs: Any + ) -> Optional[_models.OperationStatusResult]: + 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[Optional[_models.OperationStatusResult]] = kwargs.pop("cls", None) + + _request = build_start_request( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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, 202]: + 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 = None + response_headers = {} + if response.status_code == 200: + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + + if response.status_code == 202: + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def begin_start( + self, resource_group_name: str, azure_large_instance_name: str, **kwargs: Any + ) -> LROPoller[_models.OperationStatusResult]: + """The operation to start an Azure Large Instance (only for compute instances). + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_instance_name: Name of the AzureLargeInstance. Required. + :type azure_large_instance_name: str + :return: An instance of LROPoller that returns either OperationStatusResult or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.largeinstance.models.OperationStatusResult] + :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.OperationStatusResult] = 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._start_initial( + resource_group_name=resource_group_name, + azure_large_instance_name=azure_large_instance_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): + deserialized = self._deserialize("OperationStatusResult", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized + + 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[_models.OperationStatusResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.OperationStatusResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_azure_large_storage_instance_operations.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_azure_large_storage_instance_operations.py new file mode 100644 index 000000000000..fa8a25ad0b03 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_azure_large_storage_instance_operations.py @@ -0,0 +1,550 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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, 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.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 .. 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_list_by_subscription_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-07-20-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.AzureLargeInstance/azureLargeStorageInstances", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + } + + _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_by_resource_group_request(resource_group_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-07-20-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeStorageInstances", + ) # 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 + ), + } + + _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_request( + resource_group_name: str, azure_large_storage_instance_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-07-20-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureLargeInstance/azureLargeStorageInstances/{azureLargeStorageInstanceName}", + ) # 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 + ), + "azureLargeStorageInstanceName": _SERIALIZER.url( + "azure_large_storage_instance_name", azure_large_storage_instance_name, "str", pattern=r".*" + ), + } + + _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_update_request( + resource_group_name: str, azure_large_storage_instance_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-07-20-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.AzureLargeInstance/azureLargeStorageInstances/{azureLargeStorageInstanceName}", + ) # 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 + ), + "azureLargeStorageInstanceName": _SERIALIZER.url( + "azure_large_storage_instance_name", azure_large_storage_instance_name, "str", pattern=r".*" + ), + } + + _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="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +class AzureLargeStorageInstanceOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.largeinstance.LargeInstanceMgmtClient`'s + :attr:`azure_large_storage_instance` 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") + + @distributed_trace + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.AzureLargeStorageInstance"]: + """Gets a list of AzureLargeStorageInstances in the specified subscription. The + operations returns various properties of each Azure LargeStorage instance. + + :return: An iterator like instance of either AzureLargeStorageInstance or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.largeinstance.models.AzureLargeStorageInstance] + :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.AzureLargeStorageInstanceListResult] = 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_by_subscription_request( + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeStorageInstanceListResult", 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) + + 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) + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.AzureLargeStorageInstance"]: + """Gets a list of AzureLargeStorageInstances in the specified subscription and + resource group. The operations returns various properties of each Azure + LargeStorage instance. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :return: An iterator like instance of either AzureLargeStorageInstance or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.largeinstance.models.AzureLargeStorageInstance] + :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.AzureLargeStorageInstanceListResult] = 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_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeStorageInstanceListResult", 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) + + 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) + + @distributed_trace + def get( + self, resource_group_name: str, azure_large_storage_instance_name: str, **kwargs: Any + ) -> _models.AzureLargeStorageInstance: + """Gets an Azure Large Storage instance for the specified subscription, resource + group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_storage_instance_name: Name of the AzureLargeStorageInstance. Required. + :type azure_large_storage_instance_name: str + :return: AzureLargeStorageInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstance + :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.AzureLargeStorageInstance] = kwargs.pop("cls", None) + + _request = build_get_request( + resource_group_name=resource_group_name, + azure_large_storage_instance_name=azure_large_storage_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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("AzureLargeStorageInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def update( + self, + resource_group_name: str, + azure_large_storage_instance_name: str, + properties: _models.AzureLargeStorageInstanceTagsUpdate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureLargeStorageInstance: + """Patches the Tags field of a Azure Large Storage Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_storage_instance_name: Name of the AzureLargeStorageInstance. Required. + :type azure_large_storage_instance_name: str + :param properties: The resource properties to be updated. Required. + :type properties: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstanceTagsUpdate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureLargeStorageInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + azure_large_storage_instance_name: str, + properties: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.AzureLargeStorageInstance: + """Patches the Tags field of a Azure Large Storage Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_storage_instance_name: Name of the AzureLargeStorageInstance. Required. + :type azure_large_storage_instance_name: str + :param properties: The resource properties to be updated. Required. + :type properties: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AzureLargeStorageInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstance + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + azure_large_storage_instance_name: str, + properties: Union[_models.AzureLargeStorageInstanceTagsUpdate, IO[bytes]], + **kwargs: Any + ) -> _models.AzureLargeStorageInstance: + """Patches the Tags field of a Azure Large Storage Instance for the specified + subscription, resource group, and instance name. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param azure_large_storage_instance_name: Name of the AzureLargeStorageInstance. Required. + :type azure_large_storage_instance_name: str + :param properties: The resource properties to be updated. Is either a + AzureLargeStorageInstanceTagsUpdate type or a IO[bytes] type. Required. + :type properties: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstanceTagsUpdate or + IO[bytes] + :return: AzureLargeStorageInstance or the result of cls(response) + :rtype: ~azure.mgmt.largeinstance.models.AzureLargeStorageInstance + :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.AzureLargeStorageInstance] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IOBase, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "AzureLargeStorageInstanceTagsUpdate") + + _request = build_update_request( + resource_group_name=resource_group_name, + azure_large_storage_instance_name=azure_large_storage_instance_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + 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("AzureLargeStorageInstance", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_operations.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_operations.py new file mode 100644 index 000000000000..6d98df9a2cee --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_operations.py @@ -0,0 +1,151 @@ +# pylint: disable=too-many-lines,too-many-statements +# 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 typing import Any, Callable, Dict, Iterable, Optional, TypeVar +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.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 .. 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_list_request(**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-07-20-preview")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.AzureLargeInstance/operations") + + # 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 Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.largeinstance.LargeInstanceMgmtClient`'s + :attr:`operations` 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") + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """List the operations for the provider. + + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.largeinstance.models.Operation] + :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.OperationListResult] = 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( + api_version=api_version, + 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("OperationListResult", 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) + + 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) diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_patch.py b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/py.typed b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/azure/mgmt/largeinstance/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/dev_requirements.txt b/sdk/largeinstance/azure-mgmt-largeinstance/dev_requirements.txt new file mode 100644 index 000000000000..dab09d85bafa --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/dev_requirements.txt @@ -0,0 +1,2 @@ +-e ../../../tools/azure-sdk-tools +../../identity/azure-identity diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_get.py b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_get.py new file mode 100644 index 000000000000..4d794bbcc837 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_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.largeinstance import LargeInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-largeinstance +# USAGE + python azure_large_instance_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 = LargeInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="f0f4887f-d13c-4943-a8ba-d7da28d2a3fd", + ) + + response = client.azure_large_instance.get( + resource_group_name="myResourceGroup", + azure_large_instance_name="myAzureLargeInstance", + ) + print(response) + + +# x-ms-original-file: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_list_by_resource_group.py b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_list_by_resource_group.py new file mode 100644 index 000000000000..13673dd5c7c6 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_list_by_resource_group.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.largeinstance import LargeInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-largeinstance +# USAGE + python azure_large_instance_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, + 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 = LargeInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="f0f4887f-d13c-4943-a8ba-d7da28d2a3fd", + ) + + response = client.azure_large_instance.list_by_resource_group( + resource_group_name="myResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_list_by_subscription.py b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_list_by_subscription.py new file mode 100644 index 000000000000..05b43539e801 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_list_by_subscription.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.largeinstance import LargeInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-largeinstance +# USAGE + python azure_large_instance_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, + 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 = LargeInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="f0f4887f-d13c-4943-a8ba-d7da28d2a3fd", + ) + + response = client.azure_large_instance.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_operations_list.py b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_operations_list.py new file mode 100644 index 000000000000..fd3c944d6982 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_operations_list.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.largeinstance import LargeInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-largeinstance +# USAGE + python azure_large_instance_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, + 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 = LargeInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstanceOperations_List.json +if __name__ == "__main__": + main() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_restart.py b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_restart.py new file mode 100644 index 000000000000..b3330b7f8a5d --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_restart.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.largeinstance import LargeInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-largeinstance +# USAGE + python azure_large_instance_restart.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 = LargeInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.azure_large_instance.begin_restart( + resource_group_name="myResourceGroup", + azure_large_instance_name="myALInstance", + ).result() + print(response) + + +# x-ms-original-file: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_Restart.json +if __name__ == "__main__": + main() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_shutdown.py b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_shutdown.py new file mode 100644 index 000000000000..139ac3b23c92 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_shutdown.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.largeinstance import LargeInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-largeinstance +# USAGE + python azure_large_instance_shutdown.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 = LargeInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.azure_large_instance.begin_shutdown( + resource_group_name="myResourceGroup", + azure_large_instance_name="myALInstance", + ).result() + print(response) + + +# x-ms-original-file: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_Shutdown.json +if __name__ == "__main__": + main() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_start.py b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_start.py new file mode 100644 index 000000000000..a087f44d8a27 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_instance_start.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.largeinstance import LargeInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-largeinstance +# USAGE + python azure_large_instance_start.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 = LargeInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.azure_large_instance.begin_start( + resource_group_name="myResourceGroup", + azure_large_instance_name="myALInstance", + ).result() + print(response) + + +# x-ms-original-file: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_Start.json +if __name__ == "__main__": + main() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_storage_instance_get.py b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_storage_instance_get.py new file mode 100644 index 000000000000..03b2bd69a722 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_storage_instance_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.largeinstance import LargeInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-largeinstance +# USAGE + python azure_large_storage_instance_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 = LargeInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="f0f4887f-d13c-4943-a8ba-d7da28d2a3fd", + ) + + response = client.azure_large_storage_instance.get( + resource_group_name="myResourceGroup", + azure_large_storage_instance_name="myAzureLargeStorageInstance", + ) + print(response) + + +# x-ms-original-file: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_storage_instance_list_by_resource_group.py b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_storage_instance_list_by_resource_group.py new file mode 100644 index 000000000000..e76703596e5e --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_storage_instance_list_by_resource_group.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.largeinstance import LargeInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-largeinstance +# USAGE + python azure_large_storage_instance_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, + 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 = LargeInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="f0f4887f-d13c-4943-a8ba-d7da28d2a3fd", + ) + + response = client.azure_large_storage_instance.list_by_resource_group( + resource_group_name="myResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_storage_instance_list_by_subscription.py b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_storage_instance_list_by_subscription.py new file mode 100644 index 000000000000..601ce893e513 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/generated_samples/azure_large_storage_instance_list_by_subscription.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.largeinstance import LargeInstanceMgmtClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-largeinstance +# USAGE + python azure_large_storage_instance_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, + 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 = LargeInstanceMgmtClient( + credential=DefaultAzureCredential(), + subscription_id="f0f4887f-d13c-4943-a8ba-d7da28d2a3fd", + ) + + response = client.azure_large_storage_instance.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/sdk_packaging.toml b/sdk/largeinstance/azure-mgmt-largeinstance/sdk_packaging.toml new file mode 100644 index 000000000000..46d35f0e6498 --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/sdk_packaging.toml @@ -0,0 +1,12 @@ +[packaging] +package_name = "azure-mgmt-largeinstance" +package_nspkg = "azure-mgmt-nspkg" +package_pprint_name = "Largeinstance Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = false +need_azuremgmtcore = true +sample_link = "" +exclude_folders = "" +title = "LargeInstanceMgmtClient" diff --git a/sdk/largeinstance/azure-mgmt-largeinstance/setup.py b/sdk/largeinstance/azure-mgmt-largeinstance/setup.py new file mode 100644 index 000000000000..93d0bc156e6f --- /dev/null +++ b/sdk/largeinstance/azure-mgmt-largeinstance/setup.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python + +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-mgmt-largeinstance" +PACKAGE_PPRINT_NAME = "Largeinstance Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace("-", "/") +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace("-", ".") + +# Version extraction inspired from 'requests' +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError("Cannot find version information") + +with open("README.md", encoding="utf-8") as f: + readme = f.read() +with open("CHANGELOG.md", encoding="utf-8") as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product + classifiers=[ + "Development Status :: 4 - Beta", + "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", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", + ], + zip_safe=False, + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), + include_package_data=True, + package_data={ + "pytyped": ["py.typed"], + }, + install_requires=[ + "isodate>=0.6.1", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", + ], + python_requires=">=3.8", +) diff --git a/sdk/largeinstance/ci.yml b/sdk/largeinstance/ci.yml new file mode 100644 index 000000000000..11f4c0da8241 --- /dev/null +++ b/sdk/largeinstance/ci.yml @@ -0,0 +1,34 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/largeinstance/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/largeinstance/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: largeinstance + TestProxy: true + Artifacts: + - name: azure-mgmt-largeinstance + safeName: azuremgmtlargeinstance diff --git a/sdk/machinelearning/azure-mgmt-machinelearningcompute/pyproject.toml b/sdk/machinelearning/azure-mgmt-machinelearningcompute/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/machinelearning/azure-mgmt-machinelearningcompute/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/managedapplications/azure-mgmt-managedapplications/pyproject.toml b/sdk/managedapplications/azure-mgmt-managedapplications/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/managedapplications/azure-mgmt-managedapplications/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/managementpartner/azure-mgmt-managementpartner/pyproject.toml b/sdk/managementpartner/azure-mgmt-managementpartner/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/managementpartner/azure-mgmt-managementpartner/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/maps/azure-mgmt-maps/pyproject.toml b/sdk/maps/azure-mgmt-maps/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/maps/azure-mgmt-maps/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/mixedreality/azure-mgmt-mixedreality/pyproject.toml b/sdk/mixedreality/azure-mgmt-mixedreality/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/mixedreality/azure-mgmt-mixedreality/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/ml/azure-ai-ml/azure/ai/ml/_telemetry/activity.py b/sdk/ml/azure-ai-ml/azure/ai/ml/_telemetry/activity.py index d562f4a4b977..998ee9a05bcf 100644 --- a/sdk/ml/azure-ai-ml/azure/ai/ml/_telemetry/activity.py +++ b/sdk/ml/azure-ai-ml/azure/ai/ml/_telemetry/activity.py @@ -60,23 +60,23 @@ class ActivityLoggerAdapter(logging.LoggerAdapter): :type activity_info: str """ - def __init__(self, logger: logging.Logger, activity_info: str): + def __init__(self, logger: logging.Logger, activity_info: Dict): """Initialize a new instance of the class. :param logger: The activity logger. :type logger: logging.Logger :param activity_info: The info to write to the logger. - :type activity_info: str + :type activity_info: Dict """ self._activity_info = activity_info super(ActivityLoggerAdapter, self).__init__(logger, None) # type: ignore[arg-type] @property - def activity_info(self) -> str: + def activity_info(self) -> Dict: """Return current activity info. :return: The info to write to the logger - :rtype: str + :rtype: Dict """ return self._activity_info @@ -225,7 +225,6 @@ def log_activity( activity_name, completion_status, duration_ms ) if exception: - message += ", Exception={}".format(type(exception).__name__) activityLogger.activity_info["exception"] = type(exception).__name__ # type: ignore[index] if isinstance(exception, MlException): activityLogger.activity_info[ # type: ignore[index] @@ -241,9 +240,14 @@ def log_activity( activityLogger.activity_info["innerException"] = type( # type: ignore[index] exception.inner_exception ).__name__ + message += ", Exception={}".format(activityLogger.activity_info["exception"]) + message += ", ErrorCategory={}".format(activityLogger.activity_info["errorCategory"]) + message += ", ErrorMessage={}".format(activityLogger.activity_info["errorMessage"]) + activityLogger.error(message) else: activityLogger.info(message) + except Exception: # pylint: disable=broad-except return # pylint: disable=lost-exception diff --git a/sdk/ml/azure-ai-ml/setup.py b/sdk/ml/azure-ai-ml/setup.py index 93c41014e3d3..0984bd9db976 100644 --- a/sdk/ml/azure-ai-ml/setup.py +++ b/sdk/ml/azure-ai-ml/setup.py @@ -81,7 +81,7 @@ "pyjwt", "azure-storage-blob>=12.10.0", "azure-storage-file-share", - "azure-storage-file-datalake", + "azure-storage-file-datalake>=12.2.0", "pydash>=6.0.0", "isodate", "azure-common>=1.1", diff --git a/sdk/ml/azure-ai-ml/tests/datastore/e2etests/test_datastore.py b/sdk/ml/azure-ai-ml/tests/datastore/e2etests/test_datastore.py index 812d92f9aaf0..80f78c5fbf5f 100644 --- a/sdk/ml/azure-ai-ml/tests/datastore/e2etests/test_datastore.py +++ b/sdk/ml/azure-ai-ml/tests/datastore/e2etests/test_datastore.py @@ -79,6 +79,7 @@ def test_hdfs_keytab( with pytest.raises(Exception): client.datastores.get(random_name) + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_blob_store( self, client: MLClient, @@ -105,6 +106,7 @@ def test_blob_store( with pytest.raises(Exception): client.datastores.get(random_name) + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_blob_store_credential_less( self, client: MLClient, @@ -127,6 +129,7 @@ def test_blob_store_credential_less( with pytest.raises(Exception): client.datastores.get(random_name) + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_file_store( self, client: MLClient, @@ -214,6 +217,7 @@ def test_adls_gen2_store( with pytest.raises(Exception): client.datastores.get(random_name) + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_credential_less_adls_gen2_store( self, client: MLClient, diff --git a/sdk/ml/azure-ai-ml/tests/internal/e2etests/test_pipeline_job.py b/sdk/ml/azure-ai-ml/tests/internal/e2etests/test_pipeline_job.py index 0408de1f674c..06cc1091bb62 100644 --- a/sdk/ml/azure-ai-ml/tests/internal/e2etests/test_pipeline_job.py +++ b/sdk/ml/azure-ai-ml/tests/internal/e2etests/test_pipeline_job.py @@ -287,6 +287,7 @@ def pipeline_with_command_components(tsv_file, content): assert_job_cancel(pipeline_job, client, experiment_name="v15_v2_interop") + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_pipeline_with_setting_node_output_mode(self, client: MLClient): # get dataset training_data = Input(type=AssetTypes.URI_FILE, path="https://dprepdata.blob.core.windows.net/demo/Titanic.csv") diff --git a/sdk/ml/azure-ai-ml/tests/workspace/e2etests/test_workspace_connections.py b/sdk/ml/azure-ai-ml/tests/workspace/e2etests/test_workspace_connections.py index 1141648c11da..fbda35b44748 100644 --- a/sdk/ml/azure-ai-ml/tests/workspace/e2etests/test_workspace_connections.py +++ b/sdk/ml/azure-ai-ml/tests/workspace/e2etests/test_workspace_connections.py @@ -108,6 +108,7 @@ def test_workspace_connections_create_update_and_delete_git_pat( with pytest.raises(Exception): client.connections.get(name=wps_connection_name) + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_workspace_connections_create_update_and_delete_cr_msi( self, client: MLClient, @@ -150,6 +151,7 @@ def test_workspace_connections_create_update_and_delete_cr_msi( with pytest.raises(Exception): client.connections.get(name=wps_connection_name) + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_workspace_connections_create_update_and_delete_git_user_pwd( self, client: MLClient, @@ -193,6 +195,7 @@ def test_workspace_connections_create_update_and_delete_git_user_pwd( connection_list = client.connections.list(connection_type=camel_to_snake(ConnectionCategory.GIT)) + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_workspace_connections_create_update_and_delete_snowflake_user_pwd( self, client: MLClient, @@ -485,6 +488,7 @@ def test_workspace_connection_is_shared_behavior(self, client: MLClient, randstr client.workspace_hubs.begin_delete(name=hub.name, delete_dependent_resources=True) @pytest.mark.shareTest + @pytest.mark.live_test_only("Needs re-recording to work with new common sanitizers") def test_workspace_connection_data_connection_listing( self, client: MLClient, diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_sampling.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_sampling.py index 130ede8e4125..e3378780b578 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_sampling.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/azure/monitor/opentelemetry/exporter/export/trace/_sampling.py @@ -95,5 +95,5 @@ def azure_monitor_opentelemetry_sampler_factory(sampler_argument): # pylint: di try: rate = float(sampler_argument) return ApplicationInsightsSampler(rate) - except ValueError: + except (ValueError, TypeError): return ApplicationInsightsSampler() diff --git a/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/trace/test_sampling.py b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/trace/test_sampling.py index 195cd9a438c2..d443c38f381c 100644 --- a/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/trace/test_sampling.py +++ b/sdk/monitor/azure-monitor-opentelemetry-exporter/tests/trace/test_sampling.py @@ -5,12 +5,18 @@ from azure.monitor.opentelemetry.exporter.export.trace._sampling import ( ApplicationInsightsSampler, + azure_monitor_opentelemetry_sampler_factory, ) # pylint: disable=protected-access class TestApplicationInsightsSampler(unittest.TestCase): def test_constructor(self): + sampler = ApplicationInsightsSampler() + self.assertEqual(sampler._ratio, 1.0) + self.assertEqual(sampler._sample_rate, 100) + + def test_constructor_ratio(self): sampler = ApplicationInsightsSampler(0.75) self.assertEqual(sampler._ratio, 0.75) self.assertEqual(sampler._sample_rate, 75) @@ -38,3 +44,15 @@ def test_should_sample_not_sampled(self, score_mock): result = sampler.should_sample(None, 0, "test") self.assertEqual(result.attributes["_MS.sampleRate"], 50) self.assertFalse(result.decision.is_sampled()) + + def test_sampler_factory(self): + sampler = azure_monitor_opentelemetry_sampler_factory("1.0") + self.assertEqual(sampler._ratio, 1.0) + + def test_sampler_factory_none(self): + sampler = azure_monitor_opentelemetry_sampler_factory(None) + self.assertEqual(sampler._ratio, 1.0) + + def test_sampler_factory_empty(self): + sampler = azure_monitor_opentelemetry_sampler_factory("") + self.assertEqual(sampler._ratio, 1.0) diff --git a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md index 8976501ee310..7418f4e1b29f 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-opentelemetry/CHANGELOG.md @@ -1,5 +1,18 @@ # Release History +## 1.4.1 (Unreleased) + +### Features Added + +- Enable sampling for attach + ([#35218](https://github.com/Azure/azure-sdk-for-python/pull/35218)) + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + ## 1.4.0 (2024-04-09) ### Features Added diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/distro.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/distro.py index 364c80df0cf8..23935eb87653 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/distro.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_autoinstrumentation/distro.py @@ -17,6 +17,7 @@ from opentelemetry.sdk.environment_variables import ( _OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED, OTEL_EXPERIMENTAL_RESOURCE_DETECTORS, + OTEL_TRACES_SAMPLER, ) from azure.core.settings import settings @@ -70,6 +71,9 @@ def _configure_auto_instrumentation() -> None: environ.setdefault( OTEL_LOGS_EXPORTER, "azure_monitor_opentelemetry_exporter" ) + environ.setdefault( + OTEL_TRACES_SAMPLER, "azure_monitor_opentelemetry_sampler" + ) environ.setdefault( _OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED, "true" ) diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py index 4bd2b00c6766..d4745c3e8220 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_configure.py @@ -168,7 +168,7 @@ def _setup_instrumentations(configurations: Dict[str, ConfigurationValue]): continue try: # Check if dependent libraries/version are installed - conflict = get_dist_dependency_conflicts(entry_point.dist) + conflict = get_dist_dependency_conflicts(entry_point.dist) # type: ignore if conflict: _logger.debug( "Skipping instrumentation %s: %s", diff --git a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_version.py b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_version.py index 583227a68faf..07106160e649 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_version.py +++ b/sdk/monitor/azure-monitor-opentelemetry/azure/monitor/opentelemetry/_version.py @@ -4,4 +4,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "1.4.0" +VERSION = "1.4.1" diff --git a/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_distro.py b/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_distro.py index 1c45d518a30a..c4a59d293109 100644 --- a/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_distro.py +++ b/sdk/monitor/azure-monitor-opentelemetry/tests/autoinstrumentation/test_distro.py @@ -1,3 +1,4 @@ +from os import environ import warnings from unittest import TestCase from unittest.mock import patch @@ -13,6 +14,7 @@ class TestDistro(TestCase): + @patch.dict("os.environ", {}, clear=True) @patch("azure.monitor.opentelemetry._autoinstrumentation.distro._is_attach_enabled", return_value=True) @patch("azure.monitor.opentelemetry._autoinstrumentation.distro.settings") @patch( @@ -30,8 +32,56 @@ def test_configure(self, mock_diagnostics, azure_core_mock, attach_mock): self.assertEqual( azure_core_mock.tracing_implementation, OpenTelemetrySpan ) + self.assertEqual( + environ, + { + "OTEL_METRICS_EXPORTER": "azure_monitor_opentelemetry_exporter", + "OTEL_TRACES_EXPORTER": "azure_monitor_opentelemetry_exporter", + "OTEL_LOGS_EXPORTER": "azure_monitor_opentelemetry_exporter", + "OTEL_TRACES_SAMPLER": "azure_monitor_opentelemetry_sampler", + "OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED": "true", + "OTEL_EXPERIMENTAL_RESOURCE_DETECTORS": "azure_app_service", + } + ) + + @patch.dict("os.environ", { + "OTEL_METRICS_EXPORTER": "custom_metrics_exporter", + "OTEL_TRACES_EXPORTER": "custom_traces_exporter", + "OTEL_LOGS_EXPORTER": "custom_logs_exporter", + "OTEL_TRACES_SAMPLER": "custom_traces_sampler", + "OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED": "false", + "OTEL_EXPERIMENTAL_RESOURCE_DETECTORS": "custom_resource_detector", + }, clear=True) + @patch("azure.monitor.opentelemetry._autoinstrumentation.distro._is_attach_enabled", return_value=True) + @patch("azure.monitor.opentelemetry._autoinstrumentation.distro.settings") + @patch( + "azure.monitor.opentelemetry._autoinstrumentation.distro.AzureDiagnosticLogging" + ) + def test_configure_env_vars_set(self, mock_diagnostics, azure_core_mock, attach_mock): + distro = AzureMonitorDistro() + with warnings.catch_warnings(): + warnings.simplefilter("error") + distro.configure() + mock_diagnostics.info.assert_called_once_with( + "Azure Monitor OpenTelemetry Distro configured successfully.", + _ATTACH_SUCCESS_DISTRO + ) + self.assertEqual( + azure_core_mock.tracing_implementation, OpenTelemetrySpan + ) + self.assertEqual( + environ, + { + "OTEL_METRICS_EXPORTER": "custom_metrics_exporter", + "OTEL_TRACES_EXPORTER": "custom_traces_exporter", + "OTEL_LOGS_EXPORTER": "custom_logs_exporter", + "OTEL_TRACES_SAMPLER": "custom_traces_sampler", + "OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED": "false", + "OTEL_EXPERIMENTAL_RESOURCE_DETECTORS": "custom_resource_detector", + } + ) - @patch.dict("os.environ", {"OTEL_PYTHON_DISABLED_INSTRUMENTATIONS": " flask,azure_sdk , urllib3"}) + @patch.dict("os.environ", {"OTEL_PYTHON_DISABLED_INSTRUMENTATIONS": " flask,azure_sdk , urllib3"}, clear=True) @patch("azure.monitor.opentelemetry._autoinstrumentation.distro._is_attach_enabled", return_value=True) @patch("azure.monitor.opentelemetry._autoinstrumentation.distro.settings") @patch( diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index 4f845e35d981..25c00cb6bf00 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -110,10 +110,10 @@ Each set of metric values is a time series with the following characteristics: ## Examples - [Logs query](#logs-query) + - [Resource-centric logs query](#resource-centric-logs-query) - [Specify timespan](#specify-timespan) - [Handle logs query response](#handle-logs-query-response) - [Batch logs query](#batch-logs-query) -- [Resource logs query](#resource-logs-query) - [Advanced logs query scenarios](#advanced-logs-query-scenarios) - [Set logs query timeout](#set-logs-query-timeout) - [Query multiple workspaces](#query-multiple-workspaces) @@ -128,6 +128,39 @@ Each set of metric values is a time series with the following characteristics: This example shows how to query a Log Analytics workspace. To handle the response and view it in a tabular form, the [`pandas`](https://pypi.org/project/pandas/) library is used. See the [samples][samples] if you choose not to use `pandas`. +#### Resource-centric logs query + +The following example demonstrates how to query logs directly from an Azure resource without the use of a Log Analytics workspace. Here, the `query_resource` method is used instead of `query_workspace`. Instead of a workspace ID, an Azure resource identifier is passed in. For example, `/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}`. + +```python +import os +import pandas as pd +from datetime import timedelta +from azure.monitor.query import LogsQueryClient, LogsQueryStatus +from azure.core.exceptions import HttpResponseError +from azure.identity import DefaultAzureCredential + +credential = DefaultAzureCredential() +client = LogsQueryClient(credential) + +query = """AzureActivity | take 5""" + +try: + response = client.query_resource(os.environ['LOGS_RESOURCE_ID'], query, timespan=timedelta(days=1)) + if response.status == LogsQueryStatus.PARTIAL: + error = response.partial_error + data = response.partial_data + print(error) + elif response.status == LogsQueryStatus.SUCCESS: + data = response.tables + for table in data: + df = pd.DataFrame(data=table.rows, columns=table.columns) + print(df) +except HttpResponseError as err: + print("something fatal happened") + print(err) +``` + #### Specify timespan The `timespan` parameter specifies the time duration for which to query the data. This value can take one of the following forms: @@ -278,39 +311,6 @@ for res in results: ``` -### Resource logs query - -The following example demonstrates how to query logs directly from an Azure resource without the use of a Log Analytics workspace. Here, the `query_resource` method is used instead of `query_workspace`. Instead of a workspace ID, an Azure resource identifier is passed in. For example, `/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/providers/{resource-provider}/{resource-type}/{resource-name}`. - -```python -import os -import pandas as pd -from datetime import timedelta -from azure.monitor.query import LogsQueryClient, LogsQueryStatus -from azure.core.exceptions import HttpResponseError -from azure.identity import DefaultAzureCredential - -credential = DefaultAzureCredential() -client = LogsQueryClient(credential) - -query = """AzureActivity | take 5""" - -try: - response = client.query_resource(os.environ['LOGS_RESOURCE_ID'], query, timespan=timedelta(days=1)) - if response.status == LogsQueryStatus.PARTIAL: - error = response.partial_error - data = response.partial_data - print(error) - elif response.status == LogsQueryStatus.SUCCESS: - data = response.tables - for table in data: - df = pd.DataFrame(data=table.rows, columns=table.columns) - print(df) -except HttpResponseError as err: - print("something fatal happened") - print(err) -``` - ### Advanced logs query scenarios #### Set logs query timeout @@ -362,7 +362,7 @@ A full sample can be found [here](https://github.com/Azure/azure-sdk-for-python/ To get logs query execution statistics, such as CPU and memory consumption: 1. Set the `include_statistics` parameter to `True`. -2. Access the `statistics` field inside the `LogsQueryResult` object. +1. Access the `statistics` field inside the `LogsQueryResult` object. The following example prints the query execution time: @@ -546,7 +546,10 @@ Each Azure resource must reside in: - The same region as the endpoint specified when creating the client. - The same Azure subscription. -Furthermore, the metric namespace containing the metrics to be queried must be provided. For a list of metric namespaces, see [Supported metrics and log categories by resource type][metric_namespaces]. +Furthermore: + +- The user must be authorized to read monitoring data at the Azure subscription level. For example, the [Monitoring Reader role](https://learn.microsoft.com/azure/role-based-access-control/built-in-roles/monitor#monitoring-reader) on the subscription to be queried. +- The metric namespace containing the metrics to be queried must be provided. For a list of metric namespaces, see [Supported metrics and log categories by resource type][metric_namespaces]. ```python from datetime import timedelta diff --git a/sdk/network/azure-mgmt-frontdoor/CHANGELOG.md b/sdk/network/azure-mgmt-frontdoor/CHANGELOG.md index 4af1de8843ef..8b89179a7455 100644 --- a/sdk/network/azure-mgmt-frontdoor/CHANGELOG.md +++ b/sdk/network/azure-mgmt-frontdoor/CHANGELOG.md @@ -1,5 +1,14 @@ # Release History +## 1.2.0 (2024-04-15) + +### Features Added + + - Model CustomRule has a new parameter group_by + - Model PolicySettings has a new parameter javascript_challenge_expiration_in_minutes + - Model PolicySettings has a new parameter scrubbing_rules + - Model PolicySettings has a new parameter state + ## 1.1.0 (2023-05-19) ### Features Added diff --git a/sdk/network/azure-mgmt-frontdoor/README.md b/sdk/network/azure-mgmt-frontdoor/README.md index 43d213fb30ea..5084bc9e2791 100644 --- a/sdk/network/azure-mgmt-frontdoor/README.md +++ b/sdk/network/azure-mgmt-frontdoor/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure Front Door Service Client Library. -This package has been tested with Python 3.7+. +This package has been tested with Python 3.8+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,7 +12,7 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For ### Prerequisites -- Python 3.7+ is required to use this package. +- Python 3.8+ is required to use this package. - [Azure subscription](https://azure.microsoft.com/free/) ### Install the package @@ -59,6 +59,3 @@ Code samples for this package can be found at: If you encounter any bugs or have suggestions, please file an issue in the [Issues](https://github.com/Azure/azure-sdk-for-python/issues) section of the project. - - -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-mgmt-frontdoor%2FREADME.png) diff --git a/sdk/network/azure-mgmt-frontdoor/_meta.json b/sdk/network/azure-mgmt-frontdoor/_meta.json index 8c7152a71be1..b627790ac506 100644 --- a/sdk/network/azure-mgmt-frontdoor/_meta.json +++ b/sdk/network/azure-mgmt-frontdoor/_meta.json @@ -1,11 +1,11 @@ { - "commit": "7a65f22cf67826187f75981e914c7e679039257b", + "commit": "b54ffc9278eff071455b1dbb4ad2e772afce885d", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest": "3.9.2", + "autorest": "3.9.7", "use": [ - "@autorest/python@6.4.8", - "@autorest/modelerfour@4.24.3" + "@autorest/python@6.13.7", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/frontdoor/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.4.8 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", + "autorest_command": "autorest specification/frontdoor/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.13.7 --use=@autorest/modelerfour@4.27.0 --version=3.9.7 --version-tolerant=False", "readme": "specification/frontdoor/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_configuration.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_configuration.py index 5e41671c0972..82c6cc94b851 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_configuration.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class FrontDoorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class FrontDoorManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for FrontDoorManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class FrontDoorManagementClientConfiguration(Configuration): # pylint: disable= """ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(FrontDoorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.subscription_id = subscription_id self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-frontdoor/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_front_door_management_client.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_front_door_management_client.py index 6cb2e52455af..c0a8d575a4e2 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_front_door_management_client.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_front_door_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import FrontDoorManagementClientConfiguration @@ -88,7 +90,25 @@ def __init__( self._config = FrontDoorManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -119,7 +139,7 @@ def __init__( self.experiments = ExperimentsOperations(self._client, self._config, self._serialize, self._deserialize) self.reports = ReportsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -139,7 +159,7 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_serialization.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_serialization.py index 842ae727fbbc..2f781d740827 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_serialization.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,7 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -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: @@ -295,7 +288,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[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__) @@ -340,7 +333,7 @@ def _create_xml_node(cls): 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: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +344,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +383,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +408,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +438,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -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 @@ -662,12 +655,13 @@ def _serialize(self, target_obj, data_type=None, **kwargs): _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)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -709,7 +703,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -729,6 +723,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -741,7 +736,9 @@ 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. - :rtype: str + :keyword bool skip_quote: Whether to skip quote the serialized result. + Defaults to False. + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -749,10 +746,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 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) @@ -803,7 +798,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -823,7 +818,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -891,6 +886,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): @@ -903,9 +900,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) @@ -950,7 +952,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: @@ -983,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) @@ -1160,10 +1164,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1199,7 +1203,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1220,7 +1223,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1361,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, @@ -1381,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 @@ -1434,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) @@ -1471,7 +1473,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1505,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 @@ -1568,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 @@ -1642,7 +1644,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1690,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: @@ -1747,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"]: @@ -1798,7 +1800,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1852,10 +1853,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1883,7 +1884,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1900,7 +1901,7 @@ def deserialize_date(attr): 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) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1935,7 +1936,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1972,7 +1973,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1988,9 +1989,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_vendor.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_vendor.py index bd0df84f5319..0dafe0e287ff 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_vendor.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_vendor.py @@ -5,8 +5,6 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import List, cast - from azure.core.pipeline.transport import HttpRequest @@ -16,15 +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: - # Need the cast, as for some reasons "split" is typed as list[str | Any] - formatted_components = cast(List[str], template.split("/")) - components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] - template = "/".join(components) diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_version.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_version.py index 59deb8c7263b..dbf4c577231c 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_version.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0" +VERSION = "1.2.0" diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_configuration.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_configuration.py index f41c9c14bfe5..c7db56dd2a97 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_configuration.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class FrontDoorManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class FrontDoorManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for FrontDoorManagementClient. Note that all parameters used to create this instance are saved as instance @@ -33,7 +32,6 @@ class FrontDoorManagementClientConfiguration(Configuration): # pylint: disable= """ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: - super(FrontDoorManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -43,6 +41,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.subscription_id = subscription_id self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-frontdoor/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -51,9 +50,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_front_door_management_client.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_front_door_management_client.py index f6ab970c972a..537f2340590f 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_front_door_management_client.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/_front_door_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -88,7 +90,25 @@ def __init__( self._config = FrontDoorManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -119,7 +139,9 @@ def __init__( self.experiments = ExperimentsOperations(self._client, self._config, self._serialize, self._deserialize) self.reports = ReportsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -139,7 +161,7 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_endpoints_operations.py index 40d5999308f3..982524c3d80d 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -56,7 +57,7 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme self, resource_group_name: str, front_door_name: str, - content_file_paths: Union[_models.PurgeParameters, IO], + content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any ) -> None: error_map = { @@ -77,12 +78,12 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme content_type = content_type or "application/json" _json = None _content = None - if isinstance(content_file_paths, (IO, bytes)): + if isinstance(content_file_paths, (IOBase, bytes)): _content = content_file_paths else: _json = self._serialize.body(content_file_paths, "PurgeParameters") - request = build_purge_content_request( + _request = build_purge_content_request( resource_group_name=resource_group_name, front_door_name=front_door_name, subscription_id=self._config.subscription_id, @@ -90,16 +91,15 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme content_type=content_type, json=_json, content=_content, - template_url=self._purge_content_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -110,11 +110,7 @@ async def _purge_content_initial( # pylint: disable=inconsistent-return-stateme raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _purge_content_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/purge" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def begin_purge_content( @@ -139,14 +135,6 @@ async def begin_purge_content( :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -157,7 +145,7 @@ async def begin_purge_content( self, resource_group_name: str, front_door_name: str, - content_file_paths: IO, + content_file_paths: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -171,18 +159,10 @@ async def begin_purge_content( :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Required. - :type content_file_paths: IO + :type content_file_paths: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -193,7 +173,7 @@ async def begin_purge_content( self, resource_group_name: str, front_door_name: str, - content_file_paths: Union[_models.PurgeParameters, IO], + content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Removes a content from Front Door. @@ -205,19 +185,8 @@ async def begin_purge_content( :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Is either a PurgeParameters - type or a IO type. Required. - :type content_file_paths: ~azure.mgmt.frontdoor.models.PurgeParameters 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. + type or a IO[bytes] type. Required. + :type content_file_paths: ~azure.mgmt.frontdoor.models.PurgeParameters or IO[bytes] :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: @@ -247,7 +216,7 @@ async def begin_purge_content( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -259,14 +228,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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_purge_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/purge" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_experiments_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_experiments_operations.py index cdcd47385315..5c8e2b119980 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_experiments_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_experiments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -72,7 +73,6 @@ def list_by_profile( :type resource_group_name: str :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Experiment or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.frontdoor.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: @@ -94,24 +94,23 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("ExperimentList", pipeline_response) @@ -121,11 +120,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -138,10 +137,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments" - } - @distributed_trace_async async def get( self, resource_group_name: str, profile_name: str, experiment_name: str, **kwargs: Any @@ -156,7 +151,6 @@ async def get( :type profile_name: str :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Experiment or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.Experiment :raises ~azure.core.exceptions.HttpResponseError: @@ -175,22 +169,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -203,20 +196,16 @@ async def get( deserialized = self._deserialize("Experiment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, profile_name: str, experiment_name: str, - parameters: Union[_models.Experiment, IO], + parameters: Union[_models.Experiment, IO[bytes]], **kwargs: Any ) -> _models.Experiment: error_map = { @@ -237,12 +226,12 @@ async def _create_or_update_initial( 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, "Experiment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_name, @@ -251,16 +240,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -284,10 +272,6 @@ async def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } - @overload async def begin_create_or_update( self, @@ -314,14 +298,6 @@ async def begin_create_or_update( :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 Experiment or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Experiment] @@ -334,7 +310,7 @@ async def begin_create_or_update( resource_group_name: str, profile_name: str, experiment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -350,18 +326,10 @@ async def begin_create_or_update( :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_name: str :param parameters: The Experiment resource. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Experiment or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Experiment] @@ -374,7 +342,7 @@ async def begin_create_or_update( resource_group_name: str, profile_name: str, experiment_name: str, - parameters: Union[_models.Experiment, IO], + parameters: Union[_models.Experiment, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Experiment]: """Creates or updates an Experiment. @@ -387,19 +355,9 @@ async def begin_create_or_update( :type profile_name: str :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_name: str - :param parameters: The Experiment resource. Is either a Experiment type or a IO type. Required. - :type parameters: ~azure.mgmt.frontdoor.models.Experiment 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. + :param parameters: The Experiment resource. Is either a Experiment type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.frontdoor.models.Experiment or IO[bytes] :return: An instance of AsyncLROPoller that returns either Experiment or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Experiment] @@ -432,7 +390,7 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Experiment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -442,24 +400,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Experiment].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.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } + return AsyncLROPoller[_models.Experiment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, profile_name: str, experiment_name: str, - parameters: Union[_models.ExperimentUpdateModel, IO], + parameters: Union[_models.ExperimentUpdateModel, IO[bytes]], **kwargs: Any ) -> _models.Experiment: error_map = { @@ -480,12 +436,12 @@ async def _update_initial( 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, "ExperimentUpdateModel") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_name, @@ -494,16 +450,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -524,10 +479,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } - @overload async def begin_update( self, @@ -554,14 +505,6 @@ async def begin_update( :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 Experiment or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Experiment] @@ -574,7 +517,7 @@ async def begin_update( resource_group_name: str, profile_name: str, experiment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -590,18 +533,10 @@ async def begin_update( :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_name: str :param parameters: The Experiment Update Model. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Experiment or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Experiment] @@ -614,7 +549,7 @@ async def begin_update( resource_group_name: str, profile_name: str, experiment_name: str, - parameters: Union[_models.ExperimentUpdateModel, IO], + parameters: Union[_models.ExperimentUpdateModel, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Experiment]: """Updates an Experiment by Experiment id. @@ -627,20 +562,9 @@ async def begin_update( :type profile_name: str :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_name: str - :param parameters: The Experiment Update Model. Is either a ExperimentUpdateModel type or a IO - type. Required. - :type parameters: ~azure.mgmt.frontdoor.models.ExperimentUpdateModel 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. + :param parameters: The Experiment Update Model. Is either a ExperimentUpdateModel type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.frontdoor.models.ExperimentUpdateModel or IO[bytes] :return: An instance of AsyncLROPoller that returns either Experiment or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Experiment] @@ -673,7 +597,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Experiment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -683,17 +607,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Experiment].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.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } + return AsyncLROPoller[_models.Experiment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, experiment_name: str, **kwargs: Any @@ -712,22 +634,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -738,11 +659,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete( @@ -758,14 +675,6 @@ async def begin_delete( :type profile_name: str :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_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: @@ -793,7 +702,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -802,14 +711,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_operations.py index 881f230a2396..9ffcee0a3b49 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -66,7 +67,6 @@ async def check( :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -74,16 +74,19 @@ async def check( @overload async def check( - self, check_front_door_name_availability_input: IO, *, content_type: str = "application/json", **kwargs: Any + self, + check_front_door_name_availability_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a Front Door resource name. :param check_front_door_name_availability_input: Input to check. Required. - :type check_front_door_name_availability_input: IO + :type check_front_door_name_availability_input: IO[bytes] :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -91,18 +94,16 @@ async def check( @distributed_trace_async async def check( - self, check_front_door_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO], **kwargs: Any + self, + check_front_door_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], + **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a Front Door resource name. :param check_front_door_name_availability_input: Input to check. Is either a - CheckNameAvailabilityInput type or a IO type. Required. + CheckNameAvailabilityInput type or a IO[bytes] type. Required. :type check_front_door_name_availability_input: - ~azure.mgmt.frontdoor.models.CheckNameAvailabilityInput 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 + ~azure.mgmt.frontdoor.models.CheckNameAvailabilityInput or IO[bytes] :return: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -125,26 +126,25 @@ async def check( content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_front_door_name_availability_input, (IO, bytes)): + if isinstance(check_front_door_name_availability_input, (IOBase, bytes)): _content = check_front_door_name_availability_input else: _json = self._serialize.body(check_front_door_name_availability_input, "CheckNameAvailabilityInput") - request = build_check_request( + _request = build_check_request( api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -157,8 +157,6 @@ async def check( deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check.metadata = {"url": "/providers/Microsoft.Network/checkFrontDoorNameAvailability"} + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_with_subscription_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_with_subscription_operations.py index fb04feb68f12..0e919f8a2038 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_with_subscription_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_door_name_availability_with_subscription_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -31,7 +32,7 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class FrontDoorNameAvailabilityWithSubscriptionOperations: +class FrontDoorNameAvailabilityWithSubscriptionOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -66,7 +67,6 @@ async def check( :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -74,16 +74,19 @@ async def check( @overload async def check( - self, check_front_door_name_availability_input: IO, *, content_type: str = "application/json", **kwargs: Any + self, + check_front_door_name_availability_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a Front Door subdomain. :param check_front_door_name_availability_input: Input to check. Required. - :type check_front_door_name_availability_input: IO + :type check_front_door_name_availability_input: IO[bytes] :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -91,18 +94,16 @@ async def check( @distributed_trace_async async def check( - self, check_front_door_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO], **kwargs: Any + self, + check_front_door_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], + **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a Front Door subdomain. :param check_front_door_name_availability_input: Input to check. Is either a - CheckNameAvailabilityInput type or a IO type. Required. + CheckNameAvailabilityInput type or a IO[bytes] type. Required. :type check_front_door_name_availability_input: - ~azure.mgmt.frontdoor.models.CheckNameAvailabilityInput 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 + ~azure.mgmt.frontdoor.models.CheckNameAvailabilityInput or IO[bytes] :return: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -125,27 +126,26 @@ async def check( content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_front_door_name_availability_input, (IO, bytes)): + if isinstance(check_front_door_name_availability_input, (IOBase, bytes)): _content = check_front_door_name_availability_input else: _json = self._serialize.body(check_front_door_name_availability_input, "CheckNameAvailabilityInput") - request = build_check_request( + _request = build_check_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -158,10 +158,6 @@ async def check( deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/checkFrontDoorNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_doors_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_doors_operations.py index 20a76e7b39fd..a1cb6ec9f7a5 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_doors_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_front_doors_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -65,7 +66,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.FrontDoor"]: """Lists all of the Front Doors within an Azure subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FrontDoor or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.frontdoor.models.FrontDoor] :raises ~azure.core.exceptions.HttpResponseError: @@ -87,22 +87,21 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.FrontDoor"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("FrontDoorListResult", pipeline_response) @@ -112,11 +111,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -129,15 +128,12 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/frontDoors"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.FrontDoor"]: """Lists all of the Front Doors within a resource group under a subscription. :param resource_group_name: Name of the Resource group within the Azure 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 FrontDoor or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.frontdoor.models.FrontDoor] :raises ~azure.core.exceptions.HttpResponseError: @@ -159,23 +155,22 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("FrontDoorListResult", pipeline_response) @@ -185,11 +180,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -202,10 +197,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors" - } - @distributed_trace_async async def get(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> _models.FrontDoor: """Gets a Front Door with the specified Front Door name under the specified subscription and @@ -215,7 +206,6 @@ async def get(self, resource_group_name: str, front_door_name: str, **kwargs: An :type resource_group_name: str :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FrontDoor or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.FrontDoor :raises ~azure.core.exceptions.HttpResponseError: @@ -234,21 +224,20 @@ async def get(self, resource_group_name: str, front_door_name: str, **kwargs: An api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.FrontDoor] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, front_door_name=front_door_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -261,19 +250,15 @@ async def get(self, resource_group_name: str, front_door_name: str, **kwargs: An deserialized = self._deserialize("FrontDoor", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, front_door_name: str, - front_door_parameters: Union[_models.FrontDoor, IO], + front_door_parameters: Union[_models.FrontDoor, IO[bytes]], **kwargs: Any ) -> _models.FrontDoor: error_map = { @@ -294,12 +279,12 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(front_door_parameters, (IO, bytes)): + if isinstance(front_door_parameters, (IOBase, bytes)): _content = front_door_parameters else: _json = self._serialize.body(front_door_parameters, "FrontDoor") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, front_door_name=front_door_name, subscription_id=self._config.subscription_id, @@ -307,16 +292,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -340,10 +324,6 @@ async def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}" - } - @overload async def begin_create_or_update( self, @@ -367,14 +347,6 @@ async def begin_create_or_update( :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 FrontDoor or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.FrontDoor] @@ -386,7 +358,7 @@ async def begin_create_or_update( self, resource_group_name: str, front_door_name: str, - front_door_parameters: IO, + front_door_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -400,18 +372,10 @@ async def begin_create_or_update( :type front_door_name: str :param front_door_parameters: Front Door properties needed to create a new Front Door. Required. - :type front_door_parameters: IO + :type front_door_parameters: IO[bytes] :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 FrontDoor or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.FrontDoor] @@ -423,7 +387,7 @@ async def begin_create_or_update( self, resource_group_name: str, front_door_name: str, - front_door_parameters: Union[_models.FrontDoor, IO], + front_door_parameters: Union[_models.FrontDoor, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.FrontDoor]: """Creates a new Front Door with a Front Door name under the specified subscription and resource @@ -434,19 +398,8 @@ async def begin_create_or_update( :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str :param front_door_parameters: Front Door properties needed to create a new Front Door. Is - either a FrontDoor type or a IO type. Required. - :type front_door_parameters: ~azure.mgmt.frontdoor.models.FrontDoor 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. + either a FrontDoor type or a IO[bytes] type. Required. + :type front_door_parameters: ~azure.mgmt.frontdoor.models.FrontDoor or IO[bytes] :return: An instance of AsyncLROPoller that returns either FrontDoor or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.FrontDoor] @@ -478,7 +431,7 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("FrontDoor", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -491,17 +444,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.FrontDoor].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.Network/frontDoors/{frontDoorName}" - } + return AsyncLROPoller[_models.FrontDoor]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, front_door_name: str, **kwargs: Any @@ -520,21 +471,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, front_door_name=front_door_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -545,11 +495,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Network/frontDoors/{frontDoorName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -559,14 +505,6 @@ async def begin_delete(self, resource_group_name: str, front_door_name: str, **k :type resource_group_name: str :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_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: @@ -593,7 +531,7 @@ async def begin_delete(self, resource_group_name: str, front_door_name: str, **k def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -605,17 +543,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Network/frontDoors/{frontDoorName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @overload async def validate_custom_domain( @@ -639,7 +573,6 @@ async def validate_custom_domain( :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -650,7 +583,7 @@ async def validate_custom_domain( self, resource_group_name: str, front_door_name: str, - custom_domain_properties: IO, + custom_domain_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -663,11 +596,10 @@ async def validate_custom_domain( :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: IO + :type custom_domain_properties: IO[bytes] :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -678,7 +610,7 @@ async def validate_custom_domain( self, resource_group_name: str, front_door_name: str, - custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO], + custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO[bytes]], **kwargs: Any ) -> _models.ValidateCustomDomainOutput: """Validates the custom domain mapping to ensure it maps to the correct Front Door endpoint in @@ -689,12 +621,9 @@ async def validate_custom_domain( :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str :param custom_domain_properties: Custom domain to be validated. Is either a - ValidateCustomDomainInput type or a IO type. Required. - :type custom_domain_properties: ~azure.mgmt.frontdoor.models.ValidateCustomDomainInput 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 + ValidateCustomDomainInput type or a IO[bytes] type. Required. + :type custom_domain_properties: ~azure.mgmt.frontdoor.models.ValidateCustomDomainInput or + IO[bytes] :return: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -717,12 +646,12 @@ async def validate_custom_domain( content_type = content_type or "application/json" _json = None _content = None - if isinstance(custom_domain_properties, (IO, bytes)): + if isinstance(custom_domain_properties, (IOBase, bytes)): _content = custom_domain_properties else: _json = self._serialize.body(custom_domain_properties, "ValidateCustomDomainInput") - request = build_validate_custom_domain_request( + _request = build_validate_custom_domain_request( resource_group_name=resource_group_name, front_door_name=front_door_name, subscription_id=self._config.subscription_id, @@ -730,16 +659,15 @@ async def validate_custom_domain( content_type=content_type, json=_json, content=_content, - template_url=self.validate_custom_domain.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -752,10 +680,6 @@ async def validate_custom_domain( deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate_custom_domain.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/validateCustomDomain" - } + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_frontend_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_frontend_endpoints_operations.py index 3673c79b455c..c36b3943db39 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_frontend_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_frontend_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -69,7 +70,6 @@ def list_by_front_door( :type resource_group_name: str :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FrontendEndpoint or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.frontdoor.models.FrontendEndpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -91,24 +91,23 @@ def list_by_front_door( def prepare_request(next_link=None): if not next_link: - request = build_list_by_front_door_request( + _request = build_list_by_front_door_request( resource_group_name=resource_group_name, front_door_name=front_door_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_front_door.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("FrontendEndpointsListResult", pipeline_response) @@ -118,11 +117,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -135,10 +134,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_front_door.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints" - } - @distributed_trace_async async def get( self, resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, **kwargs: Any @@ -152,7 +147,6 @@ async def get( :param frontend_endpoint_name: Name of the Frontend endpoint which is unique within the Front Door. Required. :type frontend_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FrontendEndpoint or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.FrontendEndpoint :raises ~azure.core.exceptions.HttpResponseError: @@ -171,22 +165,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.FrontendEndpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, front_door_name=front_door_name, frontend_endpoint_name=frontend_endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -199,20 +192,16 @@ async def get( deserialized = self._deserialize("FrontendEndpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}" - } + return deserialized # type: ignore async def _enable_https_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, - custom_https_configuration: Union[_models.CustomHttpsConfiguration, IO], + custom_https_configuration: Union[_models.CustomHttpsConfiguration, IO[bytes]], **kwargs: Any ) -> None: error_map = { @@ -233,12 +222,12 @@ async def _enable_https_initial( # pylint: disable=inconsistent-return-statemen content_type = content_type or "application/json" _json = None _content = None - if isinstance(custom_https_configuration, (IO, bytes)): + if isinstance(custom_https_configuration, (IOBase, bytes)): _content = custom_https_configuration else: _json = self._serialize.body(custom_https_configuration, "CustomHttpsConfiguration") - request = build_enable_https_request( + _request = build_enable_https_request( resource_group_name=resource_group_name, front_door_name=front_door_name, frontend_endpoint_name=frontend_endpoint_name, @@ -247,16 +236,15 @@ async def _enable_https_initial( # pylint: disable=inconsistent-return-statemen content_type=content_type, json=_json, content=_content, - template_url=self._enable_https_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -267,11 +255,7 @@ async def _enable_https_initial( # pylint: disable=inconsistent-return-statemen raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _enable_https_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/enableHttps" - } + return cls(pipeline_response, None, {}) # type: ignore @overload async def begin_enable_https( @@ -298,14 +282,6 @@ async def begin_enable_https( :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -317,7 +293,7 @@ async def begin_enable_https( resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, - custom_https_configuration: IO, + custom_https_configuration: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -332,18 +308,10 @@ async def begin_enable_https( Door. Required. :type frontend_endpoint_name: str :param custom_https_configuration: The configuration specifying how to enable HTTPS. Required. - :type custom_https_configuration: IO + :type custom_https_configuration: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -355,7 +323,7 @@ async def begin_enable_https( resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, - custom_https_configuration: Union[_models.CustomHttpsConfiguration, IO], + custom_https_configuration: Union[_models.CustomHttpsConfiguration, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Enables a frontendEndpoint for HTTPS traffic. @@ -368,19 +336,9 @@ async def begin_enable_https( Door. Required. :type frontend_endpoint_name: str :param custom_https_configuration: The configuration specifying how to enable HTTPS. Is either - a CustomHttpsConfiguration type or a IO type. Required. - :type custom_https_configuration: ~azure.mgmt.frontdoor.models.CustomHttpsConfiguration 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. + a CustomHttpsConfiguration type or a IO[bytes] type. Required. + :type custom_https_configuration: ~azure.mgmt.frontdoor.models.CustomHttpsConfiguration or + IO[bytes] :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: @@ -411,7 +369,7 @@ async def begin_enable_https( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -423,17 +381,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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_enable_https.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/enableHttps" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _disable_https_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, **kwargs: Any @@ -452,22 +406,21 @@ async def _disable_https_initial( # pylint: disable=inconsistent-return-stateme api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_disable_https_request( + _request = build_disable_https_request( resource_group_name=resource_group_name, front_door_name=front_door_name, frontend_endpoint_name=frontend_endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._disable_https_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -478,11 +431,7 @@ async def _disable_https_initial( # pylint: disable=inconsistent-return-stateme raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _disable_https_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/disableHttps" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_disable_https( @@ -497,14 +446,6 @@ async def begin_disable_https( :param frontend_endpoint_name: Name of the Frontend endpoint which is unique within the Front Door. Required. :type frontend_endpoint_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: @@ -532,7 +473,7 @@ async def begin_disable_https( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -544,14 +485,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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_disable_https.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/disableHttps" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_managed_rule_sets_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_managed_rule_sets_operations.py index d1d8b37d5a80..6192c507d92b 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_managed_rule_sets_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_managed_rule_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -55,7 +55,6 @@ def __init__(self, *args, **kwargs) -> None: def list(self, **kwargs: Any) -> AsyncIterable["_models.ManagedRuleSetDefinition"]: """Lists all available managed rule sets. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ManagedRuleSetDefinition or the result of cls(response) :rtype: @@ -65,7 +64,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ManagedRuleSetDefinition _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) cls: ClsType[_models.ManagedRuleSetDefinitionList] = kwargs.pop("cls", None) error_map = { @@ -79,22 +78,21 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.ManagedRuleSetDefinition def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("ManagedRuleSetDefinitionList", pipeline_response) @@ -104,11 +102,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -120,7 +118,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallManagedRuleSets" - } diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_network_experiment_profiles_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_network_experiment_profiles_operations.py index 6ba3a9f03f81..9fd4f586e7cf 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_network_experiment_profiles_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_network_experiment_profiles_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -67,7 +68,6 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Profile"]: Gets a list of Network Experiment Profiles under a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Profile or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.frontdoor.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -89,22 +89,21 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Profile"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("ProfileList", pipeline_response) @@ -114,11 +113,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -131,8 +130,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/NetworkExperimentProfiles"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Profile"]: """Gets a list of Network Experiment Profiles within a resource group under a subscription. @@ -141,7 +138,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy :param resource_group_name: Name of the Resource group within the Azure 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 Profile or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.frontdoor.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -163,23 +159,22 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("ProfileList", pipeline_response) @@ -189,11 +184,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -206,10 +201,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles" - } - @distributed_trace_async async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.Profile: """Gets an NetworkExperiment Profile by ProfileName. @@ -220,7 +211,6 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) :type resource_group_name: str :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Profile or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.Profile :raises ~azure.core.exceptions.HttpResponseError: @@ -239,21 +229,20 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.Profile] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -266,16 +255,12 @@ async def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}" - } + return deserialized # type: ignore async def _create_or_update_initial( - self, profile_name: str, resource_group_name: str, parameters: Union[_models.Profile, IO], **kwargs: Any + self, profile_name: str, resource_group_name: str, parameters: Union[_models.Profile, IO[bytes]], **kwargs: Any ) -> _models.Profile: error_map = { 401: ClientAuthenticationError, @@ -295,12 +280,12 @@ async def _create_or_update_initial( 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, "Profile") - request = build_create_or_update_request( + _request = build_create_or_update_request( profile_name=profile_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, @@ -308,16 +293,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -341,10 +325,6 @@ async def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}" - } - @overload async def begin_create_or_update( self, @@ -368,14 +348,6 @@ async def begin_create_or_update( :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Profile] @@ -387,7 +359,7 @@ async def begin_create_or_update( self, profile_name: str, resource_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -401,18 +373,10 @@ async def begin_create_or_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param parameters: An Network Experiment Profile. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Profile] @@ -421,7 +385,7 @@ async def begin_create_or_update( @distributed_trace_async async def begin_create_or_update( - self, profile_name: str, resource_group_name: str, parameters: Union[_models.Profile, IO], **kwargs: Any + self, profile_name: str, resource_group_name: str, parameters: Union[_models.Profile, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Profile]: """Creates an NetworkExperiment Profile. @@ -431,20 +395,9 @@ async def begin_create_or_update( :type profile_name: str :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param parameters: An Network Experiment Profile. Is either a Profile type or a IO type. + :param parameters: An Network Experiment Profile. Is either a Profile type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.frontdoor.models.Profile 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. + :type parameters: ~azure.mgmt.frontdoor.models.Profile or IO[bytes] :return: An instance of AsyncLROPoller that returns either Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Profile] @@ -476,7 +429,7 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -486,23 +439,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Profile].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.Network/NetworkExperimentProfiles/{profileName}" - } + return AsyncLROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, profile_name: str, - parameters: Union[_models.ProfileUpdateModel, IO], + parameters: Union[_models.ProfileUpdateModel, IO[bytes]], **kwargs: Any ) -> _models.Profile: error_map = { @@ -523,12 +474,12 @@ async def _update_initial( 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, "ProfileUpdateModel") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -536,16 +487,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -566,10 +516,6 @@ async def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}" - } - @overload async def begin_update( self, @@ -593,14 +539,6 @@ async def begin_update( :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Profile] @@ -612,7 +550,7 @@ async def begin_update( self, resource_group_name: str, profile_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -626,18 +564,10 @@ async def begin_update( :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_name: str :param parameters: The Profile Update Model. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Profile] @@ -649,7 +579,7 @@ async def begin_update( self, resource_group_name: str, profile_name: str, - parameters: Union[_models.ProfileUpdateModel, IO], + parameters: Union[_models.ProfileUpdateModel, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Profile]: """Updates an NetworkExperimentProfiles by NetworkExperimentProfile name. @@ -660,20 +590,9 @@ async def begin_update( :type resource_group_name: str :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_name: str - :param parameters: The Profile Update Model. Is either a ProfileUpdateModel type or a IO type. - Required. - :type parameters: ~azure.mgmt.frontdoor.models.ProfileUpdateModel 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. + :param parameters: The Profile Update Model. Is either a ProfileUpdateModel type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.frontdoor.models.ProfileUpdateModel or IO[bytes] :return: An instance of AsyncLROPoller that returns either Profile or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.Profile] @@ -705,7 +624,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -715,17 +634,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Profile].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.Network/NetworkExperimentProfiles/{profileName}" - } + return AsyncLROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, **kwargs: Any @@ -744,21 +661,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -769,11 +685,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Network/NetworkExperimentProfiles/{profileName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -785,14 +697,6 @@ async def begin_delete(self, resource_group_name: str, profile_name: str, **kwar :type resource_group_name: str :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_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: @@ -819,7 +723,7 @@ async def begin_delete(self, resource_group_name: str, profile_name: str, **kwar def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -828,14 +732,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Network/NetworkExperimentProfiles/{profileName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_policies_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_policies_operations.py index e73b1f1eaaed..d1dc600da289 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_policies_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -67,7 +68,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model :param resource_group_name: Name of the Resource group within the Azure 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 WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -77,7 +77,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) cls: ClsType[_models.WebApplicationFirewallPolicyList] = kwargs.pop("cls", None) error_map = { @@ -91,23 +91,22 @@ def list(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_model def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("WebApplicationFirewallPolicyList", pipeline_response) @@ -117,11 +116,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -134,15 +133,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies" - } - @distributed_trace def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.WebApplicationFirewallPolicy"]: """Lists all of the protection policies within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -152,7 +146,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.WebAppli _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) cls: ClsType[_models.WebApplicationFirewallPolicyList] = kwargs.pop("cls", None) error_map = { @@ -166,22 +160,21 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.WebAppli def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("WebApplicationFirewallPolicyList", pipeline_response) @@ -191,11 +184,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -208,10 +201,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies" - } - @distributed_trace_async async def get( self, resource_group_name: str, policy_name: str, **kwargs: Any @@ -222,7 +211,6 @@ async def get( :type resource_group_name: str :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.WebApplicationFirewallPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -238,24 +226,23 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, policy_name=policy_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -268,19 +255,15 @@ async def get( deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, policy_name: str, - parameters: Union[_models.WebApplicationFirewallPolicy, IO], + parameters: Union[_models.WebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any ) -> _models.WebApplicationFirewallPolicy: error_map = { @@ -294,19 +277,19 @@ async def _create_or_update_initial( _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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = 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, "WebApplicationFirewallPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, policy_name=policy_name, subscription_id=self._config.subscription_id, @@ -314,16 +297,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -347,10 +329,6 @@ async def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } - @overload async def begin_create_or_update( self, @@ -372,14 +350,6 @@ async def begin_create_or_update( :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 WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -392,7 +362,7 @@ async def begin_create_or_update( self, resource_group_name: str, policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -404,18 +374,10 @@ async def begin_create_or_update( :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_name: str :param parameters: Policy to be created. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -428,7 +390,7 @@ async def begin_create_or_update( self, resource_group_name: str, policy_name: str, - parameters: Union[_models.WebApplicationFirewallPolicy, IO], + parameters: Union[_models.WebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.WebApplicationFirewallPolicy]: """Create or update policy with specified rule set name within a resource group. @@ -437,20 +399,9 @@ async def begin_create_or_update( :type resource_group_name: str :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_name: str - :param parameters: Policy to be created. Is either a WebApplicationFirewallPolicy type or a IO - type. Required. - :type parameters: ~azure.mgmt.frontdoor.models.WebApplicationFirewallPolicy 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. + :param parameters: Policy to be created. Is either a WebApplicationFirewallPolicy type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.frontdoor.models.WebApplicationFirewallPolicy or IO[bytes] :return: An instance of AsyncLROPoller that returns either WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -460,7 +411,7 @@ async def begin_create_or_update( _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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -483,7 +434,7 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -493,20 +444,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.WebApplicationFirewallPolicy].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.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return AsyncLROPoller[_models.WebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( - self, resource_group_name: str, policy_name: str, parameters: Union[_models.TagsObject, IO], **kwargs: Any + self, + resource_group_name: str, + policy_name: str, + parameters: Union[_models.TagsObject, IO[bytes]], + **kwargs: Any ) -> _models.WebApplicationFirewallPolicy: error_map = { 401: ClientAuthenticationError, @@ -519,19 +472,19 @@ async def _update_initial( _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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = 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, "TagsObject") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, policy_name=policy_name, subscription_id=self._config.subscription_id, @@ -539,16 +492,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -561,13 +513,9 @@ async def _update_initial( deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -591,14 +539,6 @@ async def begin_update( :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 WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -611,7 +551,7 @@ async def begin_update( self, resource_group_name: str, policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -624,18 +564,10 @@ async def begin_update( :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_name: str :param parameters: FrontdoorWebApplicationFirewallPolicy parameters to be patched. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -645,7 +577,11 @@ async def begin_update( @distributed_trace_async async def begin_update( - self, resource_group_name: str, policy_name: str, parameters: Union[_models.TagsObject, IO], **kwargs: Any + self, + resource_group_name: str, + policy_name: str, + parameters: Union[_models.TagsObject, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.WebApplicationFirewallPolicy]: """Patch a specific frontdoor webApplicationFirewall policy for tags update under the specified subscription and resource group. @@ -655,19 +591,8 @@ async def begin_update( :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_name: str :param parameters: FrontdoorWebApplicationFirewallPolicy parameters to be patched. Is either a - TagsObject type or a IO type. Required. - :type parameters: ~azure.mgmt.frontdoor.models.TagsObject 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. + TagsObject type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.frontdoor.models.TagsObject or IO[bytes] :return: An instance of AsyncLROPoller that returns either WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -677,7 +602,7 @@ async def begin_update( _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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) @@ -700,7 +625,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -710,17 +635,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.WebApplicationFirewallPolicy].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.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return AsyncLROPoller[_models.WebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, policy_name: str, **kwargs: Any @@ -736,24 +659,23 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, policy_name=policy_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -763,11 +685,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -777,14 +695,6 @@ async def begin_delete(self, resource_group_name: str, policy_name: str, **kwarg :type resource_group_name: str :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_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: @@ -792,7 +702,7 @@ async def begin_delete(self, resource_group_name: str, policy_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) 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) @@ -811,7 +721,7 @@ async def begin_delete(self, resource_group_name: str, policy_name: str, **kwarg def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) @@ -820,14 +730,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_preconfigured_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_preconfigured_endpoints_operations.py index adbb5b9001e9..9c428146208c 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_preconfigured_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_preconfigured_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -63,7 +63,6 @@ def list( :type resource_group_name: str :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PreconfiguredEndpoint or the result of cls(response) :rtype: @@ -87,24 +86,23 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, profile_name=profile_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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("PreconfiguredEndpointList", pipeline_response) @@ -114,11 +112,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -130,7 +128,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/PreconfiguredEndpoints" - } diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_reports_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_reports_operations.py index bf81f7dfdd20..cb47fb45b81a 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_reports_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_reports_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -82,7 +82,6 @@ async def get_latency_scorecards( :param country: The country associated with the Latency Scorecard. Values are country ISO codes as specified here- https://www.iso.org/iso-3166-country-codes.html. Default value is None. :type country: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LatencyScorecard or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.LatencyScorecard :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +100,7 @@ async def get_latency_scorecards( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.LatencyScorecard] = kwargs.pop("cls", None) - request = build_get_latency_scorecards_request( + _request = build_get_latency_scorecards_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_name, @@ -110,16 +109,15 @@ async def get_latency_scorecards( end_date_time_utc=end_date_time_utc, country=country, api_version=api_version, - template_url=self.get_latency_scorecards.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -132,13 +130,9 @@ async def get_latency_scorecards( deserialized = self._deserialize("LatencyScorecard", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_latency_scorecards.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}/LatencyScorecard" - } + return deserialized # type: ignore @distributed_trace_async async def get_timeseries( @@ -179,7 +173,6 @@ async def get_timeseries( :param country: The country associated with the Timeseries. Values are country ISO codes as specified here- https://www.iso.org/iso-3166-country-codes.html. Default value is None. :type country: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Timeseries or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.Timeseries :raises ~azure.core.exceptions.HttpResponseError: @@ -198,7 +191,7 @@ async def get_timeseries( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.Timeseries] = kwargs.pop("cls", None) - request = build_get_timeseries_request( + _request = build_get_timeseries_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_name, @@ -210,16 +203,15 @@ async def get_timeseries( endpoint=endpoint, country=country, api_version=api_version, - template_url=self.get_timeseries.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -232,10 +224,6 @@ async def get_timeseries( deserialized = self._deserialize("Timeseries", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get_timeseries.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}/Timeseries" - } + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_rules_engines_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_rules_engines_operations.py index d82b4d05cf25..b4dd75c5ff5a 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_rules_engines_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/aio/operations/_rules_engines_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.async_paging import AsyncItemPaged, AsyncList @@ -69,7 +70,6 @@ def list_by_front_door( :type resource_group_name: str :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RulesEngine or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.frontdoor.models.RulesEngine] :raises ~azure.core.exceptions.HttpResponseError: @@ -91,24 +91,23 @@ def list_by_front_door( def prepare_request(next_link=None): if not next_link: - request = build_list_by_front_door_request( + _request = build_list_by_front_door_request( resource_group_name=resource_group_name, front_door_name=front_door_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_front_door.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("RulesEngineListResult", pipeline_response) @@ -118,11 +117,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -135,10 +134,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_front_door.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/rulesEngines" - } - @distributed_trace_async async def get( self, resource_group_name: str, front_door_name: str, rules_engine_name: str, **kwargs: Any @@ -152,7 +147,6 @@ async def get( :param rules_engine_name: Name of the Rules Engine which is unique within the Front Door. Required. :type rules_engine_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RulesEngine or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.RulesEngine :raises ~azure.core.exceptions.HttpResponseError: @@ -171,22 +165,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RulesEngine] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, front_door_name=front_door_name, rules_engine_name=rules_engine_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -199,20 +192,16 @@ async def get( deserialized = self._deserialize("RulesEngine", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, front_door_name: str, rules_engine_name: str, - rules_engine_parameters: Union[_models.RulesEngine, IO], + rules_engine_parameters: Union[_models.RulesEngine, IO[bytes]], **kwargs: Any ) -> _models.RulesEngine: error_map = { @@ -233,12 +222,12 @@ async def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(rules_engine_parameters, (IO, bytes)): + if isinstance(rules_engine_parameters, (IOBase, bytes)): _content = rules_engine_parameters else: _json = self._serialize.body(rules_engine_parameters, "RulesEngine") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, front_door_name=front_door_name, rules_engine_name=rules_engine_name, @@ -247,16 +236,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -280,10 +268,6 @@ async def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}" - } - @overload async def begin_create_or_update( self, @@ -311,14 +295,6 @@ async def begin_create_or_update( :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 RulesEngine or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.RulesEngine] @@ -331,7 +307,7 @@ async def begin_create_or_update( resource_group_name: str, front_door_name: str, rules_engine_name: str, - rules_engine_parameters: IO, + rules_engine_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -348,18 +324,10 @@ async def begin_create_or_update( :type rules_engine_name: str :param rules_engine_parameters: Rules Engine Configuration properties needed to create a new Rules Engine Configuration. Required. - :type rules_engine_parameters: IO + :type rules_engine_parameters: IO[bytes] :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 RulesEngine or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.RulesEngine] @@ -372,7 +340,7 @@ async def begin_create_or_update( resource_group_name: str, front_door_name: str, rules_engine_name: str, - rules_engine_parameters: Union[_models.RulesEngine, IO], + rules_engine_parameters: Union[_models.RulesEngine, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.RulesEngine]: """Creates a new Rules Engine Configuration with the specified name within the specified Front @@ -386,19 +354,8 @@ async def begin_create_or_update( Required. :type rules_engine_name: str :param rules_engine_parameters: Rules Engine Configuration properties needed to create a new - Rules Engine Configuration. Is either a RulesEngine type or a IO type. Required. - :type rules_engine_parameters: ~azure.mgmt.frontdoor.models.RulesEngine 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. + Rules Engine Configuration. Is either a RulesEngine type or a IO[bytes] type. Required. + :type rules_engine_parameters: ~azure.mgmt.frontdoor.models.RulesEngine or IO[bytes] :return: An instance of AsyncLROPoller that returns either RulesEngine or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.frontdoor.models.RulesEngine] @@ -431,7 +388,7 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("RulesEngine", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -444,17 +401,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.RulesEngine].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.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}" - } + return AsyncLROPoller[_models.RulesEngine]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, front_door_name: str, rules_engine_name: str, **kwargs: Any @@ -473,22 +428,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, front_door_name=front_door_name, rules_engine_name=rules_engine_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -499,11 +453,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace_async async def begin_delete( @@ -518,14 +468,6 @@ async def begin_delete( :param rules_engine_name: Name of the Rules Engine which is unique within the Front Door. Required. :type rules_engine_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: @@ -553,7 +495,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -565,14 +507,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/__init__.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/__init__.py index f64efef93c90..983f1c5f5df2 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/__init__.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/__init__.py @@ -39,6 +39,7 @@ from ._models_py3 import FrontendEndpointUpdateParameters from ._models_py3 import FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink from ._models_py3 import FrontendEndpointsListResult +from ._models_py3 import GroupByVariable from ._models_py3 import HeaderAction from ._models_py3 import HealthProbeSettingsListResult from ._models_py3 import HealthProbeSettingsModel @@ -94,6 +95,7 @@ from ._models_py3 import ValidateCustomDomainOutput from ._models_py3 import WebApplicationFirewallPolicy from ._models_py3 import WebApplicationFirewallPolicyList +from ._models_py3 import WebApplicationFirewallScrubbingRules from ._front_door_management_client_enums import ActionType from ._front_door_management_client_enums import AggregationInterval @@ -139,6 +141,9 @@ from ._front_door_management_client_enums import RuleType from ._front_door_management_client_enums import RulesEngineMatchVariable from ._front_door_management_client_enums import RulesEngineOperator +from ._front_door_management_client_enums import ScrubbingRuleEntryMatchOperator +from ._front_door_management_client_enums import ScrubbingRuleEntryMatchVariable +from ._front_door_management_client_enums import ScrubbingRuleEntryState from ._front_door_management_client_enums import SessionAffinityEnabledState from ._front_door_management_client_enums import SkuName from ._front_door_management_client_enums import State @@ -146,6 +151,8 @@ from ._front_door_management_client_enums import TimeseriesType from ._front_door_management_client_enums import Transform from ._front_door_management_client_enums import TransformType +from ._front_door_management_client_enums import VariableName +from ._front_door_management_client_enums import WebApplicationFirewallScrubbingState from ._patch import __all__ as _patch_all from ._patch import * # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk @@ -184,6 +191,7 @@ "FrontendEndpointUpdateParameters", "FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink", "FrontendEndpointsListResult", + "GroupByVariable", "HeaderAction", "HealthProbeSettingsListResult", "HealthProbeSettingsModel", @@ -239,6 +247,7 @@ "ValidateCustomDomainOutput", "WebApplicationFirewallPolicy", "WebApplicationFirewallPolicyList", + "WebApplicationFirewallScrubbingRules", "ActionType", "AggregationInterval", "Availability", @@ -283,6 +292,9 @@ "RuleType", "RulesEngineMatchVariable", "RulesEngineOperator", + "ScrubbingRuleEntryMatchOperator", + "ScrubbingRuleEntryMatchVariable", + "ScrubbingRuleEntryState", "SessionAffinityEnabledState", "SkuName", "State", @@ -290,6 +302,8 @@ "TimeseriesType", "Transform", "TransformType", + "VariableName", + "WebApplicationFirewallScrubbingState", ] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_front_door_management_client_enums.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_front_door_management_client_enums.py index 6ab10c2a0669..74081edc4b78 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_front_door_management_client_enums.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_front_door_management_client_enums.py @@ -18,6 +18,7 @@ class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): LOG = "Log" REDIRECT = "Redirect" ANOMALY_SCORING = "AnomalyScoring" + JS_CHALLENGE = "JSChallenge" class AggregationInterval(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -259,9 +260,8 @@ class MatchProcessingBehavior(str, Enum, metaclass=CaseInsensitiveEnumMeta): If not present, defaults to Continue. """ - CONTINUE = "Continue" - STOP = "Stop" CONTINUE_ENUM = "Continue" + STOP = "Stop" class MatchVariable(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -419,6 +419,34 @@ class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): RATE_LIMIT_RULE = "RateLimitRule" +class ScrubbingRuleEntryMatchOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """When matchVariable is a collection, operate on the selector to specify which elements in the + collection this rule applies to. + """ + + EQUALS_ANY = "EqualsAny" + EQUALS = "Equals" + + +class ScrubbingRuleEntryMatchVariable(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The variable to be scrubbed from the logs.""" + + REQUEST_IP_ADDRESS = "RequestIPAddress" + REQUEST_URI = "RequestUri" + QUERY_STRING_ARG_NAMES = "QueryStringArgNames" + REQUEST_HEADER_NAMES = "RequestHeaderNames" + REQUEST_COOKIE_NAMES = "RequestCookieNames" + REQUEST_BODY_POST_ARG_NAMES = "RequestBodyPostArgNames" + REQUEST_BODY_JSON_ARG_NAMES = "RequestBodyJsonArgNames" + + +class ScrubbingRuleEntryState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Defines the state of a log scrubbing rule. Default value is enabled.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + class SessionAffinityEnabledState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Whether to allow session affinity on this host. Valid options are 'Enabled' or 'Disabled'.""" @@ -477,3 +505,18 @@ class TransformType(str, Enum, metaclass=CaseInsensitiveEnumMeta): URL_DECODE = "UrlDecode" URL_ENCODE = "UrlEncode" REMOVE_NULLS = "RemoveNulls" + + +class VariableName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Describes the supported variable for group by.""" + + SOCKET_ADDR = "SocketAddr" + GEO_LOCATION = "GeoLocation" + NONE = "None" + + +class WebApplicationFirewallScrubbingState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """State of the log scrubbing config. Default value is Enabled.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_models_py3.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_models_py3.py index 5608b54a6ea9..fb34615b08ec 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_models_py3.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/models/_models_py3.py @@ -492,7 +492,7 @@ def __init__( class CheckNameAvailabilityInput(_serialization.Model): """Input of CheckNameAvailability API. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The resource name to validate. Required. :vartype name: str @@ -561,7 +561,7 @@ def __init__(self, **kwargs: Any) -> None: class CustomHttpsConfiguration(_serialization.Model): """Https settings for a domain. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar certificate_source: Defines the source of the SSL certificate. Required. Known values are: "AzureKeyVault" and "FrontDoor". @@ -649,7 +649,7 @@ def __init__( class CustomRule(_serialization.Model): """Defines contents of a web application rule. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: Describes the name of the rule. :vartype name: str @@ -667,10 +667,12 @@ class CustomRule(_serialization.Model): :vartype rate_limit_duration_in_minutes: int :ivar rate_limit_threshold: Number of allowed requests per client within the time window. :vartype rate_limit_threshold: int + :ivar group_by: Describes the list of variables to group the rate limit requests. + :vartype group_by: list[~azure.mgmt.frontdoor.models.GroupByVariable] :ivar match_conditions: List of match conditions. Required. :vartype match_conditions: list[~azure.mgmt.frontdoor.models.MatchCondition] :ivar action: Describes what action to be applied when rule matches. Required. Known values - are: "Allow", "Block", "Log", "Redirect", and "AnomalyScoring". + are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", and "JSChallenge". :vartype action: str or ~azure.mgmt.frontdoor.models.ActionType """ @@ -691,6 +693,7 @@ class CustomRule(_serialization.Model): "rule_type": {"key": "ruleType", "type": "str"}, "rate_limit_duration_in_minutes": {"key": "rateLimitDurationInMinutes", "type": "int"}, "rate_limit_threshold": {"key": "rateLimitThreshold", "type": "int"}, + "group_by": {"key": "groupBy", "type": "[GroupByVariable]"}, "match_conditions": {"key": "matchConditions", "type": "[MatchCondition]"}, "action": {"key": "action", "type": "str"}, } @@ -706,6 +709,7 @@ def __init__( enabled_state: Optional[Union[str, "_models.CustomRuleEnabledState"]] = None, rate_limit_duration_in_minutes: Optional[int] = None, rate_limit_threshold: Optional[int] = None, + group_by: Optional[List["_models.GroupByVariable"]] = None, **kwargs: Any ) -> None: """ @@ -725,10 +729,12 @@ def __init__( :paramtype rate_limit_duration_in_minutes: int :keyword rate_limit_threshold: Number of allowed requests per client within the time window. :paramtype rate_limit_threshold: int + :keyword group_by: Describes the list of variables to group the rate limit requests. + :paramtype group_by: list[~azure.mgmt.frontdoor.models.GroupByVariable] :keyword match_conditions: List of match conditions. Required. :paramtype match_conditions: list[~azure.mgmt.frontdoor.models.MatchCondition] :keyword action: Describes what action to be applied when rule matches. Required. Known values - are: "Allow", "Block", "Log", "Redirect", and "AnomalyScoring". + are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", and "JSChallenge". :paramtype action: str or ~azure.mgmt.frontdoor.models.ActionType """ super().__init__(**kwargs) @@ -738,6 +744,7 @@ def __init__( self.rule_type = rule_type self.rate_limit_duration_in_minutes = rate_limit_duration_in_minutes self.rate_limit_threshold = rate_limit_threshold + self.group_by = group_by self.match_conditions = match_conditions self.action = action @@ -1168,7 +1175,7 @@ class RouteConfiguration(_serialization.Model): You probably want to use the sub-classes and not this class directly. Known sub-classes are: ForwardingConfiguration, RedirectConfiguration - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar odata_type: Required. :vartype odata_type: str @@ -1198,7 +1205,7 @@ def __init__(self, **kwargs: Any) -> None: class ForwardingConfiguration(RouteConfiguration): """Describes Forwarding Route. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar odata_type: Required. :vartype odata_type: str @@ -1949,7 +1956,9 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: self.next_link = next_link -class FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink(_serialization.Model): +class FrontendEndpointUpdateParametersWebApplicationFirewallPolicyLink( + _serialization.Model +): # pylint: disable=name-too-long """Defines the Web Application Firewall policy for each host (if applicable). :ivar id: Resource ID. @@ -1969,10 +1978,38 @@ def __init__(self, *, id: Optional[str] = None, **kwargs: Any) -> None: # pylin self.id = id +class GroupByVariable(_serialization.Model): + """Describes the variables available to group the rate limit requests. + + All required parameters must be populated in order to send to server. + + :ivar variable_name: Describes the supported variable for group by. Required. Known values are: + "SocketAddr", "GeoLocation", and "None". + :vartype variable_name: str or ~azure.mgmt.frontdoor.models.VariableName + """ + + _validation = { + "variable_name": {"required": True}, + } + + _attribute_map = { + "variable_name": {"key": "variableName", "type": "str"}, + } + + def __init__(self, *, variable_name: Union[str, "_models.VariableName"], **kwargs: Any) -> None: + """ + :keyword variable_name: Describes the supported variable for group by. Required. Known values + are: "SocketAddr", "GeoLocation", and "None". + :paramtype variable_name: str or ~azure.mgmt.frontdoor.models.VariableName + """ + super().__init__(**kwargs) + self.variable_name = variable_name + + class HeaderAction(_serialization.Model): """An action that can manipulate an http header. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar header_action_type: Which type of manipulation to apply to the header. Required. Known values are: "Append", "Delete", and "Overwrite". @@ -2665,7 +2702,7 @@ class ManagedRuleDefinition(_serialization.Model): "Disabled" and "Enabled". :vartype default_state: str or ~azure.mgmt.frontdoor.models.ManagedRuleEnabledState :ivar default_action: Describes the default action to be applied when the managed rule matches. - Known values are: "Allow", "Block", "Log", "Redirect", and "AnomalyScoring". + Known values are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", and "JSChallenge". :vartype default_action: str or ~azure.mgmt.frontdoor.models.ActionType :ivar description: Describes the functionality of the managed rule. :vartype description: str @@ -2697,7 +2734,7 @@ def __init__(self, **kwargs: Any) -> None: class ManagedRuleExclusion(_serialization.Model): """Exclude variables from managed rule evaluation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar match_variable: The variable type to be excluded. Required. Known values are: "RequestHeaderNames", "RequestCookieNames", "QueryStringArgNames", "RequestBodyPostArgNames", @@ -2790,7 +2827,7 @@ def __init__(self, **kwargs: Any) -> None: class ManagedRuleGroupOverride(_serialization.Model): """Defines a managed rule group override setting. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar rule_group_name: Describes the managed rule group to override. Required. :vartype rule_group_name: str @@ -2837,7 +2874,7 @@ def __init__( class ManagedRuleOverride(_serialization.Model): """Defines a managed rule group override setting. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar rule_id: Identifier for the managed rule. Required. :vartype rule_id: str @@ -2845,7 +2882,7 @@ class ManagedRuleOverride(_serialization.Model): Disabled if not specified. Known values are: "Disabled" and "Enabled". :vartype enabled_state: str or ~azure.mgmt.frontdoor.models.ManagedRuleEnabledState :ivar action: Describes the override action to be applied when rule matches. Known values are: - "Allow", "Block", "Log", "Redirect", and "AnomalyScoring". + "Allow", "Block", "Log", "Redirect", "AnomalyScoring", and "JSChallenge". :vartype action: str or ~azure.mgmt.frontdoor.models.ActionType :ivar exclusions: Describes the exclusions that are applied to this specific rule. :vartype exclusions: list[~azure.mgmt.frontdoor.models.ManagedRuleExclusion] @@ -2878,7 +2915,7 @@ def __init__( to Disabled if not specified. Known values are: "Disabled" and "Enabled". :paramtype enabled_state: str or ~azure.mgmt.frontdoor.models.ManagedRuleEnabledState :keyword action: Describes the override action to be applied when rule matches. Known values - are: "Allow", "Block", "Log", "Redirect", and "AnomalyScoring". + are: "Allow", "Block", "Log", "Redirect", "AnomalyScoring", and "JSChallenge". :paramtype action: str or ~azure.mgmt.frontdoor.models.ActionType :keyword exclusions: Describes the exclusions that are applied to this specific rule. :paramtype exclusions: list[~azure.mgmt.frontdoor.models.ManagedRuleExclusion] @@ -2893,7 +2930,7 @@ def __init__( class ManagedRuleSet(_serialization.Model): """Defines a managed rule set. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar rule_set_type: Defines the rule set type to use. Required. :vartype rule_set_type: str @@ -3071,7 +3108,7 @@ def __init__(self, *, managed_rule_sets: Optional[List["_models.ManagedRuleSet"] class MatchCondition(_serialization.Model): """Define a match condition. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar match_variable: Request variable to compare with. Required. Known values are: "RemoteAddr", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestHeader", @@ -3167,12 +3204,24 @@ class PolicySettings(_serialization.Model): :ivar request_body_check: Describes if policy managed rules will inspect the request body content. Known values are: "Disabled" and "Enabled". :vartype request_body_check: str or ~azure.mgmt.frontdoor.models.PolicyRequestBodyCheck + :ivar javascript_challenge_expiration_in_minutes: Defines the JavaScript challenge cookie + validity lifetime in minutes. This setting is only applicable to Premium_AzureFrontDoor. Value + must be an integer between 5 and 1440 with the default value being 30. + :vartype javascript_challenge_expiration_in_minutes: int + :ivar state: State of the log scrubbing config. Default value is Enabled. Known values are: + "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.frontdoor.models.WebApplicationFirewallScrubbingState + :ivar scrubbing_rules: List of log scrubbing rules applied to the Web Application Firewall + logs. + :vartype scrubbing_rules: + list[~azure.mgmt.frontdoor.models.WebApplicationFirewallScrubbingRules] """ _validation = { "custom_block_response_body": { "pattern": r"^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{4})$" }, + "javascript_challenge_expiration_in_minutes": {"maximum": 1440, "minimum": 5}, } _attribute_map = { @@ -3182,6 +3231,9 @@ class PolicySettings(_serialization.Model): "custom_block_response_status_code": {"key": "customBlockResponseStatusCode", "type": "int"}, "custom_block_response_body": {"key": "customBlockResponseBody", "type": "str"}, "request_body_check": {"key": "requestBodyCheck", "type": "str"}, + "javascript_challenge_expiration_in_minutes": {"key": "javascriptChallengeExpirationInMinutes", "type": "int"}, + "state": {"key": "logScrubbing.state", "type": "str"}, + "scrubbing_rules": {"key": "logScrubbing.scrubbingRules", "type": "[WebApplicationFirewallScrubbingRules]"}, } def __init__( @@ -3193,6 +3245,9 @@ def __init__( custom_block_response_status_code: Optional[int] = None, custom_block_response_body: Optional[str] = None, request_body_check: Optional[Union[str, "_models.PolicyRequestBodyCheck"]] = None, + javascript_challenge_expiration_in_minutes: Optional[int] = None, + state: Optional[Union[str, "_models.WebApplicationFirewallScrubbingState"]] = None, + scrubbing_rules: Optional[List["_models.WebApplicationFirewallScrubbingRules"]] = None, **kwargs: Any ) -> None: """ @@ -3214,6 +3269,17 @@ def __init__( :keyword request_body_check: Describes if policy managed rules will inspect the request body content. Known values are: "Disabled" and "Enabled". :paramtype request_body_check: str or ~azure.mgmt.frontdoor.models.PolicyRequestBodyCheck + :keyword javascript_challenge_expiration_in_minutes: Defines the JavaScript challenge cookie + validity lifetime in minutes. This setting is only applicable to Premium_AzureFrontDoor. Value + must be an integer between 5 and 1440 with the default value being 30. + :paramtype javascript_challenge_expiration_in_minutes: int + :keyword state: State of the log scrubbing config. Default value is Enabled. Known values are: + "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.frontdoor.models.WebApplicationFirewallScrubbingState + :keyword scrubbing_rules: List of log scrubbing rules applied to the Web Application Firewall + logs. + :paramtype scrubbing_rules: + list[~azure.mgmt.frontdoor.models.WebApplicationFirewallScrubbingRules] """ super().__init__(**kwargs) self.enabled_state = enabled_state @@ -3222,6 +3288,9 @@ def __init__( self.custom_block_response_status_code = custom_block_response_status_code self.custom_block_response_body = custom_block_response_body self.request_body_check = request_body_check + self.javascript_challenge_expiration_in_minutes = javascript_challenge_expiration_in_minutes + self.state = state + self.scrubbing_rules = scrubbing_rules class PreconfiguredEndpoint(Resource): @@ -3467,7 +3536,7 @@ def __init__( class PurgeParameters(_serialization.Model): """Parameters required for content purge. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar content_paths: The path to the content to be purged. Can describe a file path or a wild card directory. Required. @@ -3495,7 +3564,7 @@ def __init__(self, *, content_paths: List[str], **kwargs: Any) -> None: class RedirectConfiguration(RouteConfiguration): """Describes Redirect Route. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar odata_type: Required. :vartype odata_type: str @@ -3914,7 +3983,9 @@ def __init__( self.resource_state = None -class RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink(_serialization.Model): +class RoutingRuleUpdateParametersWebApplicationFirewallPolicyLink( + _serialization.Model +): # pylint: disable=name-too-long """Defines the Web Application Firewall policy for each routing rule (if applicable). :ivar id: Resource ID. @@ -4058,7 +4129,7 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: class RulesEngineMatchCondition(_serialization.Model): """Define a match condition. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar rules_engine_match_variable: Match Variable. Required. Known values are: "IsMobile", "RemoteAddr", "RequestMethod", "QueryString", "PostArgs", "RequestUri", "RequestPath", @@ -4194,7 +4265,7 @@ class RulesEngineRule(_serialization.Model): multiple rules match, the actions from one rule that conflict with a previous rule overwrite for a singular action, or append in the case of headers manipulation. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: A name to refer to this specific rule. Required. :vartype name: str @@ -4208,7 +4279,7 @@ class RulesEngineRule(_serialization.Model): :vartype match_conditions: list[~azure.mgmt.frontdoor.models.RulesEngineMatchCondition] :ivar match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue", "Stop", and "Continue". + "Continue" and "Stop". :vartype match_processing_behavior: str or ~azure.mgmt.frontdoor.models.MatchProcessingBehavior """ @@ -4249,7 +4320,7 @@ def __init__( :paramtype match_conditions: list[~azure.mgmt.frontdoor.models.RulesEngineMatchCondition] :keyword match_processing_behavior: If this rule is a match should the rules engine continue running the remaining rules or stop. If not present, defaults to Continue. Known values are: - "Continue", "Stop", and "Continue". + "Continue" and "Stop". :paramtype match_processing_behavior: str or ~azure.mgmt.frontdoor.models.MatchProcessingBehavior """ @@ -4454,7 +4525,7 @@ def __init__(self, *, date_time_utc: Optional[str] = None, value: Optional[float class ValidateCustomDomainInput(_serialization.Model): """Input of the custom domain to be validated for DNS mapping. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar host_name: The host name of the custom domain. Must be a domain name. Required. :vartype host_name: str @@ -4654,3 +4725,70 @@ def __init__(self, *, next_link: Optional[str] = None, **kwargs: Any) -> None: super().__init__(**kwargs) self.value = None self.next_link = next_link + + +class WebApplicationFirewallScrubbingRules(_serialization.Model): + """Defines the contents of the log scrubbing rules. + + All required parameters must be populated in order to send to server. + + :ivar match_variable: The variable to be scrubbed from the logs. Required. Known values are: + "RequestIPAddress", "RequestUri", "QueryStringArgNames", "RequestHeaderNames", + "RequestCookieNames", "RequestBodyPostArgNames", and "RequestBodyJsonArgNames". + :vartype match_variable: str or ~azure.mgmt.frontdoor.models.ScrubbingRuleEntryMatchVariable + :ivar selector_match_operator: When matchVariable is a collection, operate on the selector to + specify which elements in the collection this rule applies to. Required. Known values are: + "EqualsAny" and "Equals". + :vartype selector_match_operator: str or + ~azure.mgmt.frontdoor.models.ScrubbingRuleEntryMatchOperator + :ivar selector: When matchVariable is a collection, operator used to specify which elements in + the collection this rule applies to. + :vartype selector: str + :ivar state: Defines the state of a log scrubbing rule. Default value is enabled. Known values + are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.frontdoor.models.ScrubbingRuleEntryState + """ + + _validation = { + "match_variable": {"required": True}, + "selector_match_operator": {"required": True}, + } + + _attribute_map = { + "match_variable": {"key": "matchVariable", "type": "str"}, + "selector_match_operator": {"key": "selectorMatchOperator", "type": "str"}, + "selector": {"key": "selector", "type": "str"}, + "state": {"key": "state", "type": "str"}, + } + + def __init__( + self, + *, + match_variable: Union[str, "_models.ScrubbingRuleEntryMatchVariable"], + selector_match_operator: Union[str, "_models.ScrubbingRuleEntryMatchOperator"], + selector: Optional[str] = None, + state: Optional[Union[str, "_models.ScrubbingRuleEntryState"]] = None, + **kwargs: Any + ) -> None: + """ + :keyword match_variable: The variable to be scrubbed from the logs. Required. Known values are: + "RequestIPAddress", "RequestUri", "QueryStringArgNames", "RequestHeaderNames", + "RequestCookieNames", "RequestBodyPostArgNames", and "RequestBodyJsonArgNames". + :paramtype match_variable: str or ~azure.mgmt.frontdoor.models.ScrubbingRuleEntryMatchVariable + :keyword selector_match_operator: When matchVariable is a collection, operate on the selector + to specify which elements in the collection this rule applies to. Required. Known values are: + "EqualsAny" and "Equals". + :paramtype selector_match_operator: str or + ~azure.mgmt.frontdoor.models.ScrubbingRuleEntryMatchOperator + :keyword selector: When matchVariable is a collection, operator used to specify which elements + in the collection this rule applies to. + :paramtype selector: str + :keyword state: Defines the state of a log scrubbing rule. Default value is enabled. Known + values are: "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.frontdoor.models.ScrubbingRuleEntryState + """ + super().__init__(**kwargs) + self.match_variable = match_variable + self.selector_match_operator = selector_match_operator + self.selector = selector + self.state = state diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_endpoints_operations.py index 41719157f0c3..3a21fb0ba015 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -27,7 +28,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +72,7 @@ def build_purge_content_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -107,7 +108,7 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, front_door_name: str, - content_file_paths: Union[_models.PurgeParameters, IO], + content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any ) -> None: error_map = { @@ -128,12 +129,12 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements content_type = content_type or "application/json" _json = None _content = None - if isinstance(content_file_paths, (IO, bytes)): + if isinstance(content_file_paths, (IOBase, bytes)): _content = content_file_paths else: _json = self._serialize.body(content_file_paths, "PurgeParameters") - request = build_purge_content_request( + _request = build_purge_content_request( resource_group_name=resource_group_name, front_door_name=front_door_name, subscription_id=self._config.subscription_id, @@ -141,16 +142,15 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._purge_content_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -161,11 +161,7 @@ def _purge_content_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _purge_content_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/purge" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def begin_purge_content( @@ -190,14 +186,6 @@ def begin_purge_content( :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -208,7 +196,7 @@ def begin_purge_content( self, resource_group_name: str, front_door_name: str, - content_file_paths: IO, + content_file_paths: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -222,18 +210,10 @@ def begin_purge_content( :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Required. - :type content_file_paths: IO + :type content_file_paths: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -244,7 +224,7 @@ def begin_purge_content( self, resource_group_name: str, front_door_name: str, - content_file_paths: Union[_models.PurgeParameters, IO], + content_file_paths: Union[_models.PurgeParameters, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Removes a content from Front Door. @@ -256,19 +236,8 @@ def begin_purge_content( :param content_file_paths: The path to the content to be purged. Path can be a full URL, e.g. '/pictures/city.png' which removes a single file, or a directory with a wildcard, e.g. '/pictures/*' which removes all folders and files in the directory. Is either a PurgeParameters - type or a IO type. Required. - :type content_file_paths: ~azure.mgmt.frontdoor.models.PurgeParameters 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. + type or a IO[bytes] type. Required. + :type content_file_paths: ~azure.mgmt.frontdoor.models.PurgeParameters or IO[bytes] :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: @@ -298,7 +267,7 @@ def begin_purge_content( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -309,14 +278,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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_purge_content.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/purge" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_experiments_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_experiments_operations.py index 78e7f5421195..1cbefebda2d9 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_experiments_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_experiments_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.exceptions import ( @@ -28,7 +29,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -64,7 +65,7 @@ def build_list_by_profile_request( "profileName": _SERIALIZER.url("profile_name", profile_name, "str", pattern=r"^[a-zA-Z0-9_\-\(\)\.]*[^\.]$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -105,7 +106,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -147,7 +148,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -191,7 +192,7 @@ def build_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -234,7 +235,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -276,7 +277,6 @@ def list_by_profile( :type resource_group_name: str :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Experiment or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.frontdoor.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: @@ -298,24 +298,23 @@ def list_by_profile( def prepare_request(next_link=None): if not next_link: - request = build_list_by_profile_request( + _request = build_list_by_profile_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_profile.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("ExperimentList", pipeline_response) @@ -325,11 +324,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -342,10 +341,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_profile.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments" - } - @distributed_trace def get( self, resource_group_name: str, profile_name: str, experiment_name: str, **kwargs: Any @@ -360,7 +355,6 @@ def get( :type profile_name: str :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Experiment or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.Experiment :raises ~azure.core.exceptions.HttpResponseError: @@ -379,22 +373,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.Experiment] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -407,20 +400,16 @@ def get( deserialized = self._deserialize("Experiment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, profile_name: str, experiment_name: str, - parameters: Union[_models.Experiment, IO], + parameters: Union[_models.Experiment, IO[bytes]], **kwargs: Any ) -> _models.Experiment: error_map = { @@ -441,12 +430,12 @@ def _create_or_update_initial( 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, "Experiment") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_name, @@ -455,16 +444,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -488,10 +476,6 @@ def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } - @overload def begin_create_or_update( self, @@ -518,14 +502,6 @@ def begin_create_or_update( :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 Experiment or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: @@ -537,7 +513,7 @@ def begin_create_or_update( resource_group_name: str, profile_name: str, experiment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -553,18 +529,10 @@ def begin_create_or_update( :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_name: str :param parameters: The Experiment resource. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Experiment or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: @@ -576,7 +544,7 @@ def begin_create_or_update( resource_group_name: str, profile_name: str, experiment_name: str, - parameters: Union[_models.Experiment, IO], + parameters: Union[_models.Experiment, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Experiment]: """Creates or updates an Experiment. @@ -589,19 +557,9 @@ def begin_create_or_update( :type profile_name: str :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_name: str - :param parameters: The Experiment resource. Is either a Experiment type or a IO type. Required. - :type parameters: ~azure.mgmt.frontdoor.models.Experiment 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. + :param parameters: The Experiment resource. Is either a Experiment type or a IO[bytes] type. + Required. + :type parameters: ~azure.mgmt.frontdoor.models.Experiment or IO[bytes] :return: An instance of LROPoller that returns either Experiment or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: @@ -633,7 +591,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Experiment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -643,24 +601,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Experiment].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.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } + return LROPoller[_models.Experiment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, profile_name: str, experiment_name: str, - parameters: Union[_models.ExperimentUpdateModel, IO], + parameters: Union[_models.ExperimentUpdateModel, IO[bytes]], **kwargs: Any ) -> _models.Experiment: error_map = { @@ -681,12 +637,12 @@ def _update_initial( 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, "ExperimentUpdateModel") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_name, @@ -695,16 +651,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -725,10 +680,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } - @overload def begin_update( self, @@ -755,14 +706,6 @@ def begin_update( :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 Experiment or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: @@ -774,7 +717,7 @@ def begin_update( resource_group_name: str, profile_name: str, experiment_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -790,18 +733,10 @@ def begin_update( :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_name: str :param parameters: The Experiment Update Model. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Experiment or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: @@ -813,7 +748,7 @@ def begin_update( resource_group_name: str, profile_name: str, experiment_name: str, - parameters: Union[_models.ExperimentUpdateModel, IO], + parameters: Union[_models.ExperimentUpdateModel, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Experiment]: """Updates an Experiment by Experiment id. @@ -826,20 +761,9 @@ def begin_update( :type profile_name: str :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_name: str - :param parameters: The Experiment Update Model. Is either a ExperimentUpdateModel type or a IO - type. Required. - :type parameters: ~azure.mgmt.frontdoor.models.ExperimentUpdateModel 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. + :param parameters: The Experiment Update Model. Is either a ExperimentUpdateModel type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.frontdoor.models.ExperimentUpdateModel or IO[bytes] :return: An instance of LROPoller that returns either Experiment or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Experiment] :raises ~azure.core.exceptions.HttpResponseError: @@ -871,7 +795,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Experiment", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -881,17 +805,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Experiment].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.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } + return LROPoller[_models.Experiment]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, experiment_name: str, **kwargs: Any @@ -910,22 +832,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -936,11 +857,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete( @@ -956,14 +873,6 @@ def begin_delete( :type profile_name: str :param experiment_name: The Experiment identifier associated with the Experiment. Required. :type experiment_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: @@ -991,7 +900,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1000,14 +909,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_operations.py index a163ac3203f2..1193024e8889 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -91,7 +92,6 @@ def check( :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -99,16 +99,19 @@ def check( @overload def check( - self, check_front_door_name_availability_input: IO, *, content_type: str = "application/json", **kwargs: Any + self, + check_front_door_name_availability_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a Front Door resource name. :param check_front_door_name_availability_input: Input to check. Required. - :type check_front_door_name_availability_input: IO + :type check_front_door_name_availability_input: IO[bytes] :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -116,18 +119,16 @@ def check( @distributed_trace def check( - self, check_front_door_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO], **kwargs: Any + self, + check_front_door_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], + **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a Front Door resource name. :param check_front_door_name_availability_input: Input to check. Is either a - CheckNameAvailabilityInput type or a IO type. Required. + CheckNameAvailabilityInput type or a IO[bytes] type. Required. :type check_front_door_name_availability_input: - ~azure.mgmt.frontdoor.models.CheckNameAvailabilityInput 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 + ~azure.mgmt.frontdoor.models.CheckNameAvailabilityInput or IO[bytes] :return: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -150,26 +151,25 @@ def check( content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_front_door_name_availability_input, (IO, bytes)): + if isinstance(check_front_door_name_availability_input, (IOBase, bytes)): _content = check_front_door_name_availability_input else: _json = self._serialize.body(check_front_door_name_availability_input, "CheckNameAvailabilityInput") - request = build_check_request( + _request = build_check_request( api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -182,8 +182,6 @@ def check( deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check.metadata = {"url": "/providers/Microsoft.Network/checkFrontDoorNameAvailability"} + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_with_subscription_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_with_subscription_operations.py index bacd2f57cc9d..dbef341ed3bc 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_with_subscription_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_door_name_availability_with_subscription_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -25,7 +26,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +51,7 @@ def build_check_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -63,7 +64,7 @@ def build_check_request(subscription_id: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class FrontDoorNameAvailabilityWithSubscriptionOperations: +class FrontDoorNameAvailabilityWithSubscriptionOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -98,7 +99,6 @@ def check( :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -106,16 +106,19 @@ def check( @overload def check( - self, check_front_door_name_availability_input: IO, *, content_type: str = "application/json", **kwargs: Any + self, + check_front_door_name_availability_input: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a Front Door subdomain. :param check_front_door_name_availability_input: Input to check. Required. - :type check_front_door_name_availability_input: IO + :type check_front_door_name_availability_input: IO[bytes] :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: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -123,18 +126,16 @@ def check( @distributed_trace def check( - self, check_front_door_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO], **kwargs: Any + self, + check_front_door_name_availability_input: Union[_models.CheckNameAvailabilityInput, IO[bytes]], + **kwargs: Any ) -> _models.CheckNameAvailabilityOutput: """Check the availability of a Front Door subdomain. :param check_front_door_name_availability_input: Input to check. Is either a - CheckNameAvailabilityInput type or a IO type. Required. + CheckNameAvailabilityInput type or a IO[bytes] type. Required. :type check_front_door_name_availability_input: - ~azure.mgmt.frontdoor.models.CheckNameAvailabilityInput 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 + ~azure.mgmt.frontdoor.models.CheckNameAvailabilityInput or IO[bytes] :return: CheckNameAvailabilityOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.CheckNameAvailabilityOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -157,27 +158,26 @@ def check( content_type = content_type or "application/json" _json = None _content = None - if isinstance(check_front_door_name_availability_input, (IO, bytes)): + if isinstance(check_front_door_name_availability_input, (IOBase, bytes)): _content = check_front_door_name_availability_input else: _json = self._serialize.body(check_front_door_name_availability_input, "CheckNameAvailabilityInput") - request = build_check_request( + _request = build_check_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.check.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -190,10 +190,6 @@ def check( deserialized = self._deserialize("CheckNameAvailabilityOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - check.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/checkFrontDoorNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_doors_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_doors_operations.py index 83f109e7381c..af249fc4905e 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_doors_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_front_doors_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.exceptions import ( @@ -28,7 +29,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -50,7 +51,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -85,7 +86,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,7 +131,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -176,7 +177,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -223,7 +224,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -269,7 +270,7 @@ def build_validate_custom_domain_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -305,7 +306,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.FrontDoor"]: """Lists all of the Front Doors within an Azure subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FrontDoor or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.frontdoor.models.FrontDoor] :raises ~azure.core.exceptions.HttpResponseError: @@ -327,22 +327,21 @@ def list(self, **kwargs: Any) -> Iterable["_models.FrontDoor"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("FrontDoorListResult", pipeline_response) @@ -352,11 +351,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -369,15 +368,12 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/frontDoors"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.FrontDoor"]: """Lists all of the Front Doors within a resource group under a subscription. :param resource_group_name: Name of the Resource group within the Azure 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 FrontDoor or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.frontdoor.models.FrontDoor] :raises ~azure.core.exceptions.HttpResponseError: @@ -399,23 +395,22 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("FrontDoorListResult", pipeline_response) @@ -425,11 +420,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -442,10 +437,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors" - } - @distributed_trace def get(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> _models.FrontDoor: """Gets a Front Door with the specified Front Door name under the specified subscription and @@ -455,7 +446,6 @@ def get(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> :type resource_group_name: str :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FrontDoor or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.FrontDoor :raises ~azure.core.exceptions.HttpResponseError: @@ -474,21 +464,20 @@ def get(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.FrontDoor] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, front_door_name=front_door_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -501,19 +490,15 @@ def get(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> deserialized = self._deserialize("FrontDoor", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, front_door_name: str, - front_door_parameters: Union[_models.FrontDoor, IO], + front_door_parameters: Union[_models.FrontDoor, IO[bytes]], **kwargs: Any ) -> _models.FrontDoor: error_map = { @@ -534,12 +519,12 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(front_door_parameters, (IO, bytes)): + if isinstance(front_door_parameters, (IOBase, bytes)): _content = front_door_parameters else: _json = self._serialize.body(front_door_parameters, "FrontDoor") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, front_door_name=front_door_name, subscription_id=self._config.subscription_id, @@ -547,16 +532,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -580,10 +564,6 @@ def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}" - } - @overload def begin_create_or_update( self, @@ -607,14 +587,6 @@ def begin_create_or_update( :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 FrontDoor or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.FrontDoor] :raises ~azure.core.exceptions.HttpResponseError: @@ -625,7 +597,7 @@ def begin_create_or_update( self, resource_group_name: str, front_door_name: str, - front_door_parameters: IO, + front_door_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -639,18 +611,10 @@ def begin_create_or_update( :type front_door_name: str :param front_door_parameters: Front Door properties needed to create a new Front Door. Required. - :type front_door_parameters: IO + :type front_door_parameters: IO[bytes] :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 FrontDoor or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.FrontDoor] :raises ~azure.core.exceptions.HttpResponseError: @@ -661,7 +625,7 @@ def begin_create_or_update( self, resource_group_name: str, front_door_name: str, - front_door_parameters: Union[_models.FrontDoor, IO], + front_door_parameters: Union[_models.FrontDoor, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.FrontDoor]: """Creates a new Front Door with a Front Door name under the specified subscription and resource @@ -672,19 +636,8 @@ def begin_create_or_update( :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str :param front_door_parameters: Front Door properties needed to create a new Front Door. Is - either a FrontDoor type or a IO type. Required. - :type front_door_parameters: ~azure.mgmt.frontdoor.models.FrontDoor 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. + either a FrontDoor type or a IO[bytes] type. Required. + :type front_door_parameters: ~azure.mgmt.frontdoor.models.FrontDoor or IO[bytes] :return: An instance of LROPoller that returns either FrontDoor or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.FrontDoor] :raises ~azure.core.exceptions.HttpResponseError: @@ -715,7 +668,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("FrontDoor", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -727,17 +680,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.FrontDoor].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.Network/frontDoors/{frontDoorName}" - } + return LROPoller[_models.FrontDoor]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, front_door_name: str, **kwargs: Any @@ -756,21 +707,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, front_door_name=front_door_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -781,11 +731,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Network/frontDoors/{frontDoorName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, front_door_name: str, **kwargs: Any) -> LROPoller[None]: @@ -795,14 +741,6 @@ def begin_delete(self, resource_group_name: str, front_door_name: str, **kwargs: :type resource_group_name: str :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_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: @@ -829,7 +767,7 @@ def begin_delete(self, resource_group_name: str, front_door_name: str, **kwargs: def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -840,17 +778,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Network/frontDoors/{frontDoorName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @overload def validate_custom_domain( @@ -874,7 +808,6 @@ def validate_custom_domain( :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -885,7 +818,7 @@ def validate_custom_domain( self, resource_group_name: str, front_door_name: str, - custom_domain_properties: IO, + custom_domain_properties: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -898,11 +831,10 @@ def validate_custom_domain( :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str :param custom_domain_properties: Custom domain to be validated. Required. - :type custom_domain_properties: IO + :type custom_domain_properties: IO[bytes] :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: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -913,7 +845,7 @@ def validate_custom_domain( self, resource_group_name: str, front_door_name: str, - custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO], + custom_domain_properties: Union[_models.ValidateCustomDomainInput, IO[bytes]], **kwargs: Any ) -> _models.ValidateCustomDomainOutput: """Validates the custom domain mapping to ensure it maps to the correct Front Door endpoint in @@ -924,12 +856,9 @@ def validate_custom_domain( :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str :param custom_domain_properties: Custom domain to be validated. Is either a - ValidateCustomDomainInput type or a IO type. Required. - :type custom_domain_properties: ~azure.mgmt.frontdoor.models.ValidateCustomDomainInput 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 + ValidateCustomDomainInput type or a IO[bytes] type. Required. + :type custom_domain_properties: ~azure.mgmt.frontdoor.models.ValidateCustomDomainInput or + IO[bytes] :return: ValidateCustomDomainOutput or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.ValidateCustomDomainOutput :raises ~azure.core.exceptions.HttpResponseError: @@ -952,12 +881,12 @@ def validate_custom_domain( content_type = content_type or "application/json" _json = None _content = None - if isinstance(custom_domain_properties, (IO, bytes)): + if isinstance(custom_domain_properties, (IOBase, bytes)): _content = custom_domain_properties else: _json = self._serialize.body(custom_domain_properties, "ValidateCustomDomainInput") - request = build_validate_custom_domain_request( + _request = build_validate_custom_domain_request( resource_group_name=resource_group_name, front_door_name=front_door_name, subscription_id=self._config.subscription_id, @@ -965,16 +894,15 @@ def validate_custom_domain( content_type=content_type, json=_json, content=_content, - template_url=self.validate_custom_domain.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -987,10 +915,6 @@ def validate_custom_domain( deserialized = self._deserialize("ValidateCustomDomainOutput", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - validate_custom_domain.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/validateCustomDomain" - } + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_frontend_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_frontend_endpoints_operations.py index d5c62ed59498..937f13bd4f58 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_frontend_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_frontend_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.exceptions import ( @@ -28,7 +29,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +72,7 @@ def build_list_by_front_door_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,7 +125,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +179,7 @@ def build_enable_https_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -233,7 +234,7 @@ def build_disable_https_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -273,7 +274,6 @@ def list_by_front_door( :type resource_group_name: str :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FrontendEndpoint or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.frontdoor.models.FrontendEndpoint] :raises ~azure.core.exceptions.HttpResponseError: @@ -295,24 +295,23 @@ def list_by_front_door( def prepare_request(next_link=None): if not next_link: - request = build_list_by_front_door_request( + _request = build_list_by_front_door_request( resource_group_name=resource_group_name, front_door_name=front_door_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_front_door.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("FrontendEndpointsListResult", pipeline_response) @@ -322,11 +321,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -339,10 +338,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_front_door.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints" - } - @distributed_trace def get( self, resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, **kwargs: Any @@ -356,7 +351,6 @@ def get( :param frontend_endpoint_name: Name of the Frontend endpoint which is unique within the Front Door. Required. :type frontend_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FrontendEndpoint or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.FrontendEndpoint :raises ~azure.core.exceptions.HttpResponseError: @@ -375,22 +369,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.FrontendEndpoint] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, front_door_name=front_door_name, frontend_endpoint_name=frontend_endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,20 +396,16 @@ def get( deserialized = self._deserialize("FrontendEndpoint", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}" - } + return deserialized # type: ignore def _enable_https_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, - custom_https_configuration: Union[_models.CustomHttpsConfiguration, IO], + custom_https_configuration: Union[_models.CustomHttpsConfiguration, IO[bytes]], **kwargs: Any ) -> None: error_map = { @@ -437,12 +426,12 @@ def _enable_https_initial( # pylint: disable=inconsistent-return-statements content_type = content_type or "application/json" _json = None _content = None - if isinstance(custom_https_configuration, (IO, bytes)): + if isinstance(custom_https_configuration, (IOBase, bytes)): _content = custom_https_configuration else: _json = self._serialize.body(custom_https_configuration, "CustomHttpsConfiguration") - request = build_enable_https_request( + _request = build_enable_https_request( resource_group_name=resource_group_name, front_door_name=front_door_name, frontend_endpoint_name=frontend_endpoint_name, @@ -451,16 +440,15 @@ def _enable_https_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._enable_https_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -471,11 +459,7 @@ def _enable_https_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _enable_https_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/enableHttps" - } + return cls(pipeline_response, None, {}) # type: ignore @overload def begin_enable_https( @@ -502,14 +486,6 @@ def begin_enable_https( :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -521,7 +497,7 @@ def begin_enable_https( resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, - custom_https_configuration: IO, + custom_https_configuration: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -536,18 +512,10 @@ def begin_enable_https( Door. Required. :type frontend_endpoint_name: str :param custom_https_configuration: The configuration specifying how to enable HTTPS. Required. - :type custom_https_configuration: IO + :type custom_https_configuration: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -559,7 +527,7 @@ def begin_enable_https( resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, - custom_https_configuration: Union[_models.CustomHttpsConfiguration, IO], + custom_https_configuration: Union[_models.CustomHttpsConfiguration, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Enables a frontendEndpoint for HTTPS traffic. @@ -572,19 +540,9 @@ def begin_enable_https( Door. Required. :type frontend_endpoint_name: str :param custom_https_configuration: The configuration specifying how to enable HTTPS. Is either - a CustomHttpsConfiguration type or a IO type. Required. - :type custom_https_configuration: ~azure.mgmt.frontdoor.models.CustomHttpsConfiguration 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. + a CustomHttpsConfiguration type or a IO[bytes] type. Required. + :type custom_https_configuration: ~azure.mgmt.frontdoor.models.CustomHttpsConfiguration or + IO[bytes] :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: @@ -615,7 +573,7 @@ def begin_enable_https( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -626,17 +584,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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_enable_https.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/enableHttps" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _disable_https_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, front_door_name: str, frontend_endpoint_name: str, **kwargs: Any @@ -655,22 +609,21 @@ def _disable_https_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_disable_https_request( + _request = build_disable_https_request( resource_group_name=resource_group_name, front_door_name=front_door_name, frontend_endpoint_name=frontend_endpoint_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._disable_https_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -681,11 +634,7 @@ def _disable_https_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _disable_https_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/disableHttps" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_disable_https( @@ -700,14 +649,6 @@ def begin_disable_https( :param frontend_endpoint_name: Name of the Frontend endpoint which is unique within the Front Door. Required. :type frontend_endpoint_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: @@ -735,7 +676,7 @@ def begin_disable_https( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -746,14 +687,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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_disable_https.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/frontendEndpoints/{frontendEndpointName}/disableHttps" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_managed_rule_sets_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_managed_rule_sets_operations.py index 20a410874cda..59b4df7e2a81 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_managed_rule_sets_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_managed_rule_sets_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -26,7 +26,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -39,7 +39,7 @@ def build_list_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: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -51,7 +51,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -85,7 +85,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> Iterable["_models.ManagedRuleSetDefinition"]: """Lists all available managed rule sets. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ManagedRuleSetDefinition or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.frontdoor.models.ManagedRuleSetDefinition] @@ -94,7 +93,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ManagedRuleSetDefinition"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) cls: ClsType[_models.ManagedRuleSetDefinitionList] = kwargs.pop("cls", None) error_map = { @@ -108,22 +107,21 @@ def list(self, **kwargs: Any) -> Iterable["_models.ManagedRuleSetDefinition"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("ManagedRuleSetDefinitionList", pipeline_response) @@ -133,11 +131,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -149,7 +147,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallManagedRuleSets" - } diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_network_experiment_profiles_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_network_experiment_profiles_operations.py index 49bc844c141e..f61eabf039ae 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_network_experiment_profiles_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_network_experiment_profiles_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.exceptions import ( @@ -28,7 +29,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -52,7 +53,7 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -87,7 +88,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -123,7 +124,7 @@ def build_get_request(resource_group_name: str, profile_name: str, subscription_ "profileName": _SERIALIZER.url("profile_name", profile_name, "str", pattern=r"^[a-zA-Z0-9_\-\(\)\.]*[^\.]$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -162,7 +163,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -203,7 +204,7 @@ def build_update_request( "profileName": _SERIALIZER.url("profile_name", profile_name, "str", pattern=r"^[a-zA-Z0-9_\-\(\)\.]*[^\.]$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -243,7 +244,7 @@ def build_delete_request( "profileName": _SERIALIZER.url("profile_name", profile_name, "str", pattern=r"^[a-zA-Z0-9_\-\(\)\.]*[^\.]$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -279,7 +280,6 @@ def list(self, **kwargs: Any) -> Iterable["_models.Profile"]: Gets a list of Network Experiment Profiles under a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Profile or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.frontdoor.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -301,22 +301,21 @@ def list(self, **kwargs: Any) -> Iterable["_models.Profile"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("ProfileList", pipeline_response) @@ -326,11 +325,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -343,8 +342,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/NetworkExperimentProfiles"} - @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Profile"]: """Gets a list of Network Experiment Profiles within a resource group under a subscription. @@ -353,7 +350,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: Name of the Resource group within the Azure 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 Profile or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.frontdoor.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -375,23 +371,22 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("ProfileList", pipeline_response) @@ -401,11 +396,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -418,10 +413,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles" - } - @distributed_trace def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _models.Profile: """Gets an NetworkExperiment Profile by ProfileName. @@ -432,7 +423,6 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo :type resource_group_name: str :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Profile or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.Profile :raises ~azure.core.exceptions.HttpResponseError: @@ -451,21 +441,20 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.Profile] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, profile_name=profile_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -478,16 +467,12 @@ def get(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> _mo deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}" - } + return deserialized # type: ignore def _create_or_update_initial( - self, profile_name: str, resource_group_name: str, parameters: Union[_models.Profile, IO], **kwargs: Any + self, profile_name: str, resource_group_name: str, parameters: Union[_models.Profile, IO[bytes]], **kwargs: Any ) -> _models.Profile: error_map = { 401: ClientAuthenticationError, @@ -507,12 +492,12 @@ def _create_or_update_initial( 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, "Profile") - request = build_create_or_update_request( + _request = build_create_or_update_request( profile_name=profile_name, resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, @@ -520,16 +505,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -553,10 +537,6 @@ def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}" - } - @overload def begin_create_or_update( self, @@ -580,14 +560,6 @@ def begin_create_or_update( :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -598,7 +570,7 @@ def begin_create_or_update( self, profile_name: str, resource_group_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -612,18 +584,10 @@ def begin_create_or_update( :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str :param parameters: An Network Experiment Profile. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -631,7 +595,7 @@ def begin_create_or_update( @distributed_trace def begin_create_or_update( - self, profile_name: str, resource_group_name: str, parameters: Union[_models.Profile, IO], **kwargs: Any + self, profile_name: str, resource_group_name: str, parameters: Union[_models.Profile, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Profile]: """Creates an NetworkExperiment Profile. @@ -641,20 +605,9 @@ def begin_create_or_update( :type profile_name: str :param resource_group_name: Name of the Resource group within the Azure subscription. Required. :type resource_group_name: str - :param parameters: An Network Experiment Profile. Is either a Profile type or a IO type. + :param parameters: An Network Experiment Profile. Is either a Profile type or a IO[bytes] type. Required. - :type parameters: ~azure.mgmt.frontdoor.models.Profile 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. + :type parameters: ~azure.mgmt.frontdoor.models.Profile or IO[bytes] :return: An instance of LROPoller that returns either Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -685,7 +638,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -695,23 +648,21 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Profile].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.Network/NetworkExperimentProfiles/{profileName}" - } + return LROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, profile_name: str, - parameters: Union[_models.ProfileUpdateModel, IO], + parameters: Union[_models.ProfileUpdateModel, IO[bytes]], **kwargs: Any ) -> _models.Profile: error_map = { @@ -732,12 +683,12 @@ def _update_initial( 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, "ProfileUpdateModel") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, profile_name=profile_name, subscription_id=self._config.subscription_id, @@ -745,16 +696,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -775,10 +725,6 @@ def _update_initial( return deserialized # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}" - } - @overload def begin_update( self, @@ -802,14 +748,6 @@ def begin_update( :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -820,7 +758,7 @@ def begin_update( self, resource_group_name: str, profile_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -834,18 +772,10 @@ def begin_update( :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_name: str :param parameters: The Profile Update Model. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -856,7 +786,7 @@ def begin_update( self, resource_group_name: str, profile_name: str, - parameters: Union[_models.ProfileUpdateModel, IO], + parameters: Union[_models.ProfileUpdateModel, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Profile]: """Updates an NetworkExperimentProfiles by NetworkExperimentProfile name. @@ -867,20 +797,9 @@ def begin_update( :type resource_group_name: str :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_name: str - :param parameters: The Profile Update Model. Is either a ProfileUpdateModel type or a IO type. - Required. - :type parameters: ~azure.mgmt.frontdoor.models.ProfileUpdateModel 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. + :param parameters: The Profile Update Model. Is either a ProfileUpdateModel type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.frontdoor.models.ProfileUpdateModel or IO[bytes] :return: An instance of LROPoller that returns either Profile or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.Profile] :raises ~azure.core.exceptions.HttpResponseError: @@ -911,7 +830,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Profile", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -921,17 +840,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Profile].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.Network/NetworkExperimentProfiles/{profileName}" - } + return LROPoller[_models.Profile]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, profile_name: str, **kwargs: Any @@ -950,21 +867,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, profile_name=profile_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -975,11 +891,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Network/NetworkExperimentProfiles/{profileName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: Any) -> LROPoller[None]: @@ -991,14 +903,6 @@ def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: An :type resource_group_name: str :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_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: @@ -1025,7 +929,7 @@ def begin_delete(self, resource_group_name: str, profile_name: str, **kwargs: An def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1034,14 +938,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Network/NetworkExperimentProfiles/{profileName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_policies_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_policies_operations.py index 80730fe215ca..ed5a02a35285 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_policies_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_policies_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.exceptions import ( @@ -28,7 +29,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -41,7 +42,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: _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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,7 +62,7 @@ def build_list_request(resource_group_name: str, subscription_id: str, **kwargs: "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -76,7 +77,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -88,7 +89,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -103,7 +104,7 @@ def build_get_request(resource_group_name: str, policy_name: str, subscription_i _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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +125,7 @@ def build_get_request(resource_group_name: str, policy_name: str, subscription_i "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -141,7 +142,7 @@ def build_create_or_update_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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -163,7 +164,7 @@ def build_create_or_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -182,7 +183,7 @@ def build_update_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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -204,7 +205,7 @@ def build_update_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -222,7 +223,7 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) # Construct URL _url = kwargs.pop( "template_url", @@ -241,7 +242,7 @@ def build_delete_request( "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -274,7 +275,6 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Web :param resource_group_name: Name of the Resource group within the Azure 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 WebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.frontdoor.models.WebApplicationFirewallPolicy] @@ -283,7 +283,7 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Web _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) cls: ClsType[_models.WebApplicationFirewallPolicyList] = kwargs.pop("cls", None) error_map = { @@ -297,23 +297,22 @@ def list(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Web def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("WebApplicationFirewallPolicyList", pipeline_response) @@ -323,11 +322,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -340,15 +339,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies" - } - @distributed_trace def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.WebApplicationFirewallPolicy"]: """Lists all of the protection policies within a subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either WebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.frontdoor.models.WebApplicationFirewallPolicy] @@ -357,7 +351,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.WebApplicatio _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) cls: ClsType[_models.WebApplicationFirewallPolicyList] = kwargs.pop("cls", None) error_map = { @@ -371,22 +365,21 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.WebApplicatio def prepare_request(next_link=None): if not next_link: - request = build_list_by_subscription_request( + _request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("WebApplicationFirewallPolicyList", pipeline_response) @@ -396,11 +389,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -413,10 +406,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_subscription.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies" - } - @distributed_trace def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _models.WebApplicationFirewallPolicy: """Retrieve protection policy with specified name within a resource group. @@ -425,7 +414,6 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod :type resource_group_name: str :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: WebApplicationFirewallPolicy or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.WebApplicationFirewallPolicy :raises ~azure.core.exceptions.HttpResponseError: @@ -441,24 +429,23 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, policy_name=policy_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -471,19 +458,15 @@ def get(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> _mod deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, policy_name: str, - parameters: Union[_models.WebApplicationFirewallPolicy, IO], + parameters: Union[_models.WebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any ) -> _models.WebApplicationFirewallPolicy: error_map = { @@ -497,19 +480,19 @@ def _create_or_update_initial( _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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = 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, "WebApplicationFirewallPolicy") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, policy_name=policy_name, subscription_id=self._config.subscription_id, @@ -517,16 +500,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -550,10 +532,6 @@ def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } - @overload def begin_create_or_update( self, @@ -575,14 +553,6 @@ def begin_create_or_update( :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 WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -595,7 +565,7 @@ def begin_create_or_update( self, resource_group_name: str, policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -607,18 +577,10 @@ def begin_create_or_update( :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_name: str :param parameters: Policy to be created. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -631,7 +593,7 @@ def begin_create_or_update( self, resource_group_name: str, policy_name: str, - parameters: Union[_models.WebApplicationFirewallPolicy, IO], + parameters: Union[_models.WebApplicationFirewallPolicy, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.WebApplicationFirewallPolicy]: """Create or update policy with specified rule set name within a resource group. @@ -640,20 +602,9 @@ def begin_create_or_update( :type resource_group_name: str :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_name: str - :param parameters: Policy to be created. Is either a WebApplicationFirewallPolicy type or a IO - type. Required. - :type parameters: ~azure.mgmt.frontdoor.models.WebApplicationFirewallPolicy 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. + :param parameters: Policy to be created. Is either a WebApplicationFirewallPolicy type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.frontdoor.models.WebApplicationFirewallPolicy or IO[bytes] :return: An instance of LROPoller that returns either WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -663,7 +614,7 @@ def begin_create_or_update( _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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -686,7 +637,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -696,20 +647,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.WebApplicationFirewallPolicy].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.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return LROPoller[_models.WebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( - self, resource_group_name: str, policy_name: str, parameters: Union[_models.TagsObject, IO], **kwargs: Any + self, + resource_group_name: str, + policy_name: str, + parameters: Union[_models.TagsObject, IO[bytes]], + **kwargs: Any ) -> _models.WebApplicationFirewallPolicy: error_map = { 401: ClientAuthenticationError, @@ -722,19 +675,19 @@ def _update_initial( _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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = 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, "TagsObject") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, policy_name=policy_name, subscription_id=self._config.subscription_id, @@ -742,16 +695,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -764,13 +716,9 @@ def _update_initial( deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -794,14 +742,6 @@ def begin_update( :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 WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -814,7 +754,7 @@ def begin_update( self, resource_group_name: str, policy_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -827,18 +767,10 @@ def begin_update( :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_name: str :param parameters: FrontdoorWebApplicationFirewallPolicy parameters to be patched. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -848,7 +780,11 @@ def begin_update( @distributed_trace def begin_update( - self, resource_group_name: str, policy_name: str, parameters: Union[_models.TagsObject, IO], **kwargs: Any + self, + resource_group_name: str, + policy_name: str, + parameters: Union[_models.TagsObject, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.WebApplicationFirewallPolicy]: """Patch a specific frontdoor webApplicationFirewall policy for tags update under the specified subscription and resource group. @@ -858,19 +794,8 @@ def begin_update( :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_name: str :param parameters: FrontdoorWebApplicationFirewallPolicy parameters to be patched. Is either a - TagsObject type or a IO type. Required. - :type parameters: ~azure.mgmt.frontdoor.models.TagsObject 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. + TagsObject type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.frontdoor.models.TagsObject or IO[bytes] :return: An instance of LROPoller that returns either WebApplicationFirewallPolicy or the result of cls(response) :rtype: @@ -880,7 +805,7 @@ def begin_update( _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", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.WebApplicationFirewallPolicy] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) @@ -903,7 +828,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("WebApplicationFirewallPolicy", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -913,17 +838,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.WebApplicationFirewallPolicy].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.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return LROPoller[_models.WebApplicationFirewallPolicy]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, policy_name: str, **kwargs: Any @@ -939,24 +862,23 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, policy_name=policy_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -966,11 +888,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: - return cls(pipeline_response, None, {}) - - _delete_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, policy_name: str, **kwargs: Any) -> LROPoller[None]: @@ -980,14 +898,6 @@ def begin_delete(self, resource_group_name: str, policy_name: str, **kwargs: Any :type resource_group_name: str :param policy_name: The name of the Web Application Firewall Policy. Required. :type policy_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: @@ -995,7 +905,7 @@ def begin_delete(self, resource_group_name: str, policy_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2024-02-01")) 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) @@ -1014,7 +924,7 @@ def begin_delete(self, resource_group_name: str, policy_name: str, **kwargs: Any def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) @@ -1023,14 +933,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Network/FrontDoorWebApplicationFirewallPolicies/{policyName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_preconfigured_endpoints_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_preconfigured_endpoints_operations.py index d4f4b9f7b215..43705f16ff85 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_preconfigured_endpoints_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_preconfigured_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -26,7 +26,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -60,7 +60,7 @@ def build_list_request(resource_group_name: str, profile_name: str, subscription "profileName": _SERIALIZER.url("profile_name", profile_name, "str", pattern=r"^[a-zA-Z0-9_\-\(\)\.]*[^\.]$"), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -102,7 +102,6 @@ def list( :type resource_group_name: str :param profile_name: The Profile identifier associated with the Tenant and Partner. Required. :type profile_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PreconfiguredEndpoint or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.frontdoor.models.PreconfiguredEndpoint] @@ -125,24 +124,23 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, profile_name=profile_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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("PreconfiguredEndpointList", pipeline_response) @@ -152,11 +150,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -168,7 +166,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/PreconfiguredEndpoints" - } diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_reports_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_reports_operations.py index 2a49ffea111d..9fa26fdcb3ac 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_reports_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_reports_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -26,7 +26,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +73,7 @@ def build_get_latency_scorecards_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -130,7 +130,7 @@ def build_get_timeseries_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -199,7 +199,6 @@ def get_latency_scorecards( :param country: The country associated with the Latency Scorecard. Values are country ISO codes as specified here- https://www.iso.org/iso-3166-country-codes.html. Default value is None. :type country: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LatencyScorecard or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.LatencyScorecard :raises ~azure.core.exceptions.HttpResponseError: @@ -218,7 +217,7 @@ def get_latency_scorecards( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.LatencyScorecard] = kwargs.pop("cls", None) - request = build_get_latency_scorecards_request( + _request = build_get_latency_scorecards_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_name, @@ -227,16 +226,15 @@ def get_latency_scorecards( end_date_time_utc=end_date_time_utc, country=country, api_version=api_version, - template_url=self.get_latency_scorecards.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -249,13 +247,9 @@ def get_latency_scorecards( deserialized = self._deserialize("LatencyScorecard", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_latency_scorecards.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}/LatencyScorecard" - } + return deserialized # type: ignore @distributed_trace def get_timeseries( @@ -296,7 +290,6 @@ def get_timeseries( :param country: The country associated with the Timeseries. Values are country ISO codes as specified here- https://www.iso.org/iso-3166-country-codes.html. Default value is None. :type country: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Timeseries or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.Timeseries :raises ~azure.core.exceptions.HttpResponseError: @@ -315,7 +308,7 @@ def get_timeseries( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2019-11-01")) cls: ClsType[_models.Timeseries] = kwargs.pop("cls", None) - request = build_get_timeseries_request( + _request = build_get_timeseries_request( resource_group_name=resource_group_name, profile_name=profile_name, experiment_name=experiment_name, @@ -327,16 +320,15 @@ def get_timeseries( endpoint=endpoint, country=country, api_version=api_version, - template_url=self.get_timeseries.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -349,10 +341,6 @@ def get_timeseries( deserialized = self._deserialize("Timeseries", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get_timeseries.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/NetworkExperimentProfiles/{profileName}/Experiments/{experimentName}/Timeseries" - } + return deserialized # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_rules_engines_operations.py b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_rules_engines_operations.py index 5d6af17391c1..ba2236ab7094 100644 --- a/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_rules_engines_operations.py +++ b/sdk/network/azure-mgmt-frontdoor/azure/mgmt/frontdoor/operations/_rules_engines_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,6 +6,7 @@ # 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 from azure.core.exceptions import ( @@ -28,7 +29,7 @@ from .. import models as _models from .._serialization import Serializer -from .._vendor import _convert_request, _format_url_section +from .._vendor import _convert_request T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +72,7 @@ def build_list_by_front_door_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -124,7 +125,7 @@ def build_get_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -178,7 +179,7 @@ def build_create_or_update_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -233,7 +234,7 @@ def build_delete_request( ), } - _url: str = _format_url_section(_url, **path_format_arguments) # type: ignore + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -273,7 +274,6 @@ def list_by_front_door( :type resource_group_name: str :param front_door_name: Name of the Front Door which is globally unique. Required. :type front_door_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either RulesEngine or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.frontdoor.models.RulesEngine] :raises ~azure.core.exceptions.HttpResponseError: @@ -295,24 +295,23 @@ def list_by_front_door( def prepare_request(next_link=None): if not next_link: - request = build_list_by_front_door_request( + _request = build_list_by_front_door_request( resource_group_name=resource_group_name, front_door_name=front_door_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_front_door.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: - request = HttpRequest("GET", next_link) - request = _convert_request(request) - request.url = self._client.format_url(request.url) - request.method = "GET" - return request + _request = HttpRequest("GET", next_link) + _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("RulesEngineListResult", pipeline_response) @@ -322,11 +321,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -339,10 +338,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_front_door.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/rulesEngines" - } - @distributed_trace def get( self, resource_group_name: str, front_door_name: str, rules_engine_name: str, **kwargs: Any @@ -356,7 +351,6 @@ def get( :param rules_engine_name: Name of the Rules Engine which is unique within the Front Door. Required. :type rules_engine_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: RulesEngine or the result of cls(response) :rtype: ~azure.mgmt.frontdoor.models.RulesEngine :raises ~azure.core.exceptions.HttpResponseError: @@ -375,22 +369,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[_models.RulesEngine] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, front_door_name=front_door_name, rules_engine_name=rules_engine_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -403,20 +396,16 @@ def get( deserialized = self._deserialize("RulesEngine", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, front_door_name: str, rules_engine_name: str, - rules_engine_parameters: Union[_models.RulesEngine, IO], + rules_engine_parameters: Union[_models.RulesEngine, IO[bytes]], **kwargs: Any ) -> _models.RulesEngine: error_map = { @@ -437,12 +426,12 @@ def _create_or_update_initial( content_type = content_type or "application/json" _json = None _content = None - if isinstance(rules_engine_parameters, (IO, bytes)): + if isinstance(rules_engine_parameters, (IOBase, bytes)): _content = rules_engine_parameters else: _json = self._serialize.body(rules_engine_parameters, "RulesEngine") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, front_door_name=front_door_name, rules_engine_name=rules_engine_name, @@ -451,16 +440,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -484,10 +472,6 @@ def _create_or_update_initial( return deserialized # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}" - } - @overload def begin_create_or_update( self, @@ -515,14 +499,6 @@ def begin_create_or_update( :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 RulesEngine or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.RulesEngine] @@ -535,7 +511,7 @@ def begin_create_or_update( resource_group_name: str, front_door_name: str, rules_engine_name: str, - rules_engine_parameters: IO, + rules_engine_parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -552,18 +528,10 @@ def begin_create_or_update( :type rules_engine_name: str :param rules_engine_parameters: Rules Engine Configuration properties needed to create a new Rules Engine Configuration. Required. - :type rules_engine_parameters: IO + :type rules_engine_parameters: IO[bytes] :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 RulesEngine or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.RulesEngine] @@ -576,7 +544,7 @@ def begin_create_or_update( resource_group_name: str, front_door_name: str, rules_engine_name: str, - rules_engine_parameters: Union[_models.RulesEngine, IO], + rules_engine_parameters: Union[_models.RulesEngine, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.RulesEngine]: """Creates a new Rules Engine Configuration with the specified name within the specified Front @@ -590,19 +558,8 @@ def begin_create_or_update( Required. :type rules_engine_name: str :param rules_engine_parameters: Rules Engine Configuration properties needed to create a new - Rules Engine Configuration. Is either a RulesEngine type or a IO type. Required. - :type rules_engine_parameters: ~azure.mgmt.frontdoor.models.RulesEngine 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. + Rules Engine Configuration. Is either a RulesEngine type or a IO[bytes] type. Required. + :type rules_engine_parameters: ~azure.mgmt.frontdoor.models.RulesEngine or IO[bytes] :return: An instance of LROPoller that returns either RulesEngine or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.frontdoor.models.RulesEngine] @@ -635,7 +592,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("RulesEngine", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -647,17 +604,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.RulesEngine].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.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}" - } + return LROPoller[_models.RulesEngine]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, front_door_name: str, rules_engine_name: str, **kwargs: Any @@ -676,22 +631,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_delete_request( + _request = build_delete_request( resource_group_name=resource_group_name, front_door_name=front_door_name, rules_engine_name=rules_engine_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -702,11 +656,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def begin_delete( @@ -721,14 +671,6 @@ def begin_delete( :param rules_engine_name: Name of the Rules Engine which is unique within the Front Door. Required. :type rules_engine_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: @@ -756,7 +698,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -767,14 +709,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.Network/frontDoors/{frontDoorName}/rulesEngines/{rulesEngineName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability.py index 08c4100d22ae..4f99d4e53ea9 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability_with_subscription.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability_with_subscription.py index d89af3056782..903af2045d1f 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability_with_subscription.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/check_frontdoor_name_availability_with_subscription.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_create.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_create.py index ce40e5471ba5..ebdd529b3739 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_create.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_delete.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_delete.py index 79fac4012b5b..22853ac7c535 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_delete.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -29,11 +30,10 @@ def main(): subscription_id="subid", ) - response = client.front_doors.begin_delete( + client.front_doors.begin_delete( resource_group_name="rg1", front_door_name="frontDoor1", ).result() - print(response) # x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorDelete.json diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_disable_https.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_disable_https.py index adaf8e519d16..029289832097 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_disable_https.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_disable_https.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="subid", ) - response = client.frontend_endpoints.begin_disable_https( + client.frontend_endpoints.begin_disable_https( resource_group_name="rg1", front_door_name="frontDoor1", frontend_endpoint_name="frontendEndpoint1", ).result() - print(response) # x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorDisableHttps.json diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_enable_https.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_enable_https.py index b2526453588e..ab3e4d177582 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_enable_https.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_enable_https.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -29,7 +32,7 @@ def main(): subscription_id="subid", ) - response = client.frontend_endpoints.begin_enable_https( + client.frontend_endpoints.begin_enable_https( resource_group_name="rg1", front_door_name="frontDoor1", frontend_endpoint_name="frontendEndpoint1", @@ -44,7 +47,6 @@ def main(): "protocolType": "ServerNameIndication", }, ).result() - print(response) # x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorEnableHttps.json diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_get.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_get.py index 30020c18148a..9d029c39c4ae 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_get.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_list.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_list.py index 6aa723adbbe0..9dfeb9f7b211 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_list.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_frontend_endpoint_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_get.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_get.py index c3aaeda717cf..ee8365823547 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_get.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list.py index 51d9208cf42c..702c1019c01a 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list_all.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list_all.py index 48b8a0076495..3f94145cbe09 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list_all.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_list_all.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_purge_content.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_purge_content.py index aee709a6ae11..994d70a2849f 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_purge_content.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_purge_content.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -29,12 +32,11 @@ def main(): subscription_id="subid", ) - response = client.endpoints.begin_purge_content( + client.endpoints.begin_purge_content( resource_group_name="rg1", front_door_name="frontDoor1", content_file_paths={"contentPaths": ["/pictures.aspx", "/pictures/*"]}, ).result() - print(response) # x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorPurgeContent.json diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_create.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_create.py index 7f7baafa9896..ea6d403fc419 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_create.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_delete.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_delete.py index 5f3e65a9cf6e..ddbaf154633c 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_delete.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="subid", ) - response = client.rules_engines.begin_delete( + client.rules_engines.begin_delete( resource_group_name="rg1", front_door_name="frontDoor1", rules_engine_name="rulesEngine1", ).result() - print(response) # x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorRulesEngineDelete.json diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_get.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_get.py index 2a1cfc78badc..8860ee134109 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_get.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_list.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_list.py index f61a63452e98..39e679e8d7d9 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_list.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_rules_engine_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_validate_custom_domain.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_validate_custom_domain.py index 929b49807bc0..b45eea8e5192 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_validate_custom_domain.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/frontdoor_validate_custom_domain.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_experiment.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_experiment.py index f36da3defcd2..e74a5c9e1654 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_experiment.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_experiment.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_profile.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_profile.py index aac527418ea4..3ee6e0c4cbed 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_profile.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_create_profile.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_experiment.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_experiment.py index 1400eb4f843f..232b119ae663 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_experiment.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_experiment.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -29,12 +30,11 @@ def main(): subscription_id="subid", ) - response = client.experiments.begin_delete( + client.experiments.begin_delete( resource_group_name="MyResourceGroup", profile_name="MyProfile", experiment_name="MyExperiment", ).result() - print(response) # x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentDeleteExperiment.json diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_profile.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_profile.py index ef51a7daa727..fd2a1b33a8ab 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_profile.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_delete_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -29,11 +30,10 @@ def main(): subscription_id="subid", ) - response = client.network_experiment_profiles.begin_delete( + client.network_experiment_profiles.begin_delete( resource_group_name="MyResourceGroup", profile_name="MyProfile", ).result() - print(response) # x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentDeleteProfile.json diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_experiment.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_experiment.py index 4e2218155ad7..54b21dba2add 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_experiment.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_experiment.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_latency_scorecard.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_latency_scorecard.py index 438e1f248444..ffbeefb1a5d5 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_latency_scorecard.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_latency_scorecard.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_preconfigured_endpoints.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_preconfigured_endpoints.py index e801b9d8bd43..3bd3e73a6b6f 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_preconfigured_endpoints.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_preconfigured_endpoints.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_profile.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_profile.py index d8d1d1b604ac..1600033b5275 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_profile.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_profile.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_timeseries.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_timeseries.py index 75c493a4297c..18bbdee75cc3 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_timeseries.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_get_timeseries.py @@ -6,11 +6,17 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime import isodate +from typing import TYPE_CHECKING, Union from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_experiments.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_experiments.py index ed46cfc1118c..8106acc16b98 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_experiments.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_experiments.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_profiles.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_profiles.py index 6068c637a4a6..8080f1fd22ae 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_profiles.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_list_profiles.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_experiment.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_experiment.py index 010ef710a11f..2599fcfbdf77 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_experiment.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_experiment.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_profile.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_profile.py index f1c4c2fd400a..478e97c702a2 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_profile.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/network_experiment_update_profile.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_managed_rule_sets.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_managed_rule_sets.py index c06af0d23373..6b22b9763d69 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_managed_rule_sets.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_managed_rule_sets.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2022-05-01/examples/WafListManagedRuleSets.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafListManagedRuleSets.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies.py index cded7a43bcf0..319b5042109e 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2022-05-01/examples/WafListPolicies.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafListPolicies.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies_under_subscription.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies_under_subscription.py index 8d4b66d32f67..65250ae16c3a 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies_under_subscription.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_list_policies_under_subscription.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2022-05-01/examples/WafListPoliciesUnderSubscription.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafListPoliciesUnderSubscription.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_create_or_update.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_create_or_update.py index 8ca465c67500..6f7a07ca8e23 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_create_or_update.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_create_or_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -33,6 +36,7 @@ def main(): resource_group_name="rg1", policy_name="Policy1", parameters={ + "location": "WestUs", "properties": { "customRules": { "rules": [ @@ -113,19 +117,31 @@ def main(): }, "policySettings": { "customBlockResponseBody": "PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg==", - "customBlockResponseStatusCode": 499, + "customBlockResponseStatusCode": 429, "enabledState": "Enabled", + "javascriptChallengeExpirationInMinutes": 30, + "logScrubbing": { + "scrubbingRules": [ + { + "matchVariable": "RequestIPAddress", + "selector": None, + "selectorMatchOperator": "EqualsAny", + "state": "Enabled", + } + ], + "state": "Enabled", + }, "mode": "Prevention", "redirectUrl": "http://www.bing.com", "requestBodyCheck": "Disabled", }, }, - "sku": {"name": "Classic_AzureFrontDoor"}, + "sku": {"name": "Premium_AzureFrontDoor"}, }, ).result() print(response) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2022-05-01/examples/WafPolicyCreateOrUpdate.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_delete.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_delete.py index 9d7cc8a9b511..145e322b321f 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_delete.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -29,13 +30,12 @@ def main(): subscription_id="subid", ) - response = client.policies.begin_delete( + client.policies.begin_delete( resource_group_name="rg1", policy_name="Policy1", ).result() - print(response) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2022-05-01/examples/WafPolicyDelete.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyDelete.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_get.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_get.py index a0aab1e42d98..070e5a31d879 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_get.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2022-05-01/examples/WafPolicyGet.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyGet.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_patch.py b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_patch.py index 54ee533b3878..07616c834393 100644 --- a/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_patch.py +++ b/sdk/network/azure-mgmt-frontdoor/generated_samples/waf_policy_patch.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.frontdoor import FrontDoorManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2022-05-01/examples/WafPolicyPatch.json +# x-ms-original-file: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyPatch.json if __name__ == "__main__": main() diff --git a/sdk/network/azure-mgmt-frontdoor/sdk_packaging.toml b/sdk/network/azure-mgmt-frontdoor/sdk_packaging.toml index e219e0932021..ca9a9fa5cc7e 100644 --- a/sdk/network/azure-mgmt-frontdoor/sdk_packaging.toml +++ b/sdk/network/azure-mgmt-frontdoor/sdk_packaging.toml @@ -2,6 +2,6 @@ package_name = "azure-mgmt-frontdoor" package_pprint_name = "Front Door Service" package_doc_id = "" -is_stable = false +is_stable = true is_arm = true title = "FrontDoorManagementClient" \ No newline at end of file diff --git a/sdk/network/azure-mgmt-frontdoor/setup.py b/sdk/network/azure-mgmt-frontdoor/setup.py index d1806c0f8942..aed570f34b33 100644 --- a/sdk/network/azure-mgmt-frontdoor/setup.py +++ b/sdk/network/azure-mgmt-frontdoor/setup.py @@ -1,10 +1,10 @@ #!/usr/bin/env python -#------------------------------------------------------------------------- +# ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for # license information. -#-------------------------------------------------------------------------- +# -------------------------------------------------------------------------- import re import os.path @@ -16,64 +16,67 @@ PACKAGE_PPRINT_NAME = "Front Door Service" # a-b-c => a/b/c -package_folder_path = PACKAGE_NAME.replace('-', '/') +package_folder_path = PACKAGE_NAME.replace("-", "/") # a-b-c => a.b.c -namespace_name = PACKAGE_NAME.replace('-', '.') +namespace_name = PACKAGE_NAME.replace("-", ".") # Version extraction inspired from 'requests' -with open(os.path.join(package_folder_path, 'version.py') - if os.path.exists(os.path.join(package_folder_path, 'version.py')) - else os.path.join(package_folder_path, '_version.py'), 'r') as fd: - version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) +with open( + os.path.join(package_folder_path, "version.py") + if os.path.exists(os.path.join(package_folder_path, "version.py")) + else os.path.join(package_folder_path, "_version.py"), + "r", +) as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', fd.read(), re.MULTILINE).group(1) if not version: - raise RuntimeError('Cannot find version information') + raise RuntimeError("Cannot find version information") -with open('README.md', encoding='utf-8') as f: +with open("README.md", encoding="utf-8") as f: readme = f.read() -with open('CHANGELOG.md', encoding='utf-8') as f: +with open("CHANGELOG.md", encoding="utf-8") as f: changelog = f.read() setup( name=PACKAGE_NAME, version=version, - description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), - long_description=readme + '\n\n' + changelog, - long_description_content_type='text/markdown', - license='MIT License', - author='Microsoft Corporation', - author_email='azpysdkhelp@microsoft.com', - url='https://github.com/Azure/azure-sdk-for-python', + description="Microsoft Azure {} Client Library for Python".format(PACKAGE_PPRINT_NAME), + long_description=readme + "\n\n" + changelog, + long_description_content_type="text/markdown", + license="MIT License", + author="Microsoft Corporation", + author_email="azpysdkhelp@microsoft.com", + url="https://github.com/Azure/azure-sdk-for-python", keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - 'Development Status :: 4 - Beta', - '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', - 'License :: OSI Approved :: MIT License', + "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", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "License :: OSI Approved :: MIT License", ], zip_safe=False, - packages=find_packages(exclude=[ - 'tests', - # Exclude packages that will be covered by PEP420 or nspkg - 'azure', - 'azure.mgmt', - ]), + packages=find_packages( + exclude=[ + "tests", + # Exclude packages that will be covered by PEP420 or nspkg + "azure", + "azure.mgmt", + ] + ), include_package_data=True, package_data={ - 'pytyped': ['py.typed'], + "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", - "typing-extensions>=4.3.0; python_version<'3.8.0'", + "isodate>=0.6.1", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], - python_requires=">=3.7" + python_requires=">=3.8", ) diff --git a/sdk/networkanalytics/azure-mgmt-networkanalytics/pyproject.toml b/sdk/networkanalytics/azure-mgmt-networkanalytics/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/networkanalytics/azure-mgmt-networkanalytics/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/networkcloud/azure-mgmt-networkcloud/pyproject.toml b/sdk/networkcloud/azure-mgmt-networkcloud/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/networkcloud/azure-mgmt-networkcloud/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/oep/azure-mgmt-oep/pyproject.toml b/sdk/oep/azure-mgmt-oep/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/operationsmanagement/azure-mgmt-operationsmanagement/pyproject.toml b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/operationsmanagement/azure-mgmt-operationsmanagement/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/playwrighttesting/azure-mgmt-playwrighttesting/pyproject.toml b/sdk/playwrighttesting/azure-mgmt-playwrighttesting/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/playwrighttesting/azure-mgmt-playwrighttesting/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/purview/azure-mgmt-purview/pyproject.toml b/sdk/purview/azure-mgmt-purview/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/purview/azure-mgmt-purview/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/purview/azure-purview-catalog/CHANGELOG.md b/sdk/purview/azure-purview-catalog/CHANGELOG.md index dda0e2a605d6..40f4c8ae8418 100644 --- a/sdk/purview/azure-purview-catalog/CHANGELOG.md +++ b/sdk/purview/azure-purview-catalog/CHANGELOG.md @@ -1,14 +1,8 @@ # Release History -## 1.0.0b5 (Unreleased) +## 1.0.0b5 (2024-04-17) -### Features Added - -### Breaking Changes - -### Bugs Fixed - -### Other Changes + - This package is no longer being maintained. Use the [azure-purview-datamap](https://pypi.org/project/azure-purview-datamap/) package instead. ## 1.0.0b4 (2022-06-13) diff --git a/sdk/purview/azure-purview-catalog/README.md b/sdk/purview/azure-purview-catalog/README.md index 8812b4d0c5ba..d0208647b3cc 100644 --- a/sdk/purview/azure-purview-catalog/README.md +++ b/sdk/purview/azure-purview-catalog/README.md @@ -1,6 +1,8 @@ # Azure Purview Catalog client library for Python -Azure Purview Catalog is a fully managed cloud service whose users can discover the data sources they need and understand the data sources they find. At the same time, Data Catalog helps organizations get more value from their existing investments. + > This package is no longer being maintained. Use the [azure-purview-datamap](https://pypi.org/project/azure-purview-datamap/) package instead. + +Azure Purview Catalog is a fully managed cloud service whose users can discover the data sources they need and understand the data sources they find. At the same time, Data Catalog helps organizations get more value from their existing investments. - Search for data using technical or business terms - Browse associated technical, business, semantic, and operational metadata diff --git a/sdk/purview/azure-purview-catalog/setup.py b/sdk/purview/azure-purview-catalog/setup.py index 230bb0134123..5cb4354bfa68 100644 --- a/sdk/purview/azure-purview-catalog/setup.py +++ b/sdk/purview/azure-purview-catalog/setup.py @@ -47,7 +47,7 @@ url='https://github.com/Azure/azure-sdk-for-python', keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ - "Development Status :: 4 - Beta", + "Development Status :: 7 - Inactive", 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3', diff --git a/sdk/purview/azure-purview-datamap/MigrationGuide.md b/sdk/purview/azure-purview-datamap/MigrationGuide.md new file mode 100644 index 000000000000..e8c38b155c55 --- /dev/null +++ b/sdk/purview/azure-purview-datamap/MigrationGuide.md @@ -0,0 +1,58 @@ +# Migrate from Purview Catalog to Purview DataMap + +This guide is intended to assist in the migration to Azure Purview DataMap client library [`azure-purview-datamap`](https://pypi.org/project/azure-purview-datamap/) from [`azure-purview-catalog`](https://pypi.org/project/azure-purview-catalog/). It will focus on side-by-side comparisons for similar operations between the two packages. + +For those new to the Purview Data Map library, please refer to the README file and samples in [`azure-purview-datamap`](https://aka.ms/azure-sdk-for-python/purview-datamap) for the `azure-purview-datamap` library rather than this guide. + +## Table of contents + +- [Migration benefits](#migration-benefits) +- [General changes](#general-changes) + - [Package and client name](#package-and-client-name) +- [Additional samples](#additional-samples) + +## Migration benefits + +> Note: `azure-purview-catalog` has been deprecated. Please upgrade to `azure-purview-datamap` for continued support. + + +The new Purview DataMap library `azure-purview-datamap` includes the service models together with the DataMap APIs [API Document](https://learn.microsoft.com/rest/api/purview/datamapdataplane/operation-groups). The client name and the operation names have slightly changed but the main functionality remains the same. + +## General changes + +### Package and client name + +Previously in `azure-purview-catalog`, the client name is PurviewCatalogClient. + +```python +from azure.purview.catalog import PurviewCatalogClient +from azure.identity import DefaultAzureCredential +credential = DefaultAzureCredential() +client = PurviewCatalogClient(endpoint="https://.purview.azure.com", credential=credential) +``` + +Now in `azure-purview-datamap`, the client name is DataMapClient. + +```python +from azure.purview.datamap import DataMapClient +from azure.identity import DefaultAzureCredential +credential = DefaultAzureCredential() +client = DataMapClient(endpoint="https://.purview.azure.com", credential=credential) +``` + +### Operation name + +The operation names have slightly changed but the main functionality remains the same. Please check the below examples. + +#### Get all types +```python +# azure-purview-catalog +response = client.types.get_all_type_definitions() + +# azure-purview-datamap +response = client.type_definition.get() +``` + +## Additional samples + +For more examples, see [Samples for Purview DataMap](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/purview/azure-purview-datamap#examples). \ No newline at end of file diff --git a/sdk/qumulo/azure-mgmt-qumulo/pyproject.toml b/sdk/qumulo/azure-mgmt-qumulo/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/qumulo/azure-mgmt-qumulo/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md b/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md index 1aa18d372eb0..faa40f5fc0a0 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md +++ b/sdk/rdbms/azure-mgmt-rdbms/CHANGELOG.md @@ -1,5 +1,13 @@ # Release History +## 10.2.0b16 (2024-04-22) + +### Features Added + + - Model MigrationResource has a new parameter migrate_roles + - Model MigrationResource has a new parameter migration_instance_resource_id + - Model MigrationResourceForPatch has a new parameter migrate_roles + ## 10.2.0b15 (2024-03-04) ### Features Added diff --git a/sdk/rdbms/azure-mgmt-rdbms/_meta.json b/sdk/rdbms/azure-mgmt-rdbms/_meta.json index 4f015113e2a8..1273042ceb3b 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/_meta.json +++ b/sdk/rdbms/azure-mgmt-rdbms/_meta.json @@ -1,11 +1,11 @@ { - "commit": "a298fd4c9d0649e4ddc43c97c20a2e089d6f5a73", + "commit": "1f6e89637068d59b5ae935de9a88d5742d12f8e6", "repository_url": "https://github.com/Azure/azure-rest-api-specs", "autorest": "3.9.7", "use": [ - "@autorest/python@6.7.1", - "@autorest/modelerfour@4.26.2" + "@autorest/python@6.13.7", + "@autorest/modelerfour@4.27.0" ], - "autorest_command": "autorest specification/mysql/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.7.1 --use=@autorest/modelerfour@4.26.2 --version=3.9.7 --version-tolerant=False", - "readme": "specification/mysql/resource-manager/readme.md" + "autorest_command": "autorest specification/postgresql/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 --tag=package-flexibleserver-2023-12-01-preview --use=@autorest/python@6.13.7 --use=@autorest/modelerfour@4.27.0 --version=3.9.7 --version-tolerant=False", + "readme": "specification/postgresql/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/_version.py index 20bd285a03b6..e23121a12b07 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/_version.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "10.2.0b15" +VERSION = "10.2.0b16" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_version.py index e7e21063c7d1..e0972535f3bc 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mariadb/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.2.0b15" +VERSION = "10.2.0b16" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql/_version.py index e7e21063c7d1..e0972535f3bc 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.2.0b15" +VERSION = "10.2.0b16" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_version.py index e7e21063c7d1..e0972535f3bc 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/mysql_flexibleservers/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.2.0b15" +VERSION = "10.2.0b16" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_version.py index e7e21063c7d1..e0972535f3bc 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.2.0b15" +VERSION = "10.2.0b16" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_configuration.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_configuration.py index 69fb54a9bf86..b3b367424626 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_configuration.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy @@ -19,7 +18,7 @@ from azure.core.credentials import TokenCredential -class PostgreSQLManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class PostgreSQLManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for PostgreSQLManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class PostgreSQLManagementClientConfiguration(Configuration): # pylint: disable :type credential: ~azure.core.credentials.TokenCredential :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 "2023-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-12-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(PostgreSQLManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-06-01-preview") + api_version: str = kwargs.pop("api_version", "2023-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-rdbms/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = ARMChallengeAuthenticationPolicy( diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_postgre_sql_management_client.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_postgre_sql_management_client.py index b17a6101dbdb..debb7af4e944 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_postgre_sql_management_client.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_postgre_sql_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING +from azure.core.pipeline import policies from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient +from azure.mgmt.core.policies import ARMAutoResourceProviderRegistrationPolicy from . import models as _models from ._configuration import PostgreSQLManagementClientConfiguration @@ -128,7 +130,7 @@ class PostgreSQLManagementClient( :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 "2023-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-12-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 @@ -145,7 +147,25 @@ def __init__( self._config = PostgreSQLManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + ARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -200,7 +220,7 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + def _send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -220,7 +240,7 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore def close(self) -> None: self._client.close() diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_serialization.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_serialization.py index 4bae2292227b..2f781d740827 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_serialization.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_serialization.py @@ -63,8 +63,8 @@ import isodate # type: ignore -from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback -from azure.core.serialization import NULL as AzureCoreNull +from azure.core.exceptions import DeserializationError, SerializationError +from azure.core.serialization import NULL as CoreNull _BOM = codecs.BOM_UTF8.decode(encoding="utf-8") @@ -124,7 +124,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type: pass return ET.fromstring(data_as_str) # nosec - except ET.ParseError: + except ET.ParseError as err: # It might be because the server has an issue, and returned JSON with # content-type XML.... # So let's try a JSON load, and if it's still broken @@ -143,7 +143,7 @@ def _json_attemp(data): # The function hack is because Py2.7 messes up with exception # context otherwise. _LOGGER.critical("Wasn't XML not JSON, failing") - raise_with_traceback(DeserializationError, "XML is invalid") + raise DeserializationError("XML is invalid") from err raise DeserializationError("Cannot deserialize content-type: {}".format(content_type)) @classmethod @@ -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: @@ -295,7 +288,7 @@ class Model(object): _validation: Dict[str, Dict[str, Any]] = {} def __init__(self, **kwargs: Any) -> None: - self.additional_properties: Dict[str, Any] = {} + self.additional_properties: Optional[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__) @@ -340,7 +333,7 @@ def _create_xml_node(cls): 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: bool = False, **kwargs: Any) -> JSON: - """Return the JSON that would be sent to azure from this model. + """Return the JSON that would be sent to server from this model. This is an alias to `as_dict(full_restapi_key_transformer, keep_readonly=False)`. @@ -351,7 +344,7 @@ def serialize(self, keep_readonly: bool = False, **kwargs: Any) -> JSON: :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, keep_readonly=keep_readonly, **kwargs) # type: ignore def as_dict( self, @@ -390,7 +383,7 @@ def my_key_transformer(key, attr_desc, value): :rtype: dict """ serializer = Serializer(self._infer_class_models()) - return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) + return serializer._serialize(self, key_transformer=key_transformer, keep_readonly=keep_readonly, **kwargs) # type: ignore @classmethod def _infer_class_models(cls): @@ -415,7 +408,7 @@ def deserialize(cls: Type[ModelType], data: Any, content_type: Optional[str] = N :raises: DeserializationError if something went wrong """ deserializer = Deserializer(cls._infer_class_models()) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def from_dict( @@ -445,7 +438,7 @@ def from_dict( if key_extractors is None else key_extractors ) - return deserializer(cls.__name__, data, content_type=content_type) + return deserializer(cls.__name__, data, content_type=content_type) # type: ignore @classmethod def _flatten_subtype(cls, key, objects): @@ -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 @@ -668,7 +661,7 @@ def _serialize(self, target_obj, data_type=None, **kwargs): except (AttributeError, KeyError, TypeError) as err: msg = "Attribute {} in object {} cannot be serialized.\n{}".format(attr_name, class_name, str(target_obj)) - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err else: return serialized @@ -710,7 +703,7 @@ def body(self, data, data_type, **kwargs): ] data = deserializer._deserialize(data_type, data) except DeserializationError as err: - raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + raise SerializationError("Unable to build a model: " + str(err)) from err return self._serialize(data, data_type, **kwargs) @@ -730,6 +723,7 @@ def url(self, name, data, data_type, **kwargs): if kwargs.get("skip_quote") is True: output = str(output) + output = output.replace("{", quote("{")).replace("}", quote("}")) else: output = quote(str(output), safe="") except SerializationError: @@ -744,7 +738,7 @@ def query(self, name, data, data_type, **kwargs): :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 + :rtype: str, list :raises: TypeError if serialization fails. :raises: ValueError if data is None """ @@ -753,7 +747,7 @@ def query(self, name, data, data_type, **kwargs): if data_type.startswith("["): internal_data_type = data_type[1:-1] do_quote = not kwargs.get("skip_quote", False) - return str(self.serialize_iter(data, internal_data_type, do_quote=do_quote, **kwargs)) + return 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) @@ -804,7 +798,7 @@ def serialize_data(self, data, data_type, **kwargs): raise ValueError("No value for given attribute") try: - if data is AzureCoreNull: + if data is CoreNull: return None if data_type in self.basic_types.values(): return self.serialize_basic(data, data_type, **kwargs) @@ -824,7 +818,7 @@ def serialize_data(self, data, data_type, **kwargs): except (ValueError, TypeError) as err: msg = "Unable to serialize value: {!r} as type: {!r}." - raise_with_traceback(SerializationError, msg.format(data, data_type), err) + raise SerializationError(msg.format(data, data_type)) from err else: return self._serialize(data, **kwargs) @@ -993,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) @@ -1170,10 +1164,10 @@ def serialize_iso(attr, **kwargs): return date + microseconds + "Z" except (ValueError, OverflowError) as err: msg = "Unable to serialize datetime object." - raise_with_traceback(SerializationError, msg, err) + raise SerializationError(msg) from err except AttributeError as err: msg = "ISO-8601 object must be valid Datetime object." - raise_with_traceback(TypeError, msg, err) + raise TypeError(msg) from err @staticmethod def serialize_unix(attr, **kwargs): @@ -1209,7 +1203,6 @@ def rest_key_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1230,7 +1223,6 @@ def rest_key_case_insensitive_extractor(attr, attr_desc, data): if working_data is None: # If at any point while following flatten JSON path see None, it means # that all properties under are None as well - # https://github.com/Azure/msrest-for-python/issues/197 return None key = ".".join(dict_keys[1:]) @@ -1371,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, @@ -1391,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 @@ -1444,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) @@ -1481,7 +1473,7 @@ def _deserialize(self, target_obj, data): d_attrs[attr] = value except (AttributeError, TypeError, KeyError) as err: msg = "Unable to deserialize to object: " + class_name # type: ignore - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: additional_properties = self._build_additional_properties(attributes, data) return self._instantiate_model(response, d_attrs, additional_properties) @@ -1515,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 @@ -1578,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 @@ -1652,7 +1644,7 @@ def deserialize_data(self, data, data_type): except (ValueError, TypeError, AttributeError) as err: msg = "Unable to deserialize response data." msg += " Data: {}, {}".format(data, data_type) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return self._deserialize(obj_type, data) @@ -1700,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: @@ -1757,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"]: @@ -1808,7 +1800,6 @@ def deserialize_enum(data, enum_obj): data = data.value if isinstance(data, int): # Workaround. We might consider remove it in the future. - # https://github.com/Azure/azure-rest-api-specs/issues/141 try: return list(enum_obj.__members__.values())[data] except IndexError: @@ -1862,10 +1853,10 @@ def deserialize_decimal(attr): if isinstance(attr, ET.Element): attr = attr.text try: - return decimal.Decimal(attr) # type: ignore + return decimal.Decimal(str(attr)) # type: ignore except decimal.DecimalException as err: msg = "Invalid decimal {}".format(attr) - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err @staticmethod def deserialize_long(attr): @@ -1893,7 +1884,7 @@ def deserialize_duration(attr): duration = isodate.parse_duration(attr) except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize duration object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return duration @@ -1910,7 +1901,7 @@ def deserialize_date(attr): 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) + return isodate.parse_date(attr, defaultmonth=0, defaultday=0) @staticmethod def deserialize_time(attr): @@ -1945,7 +1936,7 @@ def deserialize_rfc(attr): date_obj = date_obj.astimezone(tz=TZ_UTC) except ValueError as err: msg = "Cannot deserialize to rfc datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1982,7 +1973,7 @@ def deserialize_iso(attr): raise OverflowError("Hit max or min date") except (ValueError, OverflowError, AttributeError) as err: msg = "Cannot deserialize datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj @@ -1998,9 +1989,10 @@ def deserialize_unix(attr): if isinstance(attr, ET.Element): attr = int(attr.text) # type: ignore try: + attr = int(attr) date_obj = datetime.datetime.fromtimestamp(attr, TZ_UTC) except ValueError as err: msg = "Cannot deserialize to unix datetime object." - raise_with_traceback(DeserializationError, msg, err) + raise DeserializationError(msg) from err else: return date_obj diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_version.py index e7e21063c7d1..e0972535f3bc 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_version.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "10.2.0b15" +VERSION = "10.2.0b16" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/_configuration.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/_configuration.py index 6db210884d91..3ebdbb3020eb 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/_configuration.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/_configuration.py @@ -8,7 +8,6 @@ from typing import Any, TYPE_CHECKING -from azure.core.configuration import Configuration from azure.core.pipeline import policies from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy @@ -19,7 +18,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class PostgreSQLManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes +class PostgreSQLManagementClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long """Configuration for PostgreSQLManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,14 +28,13 @@ class PostgreSQLManagementClientConfiguration(Configuration): # pylint: disable :type credential: ~azure.core.credentials_async.AsyncTokenCredential :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 "2023-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-12-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(PostgreSQLManagementClientConfiguration, self).__init__(**kwargs) - api_version: str = kwargs.pop("api_version", "2023-06-01-preview") + api_version: str = kwargs.pop("api_version", "2023-12-01-preview") if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -48,6 +46,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k self.api_version = api_version self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) kwargs.setdefault("sdk_moniker", "mgmt-rdbms/{}".format(VERSION)) + self.polling_interval = kwargs.get("polling_interval", 30) self._configure(**kwargs) def _configure(self, **kwargs: Any) -> None: @@ -56,9 +55,9 @@ def _configure(self, **kwargs: Any) -> None: self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/_postgre_sql_management_client.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/_postgre_sql_management_client.py index 5bbff26e2008..42f9776ce54f 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/_postgre_sql_management_client.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/_postgre_sql_management_client.py @@ -9,8 +9,10 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING +from azure.core.pipeline import policies from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient +from azure.mgmt.core.policies import AsyncARMAutoResourceProviderRegistrationPolicy from .. import models as _models from .._serialization import Deserializer, Serializer @@ -131,7 +133,7 @@ class PostgreSQLManagementClient( :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 "2023-06-01-preview". Note that overriding + :keyword api_version: Api Version. Default value is "2023-12-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 @@ -148,7 +150,25 @@ def __init__( self._config = PostgreSQLManagementClientConfiguration( credential=credential, subscription_id=subscription_id, **kwargs ) - self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + _policies = kwargs.pop("policies", None) + if _policies is None: + _policies = [ + policies.RequestIdPolicy(**kwargs), + self._config.headers_policy, + self._config.user_agent_policy, + self._config.proxy_policy, + policies.ContentDecodePolicy(**kwargs), + AsyncARMAutoResourceProviderRegistrationPolicy(), + self._config.redirect_policy, + self._config.retry_policy, + self._config.authentication_policy, + self._config.custom_hook_policy, + self._config.logging_policy, + policies.DistributedTracingPolicy(**kwargs), + policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None, + self._config.http_logging_policy, + ] + self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs) client_models = {k: v for k, v in _models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) @@ -203,7 +223,9 @@ def __init__( self._client, self._config, self._serialize, self._deserialize ) - def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + def _send_request( + self, request: HttpRequest, *, stream: bool = False, **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -223,7 +245,7 @@ def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncH request_copy = deepcopy(request) request_copy.url = self._client.format_url(request_copy.url) - return self._client.send_request(request_copy, **kwargs) + return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore async def close(self) -> None: await self._client.close() diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_administrators_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_administrators_operations.py index b4f11f1de031..ad6759b2128a 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_administrators_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_administrators_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -67,7 +67,7 @@ async def _create_initial( resource_group_name: str, server_name: str, object_id: str, - parameters: Union[_models.ActiveDirectoryAdministratorAdd, IO], + parameters: Union[_models.ActiveDirectoryAdministratorAdd, IO[bytes]], **kwargs: Any ) -> Optional[_models.ActiveDirectoryAdministrator]: error_map = { @@ -93,7 +93,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "ActiveDirectoryAdministratorAdd") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, server_name=server_name, object_id=object_id, @@ -102,16 +102,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,13 +132,9 @@ async def _create_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -168,14 +163,6 @@ async def begin_create( :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 ActiveDirectoryAdministrator or the result of cls(response) :rtype: @@ -189,7 +176,7 @@ async def begin_create( resource_group_name: str, server_name: str, object_id: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -205,18 +192,10 @@ async def begin_create( :type object_id: str :param parameters: The required parameters for adding an active directory administrator for a server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 ActiveDirectoryAdministrator or the result of cls(response) :rtype: @@ -230,7 +209,7 @@ async def begin_create( resource_group_name: str, server_name: str, object_id: str, - parameters: Union[_models.ActiveDirectoryAdministratorAdd, IO], + parameters: Union[_models.ActiveDirectoryAdministratorAdd, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ActiveDirectoryAdministrator]: """Creates a new server. @@ -243,20 +222,10 @@ async def begin_create( :param object_id: Guid of the objectId for the administrator. Required. :type object_id: str :param parameters: The required parameters for adding an active directory administrator for a - server. Is either a ActiveDirectoryAdministratorAdd type or a IO type. Required. + server. Is either a ActiveDirectoryAdministratorAdd type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ActiveDirectoryAdministratorAdd 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. + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ActiveDirectoryAdministratorAdd or + IO[bytes] :return: An instance of AsyncLROPoller that returns either ActiveDirectoryAdministrator or the result of cls(response) :rtype: @@ -290,7 +259,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("ActiveDirectoryAdministrator", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -303,17 +272,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ActiveDirectoryAdministrator].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" - } + return AsyncLROPoller[_models.ActiveDirectoryAdministrator]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any @@ -332,22 +299,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_name, object_id=object_id, 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -362,11 +328,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -381,14 +343,6 @@ async def begin_delete( :type server_name: str :param object_id: Guid of the objectId for the administrator. Required. :type object_id: 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: @@ -416,7 +370,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -427,17 +381,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -452,7 +402,6 @@ async def get( :type server_name: str :param object_id: Guid of the objectId for the administrator. Required. :type object_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ActiveDirectoryAdministrator or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ActiveDirectoryAdministrator :raises ~azure.core.exceptions.HttpResponseError: @@ -471,22 +420,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ActiveDirectoryAdministrator] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, object_id=object_id, 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -499,13 +447,9 @@ async def get( deserialized = self._deserialize("ActiveDirectoryAdministrator", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -518,7 +462,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActiveDirectoryAdministrator or the result of cls(response) :rtype: @@ -542,17 +485,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -564,13 +506,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("AdministratorListResult", pipeline_response) @@ -580,11 +522,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -596,7 +538,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_backups_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_backups_operations.py index 6d3da75a00dd..7ffc76a12663 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_backups_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_backups_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -67,7 +67,6 @@ async def get( :type server_name: str :param backup_name: The name of the backup. Required. :type backup_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerBackup or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerBackup :raises ~azure.core.exceptions.HttpResponseError: @@ -86,22 +85,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, backup_name=backup_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -114,13 +112,9 @@ async def get( deserialized = self._deserialize("ServerBackup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups/{backupName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -133,7 +127,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerBackup or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerBackup] @@ -156,17 +149,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -178,13 +170,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ServerBackupListResult", pipeline_response) @@ -194,11 +186,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -210,7 +202,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_check_name_availability_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_check_name_availability_operations.py index 150682a53f0d..1e57a18b45db 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_check_name_availability_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_check_name_availability_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -69,7 +69,6 @@ async def execute( :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: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -77,17 +76,16 @@ async def execute( @overload async def execute( - self, name_availability_request: IO, *, content_type: str = "application/json", **kwargs: Any + self, name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.NameAvailability: """Check the availability of name for resource. :param name_availability_request: The required parameters for checking if resource name is available. Required. - :type name_availability_request: IO + :type name_availability_request: IO[bytes] :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: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -95,18 +93,14 @@ async def execute( @distributed_trace_async async def execute( - self, name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO], **kwargs: Any + self, name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any ) -> _models.NameAvailability: """Check the availability of name for resource. :param name_availability_request: The required parameters for checking if resource name is - available. Is either a CheckNameAvailabilityRequest type or a IO type. Required. + available. Is either a CheckNameAvailabilityRequest type or a IO[bytes] type. Required. :type name_availability_request: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.CheckNameAvailabilityRequest 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 + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.CheckNameAvailabilityRequest or IO[bytes] :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -134,22 +128,21 @@ async def execute( else: _json = self._serialize.body(name_availability_request, "CheckNameAvailabilityRequest") - request = build_execute_request( + _request = build_execute_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.execute.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -162,10 +155,6 @@ async def execute( deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - execute.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_check_name_availability_with_location_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_check_name_availability_with_location_operations.py index 69c6e19fc953..79d466a4f17b 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_check_name_availability_with_location_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_check_name_availability_with_location_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -33,7 +33,7 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class CheckNameAvailabilityWithLocationOperations: +class CheckNameAvailabilityWithLocationOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -72,7 +72,6 @@ async def execute( :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: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -82,7 +81,7 @@ async def execute( async def execute( self, location_name: str, - name_availability_request: IO, + name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -93,11 +92,10 @@ async def execute( :type location_name: str :param name_availability_request: The required parameters for checking if resource name is available. Required. - :type name_availability_request: IO + :type name_availability_request: IO[bytes] :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: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -107,7 +105,7 @@ async def execute( async def execute( self, location_name: str, - name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO], + name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any ) -> _models.NameAvailability: """Check the availability of name for resource. @@ -115,13 +113,9 @@ async def execute( :param location_name: The name of the location. Required. :type location_name: str :param name_availability_request: The required parameters for checking if resource name is - available. Is either a CheckNameAvailabilityRequest type or a IO type. Required. + available. Is either a CheckNameAvailabilityRequest type or a IO[bytes] type. Required. :type name_availability_request: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.CheckNameAvailabilityRequest 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 + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.CheckNameAvailabilityRequest or IO[bytes] :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -149,23 +143,22 @@ async def execute( else: _json = self._serialize.body(name_availability_request, "CheckNameAvailabilityRequest") - request = build_execute_request( + _request = build_execute_request( location_name=location_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.execute.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -178,10 +171,6 @@ async def execute( deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - execute.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_configurations_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_configurations_operations.py index 0dbdd7bbed4d..decaf5963d87 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_configurations_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_configurations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -73,7 +73,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Configuration or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Configuration] @@ -96,17 +95,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,13 +116,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ConfigurationListResult", pipeline_response) @@ -134,11 +132,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,10 +149,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations" - } - @distributed_trace_async async def get( self, resource_group_name: str, server_name: str, configuration_name: str, **kwargs: Any @@ -168,7 +162,6 @@ async def get( :type server_name: str :param configuration_name: The name of the server configuration. Required. :type configuration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Configuration or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Configuration :raises ~azure.core.exceptions.HttpResponseError: @@ -187,22 +180,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, configuration_name=configuration_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,20 +207,16 @@ async def get( deserialized = self._deserialize("Configuration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" - } + return deserialized # type: ignore async def _update_initial( self, resource_group_name: str, server_name: str, configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO], + parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], **kwargs: Any ) -> Optional[_models.Configuration]: error_map = { @@ -254,7 +242,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "ConfigurationForUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, server_name=server_name, configuration_name=configuration_name, @@ -263,16 +251,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -294,13 +281,9 @@ async def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -327,14 +310,6 @@ async def begin_update( :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 Configuration or the result of cls(response) :rtype: @@ -348,7 +323,7 @@ async def begin_update( resource_group_name: str, server_name: str, configuration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -363,18 +338,10 @@ async def begin_update( :param configuration_name: The name of the server configuration. Required. :type configuration_name: str :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Configuration or the result of cls(response) :rtype: @@ -388,7 +355,7 @@ async def begin_update( resource_group_name: str, server_name: str, configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO], + parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Configuration]: """Updates a configuration of a server. @@ -401,20 +368,9 @@ async def begin_update( :param configuration_name: The name of the server configuration. Required. :type configuration_name: str :param parameters: The required parameters for updating a server configuration. Is either a - ConfigurationForUpdate type or a IO type. Required. + ConfigurationForUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ConfigurationForUpdate 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. + IO[bytes] :return: An instance of AsyncLROPoller that returns either Configuration or the result of cls(response) :rtype: @@ -448,7 +404,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Configuration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -461,24 +417,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Configuration].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.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" - } + return AsyncLROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _put_initial( self, resource_group_name: str, server_name: str, configuration_name: str, - parameters: Union[_models.Configuration, IO], + parameters: Union[_models.Configuration, IO[bytes]], **kwargs: Any ) -> Optional[_models.Configuration]: error_map = { @@ -504,7 +458,7 @@ async def _put_initial( else: _json = self._serialize.body(parameters, "Configuration") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, server_name=server_name, configuration_name=configuration_name, @@ -513,16 +467,15 @@ async def _put_initial( content_type=content_type, json=_json, content=_content, - template_url=self._put_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -544,13 +497,9 @@ async def _put_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _put_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" - } + return deserialized # type: ignore @overload async def begin_put( @@ -577,14 +526,6 @@ async def begin_put( :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 Configuration or the result of cls(response) :rtype: @@ -598,7 +539,7 @@ async def begin_put( resource_group_name: str, server_name: str, configuration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -613,18 +554,10 @@ async def begin_put( :param configuration_name: The name of the server configuration. Required. :type configuration_name: str :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Configuration or the result of cls(response) :rtype: @@ -638,7 +571,7 @@ async def begin_put( resource_group_name: str, server_name: str, configuration_name: str, - parameters: Union[_models.Configuration, IO], + parameters: Union[_models.Configuration, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Configuration]: """Updates a configuration of a server. @@ -651,19 +584,9 @@ async def begin_put( :param configuration_name: The name of the server configuration. Required. :type configuration_name: str :param parameters: The required parameters for updating a server configuration. Is either a - Configuration type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Configuration 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. + Configuration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Configuration or + IO[bytes] :return: An instance of AsyncLROPoller that returns either Configuration or the result of cls(response) :rtype: @@ -697,7 +620,7 @@ async def begin_put( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Configuration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -709,14 +632,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Configuration].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_put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" - } + return AsyncLROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_databases_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_databases_operations.py index 4589f800971b..96ac0e860624 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_databases_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_databases_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -67,7 +67,7 @@ async def _create_initial( resource_group_name: str, server_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any ) -> Optional[_models.Database]: error_map = { @@ -93,7 +93,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "Database") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, @@ -102,16 +102,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,13 +132,9 @@ async def _create_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -166,14 +161,6 @@ async def begin_create( :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 Database or the result of cls(response) :rtype: @@ -187,7 +174,7 @@ async def begin_create( resource_group_name: str, server_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -202,18 +189,10 @@ async def begin_create( :param database_name: The name of the database. Required. :type database_name: str :param parameters: The required parameters for creating or updating a database. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Database or the result of cls(response) :rtype: @@ -227,7 +206,7 @@ async def begin_create( resource_group_name: str, server_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Database]: """Creates a new database or updates an existing database. @@ -240,19 +219,8 @@ async def begin_create( :param database_name: The name of the database. Required. :type database_name: str :param parameters: The required parameters for creating or updating a database. Is either a - Database type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Database 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. + Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Database or IO[bytes] :return: An instance of AsyncLROPoller that returns either Database or the result of cls(response) :rtype: @@ -286,7 +254,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Database", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -299,17 +267,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Database].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" - } + return AsyncLROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any @@ -328,22 +294,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_name, database_name=database_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,11 +323,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -377,14 +338,6 @@ async def begin_delete( :type server_name: str :param database_name: The name of the database. Required. :type database_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: @@ -412,7 +365,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -423,17 +376,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -448,7 +397,6 @@ async def get( :type server_name: str :param database_name: The name of the database. Required. :type database_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Database or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Database :raises ~azure.core.exceptions.HttpResponseError: @@ -467,22 +415,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, database_name=database_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -495,13 +442,9 @@ async def get( deserialized = self._deserialize("Database", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -514,7 +457,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Database or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Database] @@ -537,17 +479,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -559,13 +500,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("DatabaseListResult", pipeline_response) @@ -575,11 +516,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -591,7 +532,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_firewall_rules_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_firewall_rules_operations.py index a9aff030320e..ba8c0903b511 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_firewall_rules_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_firewall_rules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -67,7 +67,7 @@ async def _create_or_update_initial( resource_group_name: str, server_name: str, firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO], + parameters: Union[_models.FirewallRule, IO[bytes]], **kwargs: Any ) -> Optional[_models.FirewallRule]: error_map = { @@ -93,7 +93,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "FirewallRule") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, server_name=server_name, firewall_rule_name=firewall_rule_name, @@ -102,16 +102,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -133,13 +132,9 @@ async def _create_or_update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -166,14 +161,6 @@ async def begin_create_or_update( :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 FirewallRule or the result of cls(response) :rtype: @@ -187,7 +174,7 @@ async def begin_create_or_update( resource_group_name: str, server_name: str, firewall_rule_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -202,18 +189,10 @@ async def begin_create_or_update( :param firewall_rule_name: The name of the server firewall rule. Required. :type firewall_rule_name: str :param parameters: The required parameters for creating or updating a firewall rule. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 FirewallRule or the result of cls(response) :rtype: @@ -227,7 +206,7 @@ async def begin_create_or_update( resource_group_name: str, server_name: str, firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO], + parameters: Union[_models.FirewallRule, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.FirewallRule]: """Creates a new firewall rule or updates an existing firewall rule. @@ -240,19 +219,8 @@ async def begin_create_or_update( :param firewall_rule_name: The name of the server firewall rule. Required. :type firewall_rule_name: str :param parameters: The required parameters for creating or updating a firewall rule. Is either - a FirewallRule type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.FirewallRule 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. + a FirewallRule type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.FirewallRule or IO[bytes] :return: An instance of AsyncLROPoller that returns either FirewallRule or the result of cls(response) :rtype: @@ -286,7 +254,7 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("FirewallRule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -299,17 +267,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.FirewallRule].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.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" - } + return AsyncLROPoller[_models.FirewallRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any @@ -328,22 +294,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_name, firewall_rule_name=firewall_rule_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,11 +323,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -377,14 +338,6 @@ async def begin_delete( :type server_name: str :param firewall_rule_name: The name of the server firewall rule. Required. :type firewall_rule_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: @@ -412,7 +365,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -423,17 +376,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -448,7 +397,6 @@ async def get( :type server_name: str :param firewall_rule_name: The name of the server firewall rule. Required. :type firewall_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FirewallRule or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: @@ -467,22 +415,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, firewall_rule_name=firewall_rule_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -495,13 +442,9 @@ async def get( deserialized = self._deserialize("FirewallRule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -514,7 +457,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FirewallRule or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.FirewallRule] @@ -537,17 +479,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -559,13 +500,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("FirewallRuleListResult", pipeline_response) @@ -575,11 +516,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -591,7 +532,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_flexible_server_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_flexible_server_operations.py index 0eca1948e8b0..6efa5dc37778 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_flexible_server_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_flexible_server_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -80,7 +80,6 @@ async def trigger_ltr_pre_backup( :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: LtrPreBackupResponse or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrPreBackupResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -91,7 +90,7 @@ async def trigger_ltr_pre_backup( self, resource_group_name: str, server_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -105,11 +104,10 @@ async def trigger_ltr_pre_backup( :param server_name: The name of the server. Required. :type server_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: LtrPreBackupResponse or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrPreBackupResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -120,7 +118,7 @@ async def trigger_ltr_pre_backup( self, resource_group_name: str, server_name: str, - parameters: Union[_models.LtrPreBackupRequest, IO], + parameters: Union[_models.LtrPreBackupRequest, IO[bytes]], **kwargs: Any ) -> _models.LtrPreBackupResponse: """PreBackup operation performs all the checks that are needed for the subsequent long term @@ -131,13 +129,10 @@ async def trigger_ltr_pre_backup( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param parameters: Request body for operation. Is either a LtrPreBackupRequest type or a IO - type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrPreBackupRequest 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 + :param parameters: Request body for operation. Is either a LtrPreBackupRequest type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrPreBackupRequest or + IO[bytes] :return: LtrPreBackupResponse or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrPreBackupResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -165,7 +160,7 @@ async def trigger_ltr_pre_backup( else: _json = self._serialize.body(parameters, "LtrPreBackupRequest") - request = build_trigger_ltr_pre_backup_request( + _request = build_trigger_ltr_pre_backup_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, @@ -173,16 +168,15 @@ async def trigger_ltr_pre_backup( content_type=content_type, json=_json, content=_content, - template_url=self.trigger_ltr_pre_backup.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -198,16 +192,16 @@ async def trigger_ltr_pre_backup( deserialized = self._deserialize("LtrPreBackupResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - trigger_ltr_pre_backup.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrPreBackup" - } + return deserialized # type: ignore async def _start_ltr_backup_initial( - self, resource_group_name: str, server_name: str, parameters: Union[_models.LtrBackupRequest, IO], **kwargs: Any + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.LtrBackupRequest, IO[bytes]], + **kwargs: Any ) -> Optional[_models.LtrBackupResponse]: error_map = { 401: ClientAuthenticationError, @@ -232,7 +226,7 @@ async def _start_ltr_backup_initial( else: _json = self._serialize.body(parameters, "LtrBackupRequest") - request = build_start_ltr_backup_request( + _request = build_start_ltr_backup_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, @@ -240,16 +234,15 @@ async def _start_ltr_backup_initial( content_type=content_type, json=_json, content=_content, - template_url=self._start_ltr_backup_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -275,13 +268,9 @@ async def _start_ltr_backup_initial( ) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _start_ltr_backup_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/startLtrBackup" - } + return deserialized # type: ignore @overload async def begin_start_ltr_backup( @@ -305,14 +294,6 @@ async def begin_start_ltr_backup( :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 LtrBackupResponse or the result of cls(response) :rtype: @@ -325,7 +306,7 @@ async def begin_start_ltr_backup( self, resource_group_name: str, server_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -338,18 +319,10 @@ async def begin_start_ltr_backup( :param server_name: The name of the server. Required. :type server_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 LtrBackupResponse or the result of cls(response) :rtype: @@ -359,7 +332,11 @@ async def begin_start_ltr_backup( @distributed_trace_async async def begin_start_ltr_backup( - self, resource_group_name: str, server_name: str, parameters: Union[_models.LtrBackupRequest, IO], **kwargs: Any + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.LtrBackupRequest, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.LtrBackupResponse]: """Start the Long Term Retention Backup operation. @@ -368,20 +345,10 @@ async def begin_start_ltr_backup( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param parameters: Request body for operation. Is either a LtrBackupRequest type or a IO type. - Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrBackupRequest 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. + :param parameters: Request body for operation. Is either a LtrBackupRequest type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrBackupRequest or + IO[bytes] :return: An instance of AsyncLROPoller that returns either LtrBackupResponse or the result of cls(response) :rtype: @@ -418,7 +385,7 @@ def get_long_running_output(pipeline_response): deserialized = self._deserialize("LtrBackupResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -430,14 +397,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.LtrBackupResponse].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_start_ltr_backup.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/startLtrBackup" - } + return AsyncLROPoller[_models.LtrBackupResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py index c7dba48c53fd..ad37233e789e 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_get_private_dns_zone_suffix_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -55,7 +55,6 @@ def __init__(self, *args, **kwargs) -> None: async def execute(self, **kwargs: Any) -> str: """Get private DNS zone suffix in the cloud. - :keyword callable cls: A custom type or function that will be passed the direct response :return: str or the result of cls(response) :rtype: str :raises ~azure.core.exceptions.HttpResponseError: @@ -74,18 +73,17 @@ async def execute(self, **kwargs: Any) -> str: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[str] = kwargs.pop("cls", None) - request = build_execute_request( + _request = build_execute_request( api_version=api_version, - template_url=self.execute.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -98,8 +96,6 @@ async def execute(self, **kwargs: Any) -> str: deserialized = self._deserialize("str", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - execute.metadata = {"url": "/providers/Microsoft.DBforPostgreSQL/getPrivateDnsZoneSuffix"} + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_location_based_capabilities_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_location_based_capabilities_operations.py index ff8d2ae94cd1..553686ede72c 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_location_based_capabilities_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_location_based_capabilities_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -59,7 +59,6 @@ def execute(self, location_name: str, **kwargs: Any) -> AsyncIterable["_models.F :param location_name: The name of the location. Required. :type location_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FlexibleServerCapability or the result of cls(response) :rtype: @@ -83,16 +82,15 @@ def execute(self, location_name: str, **kwargs: Any) -> AsyncIterable["_models.F def prepare_request(next_link=None): if not next_link: - request = build_execute_request( + _request = build_execute_request( location_name=location_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.execute.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -104,13 +102,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("CapabilitiesListResult", pipeline_response) @@ -120,11 +118,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -136,7 +134,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - execute.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/capabilities" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_log_files_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_log_files_operations.py index a1e35ddabce7..42b6840f1599 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_log_files_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_log_files_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -64,7 +64,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogFile or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.LogFile] @@ -87,17 +86,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,13 +107,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("LogFileListResult", pipeline_response) @@ -125,11 +123,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -141,7 +139,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/logFiles" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_ltr_backup_operations_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_ltr_backup_operations_operations.py index 84c5fd56ae51..0a4cc7fc4a4f 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_ltr_backup_operations_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_ltr_backup_operations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -67,7 +67,6 @@ async def get( :type server_name: str :param backup_name: The name of the backup. Required. :type backup_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LtrServerBackupOperation or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrServerBackupOperation :raises ~azure.core.exceptions.HttpResponseError: @@ -86,22 +85,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LtrServerBackupOperation] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, backup_name=backup_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -114,13 +112,9 @@ async def get( deserialized = self._deserialize("LtrServerBackupOperation", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrBackupOperations/{backupName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -133,7 +127,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LtrServerBackupOperation or the result of cls(response) :rtype: @@ -157,17 +150,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -179,13 +171,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("LtrServerBackupOperationList", pipeline_response) @@ -195,11 +187,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -211,7 +203,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrBackupOperations" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_migrations_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_migrations_operations.py index b59bf67b9519..4617d6da835a 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_migrations_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_migrations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -88,7 +88,6 @@ async def create( :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: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -101,7 +100,7 @@ async def create( resource_group_name: str, target_db_server_name: str, migration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -117,11 +116,10 @@ async def create( :param migration_name: The name of the migration. Required. :type migration_name: str :param parameters: The required parameters for creating a migration. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -134,7 +132,7 @@ async def create( resource_group_name: str, target_db_server_name: str, migration_name: str, - parameters: Union[_models.MigrationResource, IO], + parameters: Union[_models.MigrationResource, IO[bytes]], **kwargs: Any ) -> _models.MigrationResource: """Creates a new migration. @@ -148,12 +146,9 @@ async def create( :param migration_name: The name of the migration. Required. :type migration_name: str :param parameters: The required parameters for creating a migration. Is either a - MigrationResource type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource 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 + MigrationResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource or + IO[bytes] :return: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -181,7 +176,7 @@ async def create( else: _json = self._serialize.body(parameters, "MigrationResource") - request = build_create_request( + _request = build_create_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, @@ -190,16 +185,15 @@ async def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,10 +214,6 @@ async def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations/{migrationName}" - } - @distributed_trace_async async def get( self, @@ -243,7 +233,6 @@ async def get( :type target_db_server_name: str :param migration_name: The name of the migration. Required. :type migration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -262,22 +251,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MigrationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, migration_name=migration_name, 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -290,13 +278,9 @@ async def get( deserialized = self._deserialize("MigrationResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations/{migrationName}" - } + return deserialized # type: ignore @overload async def update( @@ -327,7 +311,6 @@ async def update( :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: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -340,7 +323,7 @@ async def update( resource_group_name: str, target_db_server_name: str, migration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -358,11 +341,10 @@ async def update( :param migration_name: The name of the migration. Required. :type migration_name: str :param parameters: The required parameters for updating a migration. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -375,7 +357,7 @@ async def update( resource_group_name: str, target_db_server_name: str, migration_name: str, - parameters: Union[_models.MigrationResourceForPatch, IO], + parameters: Union[_models.MigrationResourceForPatch, IO[bytes]], **kwargs: Any ) -> _models.MigrationResource: """Updates an existing migration. The request body can contain one to many of the mutable @@ -391,13 +373,9 @@ async def update( :param migration_name: The name of the migration. Required. :type migration_name: str :param parameters: The required parameters for updating a migration. Is either a - MigrationResourceForPatch type or a IO type. Required. + MigrationResourceForPatch type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResourceForPatch - 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 + or IO[bytes] :return: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -425,7 +403,7 @@ async def update( else: _json = self._serialize.body(parameters, "MigrationResourceForPatch") - request = build_update_request( + _request = build_update_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, @@ -434,16 +412,15 @@ async def update( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -456,13 +433,9 @@ async def update( deserialized = self._deserialize("MigrationResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations/{migrationName}" - } + return deserialized # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -483,7 +456,6 @@ async def delete( # pylint: disable=inconsistent-return-statements :type target_db_server_name: str :param migration_name: The name of the migration. Required. :type migration_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: @@ -502,22 +474,21 @@ async def delete( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, migration_name=migration_name, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -528,11 +499,7 @@ async def delete( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations/{migrationName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_target_server( @@ -555,7 +522,6 @@ def list_by_target_server( migrations. Known values are: "Active" and "All". Default value is None. :type migration_list_filter: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationListFilter - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MigrationResource or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource] @@ -578,18 +544,17 @@ def list_by_target_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_target_server_request( + _request = build_list_by_target_server_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, migration_list_filter=migration_list_filter, api_version=api_version, - template_url=self.list_by_target_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -601,13 +566,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("MigrationResourceListResult", pipeline_response) @@ -617,11 +582,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -633,7 +598,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_target_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_operations.py index 5bf9dea73d1b..65c105277e64 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -55,7 +55,6 @@ def __init__(self, *args, **kwargs) -> None: async def list(self, **kwargs: Any) -> _models.OperationListResult: """Lists all of the available REST API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationListResult or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.OperationListResult :raises ~azure.core.exceptions.HttpResponseError: @@ -74,18 +73,17 @@ async def list(self, **kwargs: Any) -> _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) - request = build_list_request( + _request = build_list_request( 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -98,8 +96,6 @@ async def list(self, **kwargs: Any) -> _models.OperationListResult: deserialized = self._deserialize("OperationListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = {"url": "/providers/Microsoft.DBforPostgreSQL/operations"} + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_postgre_sql_management_client_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_postgre_sql_management_client_operations.py index 69ffa12e1a7f..079b53c20015 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_postgre_sql_management_client_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_postgre_sql_management_client_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -33,7 +33,7 @@ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class PostgreSQLManagementClientOperationsMixin(PostgreSQLManagementClientMixinABC): +class PostgreSQLManagementClientOperationsMixin(PostgreSQLManagementClientMixinABC): # pylint: disable=name-too-long @overload async def check_migration_name_availability( self, @@ -62,7 +62,6 @@ async def check_migration_name_availability( :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: MigrationNameAvailabilityResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationNameAvailabilityResource :raises ~azure.core.exceptions.HttpResponseError: @@ -74,7 +73,7 @@ async def check_migration_name_availability( subscription_id: str, resource_group_name: str, target_db_server_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -91,11 +90,10 @@ async def check_migration_name_availability( :type target_db_server_name: str :param parameters: The required parameters for checking if a migration name is available. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: MigrationNameAvailabilityResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationNameAvailabilityResource :raises ~azure.core.exceptions.HttpResponseError: @@ -107,7 +105,7 @@ async def check_migration_name_availability( subscription_id: str, resource_group_name: str, target_db_server_name: str, - parameters: Union[_models.MigrationNameAvailabilityResource, IO], + parameters: Union[_models.MigrationNameAvailabilityResource, IO[bytes]], **kwargs: Any ) -> _models.MigrationNameAvailabilityResource: """Check migration name validity and availability. @@ -121,13 +119,10 @@ async def check_migration_name_availability( :param target_db_server_name: The name of the target database server. Required. :type target_db_server_name: str :param parameters: The required parameters for checking if a migration name is available. Is - either a MigrationNameAvailabilityResource type or a IO type. Required. + either a MigrationNameAvailabilityResource type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationNameAvailabilityResource 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 + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationNameAvailabilityResource or + IO[bytes] :return: MigrationNameAvailabilityResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationNameAvailabilityResource :raises ~azure.core.exceptions.HttpResponseError: @@ -155,7 +150,7 @@ async def check_migration_name_availability( else: _json = self._serialize.body(parameters, "MigrationNameAvailabilityResource") - request = build_check_migration_name_availability_request( + _request = build_check_migration_name_availability_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, @@ -163,16 +158,15 @@ async def check_migration_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_migration_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -185,10 +179,6 @@ async def check_migration_name_availability( deserialized = self._deserialize("MigrationNameAvailabilityResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_migration_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/checkMigrationNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_endpoint_connection_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_endpoint_connection_operations.py index 9e68f15e73d4..28302af0b37c 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_endpoint_connection_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_endpoint_connection_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -59,7 +59,7 @@ async def _update_initial( resource_group_name: str, server_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> Optional[_models.PrivateEndpointConnection]: error_map = { @@ -85,7 +85,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, server_name=server_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -94,16 +94,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -125,13 +124,9 @@ async def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -158,14 +153,6 @@ async def begin_update( :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 PrivateEndpointConnection or the result of cls(response) :rtype: @@ -179,7 +166,7 @@ async def begin_update( resource_group_name: str, server_name: str, private_endpoint_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -194,18 +181,10 @@ async def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param parameters: The required parameters for updating private endpoint connection. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 PrivateEndpointConnection or the result of cls(response) :rtype: @@ -219,7 +198,7 @@ async def begin_update( resource_group_name: str, server_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. @@ -232,20 +211,9 @@ async def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param parameters: The required parameters for updating private endpoint connection. Is either - a PrivateEndpointConnection type or a IO type. Required. + a PrivateEndpointConnection type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.PrivateEndpointConnection - 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. + or IO[bytes] :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -279,7 +247,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -289,17 +257,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.PrivateEndpointConnection].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.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -318,22 +284,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -348,11 +313,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -367,14 +328,6 @@ async def begin_delete( :type server_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. 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: @@ -402,7 +355,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -414,14 +367,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_endpoint_connections_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_endpoint_connections_operations.py index 0e3ecf8b2aa3..03cb307e9b38 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -67,7 +67,6 @@ async def get( :type server_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -86,22 +85,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -114,13 +112,9 @@ async def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -133,7 +127,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -157,17 +150,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -179,13 +171,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("PrivateEndpointConnectionListResult", pipeline_response) @@ -195,11 +187,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -211,7 +203,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_link_resources_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_link_resources_operations.py index 12f9bb8f7a76..bc339dcec7cb 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_link_resources_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -65,7 +65,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_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.rdbms.postgresql_flexibleservers.models.PrivateLinkResource] @@ -88,17 +87,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -110,13 +108,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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) @@ -126,11 +124,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -143,10 +141,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateLinkResources" - } - @distributed_trace_async async def get( self, resource_group_name: str, server_name: str, group_name: str, **kwargs: Any @@ -160,7 +154,6 @@ async def get( :type server_name: str :param group_name: The name of the private link resource. Required. :type group_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.rdbms.postgresql_flexibleservers.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: @@ -179,22 +172,21 @@ async def get( 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_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, group_name=group_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -207,10 +199,6 @@ async def get( deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateLinkResources/{groupName}" - } + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_quota_usages_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_quota_usages_operations.py index 8688c5b2a586..34dc315b76d4 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_quota_usages_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_quota_usages_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -59,7 +59,6 @@ def list(self, location_name: str, **kwargs: Any) -> AsyncIterable["_models.Quot :param location_name: The name of the location. Required. :type location_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either QuotaUsage or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.QuotaUsage] @@ -82,16 +81,15 @@ def list(self, location_name: str, **kwargs: Any) -> AsyncIterable["_models.Quot def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( location_name=location_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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -103,13 +101,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("QuotaUsagesListResult", pipeline_response) @@ -119,11 +117,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -135,7 +133,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/resourceType/flexibleServers/usages" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_replicas_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_replicas_operations.py index c2d1a250c20f..c4aaf33d525e 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_replicas_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_replicas_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -64,7 +64,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Server or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -87,17 +86,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -109,13 +107,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ServerListResult", pipeline_response) @@ -125,11 +123,11 @@ async def extract_data(pipeline_response): return None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -141,7 +139,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/replicas" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_server_capabilities_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_server_capabilities_operations.py index 659a8a38c512..11c8924bfbe6 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_server_capabilities_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_server_capabilities_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -64,7 +64,6 @@ def list( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FlexibleServerCapability or the result of cls(response) :rtype: @@ -88,17 +87,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, server_name=server_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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -110,13 +108,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("CapabilitiesListResult", pipeline_response) @@ -126,11 +124,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -142,7 +140,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/capabilities" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_server_threat_protection_settings_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_server_threat_protection_settings_operations.py index 7a51f7dbad93..829a14dd5375 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_server_threat_protection_settings_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_server_threat_protection_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -72,7 +72,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerThreatProtectionSettingsModel or the result of cls(response) :rtype: @@ -96,17 +95,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -118,13 +116,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ServerThreatProtectionListResult", pipeline_response) @@ -134,11 +132,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -151,10 +149,6 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings" - } - @distributed_trace_async async def get( self, @@ -173,7 +167,6 @@ async def get( :param threat_protection_name: The name of the Threat Protection state. "Default" Required. :type threat_protection_name: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ThreatProtectionName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerThreatProtectionSettingsModel or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerThreatProtectionSettingsModel :raises ~azure.core.exceptions.HttpResponseError: @@ -192,22 +185,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerThreatProtectionSettingsModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, threat_protection_name=threat_protection_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,20 +212,16 @@ async def get( deserialized = self._deserialize("ServerThreatProtectionSettingsModel", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{threatProtectionName}" - } + return deserialized # type: ignore async def _create_or_update_initial( self, resource_group_name: str, server_name: str, threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: Union[_models.ServerThreatProtectionSettingsModel, IO], + parameters: Union[_models.ServerThreatProtectionSettingsModel, IO[bytes]], **kwargs: Any ) -> Optional[_models.ServerThreatProtectionSettingsModel]: error_map = { @@ -259,7 +247,7 @@ async def _create_or_update_initial( else: _json = self._serialize.body(parameters, "ServerThreatProtectionSettingsModel") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, server_name=server_name, threat_protection_name=threat_protection_name, @@ -268,16 +256,15 @@ async def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -299,13 +286,9 @@ async def _create_or_update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{threatProtectionName}" - } + return deserialized # type: ignore @overload async def begin_create_or_update( @@ -334,14 +317,6 @@ async def begin_create_or_update( :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 ServerThreatProtectionSettingsModel or the result of cls(response) :rtype: @@ -355,7 +330,7 @@ async def begin_create_or_update( resource_group_name: str, server_name: str, threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -371,18 +346,10 @@ async def begin_create_or_update( :type threat_protection_name: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ThreatProtectionName :param parameters: The Advanced Threat Protection state for the flexible server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 ServerThreatProtectionSettingsModel or the result of cls(response) :rtype: @@ -396,7 +363,7 @@ async def begin_create_or_update( resource_group_name: str, server_name: str, threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: Union[_models.ServerThreatProtectionSettingsModel, IO], + parameters: Union[_models.ServerThreatProtectionSettingsModel, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.ServerThreatProtectionSettingsModel]: """Creates or updates a server's Advanced Threat Protection settings. @@ -410,20 +377,10 @@ async def begin_create_or_update( :type threat_protection_name: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ThreatProtectionName :param parameters: The Advanced Threat Protection state for the flexible server. Is either a - ServerThreatProtectionSettingsModel type or a IO type. Required. + ServerThreatProtectionSettingsModel type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerThreatProtectionSettingsModel 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. + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerThreatProtectionSettingsModel or + IO[bytes] :return: An instance of AsyncLROPoller that returns either ServerThreatProtectionSettingsModel or the result of cls(response) :rtype: @@ -457,7 +414,7 @@ async def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("ServerThreatProtectionSettingsModel", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -470,14 +427,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.ServerThreatProtectionSettingsModel].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.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{threatProtectionName}" - } + return AsyncLROPoller[_models.ServerThreatProtectionSettingsModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_servers_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_servers_operations.py index b290a89b5413..d252b03e18c0 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_servers_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_servers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -68,7 +68,7 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") async def _create_initial( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO], **kwargs: Any + self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any ) -> Optional[_models.Server]: error_map = { 401: ClientAuthenticationError, @@ -93,7 +93,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "Server") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, @@ -101,16 +101,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -132,13 +131,9 @@ async def _create_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -162,14 +157,6 @@ async def begin_create( :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 Server or the result of cls(response) :rtype: @@ -182,7 +169,7 @@ async def begin_create( self, resource_group_name: str, server_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -195,18 +182,10 @@ async def begin_create( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The required parameters for creating or updating a server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Server or the result of cls(response) :rtype: @@ -216,7 +195,7 @@ async def begin_create( @distributed_trace_async async def begin_create( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO], **kwargs: Any + self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.Server]: """Creates a new server. @@ -226,19 +205,8 @@ async def begin_create( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The required parameters for creating or updating a server. Is either a - Server type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server 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. + Server type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server or IO[bytes] :return: An instance of AsyncLROPoller that returns either Server or the result of cls(response) :rtype: @@ -271,7 +239,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Server", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -284,20 +252,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Server].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" - } + return AsyncLROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( - self, resource_group_name: str, server_name: str, parameters: Union[_models.ServerForUpdate, IO], **kwargs: Any + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerForUpdate, IO[bytes]], + **kwargs: Any ) -> Optional[_models.Server]: error_map = { 401: ClientAuthenticationError, @@ -322,7 +292,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "ServerForUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, @@ -330,16 +300,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -358,13 +327,9 @@ async def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -389,14 +354,6 @@ async def begin_update( :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 Server or the result of cls(response) :rtype: @@ -409,7 +366,7 @@ async def begin_update( self, resource_group_name: str, server_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -423,18 +380,10 @@ async def begin_update( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The required parameters for updating a server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Server or the result of cls(response) :rtype: @@ -444,7 +393,11 @@ async def begin_update( @distributed_trace_async async def begin_update( - self, resource_group_name: str, server_name: str, parameters: Union[_models.ServerForUpdate, IO], **kwargs: Any + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerForUpdate, IO[bytes]], + **kwargs: Any ) -> AsyncLROPoller[_models.Server]: """Updates an existing server. The request body can contain one to many of the properties present in the normal server definition. @@ -455,19 +408,9 @@ async def begin_update( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The required parameters for updating a server. Is either a ServerForUpdate - type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerForUpdate 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. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerForUpdate or + IO[bytes] :return: An instance of AsyncLROPoller that returns either Server or the result of cls(response) :rtype: @@ -500,7 +443,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Server", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -513,17 +456,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.Server].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.DBforPostgreSQL/flexibleServers/{serverName}" - } + return AsyncLROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, **kwargs: Any @@ -542,21 +483,20 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -571,11 +511,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -586,14 +522,6 @@ async def begin_delete(self, resource_group_name: str, server_name: str, **kwarg :type resource_group_name: str :param server_name: The name of the server. Required. :type server_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: @@ -620,7 +548,7 @@ async def begin_delete(self, resource_group_name: str, server_name: str, **kwarg def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -631,17 +559,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _models.Server: @@ -652,7 +576,6 @@ async def get(self, resource_group_name: str, server_name: str, **kwargs: Any) - :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Server or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server :raises ~azure.core.exceptions.HttpResponseError: @@ -671,21 +594,20 @@ async def get(self, resource_group_name: str, server_name: str, **kwargs: Any) - api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Server] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -698,13 +620,9 @@ async def get(self, resource_group_name: str, server_name: str, **kwargs: Any) - deserialized = self._deserialize("Server", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.Server"]: @@ -713,7 +631,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy :param resource_group_name: The name of the resource group. The name is case insensitive. 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 Server or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -736,16 +653,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -757,13 +673,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ServerListResult", pipeline_response) @@ -773,11 +689,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -790,15 +706,10 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers" - } - @distributed_trace def list(self, **kwargs: Any) -> AsyncIterable["_models.Server"]: """List all the servers in a given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Server or the result of cls(response) :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -821,15 +732,14 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Server"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -841,13 +751,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ServerListResult", pipeline_response) @@ -857,11 +767,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -874,13 +784,11 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/flexibleServers"} - async def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, - parameters: Optional[Union[_models.RestartParameter, IO]] = None, + parameters: Optional[Union[_models.RestartParameter, IO[bytes]]] = None, **kwargs: Any ) -> None: error_map = { @@ -909,7 +817,7 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements else: _json = None - request = build_restart_request( + _request = build_restart_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, @@ -917,16 +825,15 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._restart_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -941,11 +848,7 @@ async def _restart_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _restart_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/restart" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload async def begin_restart( @@ -969,14 +872,6 @@ async def begin_restart( :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -987,7 +882,7 @@ async def begin_restart( self, resource_group_name: str, server_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1000,18 +895,10 @@ async def begin_restart( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The parameters for restarting a server. Default value is None. - :type parameters: IO + :type parameters: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1022,7 +909,7 @@ async def begin_restart( self, resource_group_name: str, server_name: str, - parameters: Optional[Union[_models.RestartParameter, IO]] = None, + parameters: Optional[Union[_models.RestartParameter, IO[bytes]]] = None, **kwargs: Any ) -> AsyncLROPoller[None]: """Restarts a server. @@ -1033,19 +920,9 @@ async def begin_restart( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The parameters for restarting a server. Is either a RestartParameter type or - a IO type. Default value is None. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.RestartParameter 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. + a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.RestartParameter or + IO[bytes] :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: @@ -1075,7 +952,7 @@ async def begin_restart( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -1086,17 +963,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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_restart.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/restart" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, **kwargs: Any @@ -1115,21 +988,20 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1144,11 +1016,7 @@ async def _start_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/start" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1159,14 +1027,6 @@ async def begin_start(self, resource_group_name: str, server_name: str, **kwargs :type resource_group_name: str :param server_name: The name of the server. Required. :type server_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: @@ -1193,7 +1053,7 @@ async def begin_start(self, resource_group_name: str, server_name: str, **kwargs def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -1204,17 +1064,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/start" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore async def _stop_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, **kwargs: Any @@ -1233,21 +1089,20 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1262,11 +1117,7 @@ async def _stop_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _stop_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/stop" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> AsyncLROPoller[None]: @@ -1277,14 +1128,6 @@ async def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: :type resource_group_name: str :param server_name: The name of the server. Required. :type server_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: @@ -1311,7 +1154,7 @@ async def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -1322,14 +1165,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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_stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/stop" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_virtual_endpoints_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_virtual_endpoints_operations.py index 89d3b9fe75a7..2dcfd94cc951 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_virtual_endpoints_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_virtual_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -68,7 +68,7 @@ async def _create_initial( resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResource, IO], + parameters: Union[_models.VirtualEndpointResource, IO[bytes]], **kwargs: Any ) -> Optional[_models.VirtualEndpointResource]: error_map = { @@ -94,7 +94,7 @@ async def _create_initial( else: _json = self._serialize.body(parameters, "VirtualEndpointResource") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, server_name=server_name, virtual_endpoint_name=virtual_endpoint_name, @@ -103,16 +103,15 @@ async def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -134,13 +133,9 @@ async def _create_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return deserialized # type: ignore @overload async def begin_create( @@ -168,14 +163,6 @@ async def begin_create( :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 VirtualEndpointResource or the result of cls(response) :rtype: @@ -189,7 +176,7 @@ async def begin_create( resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -205,18 +192,10 @@ async def begin_create( :type virtual_endpoint_name: str :param parameters: The required parameters for creating or updating virtual endpoints. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 VirtualEndpointResource or the result of cls(response) :rtype: @@ -230,7 +209,7 @@ async def begin_create( resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResource, IO], + parameters: Union[_models.VirtualEndpointResource, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VirtualEndpointResource]: """Creates a new virtual endpoint for PostgreSQL flexible server. @@ -243,20 +222,9 @@ async def begin_create( :param virtual_endpoint_name: The name of the virtual endpoint. Required. :type virtual_endpoint_name: str :param parameters: The required parameters for creating or updating virtual endpoints. Is - either a VirtualEndpointResource type or a IO type. Required. + either a VirtualEndpointResource type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualEndpointResource - 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. + or IO[bytes] :return: An instance of AsyncLROPoller that returns either VirtualEndpointResource or the result of cls(response) :rtype: @@ -290,7 +258,7 @@ async def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualEndpointResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -303,24 +271,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VirtualEndpointResource].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return AsyncLROPoller[_models.VirtualEndpointResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _update_initial( self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResourceForPatch, IO], + parameters: Union[_models.VirtualEndpointResourceForPatch, IO[bytes]], **kwargs: Any ) -> Optional[_models.VirtualEndpointResource]: error_map = { @@ -346,7 +312,7 @@ async def _update_initial( else: _json = self._serialize.body(parameters, "VirtualEndpointResourceForPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, server_name=server_name, virtual_endpoint_name=virtual_endpoint_name, @@ -355,16 +321,15 @@ async def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -383,13 +348,9 @@ async def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return deserialized # type: ignore @overload async def begin_update( @@ -418,14 +379,6 @@ async def begin_update( :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 VirtualEndpointResource or the result of cls(response) :rtype: @@ -439,7 +392,7 @@ async def begin_update( resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -455,18 +408,10 @@ async def begin_update( :param virtual_endpoint_name: The name of the virtual endpoint. Required. :type virtual_endpoint_name: str :param parameters: The required parameters for updating a server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 VirtualEndpointResource or the result of cls(response) :rtype: @@ -480,7 +425,7 @@ async def begin_update( resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResourceForPatch, IO], + parameters: Union[_models.VirtualEndpointResourceForPatch, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.VirtualEndpointResource]: """Updates an existing virtual endpoint. The request body can contain one to many of the @@ -494,20 +439,10 @@ async def begin_update( :param virtual_endpoint_name: The name of the virtual endpoint. Required. :type virtual_endpoint_name: str :param parameters: The required parameters for updating a server. Is either a - VirtualEndpointResourceForPatch type or a IO type. Required. + VirtualEndpointResourceForPatch type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualEndpointResourceForPatch 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. + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualEndpointResourceForPatch or + IO[bytes] :return: An instance of AsyncLROPoller that returns either VirtualEndpointResource or the result of cls(response) :rtype: @@ -541,7 +476,7 @@ async def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualEndpointResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -554,17 +489,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[_models.VirtualEndpointResource].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.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return AsyncLROPoller[_models.VirtualEndpointResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) async def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any @@ -583,22 +516,21 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_name, virtual_endpoint_name=virtual_endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -613,11 +545,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace_async async def begin_delete( @@ -632,14 +560,6 @@ async def begin_delete( :type server_name: str :param virtual_endpoint_name: The name of the virtual endpoint. Required. :type virtual_endpoint_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: @@ -667,7 +587,7 @@ async def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: AsyncPollingMethod = cast( @@ -678,17 +598,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return AsyncLROPoller.from_continuation_token( + return AsyncLROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async async def get( @@ -703,7 +619,6 @@ async def get( :type server_name: str :param virtual_endpoint_name: The name of the virtual endpoint. Required. :type virtual_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualEndpointResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualEndpointResource :raises ~azure.core.exceptions.HttpResponseError: @@ -722,22 +637,21 @@ async def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualEndpointResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, virtual_endpoint_name=virtual_endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -750,13 +664,9 @@ async def get( deserialized = self._deserialize("VirtualEndpointResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -769,7 +679,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualEndpointResource or the result of cls(response) :rtype: @@ -793,17 +702,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -815,13 +723,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("VirtualEndpointsListResult", pipeline_response) @@ -831,11 +739,11 @@ async def extract_data(pipeline_response): return deserialized.next_link or None, AsyncList(list_of_elem) async def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -847,7 +755,3 @@ async def get_next(next_link=None): return pipeline_response return AsyncItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_virtual_network_subnet_usage_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_virtual_network_subnet_usage_operations.py index 252080bd4b52..7b4eab1463d0 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_virtual_network_subnet_usage_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_virtual_network_subnet_usage_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -71,7 +71,6 @@ async def execute( :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: VirtualNetworkSubnetUsageResult or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualNetworkSubnetUsageResult :raises ~azure.core.exceptions.HttpResponseError: @@ -79,18 +78,17 @@ async def execute( @overload async def execute( - self, location_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.VirtualNetworkSubnetUsageResult: """Get virtual network subnet usage for a given vNet resource id. :param location_name: The name of the location. Required. :type location_name: str :param parameters: The required parameters for creating or updating a server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: VirtualNetworkSubnetUsageResult or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualNetworkSubnetUsageResult :raises ~azure.core.exceptions.HttpResponseError: @@ -98,20 +96,20 @@ async def execute( @distributed_trace_async async def execute( - self, location_name: str, parameters: Union[_models.VirtualNetworkSubnetUsageParameter, IO], **kwargs: Any + self, + location_name: str, + parameters: Union[_models.VirtualNetworkSubnetUsageParameter, IO[bytes]], + **kwargs: Any ) -> _models.VirtualNetworkSubnetUsageResult: """Get virtual network subnet usage for a given vNet resource id. :param location_name: The name of the location. Required. :type location_name: str :param parameters: The required parameters for creating or updating a server. Is either a - VirtualNetworkSubnetUsageParameter type or a IO type. Required. + VirtualNetworkSubnetUsageParameter type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualNetworkSubnetUsageParameter 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 + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualNetworkSubnetUsageParameter or + IO[bytes] :return: VirtualNetworkSubnetUsageResult or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualNetworkSubnetUsageResult :raises ~azure.core.exceptions.HttpResponseError: @@ -139,23 +137,22 @@ async def execute( else: _json = self._serialize.body(parameters, "VirtualNetworkSubnetUsageParameter") - request = build_execute_request( + _request = build_execute_request( location_name=location_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.execute.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -168,10 +165,6 @@ async def execute( deserialized = self._deserialize("VirtualNetworkSubnetUsageResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - execute.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/checkVirtualNetworkSubnetUsage" - } + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/__init__.py index 519b896fcdd6..47290a333e72 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/__init__.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/__init__.py @@ -120,6 +120,7 @@ from ._postgre_sql_management_client_enums import IdentityType from ._postgre_sql_management_client_enums import KeyStatusEnum from ._postgre_sql_management_client_enums import LogicalReplicationOnSourceDbEnum +from ._postgre_sql_management_client_enums import MigrateRolesEnum from ._postgre_sql_management_client_enums import MigrationDbState from ._postgre_sql_management_client_enums import MigrationDetailsLevel from ._postgre_sql_management_client_enums import MigrationListFilter @@ -277,6 +278,7 @@ "IdentityType", "KeyStatusEnum", "LogicalReplicationOnSourceDbEnum", + "MigrateRolesEnum", "MigrationDbState", "MigrationDetailsLevel", "MigrationListFilter", diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/_models_py3.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/_models_py3.py index 20c65b903f9c..f0c7a015c06e 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/_models_py3.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/_models_py3.py @@ -23,7 +23,7 @@ class Resource(_serialization.Model): 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -65,7 +65,7 @@ class ProxyResource(Resource): 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -77,24 +77,6 @@ class ProxyResource(Resource): :vartype system_data: ~azure.mgmt.rdbms.postgresql_flexibleservers.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 ActiveDirectoryAdministrator(ProxyResource): """Represents an Active Directory administrator. @@ -102,7 +84,7 @@ class ActiveDirectoryAdministrator(ProxyResource): 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -216,7 +198,7 @@ def __init__( class AdminCredentials(_serialization.Model): """Server admin credentials. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar source_server_password: Password for source server. Required. :vartype source_server_password: str @@ -376,7 +358,7 @@ def __init__( class BackupRequestBase(_serialization.Model): """BackupRequestBase is the base for all backup request. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar backup_settings: Backup Settings. Required. :vartype backup_settings: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.BackupSettings @@ -402,7 +384,7 @@ def __init__(self, *, backup_settings: "_models.BackupSettings", **kwargs: Any) class BackupSettings(_serialization.Model): """The settings for the long term backup. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar backup_name: Backup Name for the current backup. Required. :vartype backup_name: str @@ -428,7 +410,7 @@ def __init__(self, *, backup_name: str, **kwargs: Any) -> None: class BackupStoreDetails(_serialization.Model): """Details about the target where the backup content will be stored. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar sas_uri_list: List of SAS uri of storage containers where backup data is to be streamed/copied. Required. @@ -586,7 +568,7 @@ class Configuration(ProxyResource): # pylint: disable=too-many-instance-attribu 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -789,7 +771,7 @@ class Database(ProxyResource): 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1356,10 +1338,10 @@ class FirewallRule(ProxyResource): 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1657,7 +1639,7 @@ class LogFile(ProxyResource): 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -1759,7 +1741,7 @@ def __init__( class LtrBackupRequest(BackupRequestBase): """The request that is made for a long term retention backup. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar backup_settings: Backup Settings. Required. :vartype backup_settings: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.BackupSettings @@ -1888,32 +1870,17 @@ def __init__( class LtrPreBackupRequest(BackupRequestBase): """A request that is made for pre-backup. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar backup_settings: Backup Settings. Required. :vartype backup_settings: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.BackupSettings """ - _validation = { - "backup_settings": {"required": True}, - } - - _attribute_map = { - "backup_settings": {"key": "backupSettings", "type": "BackupSettings"}, - } - - def __init__(self, *, backup_settings: "_models.BackupSettings", **kwargs: Any) -> None: - """ - :keyword backup_settings: Backup Settings. Required. - :paramtype backup_settings: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.BackupSettings - """ - super().__init__(backup_settings=backup_settings, **kwargs) - class LtrPreBackupResponse(_serialization.Model): """Response for the LTR pre-backup API call. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar number_of_containers: Number of storage containers the plugin will use during backup. More than one containers may be used for size limitations, parallelism, or redundancy etc. @@ -1946,7 +1913,7 @@ class LtrServerBackupOperation(ProxyResource): # pylint: disable=too-many-insta 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -2138,7 +2105,7 @@ class MigrationNameAvailabilityResource(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar name: The resource name to verify. Required. :vartype name: str @@ -2191,10 +2158,10 @@ class TrackedResource(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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -2244,10 +2211,10 @@ class MigrationResource(TrackedResource): # pylint: disable=too-many-instance-a 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -2265,6 +2232,8 @@ class MigrationResource(TrackedResource): # pylint: disable=too-many-instance-a :vartype migration_id: str :ivar current_status: Current status of migration. :vartype current_status: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationStatus + :ivar migration_instance_resource_id: ResourceId of the private endpoint migration instance. + :vartype migration_instance_resource_id: str :ivar migration_mode: There are two types of migration modes Online and Offline. Known values are: "Offline" and "Online". :vartype migration_mode: str or @@ -2273,9 +2242,10 @@ class MigrationResource(TrackedResource): # pylint: disable=too-many-instance-a values are: "Validate", "Migrate", and "ValidateAndMigrate". :vartype migration_option: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationOption - :ivar source_type: migration source server type : OnPremises, AWS, GCP, AzureVM or - PostgreSQLSingleServer. Known values are: "OnPremises", "AWS", "GCP", "AzureVM", and - "PostgreSQLSingleServer". + :ivar source_type: migration source server type : OnPremises, AWS, GCP, AzureVM, + PostgreSQLSingleServer, AWS_RDS, AWS_AURORA, AWS_EC2, GCP_CloudSQL, GCP_AlloyDB, GCP_Compute, + or EDB. Known values are: "OnPremises", "AWS", "GCP", "AzureVM", "PostgreSQLSingleServer", + "AWS_RDS", "AWS_AURORA", "AWS_EC2", "GCP_CloudSQL", "GCP_AlloyDB", "GCP_Compute", and "EDB". :vartype source_type: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.SourceType :ivar ssl_mode: SSL modes for migration. Default SSL mode for PostgreSQLSingleServer is VerifyFull and Prefer for other source types. Known values are: "Prefer", "Require", @@ -2318,6 +2288,10 @@ class MigrationResource(TrackedResource): # pylint: disable=too-many-instance-a :vartype migration_window_start_time_in_utc: ~datetime.datetime :ivar migration_window_end_time_in_utc: End time in UTC for migration window. :vartype migration_window_end_time_in_utc: ~datetime.datetime + :ivar migrate_roles: To migrate roles and permissions we need to send this flag as True. Known + values are: "True" and "False". + :vartype migrate_roles: str or + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrateRolesEnum :ivar start_data_migration: Indicates whether the data migration should start right away. Known values are: "True" and "False". :vartype start_data_migration: str or @@ -2360,6 +2334,7 @@ class MigrationResource(TrackedResource): # pylint: disable=too-many-instance-a "location": {"key": "location", "type": "str"}, "migration_id": {"key": "properties.migrationId", "type": "str"}, "current_status": {"key": "properties.currentStatus", "type": "MigrationStatus"}, + "migration_instance_resource_id": {"key": "properties.migrationInstanceResourceId", "type": "str"}, "migration_mode": {"key": "properties.migrationMode", "type": "str"}, "migration_option": {"key": "properties.migrationOption", "type": "str"}, "source_type": {"key": "properties.sourceType", "type": "str"}, @@ -2385,6 +2360,7 @@ class MigrationResource(TrackedResource): # pylint: disable=too-many-instance-a "overwrite_dbs_in_target": {"key": "properties.overwriteDbsInTarget", "type": "str"}, "migration_window_start_time_in_utc": {"key": "properties.migrationWindowStartTimeInUtc", "type": "iso-8601"}, "migration_window_end_time_in_utc": {"key": "properties.migrationWindowEndTimeInUtc", "type": "iso-8601"}, + "migrate_roles": {"key": "properties.migrateRoles", "type": "str"}, "start_data_migration": {"key": "properties.startDataMigration", "type": "str"}, "trigger_cutover": {"key": "properties.triggerCutover", "type": "str"}, "dbs_to_trigger_cutover_on": {"key": "properties.dbsToTriggerCutoverOn", "type": "[str]"}, @@ -2397,6 +2373,7 @@ def __init__( # pylint: disable=too-many-locals *, location: str, tags: Optional[Dict[str, str]] = None, + migration_instance_resource_id: Optional[str] = None, migration_mode: Optional[Union[str, "_models.MigrationMode"]] = None, migration_option: Optional[Union[str, "_models.MigrationOption"]] = None, source_type: Optional[Union[str, "_models.SourceType"]] = None, @@ -2412,6 +2389,7 @@ def __init__( # pylint: disable=too-many-locals overwrite_dbs_in_target: Optional[Union[str, "_models.OverwriteDbsInTargetEnum"]] = None, migration_window_start_time_in_utc: Optional[datetime.datetime] = None, migration_window_end_time_in_utc: Optional[datetime.datetime] = None, + migrate_roles: Optional[Union[str, "_models.MigrateRolesEnum"]] = None, start_data_migration: Optional[Union[str, "_models.StartDataMigrationEnum"]] = None, trigger_cutover: Optional[Union[str, "_models.TriggerCutoverEnum"]] = None, dbs_to_trigger_cutover_on: Optional[List[str]] = None, @@ -2424,6 +2402,8 @@ def __init__( # pylint: disable=too-many-locals :paramtype tags: dict[str, str] :keyword location: The geo-location where the resource lives. Required. :paramtype location: str + :keyword migration_instance_resource_id: ResourceId of the private endpoint migration instance. + :paramtype migration_instance_resource_id: str :keyword migration_mode: There are two types of migration modes Online and Offline. Known values are: "Offline" and "Online". :paramtype migration_mode: str or @@ -2432,9 +2412,10 @@ def __init__( # pylint: disable=too-many-locals Known values are: "Validate", "Migrate", and "ValidateAndMigrate". :paramtype migration_option: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationOption - :keyword source_type: migration source server type : OnPremises, AWS, GCP, AzureVM or - PostgreSQLSingleServer. Known values are: "OnPremises", "AWS", "GCP", "AzureVM", and - "PostgreSQLSingleServer". + :keyword source_type: migration source server type : OnPremises, AWS, GCP, AzureVM, + PostgreSQLSingleServer, AWS_RDS, AWS_AURORA, AWS_EC2, GCP_CloudSQL, GCP_AlloyDB, GCP_Compute, + or EDB. Known values are: "OnPremises", "AWS", "GCP", "AzureVM", "PostgreSQLSingleServer", + "AWS_RDS", "AWS_AURORA", "AWS_EC2", "GCP_CloudSQL", "GCP_AlloyDB", "GCP_Compute", and "EDB". :paramtype source_type: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.SourceType :keyword ssl_mode: SSL modes for migration. Default SSL mode for PostgreSQLSingleServer is VerifyFull and Prefer for other source types. Known values are: "Prefer", "Require", @@ -2471,6 +2452,10 @@ def __init__( # pylint: disable=too-many-locals :paramtype migration_window_start_time_in_utc: ~datetime.datetime :keyword migration_window_end_time_in_utc: End time in UTC for migration window. :paramtype migration_window_end_time_in_utc: ~datetime.datetime + :keyword migrate_roles: To migrate roles and permissions we need to send this flag as True. + Known values are: "True" and "False". + :paramtype migrate_roles: str or + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrateRolesEnum :keyword start_data_migration: Indicates whether the data migration should start right away. Known values are: "True" and "False". :paramtype start_data_migration: str or @@ -2492,6 +2477,7 @@ def __init__( # pylint: disable=too-many-locals super().__init__(tags=tags, location=location, **kwargs) self.migration_id = None self.current_status = None + self.migration_instance_resource_id = migration_instance_resource_id self.migration_mode = migration_mode self.migration_option = migration_option self.source_type = source_type @@ -2508,6 +2494,7 @@ def __init__( # pylint: disable=too-many-locals self.overwrite_dbs_in_target = overwrite_dbs_in_target self.migration_window_start_time_in_utc = migration_window_start_time_in_utc self.migration_window_end_time_in_utc = migration_window_end_time_in_utc + self.migrate_roles = migrate_roles self.start_data_migration = start_data_migration self.trigger_cutover = trigger_cutover self.dbs_to_trigger_cutover_on = dbs_to_trigger_cutover_on @@ -2545,6 +2532,10 @@ class MigrationResourceForPatch(_serialization.Model): # pylint: disable=too-ma ~azure.mgmt.rdbms.postgresql_flexibleservers.models.OverwriteDbsInTargetEnum :ivar migration_window_start_time_in_utc: Start time in UTC for migration window. :vartype migration_window_start_time_in_utc: ~datetime.datetime + :ivar migrate_roles: To migrate roles and permissions we need to send this flag as True. Known + values are: "True" and "False". + :vartype migrate_roles: str or + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrateRolesEnum :ivar start_data_migration: Indicates whether the data migration should start right away. Known values are: "True" and "False". :vartype start_data_migration: str or @@ -2591,6 +2582,7 @@ class MigrationResourceForPatch(_serialization.Model): # pylint: disable=too-ma }, "overwrite_dbs_in_target": {"key": "properties.overwriteDbsInTarget", "type": "str"}, "migration_window_start_time_in_utc": {"key": "properties.migrationWindowStartTimeInUtc", "type": "iso-8601"}, + "migrate_roles": {"key": "properties.migrateRoles", "type": "str"}, "start_data_migration": {"key": "properties.startDataMigration", "type": "str"}, "trigger_cutover": {"key": "properties.triggerCutover", "type": "str"}, "dbs_to_trigger_cutover_on": {"key": "properties.dbsToTriggerCutoverOn", "type": "[str]"}, @@ -2613,6 +2605,7 @@ def __init__( ] = None, overwrite_dbs_in_target: Optional[Union[str, "_models.OverwriteDbsInTargetEnum"]] = None, migration_window_start_time_in_utc: Optional[datetime.datetime] = None, + migrate_roles: Optional[Union[str, "_models.MigrateRolesEnum"]] = None, start_data_migration: Optional[Union[str, "_models.StartDataMigrationEnum"]] = None, trigger_cutover: Optional[Union[str, "_models.TriggerCutoverEnum"]] = None, dbs_to_trigger_cutover_on: Optional[List[str]] = None, @@ -2651,6 +2644,10 @@ def __init__( ~azure.mgmt.rdbms.postgresql_flexibleservers.models.OverwriteDbsInTargetEnum :keyword migration_window_start_time_in_utc: Start time in UTC for migration window. :paramtype migration_window_start_time_in_utc: ~datetime.datetime + :keyword migrate_roles: To migrate roles and permissions we need to send this flag as True. + Known values are: "True" and "False". + :paramtype migrate_roles: str or + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrateRolesEnum :keyword start_data_migration: Indicates whether the data migration should start right away. Known values are: "True" and "False". :paramtype start_data_migration: str or @@ -2683,6 +2680,7 @@ def __init__( self.setup_logical_replication_on_source_db_if_needed = setup_logical_replication_on_source_db_if_needed self.overwrite_dbs_in_target = overwrite_dbs_in_target self.migration_window_start_time_in_utc = migration_window_start_time_in_utc + self.migrate_roles = migrate_roles self.start_data_migration = start_data_migration self.trigger_cutover = trigger_cutover self.dbs_to_trigger_cutover_on = dbs_to_trigger_cutover_on @@ -2722,7 +2720,7 @@ def __init__(self, **kwargs: Any) -> None: class MigrationSecretParameters(_serialization.Model): """Migration secret parameters. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar admin_credentials: Admin credentials for source and target servers. Required. :vartype admin_credentials: @@ -3132,7 +3130,7 @@ class PrivateEndpointConnection(Resource): 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3237,7 +3235,7 @@ class PrivateLinkResource(Resource): 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3548,10 +3546,10 @@ class Server(TrackedResource): # pylint: disable=too-many-instance-attributes 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. + All required parameters must be populated in order to send to server. :ivar id: Fully qualified resource ID for the resource. E.g. - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -3791,7 +3789,7 @@ class ServerBackup(ProxyResource): 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -4168,7 +4166,7 @@ class ServerThreatProtectionSettingsModel(ProxyResource): 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str @@ -4257,7 +4255,7 @@ def __init__(self, **kwargs: Any) -> None: class Sku(_serialization.Model): """Sku information related properties of a server. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to server. :ivar name: The name of the sku, typically, tier + family + cores, e.g. Standard_D4s_v3. Required. @@ -4587,7 +4585,7 @@ class UserAssignedIdentity(_serialization.Model): 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. + All required parameters must be populated in order to send to server. :ivar user_assigned_identities: represents user assigned identities map. :vartype user_assigned_identities: dict[str, @@ -4845,7 +4843,7 @@ class VirtualEndpointResource(VirtualEndpointResourceForPatch, Resource): 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}". + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}". # pylint: disable=line-too-long :vartype id: str :ivar name: The name of the resource. :vartype name: str diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/_postgre_sql_management_client_enums.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/_postgre_sql_management_client_enums.py index 1f2487ae00f3..42b5a2ff9422 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/_postgre_sql_management_client_enums.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/_postgre_sql_management_client_enums.py @@ -184,6 +184,13 @@ class LogicalReplicationOnSourceDbEnum(str, Enum, metaclass=CaseInsensitiveEnumM FALSE = "False" +class MigrateRolesEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """To migrate roles and permissions we need to send this flag as True.""" + + TRUE = "True" + FALSE = "False" + + class MigrationDbState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Migration db state of an individual database.""" @@ -423,13 +430,22 @@ class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): class SourceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Migration source server type : OnPremises, AWS, GCP, AzureVM or PostgreSQLSingleServer.""" + """Migration source server type : OnPremises, AWS, GCP, AzureVM, PostgreSQLSingleServer, AWS_RDS, + AWS_AURORA, AWS_EC2, GCP_CloudSQL, GCP_AlloyDB, GCP_Compute, or EDB. + """ ON_PREMISES = "OnPremises" AWS = "AWS" GCP = "GCP" AZURE_VM = "AzureVM" POSTGRE_SQL_SINGLE_SERVER = "PostgreSQLSingleServer" + AWS_RDS = "AWS_RDS" + AWS_AURORA = "AWS_AURORA" + AWS_EC2 = "AWS_EC2" + GCP_CLOUD_SQL = "GCP_CloudSQL" + GCP_ALLOY_DB = "GCP_AlloyDB" + GCP_COMPUTE = "GCP_Compute" + EDB = "EDB" class SslMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_administrators_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_administrators_operations.py index 67bcd81edb88..6fc82595f301 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_administrators_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_administrators_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_create_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -84,7 +84,7 @@ def build_delete_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +120,7 @@ def build_get_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -156,7 +156,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -209,7 +209,7 @@ def _create_initial( resource_group_name: str, server_name: str, object_id: str, - parameters: Union[_models.ActiveDirectoryAdministratorAdd, IO], + parameters: Union[_models.ActiveDirectoryAdministratorAdd, IO[bytes]], **kwargs: Any ) -> Optional[_models.ActiveDirectoryAdministrator]: error_map = { @@ -235,7 +235,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "ActiveDirectoryAdministratorAdd") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, server_name=server_name, object_id=object_id, @@ -244,16 +244,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -275,13 +274,9 @@ def _create_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" - } + return deserialized # type: ignore @overload def begin_create( @@ -310,14 +305,6 @@ def begin_create( :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 ActiveDirectoryAdministrator or the result of cls(response) :rtype: @@ -331,7 +318,7 @@ def begin_create( resource_group_name: str, server_name: str, object_id: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -347,18 +334,10 @@ def begin_create( :type object_id: str :param parameters: The required parameters for adding an active directory administrator for a server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 ActiveDirectoryAdministrator or the result of cls(response) :rtype: @@ -372,7 +351,7 @@ def begin_create( resource_group_name: str, server_name: str, object_id: str, - parameters: Union[_models.ActiveDirectoryAdministratorAdd, IO], + parameters: Union[_models.ActiveDirectoryAdministratorAdd, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ActiveDirectoryAdministrator]: """Creates a new server. @@ -385,20 +364,10 @@ def begin_create( :param object_id: Guid of the objectId for the administrator. Required. :type object_id: str :param parameters: The required parameters for adding an active directory administrator for a - server. Is either a ActiveDirectoryAdministratorAdd type or a IO type. Required. + server. Is either a ActiveDirectoryAdministratorAdd type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ActiveDirectoryAdministratorAdd 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. + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ActiveDirectoryAdministratorAdd or + IO[bytes] :return: An instance of LROPoller that returns either ActiveDirectoryAdministrator or the result of cls(response) :rtype: @@ -432,7 +401,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("ActiveDirectoryAdministrator", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -444,17 +413,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ActiveDirectoryAdministrator].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" - } + return LROPoller[_models.ActiveDirectoryAdministrator]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, object_id: str, **kwargs: Any @@ -473,22 +440,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_name, object_id=object_id, 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -503,11 +469,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -522,14 +484,6 @@ def begin_delete( :type server_name: str :param object_id: Guid of the objectId for the administrator. Required. :type object_id: 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: @@ -557,7 +511,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -568,17 +522,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -593,7 +543,6 @@ def get( :type server_name: str :param object_id: Guid of the objectId for the administrator. Required. :type object_id: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ActiveDirectoryAdministrator or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ActiveDirectoryAdministrator :raises ~azure.core.exceptions.HttpResponseError: @@ -612,22 +561,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ActiveDirectoryAdministrator] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, object_id=object_id, 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -640,13 +588,9 @@ def get( deserialized = self._deserialize("ActiveDirectoryAdministrator", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators/{objectId}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -659,7 +603,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ActiveDirectoryAdministrator or the result of cls(response) :rtype: @@ -683,17 +626,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -705,13 +647,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("AdministratorListResult", pipeline_response) @@ -721,11 +663,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -737,7 +679,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/administrators" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_backups_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_backups_operations.py index a4f217903f17..0dcb36f1898e 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_backups_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_backups_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -42,7 +42,7 @@ def build_get_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +78,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -137,7 +137,6 @@ def get(self, resource_group_name: str, server_name: str, backup_name: str, **kw :type server_name: str :param backup_name: The name of the backup. Required. :type backup_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerBackup or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerBackup :raises ~azure.core.exceptions.HttpResponseError: @@ -156,22 +155,21 @@ def get(self, resource_group_name: str, server_name: str, backup_name: str, **kw api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerBackup] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, backup_name=backup_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -184,13 +182,9 @@ def get(self, resource_group_name: str, server_name: str, backup_name: str, **kw deserialized = self._deserialize("ServerBackup", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups/{backupName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -203,7 +197,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerBackup or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerBackup] @@ -226,17 +219,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -248,13 +240,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ServerBackupListResult", pipeline_response) @@ -264,11 +256,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -280,7 +272,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/backups" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_check_name_availability_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_check_name_availability_operations.py index 190e6e8c5dab..40df54f57bb1 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_check_name_availability_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_check_name_availability_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,7 +39,7 @@ def build_execute_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -100,7 +100,6 @@ def execute( :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: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -108,17 +107,16 @@ def execute( @overload def execute( - self, name_availability_request: IO, *, content_type: str = "application/json", **kwargs: Any + self, name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.NameAvailability: """Check the availability of name for resource. :param name_availability_request: The required parameters for checking if resource name is available. Required. - :type name_availability_request: IO + :type name_availability_request: IO[bytes] :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: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -126,18 +124,14 @@ def execute( @distributed_trace def execute( - self, name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO], **kwargs: Any + self, name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any ) -> _models.NameAvailability: """Check the availability of name for resource. :param name_availability_request: The required parameters for checking if resource name is - available. Is either a CheckNameAvailabilityRequest type or a IO type. Required. + available. Is either a CheckNameAvailabilityRequest type or a IO[bytes] type. Required. :type name_availability_request: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.CheckNameAvailabilityRequest 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 + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.CheckNameAvailabilityRequest or IO[bytes] :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -165,22 +159,21 @@ def execute( else: _json = self._serialize.body(name_availability_request, "CheckNameAvailabilityRequest") - request = build_execute_request( + _request = build_execute_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.execute.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -193,10 +186,6 @@ def execute( deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - execute.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_check_name_availability_with_location_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_check_name_availability_with_location_operations.py index 2a6758be447e..bd971a406b01 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_check_name_availability_with_location_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_check_name_availability_with_location_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,7 +39,7 @@ def build_execute_request(location_name: str, subscription_id: str, **kwargs: An _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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -66,7 +66,7 @@ def build_execute_request(location_name: str, subscription_id: str, **kwargs: An return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class CheckNameAvailabilityWithLocationOperations: +class CheckNameAvailabilityWithLocationOperations: # pylint: disable=name-too-long """ .. warning:: **DO NOT** instantiate this class directly. @@ -105,7 +105,6 @@ def execute( :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: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -115,7 +114,7 @@ def execute( def execute( self, location_name: str, - name_availability_request: IO, + name_availability_request: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -126,11 +125,10 @@ def execute( :type location_name: str :param name_availability_request: The required parameters for checking if resource name is available. Required. - :type name_availability_request: IO + :type name_availability_request: IO[bytes] :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: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -140,7 +138,7 @@ def execute( def execute( self, location_name: str, - name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO], + name_availability_request: Union[_models.CheckNameAvailabilityRequest, IO[bytes]], **kwargs: Any ) -> _models.NameAvailability: """Check the availability of name for resource. @@ -148,13 +146,9 @@ def execute( :param location_name: The name of the location. Required. :type location_name: str :param name_availability_request: The required parameters for checking if resource name is - available. Is either a CheckNameAvailabilityRequest type or a IO type. Required. + available. Is either a CheckNameAvailabilityRequest type or a IO[bytes] type. Required. :type name_availability_request: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.CheckNameAvailabilityRequest 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 + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.CheckNameAvailabilityRequest or IO[bytes] :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.NameAvailability :raises ~azure.core.exceptions.HttpResponseError: @@ -182,23 +176,22 @@ def execute( else: _json = self._serialize.body(name_availability_request, "CheckNameAvailabilityRequest") - request = build_execute_request( + _request = build_execute_request( location_name=location_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.execute.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -211,10 +204,6 @@ def execute( deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - execute.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/checkNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_configurations_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_configurations_operations.py index 96ff33ec192b..136a01f01f38 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_configurations_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_configurations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -80,7 +80,7 @@ def build_get_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,7 +118,7 @@ def build_update_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -159,7 +159,7 @@ def build_put_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -224,7 +224,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Configuration or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Configuration] @@ -247,17 +246,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -269,13 +267,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ConfigurationListResult", pipeline_response) @@ -285,11 +283,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -302,10 +300,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations" - } - @distributed_trace def get( self, resource_group_name: str, server_name: str, configuration_name: str, **kwargs: Any @@ -319,7 +313,6 @@ def get( :type server_name: str :param configuration_name: The name of the server configuration. Required. :type configuration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Configuration or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Configuration :raises ~azure.core.exceptions.HttpResponseError: @@ -338,22 +331,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Configuration] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, configuration_name=configuration_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -366,20 +358,16 @@ def get( deserialized = self._deserialize("Configuration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" - } + return deserialized # type: ignore def _update_initial( self, resource_group_name: str, server_name: str, configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO], + parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], **kwargs: Any ) -> Optional[_models.Configuration]: error_map = { @@ -405,7 +393,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "ConfigurationForUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, server_name=server_name, configuration_name=configuration_name, @@ -414,16 +402,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -445,13 +432,9 @@ def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -478,14 +461,6 @@ def begin_update( :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 Configuration or the result of cls(response) :rtype: @@ -499,7 +474,7 @@ def begin_update( resource_group_name: str, server_name: str, configuration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -514,18 +489,10 @@ def begin_update( :param configuration_name: The name of the server configuration. Required. :type configuration_name: str :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Configuration or the result of cls(response) :rtype: @@ -539,7 +506,7 @@ def begin_update( resource_group_name: str, server_name: str, configuration_name: str, - parameters: Union[_models.ConfigurationForUpdate, IO], + parameters: Union[_models.ConfigurationForUpdate, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Configuration]: """Updates a configuration of a server. @@ -552,20 +519,9 @@ def begin_update( :param configuration_name: The name of the server configuration. Required. :type configuration_name: str :param parameters: The required parameters for updating a server configuration. Is either a - ConfigurationForUpdate type or a IO type. Required. + ConfigurationForUpdate type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ConfigurationForUpdate 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. + IO[bytes] :return: An instance of LROPoller that returns either Configuration or the result of cls(response) :rtype: @@ -599,7 +555,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Configuration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -611,24 +567,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Configuration].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.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" - } + return LROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _put_initial( self, resource_group_name: str, server_name: str, configuration_name: str, - parameters: Union[_models.Configuration, IO], + parameters: Union[_models.Configuration, IO[bytes]], **kwargs: Any ) -> Optional[_models.Configuration]: error_map = { @@ -654,7 +608,7 @@ def _put_initial( else: _json = self._serialize.body(parameters, "Configuration") - request = build_put_request( + _request = build_put_request( resource_group_name=resource_group_name, server_name=server_name, configuration_name=configuration_name, @@ -663,16 +617,15 @@ def _put_initial( content_type=content_type, json=_json, content=_content, - template_url=self._put_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -694,13 +647,9 @@ def _put_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _put_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" - } + return deserialized # type: ignore @overload def begin_put( @@ -727,14 +676,6 @@ def begin_put( :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 Configuration or the result of cls(response) :rtype: @@ -748,7 +689,7 @@ def begin_put( resource_group_name: str, server_name: str, configuration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -763,18 +704,10 @@ def begin_put( :param configuration_name: The name of the server configuration. Required. :type configuration_name: str :param parameters: The required parameters for updating a server configuration. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Configuration or the result of cls(response) :rtype: @@ -788,7 +721,7 @@ def begin_put( resource_group_name: str, server_name: str, configuration_name: str, - parameters: Union[_models.Configuration, IO], + parameters: Union[_models.Configuration, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Configuration]: """Updates a configuration of a server. @@ -801,19 +734,9 @@ def begin_put( :param configuration_name: The name of the server configuration. Required. :type configuration_name: str :param parameters: The required parameters for updating a server configuration. Is either a - Configuration type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Configuration 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. + Configuration type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Configuration or + IO[bytes] :return: An instance of LROPoller that returns either Configuration or the result of cls(response) :rtype: @@ -847,7 +770,7 @@ def begin_put( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Configuration", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -859,14 +782,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Configuration].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_put.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/configurations/{configurationName}" - } + return LROPoller[_models.Configuration]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_databases_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_databases_operations.py index 73325028541f..15e0a4d1baf2 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_databases_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_databases_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_create_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -84,7 +84,7 @@ def build_delete_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -120,7 +120,7 @@ def build_get_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -156,7 +156,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -209,7 +209,7 @@ def _create_initial( resource_group_name: str, server_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any ) -> Optional[_models.Database]: error_map = { @@ -235,7 +235,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "Database") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, server_name=server_name, database_name=database_name, @@ -244,16 +244,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -275,13 +274,9 @@ def _create_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -308,14 +303,6 @@ def begin_create( :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 Database or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Database] @@ -328,7 +315,7 @@ def begin_create( resource_group_name: str, server_name: str, database_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -343,18 +330,10 @@ def begin_create( :param database_name: The name of the database. Required. :type database_name: str :param parameters: The required parameters for creating or updating a database. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Database or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Database] @@ -367,7 +346,7 @@ def begin_create( resource_group_name: str, server_name: str, database_name: str, - parameters: Union[_models.Database, IO], + parameters: Union[_models.Database, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Database]: """Creates a new database or updates an existing database. @@ -380,19 +359,8 @@ def begin_create( :param database_name: The name of the database. Required. :type database_name: str :param parameters: The required parameters for creating or updating a database. Is either a - Database type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Database 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. + Database type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Database or IO[bytes] :return: An instance of LROPoller that returns either Database or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Database] @@ -425,7 +393,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Database", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -437,17 +405,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Database].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" - } + return LROPoller[_models.Database]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any @@ -466,22 +432,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_name, database_name=database_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -496,11 +461,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -515,14 +476,6 @@ def begin_delete( :type server_name: str :param database_name: The name of the database. Required. :type database_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: @@ -550,7 +503,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -561,17 +514,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get(self, resource_group_name: str, server_name: str, database_name: str, **kwargs: Any) -> _models.Database: @@ -584,7 +533,6 @@ def get(self, resource_group_name: str, server_name: str, database_name: str, ** :type server_name: str :param database_name: The name of the database. Required. :type database_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Database or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Database :raises ~azure.core.exceptions.HttpResponseError: @@ -603,22 +551,21 @@ def get(self, resource_group_name: str, server_name: str, database_name: str, ** api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Database] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, database_name=database_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -631,13 +578,9 @@ def get(self, resource_group_name: str, server_name: str, database_name: str, ** deserialized = self._deserialize("Database", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases/{databaseName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server(self, resource_group_name: str, server_name: str, **kwargs: Any) -> Iterable["_models.Database"]: @@ -648,7 +591,6 @@ def list_by_server(self, resource_group_name: str, server_name: str, **kwargs: A :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Database or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Database] @@ -671,17 +613,16 @@ def list_by_server(self, resource_group_name: str, server_name: str, **kwargs: A def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -693,13 +634,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("DatabaseListResult", pipeline_response) @@ -709,11 +650,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -725,7 +666,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/databases" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_firewall_rules_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_firewall_rules_operations.py index 32d204727af4..5a7f3da515a1 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_firewall_rules_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_firewall_rules_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_create_or_update_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -86,7 +86,7 @@ def build_delete_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +124,7 @@ def build_get_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -162,7 +162,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -215,7 +215,7 @@ def _create_or_update_initial( resource_group_name: str, server_name: str, firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO], + parameters: Union[_models.FirewallRule, IO[bytes]], **kwargs: Any ) -> Optional[_models.FirewallRule]: error_map = { @@ -241,7 +241,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "FirewallRule") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, server_name=server_name, firewall_rule_name=firewall_rule_name, @@ -250,16 +250,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -281,13 +280,9 @@ def _create_or_update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -314,14 +309,6 @@ def begin_create_or_update( :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 FirewallRule or the result of cls(response) :rtype: @@ -335,7 +322,7 @@ def begin_create_or_update( resource_group_name: str, server_name: str, firewall_rule_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -350,18 +337,10 @@ def begin_create_or_update( :param firewall_rule_name: The name of the server firewall rule. Required. :type firewall_rule_name: str :param parameters: The required parameters for creating or updating a firewall rule. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 FirewallRule or the result of cls(response) :rtype: @@ -375,7 +354,7 @@ def begin_create_or_update( resource_group_name: str, server_name: str, firewall_rule_name: str, - parameters: Union[_models.FirewallRule, IO], + parameters: Union[_models.FirewallRule, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.FirewallRule]: """Creates a new firewall rule or updates an existing firewall rule. @@ -388,19 +367,8 @@ def begin_create_or_update( :param firewall_rule_name: The name of the server firewall rule. Required. :type firewall_rule_name: str :param parameters: The required parameters for creating or updating a firewall rule. Is either - a FirewallRule type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.FirewallRule 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. + a FirewallRule type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.FirewallRule or IO[bytes] :return: An instance of LROPoller that returns either FirewallRule or the result of cls(response) :rtype: @@ -434,7 +402,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("FirewallRule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -446,17 +414,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.FirewallRule].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.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" - } + return LROPoller[_models.FirewallRule]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, firewall_rule_name: str, **kwargs: Any @@ -475,22 +441,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_name, firewall_rule_name=firewall_rule_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -505,11 +470,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -524,14 +485,6 @@ def begin_delete( :type server_name: str :param firewall_rule_name: The name of the server firewall rule. Required. :type firewall_rule_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: @@ -559,7 +512,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -570,17 +523,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -595,7 +544,6 @@ def get( :type server_name: str :param firewall_rule_name: The name of the server firewall rule. Required. :type firewall_rule_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: FirewallRule or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.FirewallRule :raises ~azure.core.exceptions.HttpResponseError: @@ -614,22 +562,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.FirewallRule] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, firewall_rule_name=firewall_rule_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -642,13 +589,9 @@ def get( deserialized = self._deserialize("FirewallRule", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules/{firewallRuleName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -661,7 +604,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FirewallRule or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.FirewallRule] @@ -684,17 +626,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -706,13 +647,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("FirewallRuleListResult", pipeline_response) @@ -722,11 +663,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -738,7 +679,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/firewallRules" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_flexible_server_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_flexible_server_operations.py index 4aec292b4b29..cdfd04e6d8b7 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_flexible_server_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_flexible_server_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -43,7 +43,7 @@ def build_trigger_ltr_pre_backup_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -81,7 +81,7 @@ def build_start_ltr_backup_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -155,7 +155,6 @@ def trigger_ltr_pre_backup( :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: LtrPreBackupResponse or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrPreBackupResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -166,7 +165,7 @@ def trigger_ltr_pre_backup( self, resource_group_name: str, server_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -180,11 +179,10 @@ def trigger_ltr_pre_backup( :param server_name: The name of the server. Required. :type server_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: LtrPreBackupResponse or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrPreBackupResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -195,7 +193,7 @@ def trigger_ltr_pre_backup( self, resource_group_name: str, server_name: str, - parameters: Union[_models.LtrPreBackupRequest, IO], + parameters: Union[_models.LtrPreBackupRequest, IO[bytes]], **kwargs: Any ) -> _models.LtrPreBackupResponse: """PreBackup operation performs all the checks that are needed for the subsequent long term @@ -206,13 +204,10 @@ def trigger_ltr_pre_backup( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param parameters: Request body for operation. Is either a LtrPreBackupRequest type or a IO - type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrPreBackupRequest 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 + :param parameters: Request body for operation. Is either a LtrPreBackupRequest type or a + IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrPreBackupRequest or + IO[bytes] :return: LtrPreBackupResponse or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrPreBackupResponse :raises ~azure.core.exceptions.HttpResponseError: @@ -240,7 +235,7 @@ def trigger_ltr_pre_backup( else: _json = self._serialize.body(parameters, "LtrPreBackupRequest") - request = build_trigger_ltr_pre_backup_request( + _request = build_trigger_ltr_pre_backup_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, @@ -248,16 +243,15 @@ def trigger_ltr_pre_backup( content_type=content_type, json=_json, content=_content, - template_url=self.trigger_ltr_pre_backup.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -273,16 +267,16 @@ def trigger_ltr_pre_backup( deserialized = self._deserialize("LtrPreBackupResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - trigger_ltr_pre_backup.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrPreBackup" - } + return deserialized # type: ignore def _start_ltr_backup_initial( - self, resource_group_name: str, server_name: str, parameters: Union[_models.LtrBackupRequest, IO], **kwargs: Any + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.LtrBackupRequest, IO[bytes]], + **kwargs: Any ) -> Optional[_models.LtrBackupResponse]: error_map = { 401: ClientAuthenticationError, @@ -307,7 +301,7 @@ def _start_ltr_backup_initial( else: _json = self._serialize.body(parameters, "LtrBackupRequest") - request = build_start_ltr_backup_request( + _request = build_start_ltr_backup_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, @@ -315,16 +309,15 @@ def _start_ltr_backup_initial( content_type=content_type, json=_json, content=_content, - template_url=self._start_ltr_backup_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -350,13 +343,9 @@ def _start_ltr_backup_initial( ) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _start_ltr_backup_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/startLtrBackup" - } + return deserialized # type: ignore @overload def begin_start_ltr_backup( @@ -380,14 +369,6 @@ def begin_start_ltr_backup( :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 LtrBackupResponse or the result of cls(response) :rtype: @@ -400,7 +381,7 @@ def begin_start_ltr_backup( self, resource_group_name: str, server_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -413,18 +394,10 @@ def begin_start_ltr_backup( :param server_name: The name of the server. Required. :type server_name: str :param parameters: Request body for operation. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 LtrBackupResponse or the result of cls(response) :rtype: @@ -434,7 +407,11 @@ def begin_start_ltr_backup( @distributed_trace def begin_start_ltr_backup( - self, resource_group_name: str, server_name: str, parameters: Union[_models.LtrBackupRequest, IO], **kwargs: Any + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.LtrBackupRequest, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.LtrBackupResponse]: """Start the Long Term Retention Backup operation. @@ -443,20 +420,10 @@ def begin_start_ltr_backup( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :param parameters: Request body for operation. Is either a LtrBackupRequest type or a IO type. - Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrBackupRequest 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. + :param parameters: Request body for operation. Is either a LtrBackupRequest type or a IO[bytes] + type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrBackupRequest or + IO[bytes] :return: An instance of LROPoller that returns either LtrBackupResponse or the result of cls(response) :rtype: @@ -493,7 +460,7 @@ def get_long_running_output(pipeline_response): deserialized = self._deserialize("LtrBackupResponse", pipeline_response) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized if polling is True: @@ -505,14 +472,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.LtrBackupResponse].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_start_ltr_backup.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/startLtrBackup" - } + return LROPoller[_models.LtrBackupResponse]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_get_private_dns_zone_suffix_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_get_private_dns_zone_suffix_operations.py index 3ef38117197e..68be29f9878a 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_get_private_dns_zone_suffix_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_get_private_dns_zone_suffix_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,7 +38,7 @@ def build_execute_request(**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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +76,6 @@ def __init__(self, *args, **kwargs): def execute(self, **kwargs: Any) -> str: """Get private DNS zone suffix in the cloud. - :keyword callable cls: A custom type or function that will be passed the direct response :return: str or the result of cls(response) :rtype: str :raises ~azure.core.exceptions.HttpResponseError: @@ -95,18 +94,17 @@ def execute(self, **kwargs: Any) -> str: api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[str] = kwargs.pop("cls", None) - request = build_execute_request( + _request = build_execute_request( api_version=api_version, - template_url=self.execute.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -119,8 +117,6 @@ def execute(self, **kwargs: Any) -> str: deserialized = self._deserialize("str", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - execute.metadata = {"url": "/providers/Microsoft.DBforPostgreSQL/getPrivateDnsZoneSuffix"} + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_location_based_capabilities_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_location_based_capabilities_operations.py index 01e2855a642b..36ce6badddcb 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_location_based_capabilities_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_location_based_capabilities_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -40,7 +40,7 @@ def build_execute_request(location_name: str, subscription_id: str, **kwargs: An _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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +89,6 @@ def execute(self, location_name: str, **kwargs: Any) -> Iterable["_models.Flexib :param location_name: The name of the location. Required. :type location_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FlexibleServerCapability or the result of cls(response) :rtype: @@ -113,16 +112,15 @@ def execute(self, location_name: str, **kwargs: Any) -> Iterable["_models.Flexib def prepare_request(next_link=None): if not next_link: - request = build_execute_request( + _request = build_execute_request( location_name=location_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.execute.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -134,13 +132,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("CapabilitiesListResult", pipeline_response) @@ -150,11 +148,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -166,7 +164,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - execute.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/capabilities" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_log_files_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_log_files_operations.py index 1b37d972c064..e0a2320da27c 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_log_files_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_log_files_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -42,7 +42,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +99,6 @@ def list_by_server(self, resource_group_name: str, server_name: str, **kwargs: A :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LogFile or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.LogFile] @@ -122,17 +121,16 @@ def list_by_server(self, resource_group_name: str, server_name: str, **kwargs: A def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -144,13 +142,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("LogFileListResult", pipeline_response) @@ -160,11 +158,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -176,7 +174,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/logFiles" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_ltr_backup_operations_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_ltr_backup_operations_operations.py index 4c2db233368e..07121c0d4e33 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_ltr_backup_operations_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_ltr_backup_operations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -42,7 +42,7 @@ def build_get_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +78,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -139,7 +139,6 @@ def get( :type server_name: str :param backup_name: The name of the backup. Required. :type backup_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: LtrServerBackupOperation or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.LtrServerBackupOperation :raises ~azure.core.exceptions.HttpResponseError: @@ -158,22 +157,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.LtrServerBackupOperation] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, backup_name=backup_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -186,13 +184,9 @@ def get( deserialized = self._deserialize("LtrServerBackupOperation", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrBackupOperations/{backupName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -205,7 +199,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either LtrServerBackupOperation or the result of cls(response) :rtype: @@ -229,17 +222,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -251,13 +243,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("LtrServerBackupOperationList", pipeline_response) @@ -267,11 +259,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -283,7 +275,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/ltrBackupOperations" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_migrations_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_migrations_operations.py index 06632f75bfb5..51b5a8e801ae 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_migrations_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_migrations_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -43,7 +43,7 @@ def build_create_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -87,7 +87,7 @@ def build_get_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -128,7 +128,7 @@ def build_update_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -172,7 +172,7 @@ def build_delete_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -218,7 +218,7 @@ def build_list_by_target_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -300,7 +300,6 @@ def create( :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: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -313,7 +312,7 @@ def create( resource_group_name: str, target_db_server_name: str, migration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -329,11 +328,10 @@ def create( :param migration_name: The name of the migration. Required. :type migration_name: str :param parameters: The required parameters for creating a migration. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -346,7 +344,7 @@ def create( resource_group_name: str, target_db_server_name: str, migration_name: str, - parameters: Union[_models.MigrationResource, IO], + parameters: Union[_models.MigrationResource, IO[bytes]], **kwargs: Any ) -> _models.MigrationResource: """Creates a new migration. @@ -360,12 +358,9 @@ def create( :param migration_name: The name of the migration. Required. :type migration_name: str :param parameters: The required parameters for creating a migration. Is either a - MigrationResource type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource 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 + MigrationResource type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource or + IO[bytes] :return: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -393,7 +388,7 @@ def create( else: _json = self._serialize.body(parameters, "MigrationResource") - request = build_create_request( + _request = build_create_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, @@ -402,16 +397,15 @@ def create( content_type=content_type, json=_json, content=_content, - template_url=self.create.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -432,10 +426,6 @@ def create( return deserialized # type: ignore - create.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations/{migrationName}" - } - @distributed_trace def get( self, @@ -455,7 +445,6 @@ def get( :type target_db_server_name: str :param migration_name: The name of the migration. Required. :type migration_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -474,22 +463,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.MigrationResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, migration_name=migration_name, 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -502,13 +490,9 @@ def get( deserialized = self._deserialize("MigrationResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations/{migrationName}" - } + return deserialized # type: ignore @overload def update( @@ -539,7 +523,6 @@ def update( :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: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -552,7 +535,7 @@ def update( resource_group_name: str, target_db_server_name: str, migration_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -570,11 +553,10 @@ def update( :param migration_name: The name of the migration. Required. :type migration_name: str :param parameters: The required parameters for updating a migration. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -587,7 +569,7 @@ def update( resource_group_name: str, target_db_server_name: str, migration_name: str, - parameters: Union[_models.MigrationResourceForPatch, IO], + parameters: Union[_models.MigrationResourceForPatch, IO[bytes]], **kwargs: Any ) -> _models.MigrationResource: """Updates an existing migration. The request body can contain one to many of the mutable @@ -603,13 +585,9 @@ def update( :param migration_name: The name of the migration. Required. :type migration_name: str :param parameters: The required parameters for updating a migration. Is either a - MigrationResourceForPatch type or a IO type. Required. + MigrationResourceForPatch type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResourceForPatch - 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 + or IO[bytes] :return: MigrationResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource :raises ~azure.core.exceptions.HttpResponseError: @@ -637,7 +615,7 @@ def update( else: _json = self._serialize.body(parameters, "MigrationResourceForPatch") - request = build_update_request( + _request = build_update_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, @@ -646,16 +624,15 @@ def update( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -668,13 +645,9 @@ def update( deserialized = self._deserialize("MigrationResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - update.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations/{migrationName}" - } + return deserialized # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -695,7 +668,6 @@ def delete( # pylint: disable=inconsistent-return-statements :type target_db_server_name: str :param migration_name: The name of the migration. Required. :type migration_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: @@ -714,22 +686,21 @@ def delete( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, migration_name=migration_name, api_version=api_version, - template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -740,11 +711,7 @@ def delete( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations/{migrationName}" - } + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace def list_by_target_server( @@ -767,7 +734,6 @@ def list_by_target_server( migrations. Known values are: "Active" and "All". Default value is None. :type migration_list_filter: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationListFilter - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either MigrationResource or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationResource] @@ -790,18 +756,17 @@ def list_by_target_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_target_server_request( + _request = build_list_by_target_server_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, migration_list_filter=migration_list_filter, api_version=api_version, - template_url=self.list_by_target_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -813,13 +778,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("MigrationResourceListResult", pipeline_response) @@ -829,11 +794,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -845,7 +810,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_target_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/migrations" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_operations.py index 1b619ce80b76..79dbc5dd446c 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -38,7 +38,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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +76,6 @@ def __init__(self, *args, **kwargs): def list(self, **kwargs: Any) -> _models.OperationListResult: """Lists all of the available REST API operations. - :keyword callable cls: A custom type or function that will be passed the direct response :return: OperationListResult or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.OperationListResult :raises ~azure.core.exceptions.HttpResponseError: @@ -95,18 +94,17 @@ def list(self, **kwargs: Any) -> _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) - request = build_list_request( + _request = build_list_request( 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 = _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -119,8 +117,6 @@ def list(self, **kwargs: Any) -> _models.OperationListResult: deserialized = self._deserialize("OperationListResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - list.metadata = {"url": "/providers/Microsoft.DBforPostgreSQL/operations"} + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_postgre_sql_management_client_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_postgre_sql_management_client_operations.py index ffa2cd72662f..c08d47bb6a84 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_postgre_sql_management_client_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_postgre_sql_management_client_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -35,13 +35,13 @@ _SERIALIZER.client_side_validation = False -def build_check_migration_name_availability_request( +def build_check_migration_name_availability_request( # pylint: disable=name-too-long subscription_id: str, resource_group_name: str, target_db_server_name: 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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -78,7 +78,7 @@ def build_check_migration_name_availability_request( return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -class PostgreSQLManagementClientOperationsMixin(PostgreSQLManagementClientMixinABC): +class PostgreSQLManagementClientOperationsMixin(PostgreSQLManagementClientMixinABC): # pylint: disable=name-too-long @overload def check_migration_name_availability( self, @@ -107,7 +107,6 @@ def check_migration_name_availability( :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: MigrationNameAvailabilityResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationNameAvailabilityResource :raises ~azure.core.exceptions.HttpResponseError: @@ -119,7 +118,7 @@ def check_migration_name_availability( subscription_id: str, resource_group_name: str, target_db_server_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -136,11 +135,10 @@ def check_migration_name_availability( :type target_db_server_name: str :param parameters: The required parameters for checking if a migration name is available. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: MigrationNameAvailabilityResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationNameAvailabilityResource :raises ~azure.core.exceptions.HttpResponseError: @@ -152,7 +150,7 @@ def check_migration_name_availability( subscription_id: str, resource_group_name: str, target_db_server_name: str, - parameters: Union[_models.MigrationNameAvailabilityResource, IO], + parameters: Union[_models.MigrationNameAvailabilityResource, IO[bytes]], **kwargs: Any ) -> _models.MigrationNameAvailabilityResource: """Check migration name validity and availability. @@ -166,13 +164,10 @@ def check_migration_name_availability( :param target_db_server_name: The name of the target database server. Required. :type target_db_server_name: str :param parameters: The required parameters for checking if a migration name is available. Is - either a MigrationNameAvailabilityResource type or a IO type. Required. + either a MigrationNameAvailabilityResource type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationNameAvailabilityResource 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 + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationNameAvailabilityResource or + IO[bytes] :return: MigrationNameAvailabilityResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.MigrationNameAvailabilityResource :raises ~azure.core.exceptions.HttpResponseError: @@ -200,7 +195,7 @@ def check_migration_name_availability( else: _json = self._serialize.body(parameters, "MigrationNameAvailabilityResource") - request = build_check_migration_name_availability_request( + _request = build_check_migration_name_availability_request( subscription_id=subscription_id, resource_group_name=resource_group_name, target_db_server_name=target_db_server_name, @@ -208,16 +203,15 @@ def check_migration_name_availability( content_type=content_type, json=_json, content=_content, - template_url=self.check_migration_name_availability.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -230,10 +224,6 @@ def check_migration_name_availability( deserialized = self._deserialize("MigrationNameAvailabilityResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - check_migration_name_availability.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{targetDbServerName}/checkMigrationNameAvailability" - } + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_endpoint_connection_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_endpoint_connection_operations.py index f67f1559cafa..8ae1174f231c 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_endpoint_connection_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_endpoint_connection_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -47,7 +47,7 @@ def build_update_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -95,7 +95,7 @@ def build_delete_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,7 +154,7 @@ def _update_initial( resource_group_name: str, server_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> Optional[_models.PrivateEndpointConnection]: error_map = { @@ -180,7 +180,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "PrivateEndpointConnection") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, server_name=server_name, private_endpoint_connection_name=private_endpoint_connection_name, @@ -189,16 +189,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -220,13 +219,9 @@ def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -253,14 +248,6 @@ def begin_update( :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 PrivateEndpointConnection or the result of cls(response) :rtype: @@ -274,7 +261,7 @@ def begin_update( resource_group_name: str, server_name: str, private_endpoint_connection_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -289,18 +276,10 @@ def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param parameters: The required parameters for updating private endpoint connection. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 PrivateEndpointConnection or the result of cls(response) :rtype: @@ -314,7 +293,7 @@ def begin_update( resource_group_name: str, server_name: str, private_endpoint_connection_name: str, - parameters: Union[_models.PrivateEndpointConnection, IO], + parameters: Union[_models.PrivateEndpointConnection, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.PrivateEndpointConnection]: """Approve or reject a private endpoint connection with a given name. @@ -327,20 +306,9 @@ def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param parameters: The required parameters for updating private endpoint connection. Is either - a PrivateEndpointConnection type or a IO type. Required. + a PrivateEndpointConnection type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.PrivateEndpointConnection - 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. + or IO[bytes] :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -374,7 +342,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -384,17 +352,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.PrivateEndpointConnection].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.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[_models.PrivateEndpointConnection]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, private_endpoint_connection_name: str, **kwargs: Any @@ -413,22 +379,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -443,11 +408,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -462,14 +423,6 @@ def begin_delete( :type server_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. 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: @@ -497,7 +450,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -508,14 +461,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_endpoint_connections_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_endpoint_connections_operations.py index a4a103d58ecf..3b981ec79120 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_endpoint_connections_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_endpoint_connections_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -46,7 +46,7 @@ def build_get_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -87,7 +87,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +148,6 @@ def get( :type server_name: str :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.PrivateEndpointConnection :raises ~azure.core.exceptions.HttpResponseError: @@ -167,22 +166,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.PrivateEndpointConnection] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -195,13 +193,9 @@ def get( deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections/{privateEndpointConnectionName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -214,7 +208,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: @@ -238,17 +231,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -260,13 +252,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("PrivateEndpointConnectionListResult", pipeline_response) @@ -276,11 +268,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -292,7 +284,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateEndpointConnections" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_link_resources_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_link_resources_operations.py index 540a172407c0..b37e0bd263c9 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_link_resources_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_private_link_resources_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -42,7 +42,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -77,7 +77,7 @@ def build_get_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -137,7 +137,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_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.rdbms.postgresql_flexibleservers.models.PrivateLinkResource] @@ -160,17 +159,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -182,13 +180,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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) @@ -198,11 +196,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -215,10 +213,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateLinkResources" - } - @distributed_trace def get( self, resource_group_name: str, server_name: str, group_name: str, **kwargs: Any @@ -232,7 +226,6 @@ def get( :type server_name: str :param group_name: The name of the private link resource. Required. :type group_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.rdbms.postgresql_flexibleservers.models.PrivateLinkResource :raises ~azure.core.exceptions.HttpResponseError: @@ -251,22 +244,21 @@ def get( 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_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, group_name=group_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -279,10 +271,6 @@ def get( deserialized = self._deserialize("PrivateLinkResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/privateLinkResources/{groupName}" - } + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_quota_usages_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_quota_usages_operations.py index c21269fa7ddb..ada0950815cb 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_quota_usages_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_quota_usages_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -40,7 +40,7 @@ def build_list_request(location_name: str, subscription_id: str, **kwargs: Any) _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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,7 +89,6 @@ def list(self, location_name: str, **kwargs: Any) -> Iterable["_models.QuotaUsag :param location_name: The name of the location. Required. :type location_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either QuotaUsage or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.QuotaUsage] @@ -112,16 +111,15 @@ def list(self, location_name: str, **kwargs: Any) -> Iterable["_models.QuotaUsag def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( location_name=location_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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -133,13 +131,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("QuotaUsagesListResult", pipeline_response) @@ -149,11 +147,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -165,7 +163,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/resourceType/flexibleServers/usages" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_replicas_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_replicas_operations.py index d9b4c24a07fc..a6003e0e279f 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_replicas_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_replicas_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -42,7 +42,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +99,6 @@ def list_by_server(self, resource_group_name: str, server_name: str, **kwargs: A :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Server or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -122,17 +121,16 @@ def list_by_server(self, resource_group_name: str, server_name: str, **kwargs: A def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -144,13 +142,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ServerListResult", pipeline_response) @@ -160,11 +158,11 @@ def extract_data(pipeline_response): return None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -176,7 +174,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/replicas" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_server_capabilities_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_server_capabilities_operations.py index 1a1ff047c666..3169d3253eb5 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_server_capabilities_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_server_capabilities_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -40,7 +40,7 @@ def build_list_request(resource_group_name: str, server_name: str, subscription_ _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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +99,6 @@ def list( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either FlexibleServerCapability or the result of cls(response) :rtype: @@ -123,17 +122,16 @@ def list( def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( resource_group_name=resource_group_name, server_name=server_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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -145,13 +143,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("CapabilitiesListResult", pipeline_response) @@ -161,11 +159,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -177,7 +175,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/capabilities" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_server_threat_protection_settings_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_server_threat_protection_settings_operations.py index 35f91ff1977f..d396f2442c43 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_server_threat_protection_settings_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_server_threat_protection_settings_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +84,7 @@ def build_get_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -124,7 +124,7 @@ def build_create_or_update_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -187,7 +187,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ServerThreatProtectionSettingsModel or the result of cls(response) :rtype: @@ -211,17 +210,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -233,13 +231,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ServerThreatProtectionListResult", pipeline_response) @@ -249,11 +247,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -266,10 +264,6 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings" - } - @distributed_trace def get( self, @@ -288,7 +282,6 @@ def get( :param threat_protection_name: The name of the Threat Protection state. "Default" Required. :type threat_protection_name: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ThreatProtectionName - :keyword callable cls: A custom type or function that will be passed the direct response :return: ServerThreatProtectionSettingsModel or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerThreatProtectionSettingsModel :raises ~azure.core.exceptions.HttpResponseError: @@ -307,22 +300,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.ServerThreatProtectionSettingsModel] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, threat_protection_name=threat_protection_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -335,20 +327,16 @@ def get( deserialized = self._deserialize("ServerThreatProtectionSettingsModel", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{threatProtectionName}" - } + return deserialized # type: ignore def _create_or_update_initial( self, resource_group_name: str, server_name: str, threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: Union[_models.ServerThreatProtectionSettingsModel, IO], + parameters: Union[_models.ServerThreatProtectionSettingsModel, IO[bytes]], **kwargs: Any ) -> Optional[_models.ServerThreatProtectionSettingsModel]: error_map = { @@ -374,7 +362,7 @@ def _create_or_update_initial( else: _json = self._serialize.body(parameters, "ServerThreatProtectionSettingsModel") - request = build_create_or_update_request( + _request = build_create_or_update_request( resource_group_name=resource_group_name, server_name=server_name, threat_protection_name=threat_protection_name, @@ -383,16 +371,15 @@ def _create_or_update_initial( content_type=content_type, json=_json, content=_content, - 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -414,13 +401,9 @@ def _create_or_update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _create_or_update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{threatProtectionName}" - } + return deserialized # type: ignore @overload def begin_create_or_update( @@ -449,14 +432,6 @@ def begin_create_or_update( :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 ServerThreatProtectionSettingsModel or the result of cls(response) :rtype: @@ -470,7 +445,7 @@ def begin_create_or_update( resource_group_name: str, server_name: str, threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -486,18 +461,10 @@ def begin_create_or_update( :type threat_protection_name: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ThreatProtectionName :param parameters: The Advanced Threat Protection state for the flexible server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 ServerThreatProtectionSettingsModel or the result of cls(response) :rtype: @@ -511,7 +478,7 @@ def begin_create_or_update( resource_group_name: str, server_name: str, threat_protection_name: Union[str, _models.ThreatProtectionName], - parameters: Union[_models.ServerThreatProtectionSettingsModel, IO], + parameters: Union[_models.ServerThreatProtectionSettingsModel, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.ServerThreatProtectionSettingsModel]: """Creates or updates a server's Advanced Threat Protection settings. @@ -525,20 +492,10 @@ def begin_create_or_update( :type threat_protection_name: str or ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ThreatProtectionName :param parameters: The Advanced Threat Protection state for the flexible server. Is either a - ServerThreatProtectionSettingsModel type or a IO type. Required. + ServerThreatProtectionSettingsModel type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerThreatProtectionSettingsModel 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. + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerThreatProtectionSettingsModel or + IO[bytes] :return: An instance of LROPoller that returns either ServerThreatProtectionSettingsModel or the result of cls(response) :rtype: @@ -572,7 +529,7 @@ def begin_create_or_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("ServerThreatProtectionSettingsModel", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -584,14 +541,12 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.ServerThreatProtectionSettingsModel].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.DBforPostgreSQL/flexibleServers/{serverName}/advancedThreatProtectionSettings/{threatProtectionName}" - } + return LROPoller[_models.ServerThreatProtectionSettingsModel]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_servers_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_servers_operations.py index 183408556ffd..6e16acc7c18d 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_servers_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_servers_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_create_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -83,7 +83,7 @@ def build_update_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -121,7 +121,7 @@ def build_delete_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,7 +154,7 @@ def build_get_request(resource_group_name: str, server_name: str, subscription_i _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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +187,7 @@ def build_list_by_resource_group_request(resource_group_name: str, subscription_ _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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -217,7 +217,7 @@ def build_list_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: str = kwargs.pop("api_version", _params.pop("api-version", "2023-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,7 +245,7 @@ def build_restart_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -281,7 +281,7 @@ def build_start_request(resource_group_name: str, server_name: str, subscription _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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -314,7 +314,7 @@ def build_stop_request(resource_group_name: str, server_name: str, subscription_ _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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -363,7 +363,7 @@ def __init__(self, *args, **kwargs): self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") def _create_initial( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO], **kwargs: Any + self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any ) -> Optional[_models.Server]: error_map = { 401: ClientAuthenticationError, @@ -388,7 +388,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "Server") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, @@ -396,16 +396,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -427,13 +426,9 @@ def _create_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -457,14 +452,6 @@ def begin_create( :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 Server or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -476,7 +463,7 @@ def begin_create( self, resource_group_name: str, server_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -489,18 +476,10 @@ def begin_create( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The required parameters for creating or updating a server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Server or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -509,7 +488,7 @@ def begin_create( @distributed_trace def begin_create( - self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO], **kwargs: Any + self, resource_group_name: str, server_name: str, parameters: Union[_models.Server, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.Server]: """Creates a new server. @@ -519,19 +498,8 @@ def begin_create( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The required parameters for creating or updating a server. Is either a - Server type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server 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. + Server type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server or IO[bytes] :return: An instance of LROPoller that returns either Server or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -563,7 +531,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Server", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -575,20 +543,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Server].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" - } + return LROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( - self, resource_group_name: str, server_name: str, parameters: Union[_models.ServerForUpdate, IO], **kwargs: Any + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerForUpdate, IO[bytes]], + **kwargs: Any ) -> Optional[_models.Server]: error_map = { 401: ClientAuthenticationError, @@ -613,7 +583,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "ServerForUpdate") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, @@ -621,16 +591,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -649,13 +618,9 @@ def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -680,14 +645,6 @@ def begin_update( :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 Server or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -699,7 +656,7 @@ def begin_update( self, resource_group_name: str, server_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -713,18 +670,10 @@ def begin_update( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The required parameters for updating a server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 Server or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -733,7 +682,11 @@ def begin_update( @distributed_trace def begin_update( - self, resource_group_name: str, server_name: str, parameters: Union[_models.ServerForUpdate, IO], **kwargs: Any + self, + resource_group_name: str, + server_name: str, + parameters: Union[_models.ServerForUpdate, IO[bytes]], + **kwargs: Any ) -> LROPoller[_models.Server]: """Updates an existing server. The request body can contain one to many of the properties present in the normal server definition. @@ -744,19 +697,9 @@ def begin_update( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The required parameters for updating a server. Is either a ServerForUpdate - type or a IO type. Required. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerForUpdate 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. + type or a IO[bytes] type. Required. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.ServerForUpdate or + IO[bytes] :return: An instance of LROPoller that returns either Server or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -788,7 +731,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("Server", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -800,17 +743,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.Server].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.DBforPostgreSQL/flexibleServers/{serverName}" - } + return LROPoller[_models.Server]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, **kwargs: Any @@ -829,21 +770,20 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -858,11 +798,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: @@ -873,14 +809,6 @@ def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any :type resource_group_name: str :param server_name: The name of the server. Required. :type server_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: @@ -907,7 +835,7 @@ def begin_delete(self, resource_group_name: str, server_name: str, **kwargs: Any def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -918,17 +846,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _models.Server: @@ -939,7 +863,6 @@ def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _mod :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: Server or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server :raises ~azure.core.exceptions.HttpResponseError: @@ -958,21 +881,20 @@ def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _mod api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.Server] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -985,13 +907,9 @@ def get(self, resource_group_name: str, server_name: str, **kwargs: Any) -> _mod deserialized = self._deserialize("Server", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore - return deserialized - - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}" - } + return deserialized # type: ignore @distributed_trace def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.Server"]: @@ -1000,7 +918,6 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite :param resource_group_name: The name of the resource group. The name is case insensitive. 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 Server or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -1023,16 +940,15 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite def prepare_request(next_link=None): if not next_link: - request = build_list_by_resource_group_request( + _request = build_list_by_resource_group_request( resource_group_name=resource_group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1044,13 +960,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ServerListResult", pipeline_response) @@ -1060,11 +976,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1077,15 +993,10 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list_by_resource_group.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers" - } - @distributed_trace def list(self, **kwargs: Any) -> Iterable["_models.Server"]: """List all the servers in a given subscription. - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either Server or the result of cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server] @@ -1108,15 +1019,14 @@ def list(self, **kwargs: Any) -> Iterable["_models.Server"]: def prepare_request(next_link=None): if not next_link: - request = build_list_request( + _request = build_list_request( 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) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1128,13 +1038,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("ServerListResult", pipeline_response) @@ -1144,11 +1054,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1161,13 +1071,11 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) - list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/flexibleServers"} - def _restart_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, - parameters: Optional[Union[_models.RestartParameter, IO]] = None, + parameters: Optional[Union[_models.RestartParameter, IO[bytes]]] = None, **kwargs: Any ) -> None: error_map = { @@ -1196,7 +1104,7 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements else: _json = None - request = build_restart_request( + _request = build_restart_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, @@ -1204,16 +1112,15 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._restart_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1228,11 +1135,7 @@ def _restart_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _restart_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/restart" - } + return cls(pipeline_response, None, response_headers) # type: ignore @overload def begin_restart( @@ -1256,14 +1159,6 @@ def begin_restart( :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1274,7 +1169,7 @@ def begin_restart( self, resource_group_name: str, server_name: str, - parameters: Optional[IO] = None, + parameters: Optional[IO[bytes]] = None, *, content_type: str = "application/json", **kwargs: Any @@ -1287,18 +1182,10 @@ def begin_restart( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The parameters for restarting a server. Default value is None. - :type parameters: IO + :type parameters: IO[bytes] :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 None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: @@ -1309,7 +1196,7 @@ def begin_restart( self, resource_group_name: str, server_name: str, - parameters: Optional[Union[_models.RestartParameter, IO]] = None, + parameters: Optional[Union[_models.RestartParameter, IO[bytes]]] = None, **kwargs: Any ) -> LROPoller[None]: """Restarts a server. @@ -1320,19 +1207,9 @@ def begin_restart( :param server_name: The name of the server. Required. :type server_name: str :param parameters: The parameters for restarting a server. Is either a RestartParameter type or - a IO type. Default value is None. - :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.RestartParameter 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. + a IO[bytes] type. Default value is None. + :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.RestartParameter or + IO[bytes] :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: @@ -1362,7 +1239,7 @@ def begin_restart( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1373,17 +1250,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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_restart.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/restart" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _start_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, **kwargs: Any @@ -1402,21 +1275,20 @@ def _start_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_start_request( + _request = build_start_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._start_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1431,11 +1303,7 @@ def _start_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _start_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/start" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_start(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1446,14 +1314,6 @@ def begin_start(self, resource_group_name: str, server_name: str, **kwargs: Any) :type resource_group_name: str :param server_name: The name of the server. Required. :type server_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: @@ -1480,7 +1340,7 @@ def begin_start(self, resource_group_name: str, server_name: str, **kwargs: Any) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1491,17 +1351,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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_start.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/start" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore def _stop_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, **kwargs: Any @@ -1520,21 +1376,20 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[None] = kwargs.pop("cls", None) - request = build_stop_request( + _request = build_stop_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._stop_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1549,11 +1404,7 @@ def _stop_initial( # pylint: disable=inconsistent-return-statements response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, None, response_headers) - - _stop_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/stop" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) -> LROPoller[None]: @@ -1564,14 +1415,6 @@ def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) :type resource_group_name: str :param server_name: The name of the server. Required. :type server_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: @@ -1598,7 +1441,7 @@ def begin_stop(self, resource_group_name: str, server_name: str, **kwargs: Any) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -1609,14 +1452,10 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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_stop.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/stop" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_virtual_endpoints_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_virtual_endpoints_operations.py index f57ad1b133b0..bce3da1db64b 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_virtual_endpoints_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_virtual_endpoints_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -45,7 +45,7 @@ def build_create_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -91,7 +91,7 @@ def build_update_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -137,7 +137,7 @@ def build_delete_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -180,7 +180,7 @@ def build_get_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -223,7 +223,7 @@ def build_list_by_server_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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) accept = _headers.pop("Accept", "application/json") # Construct URL @@ -276,7 +276,7 @@ def _create_initial( resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResource, IO], + parameters: Union[_models.VirtualEndpointResource, IO[bytes]], **kwargs: Any ) -> Optional[_models.VirtualEndpointResource]: error_map = { @@ -302,7 +302,7 @@ def _create_initial( else: _json = self._serialize.body(parameters, "VirtualEndpointResource") - request = build_create_request( + _request = build_create_request( resource_group_name=resource_group_name, server_name=server_name, virtual_endpoint_name=virtual_endpoint_name, @@ -311,16 +311,15 @@ def _create_initial( content_type=content_type, json=_json, content=_content, - template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -342,13 +341,9 @@ def _create_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) + return cls(pipeline_response, deserialized, response_headers) # type: ignore - return deserialized - - _create_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return deserialized # type: ignore @overload def begin_create( @@ -376,14 +371,6 @@ def begin_create( :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 VirtualEndpointResource or the result of cls(response) :rtype: @@ -397,7 +384,7 @@ def begin_create( resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -413,18 +400,10 @@ def begin_create( :type virtual_endpoint_name: str :param parameters: The required parameters for creating or updating virtual endpoints. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 VirtualEndpointResource or the result of cls(response) :rtype: @@ -438,7 +417,7 @@ def begin_create( resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResource, IO], + parameters: Union[_models.VirtualEndpointResource, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualEndpointResource]: """Creates a new virtual endpoint for PostgreSQL flexible server. @@ -451,20 +430,9 @@ def begin_create( :param virtual_endpoint_name: The name of the virtual endpoint. Required. :type virtual_endpoint_name: str :param parameters: The required parameters for creating or updating virtual endpoints. Is - either a VirtualEndpointResource type or a IO type. Required. + either a VirtualEndpointResource type or a IO[bytes] type. Required. :type parameters: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualEndpointResource - 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. + or IO[bytes] :return: An instance of LROPoller that returns either VirtualEndpointResource or the result of cls(response) :rtype: @@ -498,7 +466,7 @@ def begin_create( def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualEndpointResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -510,24 +478,22 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VirtualEndpointResource].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.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return LROPoller[_models.VirtualEndpointResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _update_initial( self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResourceForPatch, IO], + parameters: Union[_models.VirtualEndpointResourceForPatch, IO[bytes]], **kwargs: Any ) -> Optional[_models.VirtualEndpointResource]: error_map = { @@ -553,7 +519,7 @@ def _update_initial( else: _json = self._serialize.body(parameters, "VirtualEndpointResourceForPatch") - request = build_update_request( + _request = build_update_request( resource_group_name=resource_group_name, server_name=server_name, virtual_endpoint_name=virtual_endpoint_name, @@ -562,16 +528,15 @@ def _update_initial( 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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -590,13 +555,9 @@ def _update_initial( response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) if cls: - return cls(pipeline_response, deserialized, response_headers) - - return deserialized + return cls(pipeline_response, deserialized, response_headers) # type: ignore - _update_initial.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return deserialized # type: ignore @overload def begin_update( @@ -625,14 +586,6 @@ def begin_update( :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 VirtualEndpointResource or the result of cls(response) :rtype: @@ -646,7 +599,7 @@ def begin_update( resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: IO, + parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any @@ -662,18 +615,10 @@ def begin_update( :param virtual_endpoint_name: The name of the virtual endpoint. Required. :type virtual_endpoint_name: str :param parameters: The required parameters for updating a server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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 VirtualEndpointResource or the result of cls(response) :rtype: @@ -687,7 +632,7 @@ def begin_update( resource_group_name: str, server_name: str, virtual_endpoint_name: str, - parameters: Union[_models.VirtualEndpointResourceForPatch, IO], + parameters: Union[_models.VirtualEndpointResourceForPatch, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.VirtualEndpointResource]: """Updates an existing virtual endpoint. The request body can contain one to many of the @@ -701,20 +646,10 @@ def begin_update( :param virtual_endpoint_name: The name of the virtual endpoint. Required. :type virtual_endpoint_name: str :param parameters: The required parameters for updating a server. Is either a - VirtualEndpointResourceForPatch type or a IO type. Required. + VirtualEndpointResourceForPatch type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualEndpointResourceForPatch 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. + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualEndpointResourceForPatch or + IO[bytes] :return: An instance of LROPoller that returns either VirtualEndpointResource or the result of cls(response) :rtype: @@ -748,7 +683,7 @@ def begin_update( def get_long_running_output(pipeline_response): deserialized = self._deserialize("VirtualEndpointResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized if polling is True: @@ -760,17 +695,15 @@ def get_long_running_output(pipeline_response): else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[_models.VirtualEndpointResource].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.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return LROPoller[_models.VirtualEndpointResource]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) def _delete_initial( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, server_name: str, virtual_endpoint_name: str, **kwargs: Any @@ -789,22 +722,21 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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( + _request = build_delete_request( resource_group_name=resource_group_name, server_name=server_name, virtual_endpoint_name=virtual_endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -819,11 +751,7 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements 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.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return cls(pipeline_response, None, response_headers) # type: ignore @distributed_trace def begin_delete( @@ -838,14 +766,6 @@ def begin_delete( :type server_name: str :param virtual_endpoint_name: The name of the virtual endpoint. Required. :type virtual_endpoint_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: @@ -873,7 +793,7 @@ def begin_delete( def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, None, {}) # type: ignore if polling is True: polling_method: PollingMethod = cast( @@ -884,17 +804,13 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- else: polling_method = polling if cont_token: - return LROPoller.from_continuation_token( + return LROPoller[None].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.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace def get( @@ -909,7 +825,6 @@ def get( :type server_name: str :param virtual_endpoint_name: The name of the virtual endpoint. Required. :type virtual_endpoint_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: VirtualEndpointResource or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualEndpointResource :raises ~azure.core.exceptions.HttpResponseError: @@ -928,22 +843,21 @@ def get( api_version: str = kwargs.pop("api_version", _params.pop("api-version", self._config.api_version)) cls: ClsType[_models.VirtualEndpointResource] = kwargs.pop("cls", None) - request = build_get_request( + _request = build_get_request( resource_group_name=resource_group_name, server_name=server_name, virtual_endpoint_name=virtual_endpoint_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) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -956,13 +870,9 @@ def get( deserialized = self._deserialize("VirtualEndpointResource", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - get.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints/{virtualEndpointName}" - } + return deserialized # type: ignore @distributed_trace def list_by_server( @@ -975,7 +885,6 @@ def list_by_server( :type resource_group_name: str :param server_name: The name of the server. Required. :type server_name: str - :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either VirtualEndpointResource or the result of cls(response) :rtype: @@ -999,17 +908,16 @@ def list_by_server( def prepare_request(next_link=None): if not next_link: - request = build_list_by_server_request( + _request = build_list_by_server_request( resource_group_name=resource_group_name, server_name=server_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_server.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _request = _convert_request(_request) + _request.url = self._client.format_url(_request.url) else: # make call to next link with the client's api-version @@ -1021,13 +929,13 @@ def prepare_request(next_link=None): } ) _next_request_params["api-version"] = self._config.api_version - request = HttpRequest( + _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 + _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("VirtualEndpointsListResult", pipeline_response) @@ -1037,11 +945,11 @@ def extract_data(pipeline_response): return deserialized.next_link or None, iter(list_of_elem) def get_next(next_link=None): - request = prepare_request(next_link) + _request = prepare_request(next_link) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - request, stream=_stream, **kwargs + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -1053,7 +961,3 @@ def get_next(next_link=None): return pipeline_response return ItemPaged(get_next, extract_data) - - list_by_server.metadata = { - "url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/virtualendpoints" - } diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_virtual_network_subnet_usage_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_virtual_network_subnet_usage_operations.py index e9622d8dc637..13443513efdc 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_virtual_network_subnet_usage_operations.py +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/operations/_virtual_network_subnet_usage_operations.py @@ -1,4 +1,4 @@ -# pylint: disable=too-many-lines +# pylint: disable=too-many-lines,too-many-statements # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -39,7 +39,7 @@ def build_execute_request(location_name: str, subscription_id: str, **kwargs: An _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-06-01-preview")) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "2023-12-01-preview")) content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) accept = _headers.pop("Accept", "application/json") @@ -104,7 +104,6 @@ def execute( :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: VirtualNetworkSubnetUsageResult or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualNetworkSubnetUsageResult :raises ~azure.core.exceptions.HttpResponseError: @@ -112,18 +111,17 @@ def execute( @overload def execute( - self, location_name: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + self, location_name: str, parameters: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> _models.VirtualNetworkSubnetUsageResult: """Get virtual network subnet usage for a given vNet resource id. :param location_name: The name of the location. Required. :type location_name: str :param parameters: The required parameters for creating or updating a server. Required. - :type parameters: IO + :type parameters: IO[bytes] :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: VirtualNetworkSubnetUsageResult or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualNetworkSubnetUsageResult :raises ~azure.core.exceptions.HttpResponseError: @@ -131,20 +129,20 @@ def execute( @distributed_trace def execute( - self, location_name: str, parameters: Union[_models.VirtualNetworkSubnetUsageParameter, IO], **kwargs: Any + self, + location_name: str, + parameters: Union[_models.VirtualNetworkSubnetUsageParameter, IO[bytes]], + **kwargs: Any ) -> _models.VirtualNetworkSubnetUsageResult: """Get virtual network subnet usage for a given vNet resource id. :param location_name: The name of the location. Required. :type location_name: str :param parameters: The required parameters for creating or updating a server. Is either a - VirtualNetworkSubnetUsageParameter type or a IO type. Required. + VirtualNetworkSubnetUsageParameter type or a IO[bytes] type. Required. :type parameters: - ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualNetworkSubnetUsageParameter 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 + ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualNetworkSubnetUsageParameter or + IO[bytes] :return: VirtualNetworkSubnetUsageResult or the result of cls(response) :rtype: ~azure.mgmt.rdbms.postgresql_flexibleservers.models.VirtualNetworkSubnetUsageResult :raises ~azure.core.exceptions.HttpResponseError: @@ -172,23 +170,22 @@ def execute( else: _json = self._serialize.body(parameters, "VirtualNetworkSubnetUsageParameter") - request = build_execute_request( + _request = build_execute_request( location_name=location_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, content=_content, - template_url=self.execute.metadata["url"], headers=_headers, params=_params, ) - request = _convert_request(request) - request.url = self._client.format_url(request.url) + _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 + _request, stream=_stream, **kwargs ) response = pipeline_response.http_response @@ -201,10 +198,6 @@ def execute( deserialized = self._deserialize("VirtualNetworkSubnetUsageResult", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) - - return deserialized + return cls(pipeline_response, deserialized, {}) # type: ignore - execute.metadata = { - "url": "/subscriptions/{subscriptionId}/providers/Microsoft.DBforPostgreSQL/locations/{locationName}/checkVirtualNetworkSubnetUsage" - } + return deserialized # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_add.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_add.py index a6a71911c146..8f9e0505b090 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_add.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_add.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -44,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/AdministratorAdd.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/AdministratorAdd.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_delete.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_delete.py index 299567458c29..4023dbfb69aa 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_delete.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/AdministratorDelete.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/AdministratorDelete.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_get.py index b32532f32406..6d4be14a6bcd 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrator_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/AdministratorGet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/AdministratorGet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrators_list_by_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrators_list_by_server.py index 9165b4889f58..f213b4fd33f2 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrators_list_by_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/administrators_list_by_server.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/AdministratorsListByServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/AdministratorsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/backup_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/backup_get.py index be283e225a5b..dc7f55677912 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/backup_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/backup_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/BackupGet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/BackupGet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/backup_list_by_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/backup_list_by_server.py index a0414f4fa271..24832231faf6 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/backup_list_by_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/backup_list_by_server.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/BackupListByServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/BackupListByServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/capabilities_by_location.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/capabilities_by_location.py index c3f0b044cfa2..19d4b8cdeef7 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/capabilities_by_location.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/capabilities_by_location.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/CapabilitiesByLocation.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/CapabilitiesByLocation.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_migration_name_availability.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_migration_name_availability.py index d8d956dcb247..9199ce0d682f 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_migration_name_availability.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_migration_name_availability.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/CheckMigrationNameAvailability.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/CheckMigrationNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_name_availability.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_name_availability.py index 7359079b8c23..a806bbc676ca 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_name_availability.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_name_availability.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -35,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/CheckNameAvailability.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/CheckNameAvailability.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_name_availability_location_based.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_name_availability_location_based.py index e444f22e4cf9..8ab30403cc38 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_name_availability_location_based.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/check_name_availability_location_based.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/CheckNameAvailabilityLocationBased.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/CheckNameAvailabilityLocationBased.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_get.py index 8bd1dbba531a..dc772202c14e 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ConfigurationGet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ConfigurationGet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_list_by_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_list_by_server.py index 38ee6a1be1d4..e1610b639b1e 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_list_by_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_list_by_server.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ConfigurationListByServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ConfigurationListByServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_update.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_update.py index de3a34977887..0a4570dbc507 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_update.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/configuration_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ConfigurationUpdate.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ConfigurationUpdate.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_create.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_create.py index 736406c93830..9e057bae1663 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_create.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/DatabaseCreate.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/DatabaseCreate.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_delete.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_delete.py index b3b20c9a6a72..6e1fef39a649 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_delete.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/DatabaseDelete.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/DatabaseDelete.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_get.py index 19c64860c69d..67fe0553ad75 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/database_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/DatabaseGet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/DatabaseGet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/databases_list_by_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/databases_list_by_server.py index be2ab0f74d7b..ba524ab01eb5 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/databases_list_by_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/databases_list_by_server.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/DatabasesListByServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/DatabasesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_create.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_create.py index d241ceec4c11..052e5073e84c 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_create.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/FirewallRuleCreate.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/FirewallRuleCreate.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_delete.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_delete.py index 9509e3856774..1eee7a143540 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_delete.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/FirewallRuleDelete.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/FirewallRuleDelete.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_get.py index 5cafdf86a260..d1659caead08 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/FirewallRuleGet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/FirewallRuleGet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_list_by_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_list_by_server.py index 50b8545c4fde..e936cba9add8 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_list_by_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/firewall_rule_list_by_server.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/FirewallRuleListByServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/FirewallRuleListByServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/get_private_dns_zone_suffix.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/get_private_dns_zone_suffix.py index a8f0a9c9d9b1..634756ba22e2 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/get_private_dns_zone_suffix.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/get_private_dns_zone_suffix.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -33,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/GetPrivateDnsZoneSuffix.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/GetPrivateDnsZoneSuffix.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/log_files_list_by_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/log_files_list_by_server.py index cdf23eaefff5..427ffe6e2d7a 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/log_files_list_by_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/log_files_list_by_server.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/LogFilesListByServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/LogFilesListByServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_backup.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_backup.py index 5dd7f5b38a9f..1ec3cd5d72d3 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_backup.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_backup.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/LongTermRetentionBackup.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/LongTermRetentionBackup.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_operation_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_operation_get.py index 3aa7e3e67bce..f6b8d0eba43f 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_operation_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_operation_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/LongTermRetentionOperationGet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/LongTermRetentionOperationGet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_operation_list_by_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_operation_list_by_server.py index bcdbd4a7bfe9..a84bf99973a7 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_operation_list_by_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_operation_list_by_server.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/LongTermRetentionOperationListByServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/LongTermRetentionOperationListByServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_pre_backup.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_pre_backup.py index 0d8a116e1c17..e4b0f37689ca 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_pre_backup.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/long_term_retention_pre_backup.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/LongTermRetentionPreBackup.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/LongTermRetentionPreBackup.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_cancel.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_cancel.py index 0c2c4aa70f1c..9e4cb350dc96 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_cancel.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_cancel.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -39,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_Cancel.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_Cancel.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create.py index 8faa17c3381a..40fc65514ff6 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +41,7 @@ def main(): "location": "westus", "properties": { "dbsToMigrate": ["db1", "db2", "db3", "db4"], + "migrationInstanceResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration", "migrationMode": "Offline", "overwriteDbsInTarget": "True", "secretParameters": { @@ -50,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_Create.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_Create.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_other_source_types_validate_migrate.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_other_source_types_validate_migrate.py index bb4133d70c92..0a52ac98a69a 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_other_source_types_validate_migrate.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_other_source_types_validate_migrate.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -53,6 +56,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_Create_Other_SourceTypes_Validate_Migrate.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_Create_Other_SourceTypes_Validate_Migrate.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_validate_only.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_validate_only.py index 5c18cd82f3c3..28c37ff51a94 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_validate_only.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_validate_only.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -51,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_Create_Validate_Only.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_Create_Validate_Only.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_with_other_users.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_with_other_users.py index f6efba0b0047..19508b56f12a 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_with_other_users.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_with_other_users.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -51,6 +54,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_Create_With_Other_Users.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_Create_With_Other_Users.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_with_private_endpoint_servers.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_with_private_endpoint_servers.py new file mode 100644 index 000000000000..5b04e5c7f511 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_with_private_endpoint_servers.py @@ -0,0 +1,59 @@ +# 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 typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-rdbms +# USAGE + python migrations_create_with_private_endpoint_servers.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 = PostgreSQLManagementClient( + credential=DefaultAzureCredential(), + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + ) + + response = client.migrations.create( + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + resource_group_name="testrg", + target_db_server_name="testtarget", + migration_name="testmigration", + parameters={ + "location": "westus", + "properties": { + "dbsToMigrate": ["db1", "db2", "db3", "db4"], + "migrationInstanceResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/flexibleServers/testsourcemigration", + "migrationMode": "Offline", + "overwriteDbsInTarget": "True", + "secretParameters": { + "adminCredentials": {"sourceServerPassword": "xxxxxxxx", "targetServerPassword": "xxxxxxxx"} + }, + "sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource", + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_Create_With_PrivateEndpoint_Servers.json +if __name__ == "__main__": + main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_with_roles.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_with_roles.py new file mode 100644 index 000000000000..73aad1f2dc6b --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_create_with_roles.py @@ -0,0 +1,59 @@ +# 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 typing import Any, IO, Union + +from azure.identity import DefaultAzureCredential + +from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-rdbms +# USAGE + python migrations_create_with_roles.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 = PostgreSQLManagementClient( + credential=DefaultAzureCredential(), + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + ) + + response = client.migrations.create( + subscription_id="ffffffff-ffff-ffff-ffff-ffffffffffff", + resource_group_name="testrg", + target_db_server_name="testtarget", + migration_name="testmigration", + parameters={ + "location": "westus", + "properties": { + "dbsToMigrate": ["db1", "db2", "db3", "db4"], + "migrateRoles": "True", + "migrationMode": "Offline", + "overwriteDbsInTarget": "True", + "secretParameters": { + "adminCredentials": {"sourceServerPassword": "xxxxxxxx", "targetServerPassword": "xxxxxxxx"} + }, + "sourceDbServerResourceId": "/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource", + }, + }, + ) + print(response) + + +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_Create_With_Roles.json +if __name__ == "__main__": + main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_delete.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_delete.py index 676402943288..f607faa17ced 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_delete.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): ) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_Delete.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_Delete.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get.py index 9edce0e92b64..ac2bcf3fbbbc 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_Get.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_Get.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_and_migration.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_and_migration.py index 11b9d5e4e34b..71c0563a3443 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_and_migration.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_and_migration.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_GetMigrationWithSuccessfulValidationAndMigration.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_GetMigrationWithSuccessfulValidationAndMigration.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_but_migration_failure.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_but_migration_failure.py index c289fb14c7a1..01becf4ba94a 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_but_migration_failure.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_but_migration_failure.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_GetMigrationWithSuccessfulValidationButMigrationFailure.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_GetMigrationWithSuccessfulValidationButMigrationFailure.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_only.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_only.py index 1a8f910c187a..d0015851d0fc 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_only.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_successful_validation_only.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_GetMigrationWithSuccessfulValidationOnly.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_GetMigrationWithSuccessfulValidationOnly.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_validation_failures.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_validation_failures.py index 46246a779f94..b3b4b480a09d 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_validation_failures.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_get_migration_with_validation_failures.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +39,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_GetMigrationWithValidationFailures.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_GetMigrationWithValidationFailures.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_list_by_target_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_list_by_target_server.py index 141214f63d31..4c161e7034b7 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_list_by_target_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_list_by_target_server.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +39,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_ListByTargetServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_ListByTargetServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_update.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_update.py index 093aad37e5d1..c5be12a07150 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_update.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/migrations_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -39,6 +42,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/Migrations_Update.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/Migrations_Update.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/operation_list.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/operation_list.py index 0d181b51dc5d..9bdcd02267e6 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/operation_list.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/operation_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -33,6 +34,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/OperationList.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/OperationList.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_delete.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_delete.py index fe2a0833a785..96063020daf4 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_delete.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/PrivateEndpointConnectionDelete.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/PrivateEndpointConnectionDelete.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_get.py index fab8dc3a122e..5e4eb28a068b 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/PrivateEndpointConnectionGet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/PrivateEndpointConnectionGet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_list.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_list.py index 99595cef1081..06544efa5322 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_list.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/PrivateEndpointConnectionList.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/PrivateEndpointConnectionList.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_update.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_update.py index b9bbe02c00fb..4de9cf453c5e 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_update.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_endpoint_connection_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/PrivateEndpointConnectionUpdate.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/PrivateEndpointConnectionUpdate.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_link_resources_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_link_resources_get.py index 5be8481dc8ae..f264aeb39217 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_link_resources_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_link_resources_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/PrivateLinkResourcesGet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/PrivateLinkResourcesGet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_link_resources_list.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_link_resources_list.py index ccf0e9231d3a..f073800e10c6 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_link_resources_list.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/private_link_resources_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/PrivateLinkResourcesList.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/PrivateLinkResourcesList.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_forced_standalone_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_forced_standalone_server.py index 3c216d47000a..8e498dfc8e3c 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_forced_standalone_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_forced_standalone_server.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/PromoteReplicaAsForcedStandaloneServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/PromoteReplicaAsForcedStandaloneServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_forced_switchover.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_forced_switchover.py index 8948c43e9281..4f63adf8f46d 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_forced_switchover.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_forced_switchover.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/PromoteReplicaAsForcedSwitchover.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/PromoteReplicaAsForcedSwitchover.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_planned_standalone_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_planned_standalone_server.py index d0c5f7f6d87b..20acb7268273 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_planned_standalone_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_planned_standalone_server.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/PromoteReplicaAsPlannedStandaloneServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/PromoteReplicaAsPlannedStandaloneServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_planned_switchover.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_planned_switchover.py index 8623befbf17b..54c8d3cb67f6 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_planned_switchover.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/promote_replica_as_planned_switchover.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/PromoteReplicaAsPlannedSwitchover.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/PromoteReplicaAsPlannedSwitchover.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/quota_usages_for_flexible_servers.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/quota_usages_for_flexible_servers.py index a76e53c42ced..58f65d1b7147 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/quota_usages_for_flexible_servers.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/quota_usages_for_flexible_servers.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/QuotaUsagesForFlexibleServers.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/QuotaUsagesForFlexibleServers.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/replicas_list_by_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/replicas_list_by_server.py index 11da8a7671eb..8adc876b4f99 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/replicas_list_by_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/replicas_list_by_server.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ReplicasListByServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ReplicasListByServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_capabilities.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_capabilities.py index fdb63841d367..4cb74fbacd01 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_capabilities.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_capabilities.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerCapabilities.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerCapabilities.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create.py index da6e92f29f1a..1f3a70e808f8 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -55,6 +58,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerCreate.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerCreate.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_geo_restore_with_data_encryption_enabled.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_geo_restore_with_data_encryption_enabled.py index fe6f6c4a950e..ca14117f704b 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_geo_restore_with_data_encryption_enabled.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_geo_restore_with_data_encryption_enabled.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -58,6 +61,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerCreateGeoRestoreWithDataEncryptionEnabled.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerCreateGeoRestoreWithDataEncryptionEnabled.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_point_in_time_restore.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_point_in_time_restore.py index 342d9678934c..18f93fe9efcf 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_point_in_time_restore.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_point_in_time_restore.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -44,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerCreatePointInTimeRestore.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerCreatePointInTimeRestore.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_replica.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_replica.py index 2bafc726069d..2c0473ac8e58 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_replica.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_replica.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -57,6 +60,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerCreateReplica.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerCreateReplica.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_revive_dropped.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_revive_dropped.py index b9df60d8892b..bfb066d9dbc4 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_revive_dropped.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_revive_dropped.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -44,6 +47,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerCreateReviveDropped.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerCreateReviveDropped.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_with_aad_auth_enabled.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_with_aad_auth_enabled.py index 19e58edaa488..5d8e1844a558 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_with_aad_auth_enabled.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_with_aad_auth_enabled.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -61,6 +64,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerCreateWithAadAuthEnabled.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerCreateWithAadAuthEnabled.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_with_data_encryption_enabled.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_with_data_encryption_enabled.py index 83d96cefdb6b..7e6c59fbae06 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_with_data_encryption_enabled.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_create_with_data_encryption_enabled.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -68,6 +71,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerCreateWithDataEncryptionEnabled.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerCreateWithDataEncryptionEnabled.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_delete.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_delete.py index 17847e968e6a..7c9343ec7395 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_delete.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerDelete.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerDelete.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get.py index 7b95f61a45e2..2f1bb6e6e5bf 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerGet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerGet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get_with_private_endpoints.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get_with_private_endpoints.py index 5be403efac9d..b2f9655191a2 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get_with_private_endpoints.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get_with_private_endpoints.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerGetWithPrivateEndpoints.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerGetWithPrivateEndpoints.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get_with_vnet.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get_with_vnet.py index 3213194848f9..57c08d997136 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get_with_vnet.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_get_with_vnet.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +37,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerGetWithVnet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerGetWithVnet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_list.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_list.py index 14aa4b7847c8..1ac3245500c5 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_list.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_list.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -34,6 +35,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerList.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerList.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_list_by_resource_group.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_list_by_resource_group.py index 0f30b595ff64..4bb2e451c3d8 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_list_by_resource_group.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_list_by_resource_group.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +37,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerListByResourceGroup.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerListByResourceGroup.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_restart.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_restart.py index 9d7ef1a2b93a..60ce80a1d60f 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_restart.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_restart.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerRestart.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerRestart.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_restart_with_failover.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_restart_with_failover.py index c7c7c1e35f50..e52b97a48875 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_restart_with_failover.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_restart_with_failover.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerRestartWithFailover.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerRestartWithFailover.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_start.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_start.py index b96556bea61e..e81130a48c2c 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_start.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_start.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerStart.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerStart.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_stop.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_stop.py index bac6697ea709..efcf902bd8e3 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_stop.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_stop.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -35,6 +36,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerStop.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerStop.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_create_or_update.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_create_or_update.py index e6b940529cd1..c96e8cffc908 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_create_or_update.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_create_or_update.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -38,6 +44,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerThreatProtectionSettingsCreateOrUpdate.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerThreatProtectionSettingsCreateOrUpdate.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_get.py index 6d8f4cfee54b..57e4e77ac3eb 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_get.py @@ -6,9 +6,15 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import TYPE_CHECKING, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models """ # PREREQUISITES pip install azure-identity @@ -37,6 +43,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerThreatProtectionSettingsGet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerThreatProtectionSettingsGet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_list_by_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_list_by_server.py index 0ad951f0b8ff..cd95854dabf2 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_list_by_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_threat_protection_settings_list_by_server.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerThreatProtectionSettingsListByServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerThreatProtectionSettingsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update.py index e7bded4471fe..41757fe8ea6b 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -45,6 +48,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerUpdate.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerUpdate.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_aad_auth_enabled.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_aad_auth_enabled.py index 1359b31642c3..0beb2d0b29a0 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_aad_auth_enabled.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_aad_auth_enabled.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -50,6 +53,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerUpdateWithAadAuthEnabled.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerUpdateWithAadAuthEnabled.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_customer_maintenance_window.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_customer_maintenance_window.py index dc593706bd41..ea5b03a8538e 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_customer_maintenance_window.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_customer_maintenance_window.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -42,6 +45,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerUpdateWithCustomerMaintenanceWindow.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerUpdateWithCustomerMaintenanceWindow.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_data_encryption_enabled.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_data_encryption_enabled.py index 6a739ba6d5f4..32a6ea1579df 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_data_encryption_enabled.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_data_encryption_enabled.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -58,6 +61,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerUpdateWithDataEncryptionEnabled.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerUpdateWithDataEncryptionEnabled.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_major_version_upgrade.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_major_version_upgrade.py index f61bbe795c70..a59a96be082c 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_major_version_upgrade.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/server_update_with_major_version_upgrade.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +40,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/ServerUpdateWithMajorVersionUpgrade.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/ServerUpdateWithMajorVersionUpgrade.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_create.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_create.py index 3b8881b2b78b..e554db93b501 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_create.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_create.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/VirtualEndpointCreate.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/VirtualEndpointCreate.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_delete.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_delete.py index 6bd6e95260ea..937e8e1bb88f 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_delete.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_delete.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -36,6 +37,6 @@ def main(): ).result() -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/VirtualEndpointDelete.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/VirtualEndpointDelete.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_update.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_update.py index aca699f91b71..5345b92bbb92 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_update.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoint_update.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/VirtualEndpointUpdate.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/VirtualEndpointUpdate.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoints_get.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoints_get.py index f79ddcdb0254..9b3313343a74 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoints_get.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoints_get.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/VirtualEndpointsGet.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/VirtualEndpointsGet.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoints_list_by_server.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoints_list_by_server.py index f215369e43f7..7aeca39c1d92 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoints_list_by_server.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_endpoints_list_by_server.py @@ -7,6 +7,7 @@ # -------------------------------------------------------------------------- from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -37,6 +38,6 @@ def main(): print(item) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/VirtualEndpointsListByServer.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/VirtualEndpointsListByServer.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_network_subnet_usage.py b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_network_subnet_usage.py index 3e7492e8f6d9..b319b636d887 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_network_subnet_usage.py +++ b/sdk/rdbms/azure-mgmt-rdbms/generated_samples/postgresql_flexibleservers/virtual_network_subnet_usage.py @@ -6,7 +6,10 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from typing import Any, IO, Union + from azure.identity import DefaultAzureCredential + from azure.mgmt.rdbms.postgresql_flexibleservers import PostgreSQLManagementClient """ @@ -38,6 +41,6 @@ def main(): print(response) -# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-06-01-preview/examples/VirtualNetworkSubnetUsage.json +# x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/preview/2023-12-01-preview/examples/VirtualNetworkSubnetUsage.json if __name__ == "__main__": main() diff --git a/sdk/rdbms/azure-mgmt-rdbms/setup.py b/sdk/rdbms/azure-mgmt-rdbms/setup.py index 26c6548c5ce3..cfa61df6bdaa 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/setup.py +++ b/sdk/rdbms/azure-mgmt-rdbms/setup.py @@ -74,9 +74,9 @@ "pytyped": ["py.typed"], }, install_requires=[ - "isodate<1.0.0,>=0.6.1", - "azure-common~=1.1", - "azure-mgmt-core>=1.3.2,<2.0.0", + "isodate>=0.6.1", + "azure-common>=1.1", + "azure-mgmt-core>=1.3.2", ], python_requires=">=3.8", ) diff --git a/sdk/resourceconnector/azure-mgmt-resourceconnector/pyproject.toml b/sdk/resourceconnector/azure-mgmt-resourceconnector/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/resourceconnector/azure-mgmt-resourceconnector/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/scheduler/azure-mgmt-scheduler/pyproject.toml b/sdk/scheduler/azure-mgmt-scheduler/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/scheduler/azure-mgmt-scheduler/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/scvmm/azure-mgmt-scvmm/pyproject.toml b/sdk/scvmm/azure-mgmt-scvmm/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/scvmm/azure-mgmt-scvmm/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/search/azure-mgmt-search/pyproject.toml b/sdk/search/azure-mgmt-search/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/search/azure-mgmt-search/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/search/azure-search-documents/CHANGELOG.md b/sdk/search/azure-search-documents/CHANGELOG.md index 80a5be9902e1..b3afa370a3d2 100644 --- a/sdk/search/azure-search-documents/CHANGELOG.md +++ b/sdk/search/azure-search-documents/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 11.6.0b4 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + ## 11.6.0b3 (2024-04-09) ### Features Added diff --git a/sdk/search/azure-search-documents/azure/search/documents/_version.py b/sdk/search/azure-search-documents/azure/search/documents/_version.py index 3196c3e69697..7efc5a0a00b1 100644 --- a/sdk/search/azure-search-documents/azure/search/documents/_version.py +++ b/sdk/search/azure-search-documents/azure/search/documents/_version.py @@ -3,6 +3,6 @@ # Licensed under the MIT License. # ------------------------------------ -VERSION = "11.6.0b3" # type: str +VERSION = "11.6.0b4" # type: str SDK_MONIKER = "search-documents/{}".format(VERSION) # type: str diff --git a/sdk/search/azure-search-documents/tests/async_tests/test_buffered_sender_async.py b/sdk/search/azure-search-documents/tests/async_tests/test_buffered_sender_async.py index 4e035d570bf8..3c166e74983c 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/test_buffered_sender_async.py +++ b/sdk/search/azure-search-documents/tests/async_tests/test_buffered_sender_async.py @@ -10,11 +10,13 @@ from azure.core.credentials import AzureKeyCredential from azure.core.exceptions import HttpResponseError, ServiceResponseTimeoutError from azure.search.documents.models import IndexingResult +from test_search_index_client_async import await_prepared_test CREDENTIAL = AzureKeyCredential(key="test_api_key") class TestSearchBatchingClientAsync: + @await_prepared_test async def test_search_indexing_buffered_sender_kwargs(self): async with SearchIndexingBufferedSender("endpoint", "index name", CREDENTIAL, window=100) as client: assert client._batch_action_count == 512 @@ -22,6 +24,7 @@ async def test_search_indexing_buffered_sender_kwargs(self): assert client._auto_flush_interval == 60 assert client._auto_flush + @await_prepared_test async def test_batch_queue(self): async with SearchIndexingBufferedSender("endpoint", "index name", CREDENTIAL, auto_flush=False) as client: assert client._index_documents_batch @@ -35,6 +38,7 @@ async def test_batch_queue(self): await client._index_documents_batch.enqueue_actions(actions) assert len(client.actions) == 7 + @await_prepared_test @mock.patch( "azure.search.documents.aio._search_indexing_buffered_sender_async.SearchIndexingBufferedSender._process_if_needed" ) @@ -44,6 +48,7 @@ async def test_process_if_needed(self, mock_process_if_needed): await client.delete_documents(["delete1", "delete2"]) assert mock_process_if_needed.called + @await_prepared_test @mock.patch( "azure.search.documents.aio._search_indexing_buffered_sender_async.SearchIndexingBufferedSender._cleanup" ) @@ -53,6 +58,7 @@ async def test_context_manager(self, mock_cleanup): await client.delete_documents(["delete1", "delete2"]) assert mock_cleanup.called + @await_prepared_test async def test_flush(self): DOCUMENT = { "category": "Hotel", @@ -72,6 +78,7 @@ async def test_flush(self): await client.flush() assert len(client.actions) == 0 + @await_prepared_test async def test_callback_new(self): on_new = mock.AsyncMock() async with SearchIndexingBufferedSender( @@ -80,6 +87,7 @@ async def test_callback_new(self): await client.upload_documents(["upload1"]) assert on_new.called + @await_prepared_test async def test_callback_error(self): async def mock_fail_index_documents(actions, timeout=86400): if len(actions) > 0: @@ -100,6 +108,7 @@ async def mock_fail_index_documents(actions, timeout=86400): await client.flush() assert on_error.called + @await_prepared_test async def test_callback_error_on_timeout(self): async def mock_fail_index_documents(actions, timeout=86400): if len(actions) > 0: @@ -122,6 +131,7 @@ async def mock_fail_index_documents(actions, timeout=86400): await client.flush(timeout=-1) assert on_error.call_count == 2 + @await_prepared_test async def test_callback_progress(self): async def mock_successful_index_documents(actions, timeout=86400): if len(actions) > 0: diff --git a/sdk/search/azure-search-documents/tests/async_tests/test_search_client_async.py b/sdk/search/azure-search-documents/tests/async_tests/test_search_client_async.py index f658005eee98..c41691889a96 100644 --- a/sdk/search/azure-search-documents/tests/async_tests/test_search_client_async.py +++ b/sdk/search/azure-search-documents/tests/async_tests/test_search_client_async.py @@ -7,11 +7,13 @@ from azure.search.documents._generated.models import SearchDocumentsResult, SearchResult from azure.search.documents.aio import SearchClient from azure.search.documents.aio._search_client_async import AsyncSearchPageIterator +from test_search_index_client_async import await_prepared_test CREDENTIAL = AzureKeyCredential(key="test_api_key") class TestSearchClientAsync: + @await_prepared_test @mock.patch( "azure.search.documents._generated.aio.operations._documents_operations.DocumentsOperations.search_post" ) diff --git a/sdk/serialconsole/azure-mgmt-serialconsole/pyproject.toml b/sdk/serialconsole/azure-mgmt-serialconsole/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/serialconsole/azure-mgmt-serialconsole/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/servicenetworking/azure-mgmt-servicenetworking/pyproject.toml b/sdk/servicenetworking/azure-mgmt-servicenetworking/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/servicenetworking/azure-mgmt-servicenetworking/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/sphere/azure-mgmt-sphere/pyproject.toml b/sdk/sphere/azure-mgmt-sphere/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/sphere/azure-mgmt-sphere/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/springappdiscovery/azure-mgmt-springappdiscovery/pyproject.toml b/sdk/springappdiscovery/azure-mgmt-springappdiscovery/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/springappdiscovery/azure-mgmt-springappdiscovery/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/storage/azure-mgmt-storagesync/pyproject.toml b/sdk/storage/azure-mgmt-storagesync/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/storage/azure-mgmt-storagesync/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/storage/azure-storage-blob-changefeed/CHANGELOG.md b/sdk/storage/azure-storage-blob-changefeed/CHANGELOG.md index 0990f62da4c8..4b3859ef9b9e 100644 --- a/sdk/storage/azure-storage-blob-changefeed/CHANGELOG.md +++ b/sdk/storage/azure-storage-blob-changefeed/CHANGELOG.md @@ -1,6 +1,11 @@ -## Release History +# Release History -## 12.0.0b5 (Unreleased) +## 12.0.0b6 (Unreleased) + +### Features Added + + +## 12.0.0b5 (2024-04-16) This version and all future versions will require Python 3.8+. Python 3.6 and 3.7 are no longer supported. diff --git a/sdk/storage/azure-storage-blob-changefeed/azure/storage/blob/changefeed/_version.py b/sdk/storage/azure-storage-blob-changefeed/azure/storage/blob/changefeed/_version.py index 58517ac93b1a..1ff7f8ce4f8e 100644 --- a/sdk/storage/azure-storage-blob-changefeed/azure/storage/blob/changefeed/_version.py +++ b/sdk/storage/azure-storage-blob-changefeed/azure/storage/blob/changefeed/_version.py @@ -4,4 +4,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "12.0.0b5" +VERSION = "12.0.0b6" diff --git a/sdk/storage/azure-storage-blob/CHANGELOG.md b/sdk/storage/azure-storage-blob/CHANGELOG.md index 3206d2d1e3df..c9e9f9750132 100644 --- a/sdk/storage/azure-storage-blob/CHANGELOG.md +++ b/sdk/storage/azure-storage-blob/CHANGELOG.md @@ -2,7 +2,15 @@ ## 12.21.0b1 (Unreleased) -## 12.20.0b1 (Unreleased) +### Features Added + + +## 12.20.0 (Unreleased) + +### Features Added + + +## 12.20.0b1 (2024-04-16) This version and all future versions will require Python 3.8+. Python 3.7 is no longer supported. @@ -16,14 +24,14 @@ tokens to be used with multiple services. By default, the SAS token service scop Python 3.12. - Fixed an issue where authentication errors could raise `AttributeError` instead of `ClientAuthenticationError` when using async OAuth credentials. -- Fixed an typing issue which incorrectly typed the `readinto` API. The correct input type is `IO[bytes]`. +- Fixed a typing issue which incorrectly typed the `readinto` API. The correct input type is `IO[bytes]`. - Fixed a typo in the initialization of `completion_time` for the `CopyProperties` model. - Fixed a couple of issues with `upload_blob` when using Iterators/Generators as the data input. ### Other Changes - Passing `prefix` to the following `ContainerClient` APIs now raises a `ValueError`: `list_blobs`, `list_blobs_names`, and `walk_blobs`. This change was made to avoid confusion for filtering results. -The `name_starts_with` parameter is the correct prameter to pass for filtering. +The `name_starts_with` parameter is the correct parameter to pass for filtering. ## 12.19.1 (2024-03-05) diff --git a/sdk/storage/azure-storage-blob/assets.json b/sdk/storage/azure-storage-blob/assets.json index 5a63d8af02a2..a68d1dba0adf 100644 --- a/sdk/storage/azure-storage-blob/assets.json +++ b/sdk/storage/azure-storage-blob/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-blob", - "Tag": "python/storage/azure-storage-blob_72aa299e55" + "Tag": "python/storage/azure-storage-blob_c4f327d388" } diff --git a/sdk/storage/azure-storage-blob/tests/test_cpk.py b/sdk/storage/azure-storage-blob/tests/test_cpk.py index 38ea332eceb6..9f7f2e9485b3 100644 --- a/sdk/storage/azure-storage-blob/tests/test_cpk.py +++ b/sdk/storage/azure-storage-blob/tests/test_cpk.py @@ -105,7 +105,7 @@ def test_put_block_and_put_block_list(self, **kwargs): assert put_block_list_resp['etag'] is not None assert put_block_list_resp['last_modified'] is not None assert put_block_list_resp['request_server_encrypted'] - assert put_block_list_resp['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert put_block_list_resp['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -118,7 +118,7 @@ def test_put_block_and_put_block_list(self, **kwargs): assert blob.readall() == b'AAABBBCCC' assert blob.properties.etag == put_block_list_resp['etag'] assert blob.properties.last_modified == put_block_list_resp['last_modified'] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash self._teardown(bsc) @pytest.mark.live_test_only @@ -149,7 +149,7 @@ def test_create_block_blob_with_chunks(self, **kwargs): assert upload_response['etag'] is not None assert upload_response['last_modified'] is not None assert upload_response['request_server_encrypted'] - assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -162,7 +162,7 @@ def test_create_block_blob_with_chunks(self, **kwargs): assert blob.readall() == self.byte_data assert blob.properties.etag == upload_response['etag'] assert blob.properties.last_modified == upload_response['last_modified'] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash self._teardown(bsc) @pytest.mark.live_test_only @@ -190,7 +190,7 @@ def test_create_block_blob_with_sub_streams(self, **kwargs): assert upload_response['etag'] is not None assert upload_response['last_modified'] is not None assert upload_response['request_server_encrypted'] - assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -203,7 +203,7 @@ def test_create_block_blob_with_sub_streams(self, **kwargs): assert blob.readall() == self.byte_data assert blob.properties.etag == upload_response['etag'] assert blob.properties.last_modified == upload_response['last_modified'] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash self._teardown(bsc) @BlobPreparer() @@ -230,7 +230,7 @@ def test_create_block_blob_with_single_chunk(self, **kwargs): assert upload_response['etag'] is not None assert upload_response['last_modified'] is not None assert upload_response['request_server_encrypted'] - assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -243,7 +243,7 @@ def test_create_block_blob_with_single_chunk(self, **kwargs): assert blob.readall() == data assert blob.properties.etag == upload_response['etag'] assert blob.properties.last_modified == upload_response['last_modified'] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash self._teardown(bsc) @BlobPreparer() @@ -308,7 +308,7 @@ def test_put_block_from_url_and_commit_with_cpk(self, **kwargs): assert put_block_list_resp['etag'] is not None assert put_block_list_resp['last_modified'] is not None assert put_block_list_resp['request_server_encrypted'] - assert put_block_list_resp['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert put_block_list_resp['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content blob = destination_blob_client.download_blob(cpk=TEST_ENCRYPTION_KEY) @@ -317,7 +317,7 @@ def test_put_block_from_url_and_commit_with_cpk(self, **kwargs): assert blob.readall() == self.byte_data[0: 8 * 1024] assert blob.properties.etag == put_block_list_resp['etag'] assert blob.properties.last_modified == put_block_list_resp['last_modified'] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash self._teardown(bsc) @BlobPreparer() @@ -346,7 +346,7 @@ def test_append_block(self, **kwargs): assert append_blob_prop['etag'] is not None assert append_blob_prop['last_modified'] is not None assert append_blob_prop['request_server_encrypted'] - assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -357,7 +357,7 @@ def test_append_block(self, **kwargs): # Assert content was retrieved with the cpk assert blob.readall() == b'AAABBBCCC' - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @BlobPreparer() @recorded_by_proxy @@ -404,7 +404,7 @@ def test_append_block_from_url(self, **kwargs): assert append_blob_prop['etag'] is not None assert append_blob_prop['last_modified'] is not None assert append_blob_prop['request_server_encrypted'] - assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -415,7 +415,7 @@ def test_append_block_from_url(self, **kwargs): # Assert content was retrieved with the cpk assert blob.readall() == self.byte_data[0: 4 * 1024] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash self._teardown(bsc) @BlobPreparer() @@ -444,7 +444,7 @@ def test_create_append_blob_with_chunks(self, **kwargs): assert append_blob_prop['etag'] is not None assert append_blob_prop['last_modified'] is not None assert append_blob_prop['request_server_encrypted'] - assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -455,7 +455,7 @@ def test_create_append_blob_with_chunks(self, **kwargs): # Assert content was retrieved with the cpk assert blob.readall() == self.byte_data - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash self._teardown(bsc) @BlobPreparer() @@ -486,7 +486,7 @@ def test_update_page(self, **kwargs): assert page_blob_prop['etag'] is not None assert page_blob_prop['last_modified'] is not None assert page_blob_prop['request_server_encrypted'] - assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -499,7 +499,7 @@ def test_update_page(self, **kwargs): # Assert content was retrieved with the cpk assert blob.readall() == self.byte_data - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash self._teardown(bsc) @BlobPreparer() @@ -548,7 +548,7 @@ def test_update_page_from_url(self, **kwargs): assert page_blob_prop['etag'] is not None assert page_blob_prop['last_modified'] is not None assert page_blob_prop['request_server_encrypted'] - assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -561,7 +561,7 @@ def test_update_page_from_url(self, **kwargs): # Assert content was retrieved with the cpk assert blob.readall() == self.byte_data - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash self._teardown(bsc) @pytest.mark.live_test_only @@ -590,7 +590,7 @@ def test_create_page_blob_with_chunks(self, **kwargs): assert page_blob_prop['etag'] is not None assert page_blob_prop['last_modified'] is not None assert page_blob_prop['request_server_encrypted'] - assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -601,7 +601,7 @@ def test_create_page_blob_with_chunks(self, **kwargs): # Assert content was retrieved with the cpk assert blob.readall() == self.byte_data - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash self._teardown(bsc) @BlobPreparer() @@ -633,7 +633,7 @@ def test_get_set_blob_metadata(self, **kwargs): # Assert assert blob_props.server_encrypted - assert blob_props.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob_props.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash # Act set blob properties metadata = {'hello': 'world', 'number': '42', 'up': 'upval'} diff --git a/sdk/storage/azure-storage-blob/tests/test_cpk_async.py b/sdk/storage/azure-storage-blob/tests/test_cpk_async.py index 1cb7ae7057b4..14610b6beb25 100644 --- a/sdk/storage/azure-storage-blob/tests/test_cpk_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_cpk_async.py @@ -104,7 +104,7 @@ async def test_put_block_and_put_block_list(self, **kwargs): assert put_block_list_resp['etag'] is not None assert put_block_list_resp['last_modified'] is not None assert put_block_list_resp['request_server_encrypted'] - assert put_block_list_resp['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert put_block_list_resp['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -117,7 +117,7 @@ async def test_put_block_and_put_block_list(self, **kwargs): assert await blob.readall() == b'AAABBBCCC' assert blob.properties.etag == put_block_list_resp['etag'] assert blob.properties.last_modified == put_block_list_resp['last_modified'] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @pytest.mark.live_test_only @BlobPreparer() @@ -146,7 +146,7 @@ async def test_create_block_blob_with_chunks(self, **kwargs): assert upload_response['etag'] is not None assert upload_response['last_modified'] is not None assert upload_response['request_server_encrypted'] - assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -159,7 +159,7 @@ async def test_create_block_blob_with_chunks(self, **kwargs): assert await blob.readall() == self.byte_data assert blob.properties.etag == upload_response['etag'] assert blob.properties.last_modified == upload_response['last_modified'] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @pytest.mark.live_test_only @BlobPreparer() @@ -188,7 +188,7 @@ async def test_create_block_blob_with_sub_streams(self, **kwargs): assert upload_response['etag'] is not None assert upload_response['last_modified'] is not None assert upload_response['request_server_encrypted'] - assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -201,7 +201,7 @@ async def test_create_block_blob_with_sub_streams(self, **kwargs): assert await blob.readall() == self.byte_data assert blob.properties.etag == upload_response['etag'] assert blob.properties.last_modified == upload_response['last_modified'] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @BlobPreparer() @recorded_by_proxy_async @@ -226,7 +226,7 @@ async def test_create_block_blob_with_single_chunk(self, **kwargs): assert upload_response['etag'] is not None assert upload_response['last_modified'] is not None assert upload_response['request_server_encrypted'] - assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert upload_response['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -239,7 +239,7 @@ async def test_create_block_blob_with_single_chunk(self, **kwargs): assert await blob.readall() == data assert blob.properties.etag == upload_response['etag'] assert blob.properties.last_modified == upload_response['last_modified'] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @BlobPreparer() @recorded_by_proxy_async @@ -303,7 +303,7 @@ async def test_put_block_from_url_and_commit(self, **kwargs): assert put_block_list_resp['etag'] is not None assert put_block_list_resp['last_modified'] is not None assert put_block_list_resp['request_server_encrypted'] - assert put_block_list_resp['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert put_block_list_resp['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content blob = await destination_blob_client.download_blob(cpk=TEST_ENCRYPTION_KEY) @@ -312,7 +312,7 @@ async def test_put_block_from_url_and_commit(self, **kwargs): assert await blob.readall() == self.byte_data[0: 8 * 1024] assert blob.properties.etag == put_block_list_resp['etag'] assert blob.properties.last_modified == put_block_list_resp['last_modified'] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @BlobPreparer() @recorded_by_proxy_async @@ -339,7 +339,7 @@ async def test_append_block(self, **kwargs): assert append_blob_prop['etag'] is not None assert append_blob_prop['last_modified'] is not None assert append_blob_prop['request_server_encrypted'] - assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -350,7 +350,7 @@ async def test_append_block(self, **kwargs): # Assert content was retrieved with the cpk assert await blob.readall() == b'AAABBBCCC' - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @BlobPreparer() @recorded_by_proxy_async @@ -396,7 +396,7 @@ async def test_append_block_from_url(self, **kwargs): assert append_blob_prop['etag'] is not None assert append_blob_prop['last_modified'] is not None assert append_blob_prop['request_server_encrypted'] - assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -407,7 +407,7 @@ async def test_append_block_from_url(self, **kwargs): # Assert content was retrieved with the cpk assert await blob.readall() == self.byte_data[0: 4 * 1024] - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @BlobPreparer() @recorded_by_proxy_async @@ -434,7 +434,7 @@ async def test_create_append_blob_with_chunks(self, **kwargs): assert append_blob_prop['etag'] is not None assert append_blob_prop['last_modified'] is not None assert append_blob_prop['request_server_encrypted'] - assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert append_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -445,7 +445,7 @@ async def test_create_append_blob_with_chunks(self, **kwargs): # Assert content was retrieved with the cpk assert await blob.readall() == self.byte_data - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @BlobPreparer() @recorded_by_proxy_async @@ -474,7 +474,7 @@ async def test_update_page(self, **kwargs): assert page_blob_prop['etag'] is not None assert page_blob_prop['last_modified'] is not None assert page_blob_prop['request_server_encrypted'] - assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -487,7 +487,7 @@ async def test_update_page(self, **kwargs): # Assert content was retrieved with the cpk assert await blob.readall() == self.byte_data - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @BlobPreparer() @recorded_by_proxy_async @@ -534,7 +534,7 @@ async def test_update_page_from_url(self, **kwargs): assert page_blob_prop['etag'] is not None assert page_blob_prop['last_modified'] is not None assert page_blob_prop['request_server_encrypted'] - assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -547,7 +547,7 @@ async def test_update_page_from_url(self, **kwargs): # Assert content was retrieved with the cpk assert await blob.readall() == self.byte_data - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @pytest.mark.live_test_only @BlobPreparer() @@ -575,7 +575,7 @@ async def test_create_page_blob_with_chunks(self, **kwargs): assert page_blob_prop['etag'] is not None assert page_blob_prop['last_modified'] is not None assert page_blob_prop['request_server_encrypted'] - assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash + # assert page_blob_prop['encryption_key_sha256'] == TEST_ENCRYPTION_KEY.key_hash # Act get the blob content without cpk should fail with pytest.raises(HttpResponseError): @@ -586,7 +586,7 @@ async def test_create_page_blob_with_chunks(self, **kwargs): # Assert content was retrieved with the cpk assert await blob.readall() == self.byte_data - assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob.properties.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash @BlobPreparer() @recorded_by_proxy_async @@ -614,7 +614,7 @@ async def test_get_set_blob_metadata(self, **kwargs): # Assert assert blob_props.server_encrypted - assert blob_props.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash + # assert blob_props.encryption_key_sha256 == TEST_ENCRYPTION_KEY.key_hash # Act set blob properties metadata = {'hello': 'world', 'number': '42', 'up': 'upval'} diff --git a/sdk/storage/azure-storage-file-datalake/CHANGELOG.md b/sdk/storage/azure-storage-file-datalake/CHANGELOG.md index 5c7415c8b94c..d9a318493fc0 100644 --- a/sdk/storage/azure-storage-file-datalake/CHANGELOG.md +++ b/sdk/storage/azure-storage-file-datalake/CHANGELOG.md @@ -2,7 +2,15 @@ ## 12.16.0b1 (Unreleased) -## 12.15.0b1 (Unreleased) +### Features Added + + +## 12.15.0 (Unreleased) + +### Features Added + + +## 12.15.0b1 (2024-04-16) This version and all future versions will require Python 3.8+. Python 3.7 is no longer supported. diff --git a/sdk/storage/azure-storage-file-datalake/assets.json b/sdk/storage/azure-storage-file-datalake/assets.json index b1078bd0bfba..cbe0c3dc25c0 100644 --- a/sdk/storage/azure-storage-file-datalake/assets.json +++ b/sdk/storage/azure-storage-file-datalake/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-file-datalake", - "Tag": "python/storage/azure-storage-file-datalake_26175fa0e0" + "Tag": "python/storage/azure-storage-file-datalake_95d136bf90" } diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py index 6750ed6647e0..dfb4071a2636 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_directory_client.py @@ -104,14 +104,18 @@ def from_connection_string( - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError. If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" should be the storage account key. - :paramtype credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long + :type credential: + ~azure.core.credentials.AzureNamedKeyCredential or + ~azure.core.credentials.AzureSasCredential or + ~azure.core.credentials.TokenCredential or + str or dict[str, str] or None :param directory_name: The name of directory to interact with. The directory is under file system. :type directory_name: str :keyword str audience: The audience to use when requesting tokens for Azure Active Directory authentication. Only has an effect when credential is of type TokenCredential. The value could be https://storage.azure.com/ (default) or https://.blob.core.windows.net. - :return: a DataLakeDirectoryClient + :return: A DataLakeDirectoryClient. :rtype: ~azure.storage.filedatalake.DataLakeDirectoryClient """ account_url, _, credential = parse_connection_str(conn_str, credential, 'dfs') @@ -194,7 +198,7 @@ def create_directory(self, metadata=None, # type: Optional[Dict[str, str]] see `here `_. :return: A dictionary of response headers. - :rtype: Dict[str, Union[str, datetime]] + :rtype: dict[str, Union[str, datetime]] .. admonition:: Example: diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py index 662c979f6754..5f5df8a25584 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_file_client.py @@ -114,12 +114,16 @@ def from_connection_string( Credentials provided here will take precedence over those in the connection string. If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" should be the storage account key. - :paramtype credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long + :type credential: + ~azure.core.credentials.AzureNamedKeyCredential or + ~azure.core.credentials.AzureSasCredential or + ~azure.core.credentials.TokenCredential or + str or dict[str, str] or None :keyword str audience: The audience to use when requesting tokens for Azure Active Directory authentication. Only has an effect when credential is of type TokenCredential. The value could be https://storage.azure.com/ (default) or https://.blob.core.windows.net. - :return a DataLakeFileClient - :rtype ~azure.storage.filedatalake.DataLakeFileClient + :returns: A DataLakeFileClient. + :rtype: ~azure.storage.filedatalake.DataLakeFileClient """ account_url, _, credential = parse_connection_str(conn_str, credential, 'dfs') return cls( diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py index cbb23c5d6002..e22fee3ffdf2 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_data_lake_service_client.py @@ -150,12 +150,16 @@ def from_connection_string( an instance of a AzureSasCredential from azure.core.credentials, an account shared access key, or an instance of a TokenCredentials class from azure.identity. Credentials provided here will take precedence over those in the connection string. - :paramtype credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] # pylint: disable=line-too-long + :type credential: + ~azure.core.credentials.AzureNamedKeyCredential or + ~azure.core.credentials.AzureSasCredential or + ~azure.core.credentials.TokenCredential or + str or dict[str, str] or None :keyword str audience: The audience to use when requesting tokens for Azure Active Directory authentication. Only has an effect when credential is of type TokenCredential. The value could be https://storage.azure.com/ (default) or https://.blob.core.windows.net. - :return a DataLakeServiceClient - :rtype ~azure.storage.filedatalake.DataLakeServiceClient + :returns: A DataLakeServiceClient. + :rtype: ~azure.storage.filedatalake.DataLakeServiceClient .. admonition:: Example: @@ -613,7 +617,7 @@ def get_service_properties(self, **kwargs): #other-client--per-operation-configuration>`_. :returns: An object containing datalake service properties such as analytics logging, hour/minute metrics, cors rules, etc. - :rtype: Dict[str, Any] + :rtype: dict[str, Any] """ props = self._blob_service_client.get_service_properties(**kwargs) # pylint: disable=protected-access return get_datalake_service_properties(props) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py index 98acdc589a45..b85926a2d7c0 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_file_system_client.py @@ -164,12 +164,16 @@ def from_connection_string( Credentials provided here will take precedence over those in the connection string. If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" should be the storage account key. - :paramtype credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long + :type credential: + ~azure.core.credentials.AzureNamedKeyCredential or + ~azure.core.credentials.AzureSasCredential or + ~azure.core.credentials.TokenCredential or + str or dict[str, str] or None :keyword str audience: The audience to use when requesting tokens for Azure Active Directory authentication. Only has an effect when credential is of type TokenCredential. The value could be https://storage.azure.com/ (default) or https://.blob.core.windows.net. - :return a FileSystemClient - :rtype ~azure.storage.filedatalake.FileSystemClient + :returns: A FileSystemClient. + :rtype: ~azure.storage.filedatalake.FileSystemClient .. admonition:: Example: @@ -275,7 +279,7 @@ def create_file_system(self, metadata=None, # type: Optional[Dict[str, str]] see `here `_. :returns: A dictionary of response headers. - :rtype: Dict[str, Union[str, datetime]] + :rtype: dict[str, Union[str, datetime]] .. admonition:: Example: @@ -457,7 +461,7 @@ def set_file_system_metadata( # type: ignore see `here `_. :returns: filesystem-updated property dict (Etag and last modified). - :rtype: Dict[str, str] + :rtype: dict[str, str] or dict[str, ~datetime.datetime] .. admonition:: Example: @@ -510,7 +514,7 @@ def set_file_system_access_policy( see `here `_. :returns: File System-updated property dict (Etag and last modified). - :rtype: dict[str, str or ~datetime.datetime] + :rtype: dict[str, str] or dict[str, ~datetime.datetime] """ return self._container_client.set_container_access_policy(signed_identifiers, public_access=public_access, **kwargs) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py index 2222f2a225ad..d078d1e4c58c 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_models.py @@ -770,7 +770,7 @@ class LocationMode(object): class DelimitedJsonDialect(BlobDelimitedJSON): """Defines the input or output JSON serialization for a datalake query. - :keyword str delimiter: The line separator character, default value is '\n' + :keyword str delimiter: The line separator character, default value is '\\\\n'. """ @@ -782,7 +782,7 @@ class DelimitedTextDialect(BlobDelimitedTextDialect): :keyword str quotechar: Field quote, defaults to '"'. :keyword str lineterminator: - Record separator, defaults to '\n'. + Record separator, defaults to '\\\\n'. :keyword str escapechar: Escape char, defaults to empty. :keyword bool has_header: diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py index dac7171edaac..11891ffc8e47 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_path_client.py @@ -282,7 +282,7 @@ def _create(self, resource_type, content_settings=None, metadata=None, **kwargs) :return: A dictionary of response headers. :keyword str encryption_context: Specifies the encryption context to set on the file. - :rtype: Dict[str, Union[str, datetime]] + :rtype: dict[str, str] or dict[str, ~datetime.datetime] """ lease_id = kwargs.get('lease_id', None) lease_duration = kwargs.get('lease_duration', None) @@ -347,7 +347,7 @@ def _delete(self, **kwargs): see `here `_. :returns: A dictionary containing information about the deleted path. - :rtype: Dict[str, Any] + :rtype: dict[str, Any] """ # Perform paginated delete only if using OAuth, deleting a directory, and api version is 2023-08-03 or later # The pagination is only for ACL checks, the final request remains the atomic delete operation @@ -980,7 +980,7 @@ def set_metadata(self, metadata, # type: Dict[str, str] :param metadata: A dict containing name-value pairs to associate with the file system as metadata. Example: {'category':'test'} - :type metadata: Dict[str, str] + :type metadata: dict[str, str] :keyword lease: If specified, set_file_system_metadata only succeeds if the file system's lease is active and matches this ID. @@ -1012,6 +1012,7 @@ def set_metadata(self, metadata, # type: Dict[str, str] see `here `_. :returns: file system-updated property dict (Etag and last modified). + :rtype: dict[str, str] or dict[str, ~datetime.datetime] """ return self._blob_client.set_blob_metadata(metadata=metadata, **kwargs) @@ -1052,7 +1053,7 @@ def set_http_headers(self, content_settings: Optional["ContentSettings"] = None, see `here `_. :returns: file/directory-updated property dict (Etag and last modified) - :rtype: Dict[str, Any] + :rtype: dict[str, Any] """ return self._blob_client.set_http_headers(content_settings=content_settings, **kwargs) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies.py index b72fd6440d56..4abfc9163a84 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies.py @@ -42,7 +42,7 @@ if TYPE_CHECKING: from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import ( # pylint: disable=non-abstract-transport-import + from azure.core.pipeline import ( # pylint: disable=non-abstract-transport-import PipelineRequest, PipelineResponse ) @@ -411,8 +411,9 @@ def _set_next_host_location(self, settings: Dict[str, Any], request: "PipelineRe """ A function which sets the next host location on the request, if applicable. - :param Dict[str, Any]] settings: The configurable values pertaining to the next host location. - :param PipelineRequest request: A pipeline request object. + :param dict[str, Any]] settings: The configurable values pertaining to the next host location. + :param request: A pipeline request object. + :type request: ~azure.core.pipeline.PipelineRequest """ if settings['hosts'] and all(settings['hosts'].values()): url = urlparse(request.url) @@ -451,7 +452,7 @@ def get_backoff_time(self, settings: Dict[str, Any]) -> float: # pylint: disabl """ Formula for computing the current backoff. Should be calculated by child class. - :param Dict[str, Any]] settings: The configurable values pertaining to the backoff time. + :param dict[str, Any]] settings: The configurable values pertaining to the backoff time. :returns: The backoff time. :rtype: float """ @@ -471,12 +472,14 @@ def increment( ) -> bool: """Increment the retry counters. - Dict[str, Any]] settings: The configurable values pertaining to the increment operation. - :param PipelineRequest request: A pipeline request object. - :param Optional[PipelineResponse] response: A pipeline response object. + :param dict[str, Any]] settings: The configurable values pertaining to the increment operation. + :param request: A pipeline request object. + :type request: ~azure.core.pipeline.PipelineRequest + :param response: A pipeline response object. + :type response: ~azure.core.pipeline.PipelineResponse or None :param error: An error encountered during the request, or None if the response was received successfully. - :paramtype error: Optional[AzureError] + :type error: ~azure.core.exceptions.AzureError or None :returns: Whether the retry attempts are exhausted. :rtype: bool """ @@ -608,7 +611,7 @@ def get_backoff_time(self, settings: Dict[str, Any]) -> float: """ Calculates how long to sleep before retrying. - :param Dict[str, Any]] settings: The configurable values pertaining to get backoff time. + :param dict[str, Any]] settings: The configurable values pertaining to get backoff time. :returns: A float indicating how long to wait before retrying the request, or None to indicate no retry should be performed. @@ -660,7 +663,7 @@ def get_backoff_time(self, settings: Dict[str, Any]) -> float: """ Calculates how long to sleep before retrying. - :param Dict[str, Any]] settings: The configurable values pertaining to the backoff time. + :param dict[str, Any]] settings: The configurable values pertaining to the backoff time. :returns: A float indicating how long to wait before retrying the request, or None to indicate no retry should be performed. diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies_async.py index bf03d3690598..c41637ee432b 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/policies_async.py @@ -19,7 +19,7 @@ if TYPE_CHECKING: from azure.core.credentials_async import AsyncTokenCredential - from azure.core.pipeline.transport import ( # pylint: disable=non-abstract-transport-import + from azure.core.pipeline import ( # pylint: disable=non-abstract-transport-import PipelineRequest, PipelineResponse ) @@ -195,7 +195,7 @@ def get_backoff_time(self, settings: Dict[str, Any]) -> float: """ Calculates how long to sleep before retrying. - :param Dict[str, Any]] settings: The configurable values pertaining to the backoff time. + :param dict[str, Any]] settings: The configurable values pertaining to the backoff time. :return: An integer indicating how long to wait before retrying the request, or None to indicate no retry should be performed. @@ -247,7 +247,7 @@ def get_backoff_time(self, settings: Dict[str, Any]) -> float: """ Calculates how long to sleep before retrying. - :param Dict[str, Any]] settings: The configurable values pertaining to the backoff time. + :param dict[str, Any]] settings: The configurable values pertaining to the backoff time. :return: An integer indicating how long to wait before retrying the request, or None to indicate no retry should be performed. diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py index 9561ad2e8b1e..648a354c6eb3 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_directory_client_async.py @@ -158,7 +158,7 @@ async def create_directory(self, metadata=None, # type: Optional[Dict[str, str] see `here `_. :return: A dictionary of response headers. - :rtype: Dict[str, Union[str, datetime]] + :rtype: dict[str, str] or dict[str, ~datetime.datetime] .. admonition:: Example: @@ -612,15 +612,6 @@ def get_file_client(self, file # type: Union[FileProperties, str] :type file: str or ~azure.storage.filedatalake.FileProperties :returns: A DataLakeFileClient. :rtype: ~azure.storage.filedatalake.aio.DataLakeFileClient - - .. admonition:: Example: - - .. literalinclude:: ../samples/test_datalake_service_samples.py - :start-after: [START bsc_get_file_client] - :end-before: [END bsc_get_file_client] - :language: python - :dedent: 12 - :caption: Getting the file client to interact with a specific file. """ try: file_path = file.get('name') @@ -649,15 +640,6 @@ def get_sub_directory_client(self, sub_directory # type: Union[DirectoryPropert :type sub_directory: str or ~azure.storage.filedatalake.DirectoryProperties :returns: A DataLakeDirectoryClient. :rtype: ~azure.storage.filedatalake.aio.DataLakeDirectoryClient - - .. admonition:: Example: - - .. literalinclude:: ../samples/test_datalake_service_samples.py - :start-after: [START bsc_get_directory_client] - :end-before: [END bsc_get_directory_client] - :language: python - :dedent: 12 - :caption: Getting the directory client to interact with a specific directory. """ try: subdir_path = sub_directory.get('name') diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py index 25f8e417a494..b318f534b2e6 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_file_client_async.py @@ -92,7 +92,7 @@ async def create_file(self, content_settings=None, # type: Optional[ContentSett ContentSettings object used to set path properties. :param metadata: Name-value pairs associated with the file as metadata. - :type metadata: Optional[Dict[str, str]] + :type metadata: Optional[dict[str, str]] :keyword lease: Required if the file has an active lease. Value can be a DataLakeLeaseClient object or the lease ID as a string. @@ -345,7 +345,7 @@ async def upload_data( ContentSettings object used to set path properties. :keyword metadata: Name-value pairs associated with the blob as metadata. - :paramtype metadata: Optional[Dict[str, str]] + :paramtype metadata: Optional[dict[str, str]] :keyword ~azure.storage.filedatalake.DataLakeLeaseClient or str lease: Required if the blob has an active lease. Value can be a DataLakeLeaseClient object or the lease ID as a string. diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py index 7a1ae894304a..51012d78a298 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_data_lake_service_client_async.py @@ -555,7 +555,7 @@ async def get_service_properties(self, **kwargs): #other-client--per-operation-configuration>`_. :returns: An object containing datalake service properties such as analytics logging, hour/minute metrics, cors rules, etc. - :rtype: Dict[str, Any] + :rtype: dict[str, Any] """ props = await self._blob_service_client.get_service_properties(**kwargs) # pylint: disable=protected-access return get_datalake_service_properties(props) diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py index d123b63f4917..fb7934463a50 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_file_system_client_async.py @@ -43,32 +43,32 @@ class FileSystemClient(AsyncStorageAccountHostsMixin, FileSystemClientBase): """A client to interact with a specific file system, even if that file system - may not yet exist. - - For operations relating to a specific directory or file within this file system, a directory client or file client - can be retrieved using the :func:`~get_directory_client` or :func:`~get_file_client` functions. - - :ivar str url: - The full endpoint URL to the file system, including SAS token if used. - :ivar str primary_endpoint: - The full primary endpoint URL. - :ivar str primary_hostname: - The hostname of the primary endpoint. - :param str account_url: - The URI to the storage account. - :param file_system_name: - The file system for the directory or files. - :type file_system_name: str - :param credential: - The credentials with which to authenticate. This is optional if the - account URL already has a SAS token. The value can be a SAS token string, - an instance of a AzureSasCredential or AzureNamedKeyCredential from azure.core.credentials, - an account shared access key, or an instance of a TokenCredentials class from azure.identity. - If the resource URI already contains a SAS token, this will be ignored in favor of an explicit credential - - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError. - If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" - should be the storage account key. - :keyword str api_version: + may not yet exist. + + For operations relating to a specific directory or file within this file system, a directory client or file client + can be retrieved using the :func:`~get_directory_client` or :func:`~get_file_client` functions. + + :ivar str url: + The full endpoint URL to the file system, including SAS token if used. + :ivar str primary_endpoint: + The full primary endpoint URL. + :ivar str primary_hostname: + The hostname of the primary endpoint. + :param str account_url: + The URI to the storage account. + :param file_system_name: + The file system for the directory or files. + :type file_system_name: str + :param credential: + The credentials with which to authenticate. This is optional if the + account URL already has a SAS token. The value can be a SAS token string, + an instance of a AzureSasCredential or AzureNamedKeyCredential from azure.core.credentials, + an account shared access key, or an instance of a TokenCredentials class from azure.identity. + If the resource URI already contains a SAS token, this will be ignored in favor of an explicit credential + - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError. + If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" + should be the storage account key. + :keyword str api_version: The Storage API version to use for requests. Default value is the most recent service version that is compatible with the current SDK. Setting to an older version may result in reduced feature compatibility. :keyword str audience: The audience to use when requesting tokens for Azure Active Directory @@ -218,7 +218,7 @@ async def create_file_system(self, metadata=None, # type: Optional[Dict[str, st see `here `_. :returns: A dictionary of response headers. - :rtype: Dict[str, Union[str, datetime]] + :rtype: dict[str, Union[str, datetime]] .. admonition:: Example: diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py index 690bd1f1b351..82541e8d5526 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_path_client_async.py @@ -191,7 +191,7 @@ async def _create(self, resource_type, content_settings=None, metadata=None, **k :return: A dictionary of response headers. :keyword str encryption_context: Specifies the encryption context to set on the file. - :rtype: Dict[str, Union[str, datetime]] + :rtype: dict[str, Union[str, datetime]] """ lease_id = kwargs.get('lease_id', None) lease_duration = kwargs.get('lease_duration', None) @@ -242,7 +242,7 @@ async def _delete(self, **kwargs): see `here `_. :returns: A dictionary containing information about the deleted path. - :rtype: Dict[str, Any] + :rtype: dict[str, Any] """ # Perform paginated delete only if using OAuth, deleting a directory, and api version is 2023-08-03 or later # The pagination is only for ACL checks, the final request remains the atomic delete operation @@ -833,7 +833,7 @@ async def set_http_headers(self, content_settings=None, # type: Optional[Conten see `here `_. :returns: file/directory-updated property dict (Etag and last modified) - :rtype: Dict[str, Any] + :rtype: dict[str, Any] """ return await self._blob_client.set_http_headers(content_settings=content_settings, **kwargs) @@ -880,15 +880,6 @@ async def acquire_lease(self, lease_duration=-1, # type: Optional[int] #other-client--per-operation-configuration>`_. :returns: A DataLakeLeaseClient object, that can be run in a context manager. :rtype: ~azure.storage.filedatalake.aio.DataLakeLeaseClient - - .. admonition:: Example: - - .. literalinclude:: ../samples/test_file_system_samples.py - :start-after: [START acquire_lease_on_file_system] - :end-before: [END acquire_lease_on_file_system] - :language: python - :dedent: 8 - :caption: Acquiring a lease on the file_system. """ lease = DataLakeLeaseClient(self, lease_id=lease_id) # type: ignore await lease.acquire(lease_duration=lease_duration, **kwargs) diff --git a/sdk/storage/azure-storage-file-datalake/pyproject.toml b/sdk/storage/azure-storage-file-datalake/pyproject.toml index ff779a518143..c75e8bac159a 100644 --- a/sdk/storage/azure-storage-file-datalake/pyproject.toml +++ b/sdk/storage/azure-storage-file-datalake/pyproject.toml @@ -3,3 +3,4 @@ mypy = false pyright = false type_check_samples = false verifytypes = false +strict_sphinx = true diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_cpk.py b/sdk/storage/azure-storage-file-datalake/tests/test_cpk.py index 84c531b5407f..3cf39f56083e 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_cpk.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_cpk.py @@ -88,7 +88,7 @@ def test_create_directory_cpk(self, **kwargs): # Assert assert response is not None assert response['request_server_encrypted'] - assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] + # assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] @DataLakePreparer() @recorded_by_proxy @@ -124,7 +124,7 @@ def test_create_file_cpk(self, **kwargs): # Assert assert response is not None assert response['request_server_encrypted'] - assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] + # assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] @DataLakePreparer() @recorded_by_proxy @@ -210,7 +210,7 @@ def test_file_upload_data_file_cpk(self, **kwargs): # Assert assert response is not None assert response['request_server_encrypted'] - assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] + # assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] @DataLakePreparer() @recorded_by_proxy @@ -231,7 +231,7 @@ def test_file_append_flush_data_cpk(self, **kwargs): # Assert assert response is not None assert response['request_server_encrypted'] - assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] + # assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] @DataLakePreparer() @recorded_by_proxy diff --git a/sdk/storage/azure-storage-file-datalake/tests/test_cpk_async.py b/sdk/storage/azure-storage-file-datalake/tests/test_cpk_async.py index bfeb5f7659a7..0c1d4c62759d 100644 --- a/sdk/storage/azure-storage-file-datalake/tests/test_cpk_async.py +++ b/sdk/storage/azure-storage-file-datalake/tests/test_cpk_async.py @@ -91,7 +91,7 @@ async def test_create_directory_cpk(self, **kwargs): # Assert assert response is not None assert response['request_server_encrypted'] - assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] + # assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] @DataLakePreparer() @recorded_by_proxy_async @@ -127,7 +127,7 @@ async def test_create_file_cpk(self, **kwargs): # Assert assert response is not None assert response['request_server_encrypted'] - assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] + # assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] @DataLakePreparer() @recorded_by_proxy_async @@ -213,7 +213,7 @@ async def test_file_upload_data_file_cpk(self, **kwargs): # Assert assert response is not None assert response['request_server_encrypted'] - assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] + # assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] @DataLakePreparer() @recorded_by_proxy_async @@ -234,7 +234,7 @@ async def test_file_append_flush_data_cpk(self, **kwargs): # Assert assert response is not None assert response['request_server_encrypted'] - assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] + # assert TEST_ENCRYPTION_KEY.key_hash == response['encryption_key_sha256'] @DataLakePreparer() @recorded_by_proxy_async diff --git a/sdk/storage/azure-storage-file-share/CHANGELOG.md b/sdk/storage/azure-storage-file-share/CHANGELOG.md index e39968775d9e..8c650a5eab73 100644 --- a/sdk/storage/azure-storage-file-share/CHANGELOG.md +++ b/sdk/storage/azure-storage-file-share/CHANGELOG.md @@ -2,7 +2,15 @@ ## 12.17.0b1 (Unreleased) -## 12.16.0b1 (Unreleased) +### Features Added + + +## 12.16.0 (Unreleased) + +### Features Added + + +## 12.16.0b1 (2024-04-16) This version and all future versions will require Python 3.8+. Python 3.7 is no longer supported. diff --git a/sdk/storage/azure-storage-file-share/assets.json b/sdk/storage/azure-storage-file-share/assets.json index 50f039a2bbe9..b4ad58843489 100644 --- a/sdk/storage/azure-storage-file-share/assets.json +++ b/sdk/storage/azure-storage-file-share/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-file-share", - "Tag": "python/storage/azure-storage-file-share_52c1f9ced5" + "Tag": "python/storage/azure-storage-file-share_1159609065" } diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_directory_client.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_directory_client.py index 4a509c9331bf..9a302675c87e 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_directory_client.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_directory_client.py @@ -3,6 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +# pylint: disable=too-many-lines import functools import sys @@ -169,7 +170,8 @@ def from_directory_url( - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError. If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" should be the storage account key. - :paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long + :type credential: + Optional[Union[str, dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] :keyword str audience: The audience to use when requesting tokens for Azure Active Directory authentication. Only has an effect when credential is of type TokenCredential. The value could be https://storage.azure.com/ (default) or https://.file.core.windows.net. @@ -231,7 +233,8 @@ def from_connection_string( - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError. If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" should be the storage account key. - :paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long + :type credential: + Optional[Union[str, dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] :keyword str audience: The audience to use when requesting tokens for Azure Active Directory authentication. Only has an effect when credential is of type TokenCredential. The value could be https://storage.azure.com/ (default) or https://.file.core.windows.net. @@ -337,7 +340,7 @@ def create_directory(self, **kwargs): This parameter was introduced in API version '2021-06-08'. :paramtype file_change_time: str or ~datetime.datetime - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the directory as metadata. :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see @@ -346,7 +349,7 @@ def create_directory(self, **kwargs): see `here `_. :returns: Directory-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -725,7 +728,7 @@ def set_directory_metadata(self, metadata, **kwargs): :param metadata: Name-value pairs associated with the directory as metadata. - :type metadata: dict(str, str) + :type metadata: dict[str, str] :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. @@ -733,7 +736,7 @@ def set_directory_metadata(self, metadata, **kwargs): see `here `_. :returns: Directory-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] """ timeout = kwargs.pop('timeout', None) headers = kwargs.pop('headers', {}) @@ -786,13 +789,13 @@ def set_http_headers(self, file_attributes="none", # type: Union[str, NTFSAttri The file system attributes for files and directories. If not set, indicates preservation of existing values. Here is an example for when the var type is str: 'Temporary|Archive' - :type file_attributes: str or :class:`~azure.storage.fileshare.NTFSAttributes` + :type file_attributes: str or ~azure.storage.fileshare.NTFSAttributes :param file_creation_time: Creation time for the file Default value: Preserve. - :type file_creation_time: str or datetime + :type file_creation_time: str or ~datetime.datetime :param file_last_write_time: Last write time for the file Default value: Preserve. - :type file_last_write_time: str or datetime + :type file_last_write_time: str or ~datetime.datetime :param file_permission: If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission size is <= 8KB, else x-ms-file-permission-key @@ -818,7 +821,7 @@ def set_http_headers(self, file_attributes="none", # type: Union[str, NTFSAttri see `here `_. :returns: File-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] """ timeout = kwargs.pop('timeout', None) file_permission = _get_file_permission(file_permission, permission_key, 'preserve') @@ -847,7 +850,7 @@ def create_subdirectory( :param str directory_name: The name of the subdirectory. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the subdirectory as metadata. :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see @@ -918,9 +921,10 @@ def upload_file( The name of the file. :param data: Content of the file. + :type data: Union[bytes, str, Iterable[AnyStr], IO[AnyStr]] :param int length: Length of the file in bytes. Specify its maximum size, up to 1 TiB. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the file as metadata. :keyword ~azure.storage.fileshare.ContentSettings content_settings: ContentSettings object used to set file properties. Used to set content type, encoding, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_download.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_download.py index ebfe0fdaac90..54406a400878 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_download.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_download.py @@ -143,7 +143,7 @@ def __init__(self, size, content, downloader, chunk_size): self._current_content = content self._iter_downloader = downloader self._iter_chunks = None - self._complete = (size == 0) + self._complete = size == 0 def __len__(self): return self.size diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_file_client.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_file_client.py index bbcc6e9356e9..a035cd840972 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_file_client.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_file_client.py @@ -230,7 +230,8 @@ def from_file_url( - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError. If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" should be the storage account key. - :paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long + :type credential: + Optional[Union[str, dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] :keyword str audience: The audience to use when requesting tokens for Azure Active Directory authentication. Only has an effect when credential is of type TokenCredential. The value could be https://storage.azure.com/ (default) or https://.file.core.windows.net. @@ -291,7 +292,8 @@ def from_connection_string( - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError. If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" should be the storage account key. - :paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long + :type credential: + Optional[Union[str, dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] :keyword str audience: The audience to use when requesting tokens for Azure Active Directory authentication. Only has an effect when credential is of type TokenCredential. The value could be https://storage.azure.com/ (default) or https://.file.core.windows.net. @@ -393,7 +395,7 @@ def create_file( # type: ignore If not set, the default value would be "None" and the attributes will be set to "Archive". Here is an example for when the var type is str: 'Temporary|Archive'. file_attributes value is not case sensitive. - :type file_attributes: str or :class:`~azure.storage.fileshare.NTFSAttributes` + :type file_attributes: str or ~azure.storage.fileshare.NTFSAttributes :param file_creation_time: Creation time for the file Default value: Now. :type file_creation_time: str or ~datetime.datetime @@ -421,7 +423,7 @@ def create_file( # type: ignore :keyword ~azure.storage.fileshare.ContentSettings content_settings: ContentSettings object used to set file properties. Used to set content type, encoding, language, disposition, md5, and cache control. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the file as metadata. :keyword lease: Required if the file has an active lease. Value can be a ShareLeaseClient object @@ -437,7 +439,7 @@ def create_file( # type: ignore see `here `_. :returns: File-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -500,6 +502,7 @@ def upload_file( :param data: Content of the file. + :type data: Union[bytes, str, Iterable[AnyStr], IO[AnyStr]] :param int length: Length of the file in bytes. Specify its maximum size, up to 1 TiB. :param file_attributes: @@ -532,7 +535,7 @@ def upload_file( This parameter was introduced in API version '2021-06-08'. :paramtype file_change_time: str or ~datetime.datetime - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the file as metadata. :keyword ~azure.storage.fileshare.ContentSettings content_settings: ContentSettings object used to set file properties. Used to set content type, encoding, @@ -567,7 +570,7 @@ def upload_file( :keyword str encoding: Defaults to UTF-8. :returns: File-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -621,7 +624,7 @@ def upload_file( @distributed_trace def start_copy_from_url(self, source_url, **kwargs): - # type: (str, Any) -> Any + # type: (str, Any) -> Dict[str, Any] """Initiates the copying of data from a source URL into the file referenced by the client. @@ -703,7 +706,7 @@ def start_copy_from_url(self, source_url, **kwargs): :keyword metadata: Name-value pairs associated with the file as metadata. - :type metadata: dict(str, str) + :type metadata: dict[str, str] :keyword lease: Required if the file has an active lease. Value can be a ShareLeaseClient object or the lease ID as a string. @@ -717,7 +720,8 @@ def start_copy_from_url(self, source_url, **kwargs): This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. - :rtype: dict(str, Any) + :returns: Response after data copying operation has been initiated. + :rtype: dict[str, Any] .. admonition:: Example: @@ -1086,7 +1090,7 @@ def set_http_headers(self, content_settings, # type: ContentSettings The file system attributes for files and directories. If not set, indicates preservation of existing values. Here is an example for when the var type is str: 'Temporary|Archive' - :type file_attributes: str or :class:`~azure.storage.fileshare.NTFSAttributes` + :type file_attributes: str or ~azure.storage.fileshare.NTFSAttributes :param file_creation_time: Creation time for the file Default value: Preserve. :type file_creation_time: str or ~datetime.datetime @@ -1125,7 +1129,7 @@ def set_http_headers(self, content_settings, # type: ContentSettings see `here `_. :returns: File-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] """ access_conditions = get_access_conditions(kwargs.pop('lease', None)) timeout = kwargs.pop('timeout', None) @@ -1169,7 +1173,7 @@ def set_file_metadata(self, metadata=None, **kwargs): :param metadata: Name-value pairs associated with the file as metadata. - :type metadata: dict(str, str) + :type metadata: dict[str, str] :keyword lease: Required if the file has an active lease. Value can be a ShareLeaseClient object or the lease ID as a string. @@ -1184,7 +1188,7 @@ def set_file_metadata(self, metadata=None, **kwargs): see `here `_. :returns: File-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] """ access_conditions = get_access_conditions(kwargs.pop('lease', None)) timeout = kwargs.pop('timeout', None) @@ -1387,6 +1391,8 @@ def upload_range_from_url(self, source_url, :keyword str source_authorization: Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is the prefix of the source_authorization string. + :returns: Result after writing to the specified range of the destination Azure File endpoint. + :rtype: dict[str, Any] """ options = self._upload_range_from_url_options( source_url=source_url, @@ -1514,7 +1520,7 @@ def get_ranges_diff( :returns: A tuple of two lists of file ranges as dictionaries with 'start' and 'end' keys. The first element are filled file ranges, the 2nd element is cleared file ranges. - :rtype: tuple(list(dict(str, str), list(dict(str, str)) + :rtype: tuple[list[dict[str, str], list[dict[str, str]] """ options = self._get_ranges_options( offset=offset, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py index a5530bab7f27..dc42fef21bc3 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_models.py @@ -624,7 +624,7 @@ class DirectoryPropertiesPaged(PageIterator): :ivar str location_mode: The location mode being used to list results. The available options include "primary" and "secondary". :ivar current_page: The current page of listed results. - :vartype current_page: list(dict(str, Any)) + :vartype current_page: list[dict[str, Any]] :param callable command: Function to retrieve the next page of items. :param str prefix: Filters the results to return only directories whose names diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py index c14ddc99a018..6335fd7ed1c4 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_client.py @@ -145,9 +145,10 @@ def from_share_url( ) -> Self: """ :param str share_url: The full URI to the share. - :param str snapshot: + :param snapshot: An optional share snapshot on which to operate. This can be the snapshot ID string or the response returned from :func:`create_snapshot`. + :type snapshot: Optional[Union[str, dict[str, Any]]] :param credential: The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, @@ -157,7 +158,8 @@ def from_share_url( - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError. If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" should be the storage account key. - :paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long + :type credential: + Optional[Union[str, dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] :returns: A share client. :rtype: ~azure.storage.fileshare.ShareClient """ @@ -209,11 +211,11 @@ def from_connection_string( :param str conn_str: A connection string to an Azure Storage account. - :param share_name: The name of the share. - :type share_name: str - :param str snapshot: + :param str share_name: The name of the share. + :param snapshot: The optional share snapshot on which to operate. This can be the snapshot ID string or the response returned from :func:`create_snapshot`. + :type snapshot: Optional[Union[str, dict[str, Any]]] :param credential: The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be a SAS token string, @@ -223,7 +225,8 @@ def from_connection_string( - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError. If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" should be the storage account key. - :paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long + :type credential: + Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] :returns: A share client. :rtype: ~azure.storage.fileshare.ShareClient @@ -335,7 +338,7 @@ def create_share(self, **kwargs): """Creates a new Share under the account. If a share with the same name already exists, the operation fails. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the share as metadata. :keyword int quota: The quota to be allotted. @@ -414,7 +417,7 @@ def create_snapshot( # type: ignore is taken, with a DateTime value appended to indicate the time at which the snapshot was taken. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the share as metadata. :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see @@ -571,7 +574,7 @@ def set_share_quota(self, quota, **kwargs): This keyword argument was introduced in API version '2020-08-04'. :returns: Share-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -623,7 +626,7 @@ def set_share_properties(self, **kwargs): Required if the share has an active lease. Value can be a ShareLeaseClient object or the lease ID as a string. :returns: Share-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -664,7 +667,7 @@ def set_share_metadata(self, metadata, **kwargs): :param metadata: Name-value pairs associated with the share as metadata. - :type metadata: dict(str, str) + :type metadata: dict[str, Any] :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. @@ -679,7 +682,7 @@ def set_share_metadata(self, metadata, **kwargs): This keyword argument was introduced in API version '2020-08-04'. :returns: Share-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -752,7 +755,7 @@ def set_share_access_policy(self, signed_identifiers, **kwargs): A dictionary of access policies to associate with the share. The dictionary may contain up to 5 elements. An empty dictionary will clear the access policies set on the service. - :type signed_identifiers: dict(str, :class:`~azure.storage.fileshare.AccessPolicy`) + :type signed_identifiers: dict[str, ~azure.storage.fileshare.AccessPolicy] :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. @@ -767,7 +770,7 @@ def set_share_access_policy(self, signed_identifiers, **kwargs): This keyword argument was introduced in API version '2020-08-04'. :returns: Share-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, str] """ access_conditions = get_access_conditions(kwargs.pop('lease', None)) timeout = kwargs.pop('timeout', None) @@ -834,7 +837,7 @@ def list_directories_and_files( marker=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> Iterable[Dict[str,str]] + # type: (...) -> Iterable[Dict[str, str]] """Lists the directories and files under the share. :param str directory_name: @@ -866,7 +869,7 @@ def list_directories_and_files( see `here `_. :returns: An auto-paging iterable of dict-like DirectoryProperties and FileProperties - :rtype: Iterable[Dict[str,str]] + :rtype: Iterable[dict[str, str]] .. admonition:: Example: @@ -964,7 +967,7 @@ def create_directory(self, directory_name, **kwargs): The name of the directory. :keyword metadata: Name-value pairs associated with the directory as metadata. - :type metadata: dict(str, str) + :type metadata: dict[str, str] :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_service_client.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_service_client.py index cc4ea30cc8cb..0a08bd6ac0e3 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_service_client.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_share_service_client.py @@ -155,7 +155,8 @@ def from_connection_string( - except in the case of AzureSasCredential, where the conflicting SAS tokens will raise a ValueError. If using an instance of AzureNamedKeyCredential, "name" should be the storage account name, and "key" should be the storage account key. - :paramtype credential: Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] # pylint: disable=line-too-long + :type credential: + Optional[Union[str, Dict[str, str], AzureNamedKeyCredential, AzureSasCredential, "TokenCredential"]] :returns: A File Share service client. :rtype: ~azure.storage.fileshare.ShareServiceClient @@ -230,7 +231,7 @@ def set_service_properties( You can include up to five CorsRule elements in the list. If an empty list is specified, all CORS rules will be deleted, and CORS will be disabled for the service. - :type cors: list(:class:`~azure.storage.fileshare.CorsRule`) + :type cors: list[~azure.storage.fileshare.CorsRule] :param protocol: Sets protocol settings :type protocol: ~azure.storage.fileshare.ShareProtocolSettings @@ -334,7 +335,7 @@ def create_share( which to interact with the newly created share. :param str share_name: The name of the share to create. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: A dict with name_value pairs to associate with the share as metadata. Example:{'Category':'test'} :keyword int quota: diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/policies.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/policies.py index b72fd6440d56..82a9f9e8f2ba 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/policies.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/policies.py @@ -12,7 +12,7 @@ import uuid from io import SEEK_SET, UnsupportedOperation from time import time -from typing import Any, Dict, Optional, TYPE_CHECKING, Union +from typing import Any, Dict, Optional, TYPE_CHECKING from urllib.parse import ( parse_qsl, urlencode, @@ -471,12 +471,11 @@ def increment( ) -> bool: """Increment the retry counters. - Dict[str, Any]] settings: The configurable values pertaining to the increment operation. + :param dict[str, Any]] settings: The configurable values pertaining to the increment operation. :param PipelineRequest request: A pipeline request object. :param Optional[PipelineResponse] response: A pipeline response object. - :param error: An error encountered during the request, or + :param Optional[AzureError] error: An error encountered during the request, or None if the response was received successfully. - :paramtype error: Optional[AzureError] :returns: Whether the retry attempts are exhausted. :rtype: bool """ diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_directory_client_async.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_directory_client_async.py index 939573d66d1e..1b31f8a5ea8c 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_directory_client_async.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_directory_client_async.py @@ -215,7 +215,7 @@ async def create_directory(self, **kwargs): This parameter was introduced in API version '2021-06-08'. :paramtype file_change_time: str or ~datetime.datetime - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the directory as metadata. :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see @@ -224,7 +224,7 @@ async def create_directory(self, **kwargs): see `here `_. :returns: Directory-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -626,7 +626,7 @@ async def set_directory_metadata(self, metadata, **kwargs): :param metadata: Name-value pairs associated with the directory as metadata. - :type metadata: dict(str, str) + :type metadata: dict[str, str] :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. @@ -634,7 +634,7 @@ async def set_directory_metadata(self, metadata, **kwargs): see `here `_. :returns: Directory-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] """ timeout = kwargs.pop('timeout', None) headers = kwargs.pop('headers', {}) @@ -663,13 +663,13 @@ async def set_http_headers(self, file_attributes="none", # type: Union[str, NTF The file system attributes for files and directories. If not set, indicates preservation of existing values. Here is an example for when the var type is str: 'Temporary|Archive' - :type file_attributes: str or :class:`~azure.storage.fileshare.NTFSAttributes` + :type file_attributes: str or ~azure.storage.fileshare.NTFSAttributes :param file_creation_time: Creation time for the file Default value: Preserve. - :type file_creation_time: str or datetime + :type file_creation_time: str or ~datetime.datetime :param file_last_write_time: Last write time for the file Default value: Preserve. - :type file_last_write_time: str or datetime + :type file_last_write_time: str or ~datetime.datetime :param file_permission: If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission size is <= 8KB, else x-ms-file-permission-key @@ -695,7 +695,7 @@ async def set_http_headers(self, file_attributes="none", # type: Union[str, NTF see `here `_. :returns: File-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] """ timeout = kwargs.pop('timeout', None) file_permission = _get_file_permission(file_permission, permission_key, 'preserve') @@ -725,7 +725,7 @@ async def create_subdirectory( :param str directory_name: The name of the subdirectory. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the subdirectory as metadata. :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see @@ -796,9 +796,10 @@ async def upload_file( The name of the file. :param data: Content of the file. + :type data: Union[bytes, str, Iterable[AnyStr], AsyncIterable[AnyStr], IO[AnyStr]] :param int length: Length of the file in bytes. Specify its maximum size, up to 1 TiB. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the file as metadata. :keyword ~azure.storage.fileshare.ContentSettings content_settings: ContentSettings object used to set file properties. Used to set content type, encoding, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_download_async.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_download_async.py index f99ae0d3a042..4bead0ebf43f 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_download_async.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_download_async.py @@ -96,7 +96,7 @@ def __init__(self, size, content, downloader, chunk_size): self._current_content = content self._iter_downloader = downloader self._iter_chunks = None - self._complete = (size == 0) + self._complete = size == 0 def __len__(self): return self.size diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_file_client_async.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_file_client_async.py index 518282137a32..2e4cfc28dc04 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_file_client_async.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_file_client_async.py @@ -256,7 +256,7 @@ async def create_file( # type: ignore If not set, the default value would be "None" and the attributes will be set to "Archive". Here is an example for when the var type is str: 'Temporary|Archive'. file_attributes value is not case sensitive. - :type file_attributes: str or :class:`~azure.storage.fileshare.NTFSAttributes` + :type file_attributes: str or ~azure.storage.fileshare.NTFSAttributes :param file_creation_time: Creation time for the file Default value: Now. :type file_creation_time: str or ~datetime.datetime @@ -284,7 +284,7 @@ async def create_file( # type: ignore :keyword ~azure.storage.fileshare.ContentSettings content_settings: ContentSettings object used to set file properties. Used to set content type, encoding, language, disposition, md5, and cache control. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the file as metadata. :keyword lease: Required if the file has an active lease. Value can be a ShareLeaseClient object @@ -300,7 +300,7 @@ async def create_file( # type: ignore see `here `_. :returns: File-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -364,6 +364,7 @@ async def upload_file( :param data: Content of the file. + :type data: Union[bytes, str, Iterable[AnyStr], AsyncIterable[AnyStr], IO[AnyStr]] :param int length: Length of the file in bytes. Specify its maximum size, up to 1 TiB. :param file_attributes: @@ -396,7 +397,7 @@ async def upload_file( This parameter was introduced in API version '2021-06-08'. :paramtype file_change_time: str or ~datetime.datetime - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the file as metadata. :keyword ~azure.storage.fileshare.ContentSettings content_settings: ContentSettings object used to set file properties. Used to set content type, encoding, @@ -431,7 +432,7 @@ async def upload_file( see `here `_. :returns: File-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -570,7 +571,7 @@ async def start_copy_from_url(self, source_url, **kwargs): :keyword metadata: Name-value pairs associated with the file as metadata. - :type metadata: dict(str, str) + :type metadata: dict[str, str] :keyword lease: Required if the file has an active lease. Value can be a ShareLeaseClient object or the lease ID as a string. @@ -584,7 +585,8 @@ async def start_copy_from_url(self, source_url, **kwargs): This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. - :rtype: dict(str, Any) + :returns: Response after data copying operation has been initiated. + :rtype: dict[str, Any] .. admonition:: Example: @@ -959,7 +961,7 @@ async def set_http_headers(self, content_settings, # type: ContentSettings The file system attributes for files and directories. If not set, indicates preservation of existing values. Here is an example for when the var type is str: 'Temporary|Archive' - :type file_attributes: str or :class:`~azure.storage.fileshare.NTFSAttributes` + :type file_attributes: str or ~azure.storage.fileshare.NTFSAttributes :param file_creation_time: Creation time for the file Default value: Preserve. :type file_creation_time: str or ~datetime.datetime @@ -998,7 +1000,7 @@ async def set_http_headers(self, content_settings, # type: ContentSettings see `here `_. :returns: File-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] """ access_conditions = get_access_conditions(kwargs.pop('lease', None)) timeout = kwargs.pop('timeout', None) @@ -1043,7 +1045,7 @@ async def set_file_metadata(self, metadata=None, **kwargs): # type: ignore :param metadata: Name-value pairs associated with the file as metadata. - :type metadata: dict(str, str) + :type metadata: dict[str, str] :keyword lease: Required if the file has an active lease. Value can be a ShareLeaseClient object or the lease ID as a string. @@ -1058,7 +1060,7 @@ async def set_file_metadata(self, metadata=None, **kwargs): # type: ignore see `here `_. :returns: File-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] """ access_conditions = get_access_conditions(kwargs.pop('lease', None)) timeout = kwargs.pop('timeout', None) @@ -1220,6 +1222,8 @@ async def upload_range_from_url(self, source_url, :keyword str source_authorization: Authenticate as a service principal using a client secret to access a source blob. Ensure "bearer " is the prefix of the source_authorization string. + :returns: Result after writing to the specified range of the destination Azure File endpoint. + :rtype: dict[str, Any] """ options = self._upload_range_from_url_options( source_url=source_url, @@ -1315,7 +1319,7 @@ async def get_ranges_diff( :returns: A tuple of two lists of file ranges as dictionaries with 'start' and 'end' keys. The first element are filled file ranges, the 2nd element is cleared file ranges. - :rtype: tuple(list(dict(str, str), list(dict(str, str)) + :rtype: tuple[list[dict[str, int]], list[dict[str, int]]] """ options = self._get_ranges_options( offset=offset, diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_models.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_models.py index e943afc8ef3c..b0bb3ccb54e2 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_models.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_models.py @@ -134,7 +134,7 @@ class DirectoryPropertiesPaged(AsyncPageIterator): :ivar str location_mode: The location mode being used to list results. The available options include "primary" and "secondary". :ivar current_page: The current page of listed results. - :vartype current_page: list(dict(str, Any)) + :vartype current_page: list[dict[str, Any]] :param callable command: Function to retrieve the next page of items. :param str prefix: Filters the results to return only directories whose names diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py index 846c29bba9d9..d942fbd17acc 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_client_async.py @@ -201,7 +201,7 @@ async def create_share(self, **kwargs): """Creates a new Share under the account. If a share with the same name already exists, the operation fails. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the share as metadata. :keyword int quota: The quota to be allotted. @@ -280,7 +280,7 @@ async def create_snapshot( # type: ignore is taken, with a DateTime value appended to indicate the time at which the snapshot was taken. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the share as metadata. :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see @@ -436,7 +436,7 @@ async def set_share_quota(self, quota, **kwargs): This keyword argument was introduced in API version '2020-08-04'. :returns: Share-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -488,7 +488,7 @@ async def set_share_properties(self, **kwargs): Required if the share has an active lease. Value can be a ShareLeaseClient object or the lease ID as a string. :returns: Share-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -529,7 +529,7 @@ async def set_share_metadata(self, metadata, **kwargs): :param metadata: Name-value pairs associated with the share as metadata. - :type metadata: dict(str, str) + :type metadata: dict[str, Any] :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. @@ -544,7 +544,7 @@ async def set_share_metadata(self, metadata, **kwargs): This keyword argument was introduced in API version '2020-08-04'. :returns: Share-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, Any] .. admonition:: Example: @@ -617,7 +617,7 @@ async def set_share_access_policy(self, signed_identifiers, **kwargs): A dictionary of access policies to associate with the share. The dictionary may contain up to 5 elements. An empty dictionary will clear the access policies set on the service. - :type signed_identifiers: dict(str, :class:`~azure.storage.fileshare.AccessPolicy`) + :type signed_identifiers: dict[str, ~azure.storage.fileshare.AccessPolicy] :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see https://learn.microsoft.com/rest/api/storageservices/setting-timeouts-for-file-service-operations. @@ -632,7 +632,7 @@ async def set_share_access_policy(self, signed_identifiers, **kwargs): This keyword argument was introduced in API version '2020-08-04'. :returns: Share-updated property dict (Etag and last modified). - :rtype: dict(str, Any) + :rtype: dict[str, str] """ access_conditions = get_access_conditions(kwargs.pop('lease', None)) timeout = kwargs.pop('timeout', None) @@ -816,7 +816,7 @@ async def create_directory(self, directory_name, **kwargs): :param str directory_name: The name of the directory. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: Name-value pairs associated with the directory as metadata. :keyword int timeout: Sets the server-side timeout for the operation in seconds. For more details see diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_service_client_async.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_service_client_async.py index 715a85e0c4d3..2183ec1e3d7c 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_service_client_async.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/aio/_share_service_client_async.py @@ -174,7 +174,7 @@ async def set_service_properties( You can include up to five CorsRule elements in the list. If an empty list is specified, all CORS rules will be deleted, and CORS will be disabled for the service. - :type cors: list(:class:`~azure.storage.fileshare.CorsRule`) + :type cors: list[~azure.storage.fileshare.CorsRule] :param protocol: Sets protocol settings :type protocol: ~azure.storage.fileshare.ShareProtocolSettings @@ -277,7 +277,7 @@ async def create_share( which to interact with the newly created share. :param str share_name: The name of the share to create. - :keyword dict(str,str) metadata: + :keyword dict[str, str] metadata: A dict with name_value pairs to associate with the share as metadata. Example:{'Category':'test'} :keyword int quota: diff --git a/sdk/storage/azure-storage-queue/CHANGELOG.md b/sdk/storage/azure-storage-queue/CHANGELOG.md index e60013f7a6f7..a2d7a04f146a 100644 --- a/sdk/storage/azure-storage-queue/CHANGELOG.md +++ b/sdk/storage/azure-storage-queue/CHANGELOG.md @@ -2,7 +2,15 @@ ## 12.11.0b1 (Unreleased) -## 12.10.0b1 (Unreleased) +### Features Added + + +## 12.10.0 (Unreleased) + +### Features Added + + +## 12.10.0b1 (2024-04-16) This version and all future versions will require Python 3.8+. Python 3.7 is no longer supported. diff --git a/sdk/storage/azure-storage-queue/assets.json b/sdk/storage/azure-storage-queue/assets.json index ba267a54fa0c..866e4b465469 100644 --- a/sdk/storage/azure-storage-queue/assets.json +++ b/sdk/storage/azure-storage-queue/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/storage/azure-storage-queue", - "Tag": "python/storage/azure-storage-queue_cb6f8d2b58" + "Tag": "python/storage/azure-storage-queue_da8bdfe45e" } diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py index 45cd246acf11..a32dc78e5215 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_client.py @@ -41,7 +41,7 @@ class QueueClient(StorageAccountHostsMixin, StorageEncryptionMixin): For more optional configuration, please click `here `_. + #optional-configuration>`__. :param str account_url: The URL to the storage account. In order to create a client given the full URI to the queue, @@ -206,7 +206,7 @@ def create_queue( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: None or the result of cls(response) :rtype: None :raises: StorageErrorException @@ -250,7 +250,7 @@ def delete_queue(self, **kwargs: Any) -> None: https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :rtype: None .. admonition:: Example: @@ -317,7 +317,7 @@ def set_queue_metadata( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: A dictionary of response headers. :rtype: Dict[str, Any] @@ -352,7 +352,7 @@ def get_queue_access_policy(self, **kwargs: Any) -> Dict[str, AccessPolicy]: https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: A dictionary of access policies associated with the queue. :rtype: Dict[str, ~azure.storage.queue.AccessPolicy] """ @@ -395,7 +395,7 @@ def set_queue_access_policy( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. .. admonition:: Example: @@ -466,7 +466,7 @@ def send_message( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: A :class:`~azure.storage.queue.QueueMessage` object. This object is also populated with the content although it is not @@ -558,7 +558,7 @@ def receive_message( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: Returns a message from the Queue or None if the Queue is empty. :rtype: ~azure.storage.queue.QueueMessage or None @@ -627,6 +627,7 @@ def receive_messages( a single message is retrieved from the queue with this operation. `by_page()` can be used to provide a page iterator on the AsyncItemPaged if messages_per_page is set. `next()` can be used to get the next page. + .. admonition:: Example: .. literalinclude:: ../samples/queue_samples_message.py @@ -650,7 +651,7 @@ def receive_messages( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: Returns a message iterator of dict-like Message objects. :rtype: ~azure.core.paging.ItemPaged[~azure.storage.queue.QueueMessage] @@ -737,7 +738,7 @@ def update_message( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: A :class:`~azure.storage.queue.QueueMessage` object. For convenience, this object is also populated with the content, although it is not returned by the service. @@ -849,7 +850,7 @@ def peek_messages( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: A list of :class:`~azure.storage.queue.QueueMessage` objects. Note that next_visible_on and pop_receipt will not be populated as peek does @@ -903,7 +904,7 @@ def clear_messages(self, **kwargs: Any) -> None: https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. .. admonition:: Example: @@ -949,7 +950,7 @@ def delete_message( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. .. admonition:: Example: diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_service_client.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_service_client.py index 833e20bdaa14..d8600993c7e2 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_service_client.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_queue_service_client.py @@ -47,7 +47,7 @@ class QueueServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin): For more optional configuration, please click `here `_. + #optional-configuration>`__. :param str account_url: The URL to the queue service endpoint. Any other entities included @@ -291,7 +291,7 @@ def list_queues( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. This function may make multiple + #other-client--per-operation-configuration>`__. This function may make multiple calls to the service in which case the timeout value specified will be applied to each individual call. :returns: An iterable (auto-paging) of QueueProperties. diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py index 077cac02159f..10f70e86a3fc 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_client_async.py @@ -221,7 +221,7 @@ async def create_queue( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: None or the result of cls(response) :rtype: None :raises: StorageErrorException @@ -262,7 +262,7 @@ async def delete_queue(self, **kwargs: Any) -> None: https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :rtype: None .. admonition:: Example: @@ -327,7 +327,7 @@ async def set_queue_metadata( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: A dictionary of response headers. :rtype: Dict[str, Any] @@ -360,7 +360,7 @@ async def get_queue_access_policy(self, **kwargs: Any) -> Dict[str, AccessPolicy https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: A dictionary of access policies associated with the queue. :rtype: dict(str, ~azure.storage.queue.AccessPolicy) """ @@ -402,7 +402,7 @@ async def set_queue_access_policy( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. .. admonition:: Example: @@ -471,7 +471,7 @@ async def send_message( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: A :class:`~azure.storage.queue.QueueMessage` object. This object is also populated with the content although it is not @@ -564,7 +564,7 @@ async def receive_message( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: Returns a message from the Queue or None if the Queue is empty. :rtype: ~azure.storage.queue.QueueMessage or None @@ -647,7 +647,7 @@ def receive_messages( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: Returns a message iterator of dict-like Message objects. :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.storage.queue.QueueMessage] @@ -734,7 +734,7 @@ async def update_message( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: A :class:`~azure.storage.queue.QueueMessage` object. For convenience, this object is also populated with the content, although it is not returned by the service. @@ -849,7 +849,7 @@ async def peek_messages( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. :return: A list of :class:`~azure.storage.queue.QueueMessage` objects. Note that next_visible_on and pop_receipt will not be populated as peek does @@ -901,7 +901,7 @@ async def clear_messages(self, **kwargs: Any) -> None: https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. .. admonition:: Example: @@ -947,7 +947,7 @@ async def delete_message( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. + #other-client--per-operation-configuration>`__. .. admonition:: Example: diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_service_client_async.py b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_service_client_async.py index 713df4e751e2..2d231dd1b72a 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_service_client_async.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/aio/_queue_service_client_async.py @@ -287,7 +287,7 @@ def list_queues( https://learn.microsoft.com/en-us/rest/api/storageservices/setting-timeouts-for-queue-service-operations. This value is not tracked or validated on the client. To configure client-side network timesouts see `here `_. This function may make multiple + #other-client--per-operation-configuration>`__. This function may make multiple calls to the service in which case the timeout value specified will be applied to each individual call. :returns: An iterable (auto-paging) of QueueProperties. diff --git a/sdk/storage/azure-storage-queue/pyproject.toml b/sdk/storage/azure-storage-queue/pyproject.toml index 78755ba24174..7ecdec4f12ba 100644 --- a/sdk/storage/azure-storage-queue/pyproject.toml +++ b/sdk/storage/azure-storage-queue/pyproject.toml @@ -3,3 +3,4 @@ mypy = true pyright = false type_check_samples = true verifytypes = true +strict_sphinx = true diff --git a/sdk/storagemover/azure-mgmt-storagemover/pyproject.toml b/sdk/storagemover/azure-mgmt-storagemover/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/storagemover/azure-mgmt-storagemover/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/synapse/azure-synapse-spark/pyproject.toml b/sdk/synapse/azure-synapse-spark/pyproject.toml index a3a58bd09030..269a50218a98 100644 --- a/sdk/synapse/azure-synapse-spark/pyproject.toml +++ b/sdk/synapse/azure-synapse-spark/pyproject.toml @@ -4,3 +4,4 @@ pyright = false type_check_samples = false verifytypes = false ci_enabled = false +strict_sphinx = true diff --git a/sdk/tables/azure-data-tables/assets.json b/sdk/tables/azure-data-tables/assets.json index 9458dc3b3254..d55ffbf09f86 100644 --- a/sdk/tables/azure-data-tables/assets.json +++ b/sdk/tables/azure-data-tables/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/tables/azure-data-tables", - "Tag": "python/tables/azure-data-tables_43b65ccf3f" + "Tag": "python/tables/azure-data-tables_602e1ddae5" } diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_entity.py b/sdk/tables/azure-data-tables/azure/data/tables/_entity.py index e2204208b08e..5a453b226504 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_entity.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_entity.py @@ -53,8 +53,7 @@ def metadata(self) -> EntityMetadata: class EdmType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """ - Used by :class:`~.EntityProperty` to represent the type of the entity property - to be stored by the Table service. + Represent the type of the entity property to be stored by the Table service. """ BINARY = "Edm.Binary" @@ -83,18 +82,20 @@ class EdmType(str, Enum, metaclass=CaseInsensitiveEnumMeta): EntityProperty = NamedTuple("EntityProperty", [("value", Any), ("edm_type", Union[str, EdmType])]) -""" -An entity property. Used to explicitly set :class:`~EdmType` when necessary. +"""An entity property. Used to explicitly set :class:`~azure.data.Tables.EdmType` when necessary. Values which require explicit typing are GUID, INT64, and BINARY. Other EdmTypes may be explicitly create as EntityProperty objects but need not be. For example, -the below with both create STRING typed properties on the entity:: +the below with both create STRING typed properties on the entity: + +.. code-block:: python + entity = TableEntity() entity.a = 'b' entity.x = EntityProperty('y', EdmType.STRING) -:param value: +:param value: The entity property value. :type value: Any -:param edm_type: Type of the value +:param edm_type: The Edm type of the entity property value. :type edm_type: str or ~azure.data.tables.EdmType """ diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_models.py b/sdk/tables/azure-data-tables/azure/data/tables/_models.py index 24f34dc60b8d..389db3b0fc6d 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_models.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_models.py @@ -471,9 +471,11 @@ def service_properties_deserialize(generated: GenTableServiceProperties) -> Dict ), "hour_metrics": TableMetrics._from_generated(generated.hour_metrics), # pylint: disable=protected-access "minute_metrics": TableMetrics._from_generated(generated.minute_metrics), # pylint: disable=protected-access - "cors": [TableCorsRule._from_generated(cors) for cors in generated.cors] # pylint: disable=protected-access - if generated.cors - else generated.cors, + "cors": ( + [TableCorsRule._from_generated(cors) for cors in generated.cors] # pylint: disable=protected-access + if generated.cors + else generated.cors + ), } diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_batch.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_batch.py index b62e75c1d8cc..7da69a65147c 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_batch.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_batch.py @@ -123,16 +123,25 @@ def create(self, entity: EntityType, **kwargs) -> None: request.url = self._base_url + request.url self.requests.append(request) - def update(self, entity: EntityType, mode: Union[str, UpdateMode] = UpdateMode.MERGE, **kwargs) -> None: + def update( + self, + entity: EntityType, + mode: Union[str, UpdateMode] = UpdateMode.MERGE, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs, + ) -> None: """Adds an update operation to the current batch. :param entity: The properties for the table entity. :type entity: ~azure.data.tables.TableEntity or dict[str, Any] :param mode: Merge or Replace entity :type mode: ~azure.data.tables.UpdateMode - :keyword str etag: Etag of the entity - :keyword match_condition: MatchCondition - :paramtype match_condition: ~azure.core.MatchCondition + :keyword etag: Etag of the entity. + :paramtype etag: str or None + :keyword match_condition: The match condition to use upon the etag. + :paramtype match_condition: ~azure.core.MatchConditions or None :return: None :raises ValueError: @@ -150,8 +159,6 @@ def update(self, entity: EntityType, mode: Union[str, UpdateMode] = UpdateMode.M partition_key = _prepare_key(entity["PartitionKey"]) row_key = _prepare_key(entity["RowKey"]) - match_condition = kwargs.pop("match_condition", None) - etag = kwargs.pop("etag", None) if match_condition and not etag and isinstance(entity, TableEntity): if hasattr(entity, "metadata"): etag = entity.metadata.get("etag") @@ -188,14 +195,22 @@ def update(self, entity: EntityType, mode: Union[str, UpdateMode] = UpdateMode.M request.url = self._base_url + request.url self.requests.append(request) - def delete(self, entity: EntityType, **kwargs) -> None: + def delete( + self, + entity: EntityType, + *, + etag: Optional[str] = None, + match_condition: Optional[MatchConditions] = None, + **kwargs, + ) -> None: """Adds a delete operation to the current branch. - param entity: The properties for the table entity. + :param entity: The properties for the table entity. :type entity: ~azure.data.tables.TableEntity or dict[str, Any] - :keyword str etag: Etag of the entity - :keyword match_condition: MatchCondition - :paramtype match_condition: ~azure.core.MatchCondition + :keyword etag: Etag of the entity. + :paramtype etag: str or None + :keyword match_condition: The match condition to use upon the etag. + :paramtype match_condition: ~azure.core.MatchConditions or None :return: None :raises: ValueError @@ -209,19 +224,16 @@ def delete(self, entity: EntityType, **kwargs) -> None: :caption: Creating and adding an entity to a Table """ self._verify_partition_key(entity) - match_condition = kwargs.pop("match_condition", None) - etag = kwargs.pop("etag", None) if match_condition and not etag and isinstance(entity, TableEntity): etag = entity.metadata.get("etag") - match_condition = _get_match_condition( - etag=etag, match_condition=match_condition or MatchConditions.Unconditionally - ) request = build_table_delete_entity_request( table=self.table_name, partition_key=_prepare_key(entity["PartitionKey"]), row_key=_prepare_key(entity["RowKey"]), - etag=etag, - match_condition=match_condition, + etag=etag, # type: ignore[arg-type] # Set None to skip checking etag. + match_condition=_get_match_condition( + etag=etag, match_condition=match_condition or MatchConditions.Unconditionally + ), version=self._config.version, **kwargs, ) @@ -229,7 +241,7 @@ def delete(self, entity: EntityType, **kwargs) -> None: self.requests.append(request) def upsert(self, entity: EntityType, mode: Union[str, UpdateMode] = UpdateMode.MERGE, **kwargs) -> None: - """Adds an upsert (update/merge) operation to the batch. + """Adds an upsert (merge or replace) operation to the batch. :param entity: The properties for the table entity. :type entity: ~azure.data.tables.TableEntity or dict[str, Any] diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py index 7fb71b726aa1..06fe5bd52806 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_client.py @@ -49,9 +49,9 @@ class TableClient(TablesBaseClient): account URL already has a SAS token. The value can be one of AzureNamedKeyCredential (azure-core), AzureSasCredential (azure-core), or a TokenCredential implementation from azure-identity. :vartype credential: - ~azure.core.credentials.AzureNamedKeyCredential or - ~azure.core.credentials.AzureSasCredential or - ~azure.core.credentials.TokenCredential or None + ~azure.core.credentials.AzureNamedKeyCredential or + ~azure.core.credentials.AzureSasCredential or + ~azure.core.credentials.TokenCredential or None """ def __init__( # pylint: disable=missing-client-constructor-parameter-credential @@ -77,7 +77,7 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential ~azure.core.credentials.TokenCredential or None :keyword api_version: Specifies the version of the operation to use for this request. Default value is "2019-02-02". - :paramtype api_version: str + :paramtype api_version: str or None :returns: None """ if not table_name: @@ -120,7 +120,7 @@ def from_table_url( :keyword credential: The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be one of AzureNamedKeyCredential (azure-core), - AzureSasCredential (azure-core), or a TokenCredential implementation from azure-identity. + AzureSasCredential (azure-core), or a TokenCredential implementation from azure-identity. :paramtype credential: ~azure.core.credentials.AzureNamedKeyCredential or ~azure.core.credentials.AzureSasCredential or None @@ -154,7 +154,7 @@ def get_table_access_policy(self, **kwargs) -> Dict[str, Optional[TableAccessPol """Retrieves details about any stored access policies specified on the table that may be used with Shared Access Signatures. - :return: Dictionary of SignedIdentifiers + :return: Dictionary of SignedIdentifiers. :rtype: dict[str, ~azure.data.tables.TableAccessPolicy] or dict[str, None] :raises: :class:`~azure.core.exceptions.HttpResponseError` """ @@ -180,11 +180,11 @@ def get_table_access_policy(self, **kwargs) -> Dict[str, Optional[TableAccessPol return output @distributed_trace - def set_table_access_policy(self, signed_identifiers: Dict[str, Optional[TableAccessPolicy]], **kwargs) -> None: + def set_table_access_policy(self, signed_identifiers: Mapping[str, Optional[TableAccessPolicy]], **kwargs) -> None: """Sets stored access policies for the table that may be used with Shared Access Signatures. - :param signed_identifiers: Access policies to set for the table - :type signed_identifiers: dict[str, ~azure.data.tables.TableAccessPolicy] or dict[str, None] + :param signed_identifiers: Access policies to set for the table. + :type signed_identifiers: Mapping[str, Optional[~azure.data.tables.TableAccessPolicy]] :return: None :raises: :class:`~azure.core.exceptions.HttpResponseError` """ @@ -222,7 +222,7 @@ def create_table(self, **kwargs) -> TableItem: :end-before: [END create_table_from_table_client] :language: python :dedent: 8 - :caption: Creating a table from the TableClient object + :caption: Creating a table from the TableClient object. """ table_properties = TableProperties(table_name=self.table_name) try: @@ -237,8 +237,7 @@ def create_table(self, **kwargs) -> TableItem: @distributed_trace def delete_table(self, **kwargs) -> None: - """Deletes the table under the current account. No error will be raised - if the table does not exist + """Deletes the table under the current account. No error will be raised if the table does not exist. :return: None :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -250,7 +249,7 @@ def delete_table(self, **kwargs) -> None: :end-before: [END delete_table_from_table_client] :language: python :dedent: 8 - :caption: Deleting a table from the TableClient object + :caption: Deleting a table from the TableClient object. """ try: self._client.table.delete(table=self.table_name, **kwargs) @@ -278,11 +277,11 @@ def delete_entity( :param str partition_key: The partition key of the entity. :param str row_key: The row key of the entity. - :keyword str etag: Etag of the entity + :keyword etag: Etag of the entity. + :paramtype etag: str or None :keyword match_condition: The condition under which to perform the operation. Supported values include: MatchConditions.IfNotModified, MatchConditions.Unconditionally. - The default value is Unconditionally. - :paramtype match_condition: ~azure.core.MatchConditions + :paramtype match_condition: ~azure.core.MatchConditions or None :return: None :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -308,13 +307,13 @@ def delete_entity( """Deletes the specified entity in a table. No error will be raised if the entity or PartitionKey-RowKey pairing is not found. - :param entity: The entity to delete + :param entity: The entity to delete. :type entity: Union[TableEntity, Mapping[str, Any]] - :keyword str etag: Etag of the entity + :keyword etag: Etag of the entity. + :paramtype etag: str or None :keyword match_condition: The condition under which to perform the operation. Supported values include: MatchConditions.IfNotModified, MatchConditions.Unconditionally. - The default value is Unconditionally. - :paramtype match_condition: ~azure.core.MatchConditions + :paramtype match_condition: ~azure.core.MatchConditions or None :return: None :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -369,13 +368,13 @@ def delete_entity(self, *args: Union[EntityType, str], **kwargs: Any) -> None: @distributed_trace def create_entity(self, entity: EntityType, **kwargs) -> Dict[str, Any]: - """Insert entity in a table. + """Inserts entity in a table. :param entity: The properties for the table entity. :type entity: Union[TableEntity, Mapping[str, Any]] - :return: Dictionary mapping operation metadata returned from the service + :return: Dictionary mapping operation metadata returned from the service. :rtype: dict[str, Any] - :raises: :class:`~azure.core.exceptions.HttpResponseError` + :raises: :class:`~azure.core.exceptions.ResourceExistsError` If the entity already exists .. admonition:: Example: @@ -415,18 +414,18 @@ def update_entity( match_condition: Optional[MatchConditions] = None, **kwargs, ) -> Dict[str, Any]: - """Update entity in a table. + """Updates an entity in a table. :param entity: The properties for the table entity. :type entity: ~azure.data.tables.TableEntity or dict[str, Any] - :param mode: Merge or Replace entity + :param mode: Merge or Replace entity. :type mode: ~azure.data.tables.UpdateMode - :keyword str etag: Etag of the entity + :keyword str etag: Etag of the entity. + :paramtype etag: str or None :keyword match_condition: The condition under which to perform the operation. Supported values include: MatchConditions.IfNotModified, MatchConditions.Unconditionally. - The default value is Unconditionally. - :paramtype match_condition: ~azure.core.MatchConditions - :return: Dictionary mapping operation metadata returned from the service + :paramtype match_condition: ~azure.core.MatchConditions or None + :return: Dictionary mapping operation metadata returned from the service. :rtype: dict[str, Any] :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -437,7 +436,7 @@ def update_entity( :end-before: [END update_entity] :language: python :dedent: 16 - :caption: Updating an already exiting entity in a Table + :caption: Updating an already existing entity in a Table """ if match_condition and not etag and isinstance(entity, TableEntity): etag = entity.metadata.get("etag") @@ -493,9 +492,10 @@ def list_entities( ) -> ItemPaged[TableEntity]: """Lists entities in a table. - :keyword int results_per_page: Number of entities returned per service request. + :keyword results_per_page: Number of entities returned per service request. + :paramtype results_per_page: int or None :keyword select: Specify desired properties of an entity to return. - :paramtype select: str or list[str] + :paramtype select: str or list[str] or None :return: An iterator of :class:`~azure.data.tables.TableEntity` :rtype: ~azure.core.paging.ItemPaged[~azure.data.tables.TableEntity] :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -507,7 +507,7 @@ def list_entities( :end-before: [END list_entities] :language: python :dedent: 16 - :caption: List all entities held within a table + :caption: Listing all entities held within a table """ if select and not isinstance(select, str): select = ",".join(select) @@ -532,15 +532,16 @@ def query_entities( **kwargs, ) -> ItemPaged[TableEntity]: # pylint: disable=line-too-long - """Lists entities in a table. + """Queries entities in a table. :param str query_filter: Specify a filter to return certain entities. For more information on filter formatting, see the `samples documentation `_. - :keyword int results_per_page: Number of entities returned per service request. + :keyword results_per_page: Number of entities returned per service request. + :paramtype results_per_page: int or None :keyword select: Specify desired properties of an entity to return. - :paramtype select: str or list[str] + :paramtype select: str or list[str] or None :keyword parameters: Dictionary for formatting query with additional, user defined parameters - :paramtype parameters: dict[str, Any] + :paramtype parameters: dict[str, Any] or None :return: An iterator of :class:`~azure.data.tables.TableEntity` :rtype: ~azure.core.paging.ItemPaged[~azure.data.tables.TableEntity] :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -552,7 +553,7 @@ def query_entities( :end-before: [END query_entities] :language: python :dedent: 8 - :caption: Query entities held within a table + :caption: Querying entities held within a table """ query_filter = _parameter_filter_substitution(parameters, query_filter) if select and not isinstance(select, str): @@ -577,15 +578,15 @@ def get_entity( select: Optional[Union[str, List[str]]] = None, **kwargs, ) -> TableEntity: - """Get a single entity in a table. + """Gets a single entity in a table. :param partition_key: The partition key of the entity. :type partition_key: str :param row_key: The row key of the entity. :type row_key: str :keyword select: Specify desired properties of an entity to return. - :paramtype select: str or list[str] - :return: Dictionary mapping operation metadata returned from the service + :paramtype select: str or list[str] or None + :return: Dictionary mapping operation metadata returned from the service. :rtype: ~azure.data.tables.TableEntity :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -596,7 +597,7 @@ def get_entity( :end-before: [END get_entity] :language: python :dedent: 16 - :caption: Get a single entity from a table + :caption: Getting an entity with PartitionKey and RowKey from a table """ user_select = None if select and not isinstance(select, str): @@ -617,13 +618,13 @@ def get_entity( @distributed_trace def upsert_entity(self, entity: EntityType, mode: UpdateMode = UpdateMode.MERGE, **kwargs) -> Dict[str, Any]: - """Update/Merge or Insert entity into table. + """Updates (merge or replace) an entity into a table. :param entity: The properties for the table entity. :type entity: ~azure.data.tables.TableEntity or dict[str, Any] - :param mode: Merge or Replace entity + :param mode: Merge or Replace entity. :type mode: ~azure.data.tables.UpdateMode - :return: Dictionary mapping operation metadata returned from the service + :return: Dictionary mapping operation metadata returned from the service. :rtype: dict[str, Any] :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -634,7 +635,7 @@ def upsert_entity(self, entity: EntityType, mode: UpdateMode = UpdateMode.MERGE, :end-before: [END upsert_entity] :language: python :dedent: 16 - :caption: Update/merge or insert an entity into a table + :caption: Replacing/Merging or Inserting an entity into a table """ entity_json = _add_entity_properties(entity) partition_key = entity_json["PartitionKey"] @@ -674,7 +675,7 @@ def upsert_entity(self, entity: EntityType, mode: UpdateMode = UpdateMode.MERGE, @distributed_trace def submit_transaction(self, operations: Iterable[TransactionOperationType], **kwargs) -> List[Mapping[str, Any]]: - """Commit a list of operations as a single transaction. + """Commits a list of operations as a single transaction. If any one of these operations fails, the entire transaction will be rejected. diff --git a/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py b/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py index 571d0ef441f0..1c30a170e417 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/_table_shared_access_signature.py @@ -4,7 +4,7 @@ # license information. # -------------------------------------------------------------------------- from datetime import datetime -from typing import Optional, Union, Any +from typing import Optional, Union from azure.core.credentials import AzureNamedKeyCredential from ._models import AccountSasPermissions, TableSasPermissions, ResourceTypes, SASProtocol @@ -23,7 +23,10 @@ def generate_account_sas( resource_types: ResourceTypes, permission: Union[str, AccountSasPermissions], expiry: Union[datetime, str], - **kwargs: Any + *, + start: Optional[Union[datetime, str]] = None, + ip_address_or_range: Optional[str] = None, + protocol: Optional[Union[SASProtocol, str]] = None, ) -> str: """ Generates a shared access signature for the table service. @@ -55,16 +58,17 @@ def generate_account_sas( storage service receives the request. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC. - :paramtype start: ~datetime.datetime or str - :keyword str ip_address_or_range: + :paramtype start: ~datetime.datetime or str or None + :keyword ip_address_or_range: Specifies an IP address or a range of IP addresses from which to accept requests. If the IP address from which the request originates does not match the IP address or address range specified on the SAS token, the request is not authenticated. For example, specifying sip=168.1.5.65 or sip=168.1.5.60-168.1.5.70 on the SAS restricts the request to those IP addresses. + :paramtype ip_address_or_range: str or None :keyword protocol: Specifies the protocol permitted for a request made. - :paramtype protocol: str or ~azure.data.tables.SASProtocol + :paramtype protocol: str or ~azure.data.tables.SASProtocol or None :return: A Shared Access Signature (sas) token. :rtype: str """ @@ -78,13 +82,27 @@ def generate_account_sas( resource_types, permission, expiry, - start=kwargs.pop("start", None), - ip_address_or_range=kwargs.pop("ip_address_or_range", None), - protocol=kwargs.pop("protocol", None), + start=start, + ip_address_or_range=ip_address_or_range, + protocol=protocol, ) -def generate_table_sas(credential: AzureNamedKeyCredential, table_name: str, **kwargs: Any) -> str: +def generate_table_sas( + credential: AzureNamedKeyCredential, + table_name: str, + *, + permission: Optional[Union[TableSasPermissions, str]] = None, + expiry: Optional[Union[datetime, str]] = None, + start: Optional[Union[datetime, str]] = None, + ip_address_or_range: Optional[str] = None, + policy_id: Optional[str] = None, + protocol: Optional[Union[SASProtocol, str]] = None, + start_pk: Optional[str] = None, + start_rk: Optional[str] = None, + end_pk: Optional[str] = None, + end_rk: Optional[str] = None, +) -> str: """ Generates a shared access signature for the table service. Use the returned signature with the sas_token parameter of TableService. @@ -94,12 +112,13 @@ def generate_table_sas(credential: AzureNamedKeyCredential, table_name: str, **k :type credential: ~azure.core.credentials.AzureNamedKeyCredential :param table_name: Table name :type table_name: str - :keyword ~azure.data.tables.TableSasPermissions permission: + :keyword permission: The permissions associated with the shared access signature. The user is restricted to operations allowed by the permissions. Required unless an id is given referencing a stored access policy which contains this field. This field must be omitted if it has been specified in an associated stored access policy. + :paramtype permission: ~azure.data.tables.TableSasPermissions or str or None :keyword expiry: The time at which the shared access signature becomes invalid. Required unless an id is given referencing a stored access policy @@ -107,28 +126,34 @@ def generate_table_sas(credential: AzureNamedKeyCredential, table_name: str, **k been specified in an associated stored access policy. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC. - :paramtype expiry: ~datetime.datetime or str + :paramtype expiry: ~datetime.datetime or str or None :keyword start: The time at which the shared access signature becomes valid. If omitted, start time for this call is assumed to be the time when the storage service receives the request. Azure will always convert values to UTC. If a date is passed in without timezone info, it is assumed to be UTC. - :paramtype start: ~datetime.datetime or str - :keyword str ip_address_or_range: + :paramtype start: ~datetime.datetime or str or None + :keyword ip_address_or_range: Specifies an IP address or a range of IP addresses from which to accept requests. If the IP address from which the request originates does not match the IP address or address range specified on the SAS token, the request is not authenticated. For example, specifying sip=168.1.5.65 or sip=168.1.5.60-168.1.5.70 on the SAS restricts the request to those IP addresses. - :keyword str policy_id: Access policy ID. + :paramtype ip_address_or_range: str or None + :keyword policy_id: Access policy ID. + :paramtype policy_id: str or None :keyword protocol: Specifies the protocol permitted for a request made. - :paramtype protocol: str or ~azure.data.tables.SASProtocol - :keyword str start_rk: Starting row key - :keyword str start_pk: Starting partition key - :keyword str end_rk: End row key - :keyword str end_pk: End partition key + :paramtype protocol: str or ~azure.data.tables.SASProtocol or None + :keyword start_rk: Starting row key. + :paramtype start_rk: str or None + :keyword start_pk: Starting partition key. + :paramtype start_pk: str or None + :keyword end_rk: End row key. + :paramtype end_rk: str or None + :keyword end_pk: End partition key. + :paramtype end_pk: str or None :return: A Shared Access Signature (sas) token. :rtype: str """ @@ -136,17 +161,16 @@ def generate_table_sas(credential: AzureNamedKeyCredential, table_name: str, **k sas = TableSharedAccessSignature(credential) return sas.generate_table( table_name=table_name, - permission=kwargs.pop("permission", None), - expiry=kwargs.pop("expiry", None), - start=kwargs.pop("start", None), - policy_id=kwargs.pop("policy_id", None), - ip=kwargs.pop("ip_address_or_range", None), - protocol=kwargs.pop("protocol", None), - start_pk=kwargs.pop("start_pk", None), - start_rk=kwargs.pop("start_rk", None), - end_pk=kwargs.pop("end_pk", None), - end_rk=kwargs.pop("end_rk", None), - **kwargs + permission=permission, + expiry=expiry, + start=start, + policy_id=policy_id, + ip_address_or_range=ip_address_or_range, + protocol=protocol, + start_pk=start_pk, + start_rk=start_rk, + end_pk=end_pk, + end_rk=end_rk, ) @@ -167,7 +191,7 @@ def __init__(self, credential: AzureNamedKeyCredential): def generate_table( self, table_name, - permission: Optional[TableSasPermissions] = None, + permission: Optional[Union[TableSasPermissions, str]] = None, expiry: Optional[Union[datetime, str]] = None, start: Optional[Union[datetime, str]] = None, policy_id: Optional[str] = None, @@ -177,7 +201,6 @@ def generate_table( start_rk: Optional[str] = None, end_pk: Optional[str] = None, end_rk: Optional[str] = None, - **kwargs # pylint: disable=unused-argument ) -> str: """ Generates a shared access signature for the table. @@ -191,7 +214,7 @@ def generate_table( Required unless an id is given referencing a stored access policy which contains this field. This field must be omitted if it has been specified in an associated stored access policy. - :type permission: ~azure.data.table.TableSasPermissions or None + :type permission: ~azure.data.table.TableSasPermissions or str or None :param expiry: The time at which the shared access signature becomes invalid. Required unless an id is given referencing a stored access policy diff --git a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py index a7c8ec7043e7..1240c7b6b0e5 100644 --- a/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py +++ b/sdk/tables/azure-data-tables/azure/data/tables/aio/_table_client_async.py @@ -75,14 +75,14 @@ def __init__( # pylint: disable=missing-client-constructor-parameter-credential :keyword credential: The credentials with which to authenticate. This is optional if the account URL already has a SAS token. The value can be one of AzureNamedKeyCredential (azure-core), - AzureSasCredential (azure-core), or an AsyncTokenCredential implementation from azure-identity. + AzureSasCredential (azure-core), or an AsyncTokenCredential implementation from azure-identity. :paramtype credential: ~azure.core.credentials.AzureNamedKeyCredential or ~azure.core.credentials.AzureSasCredential or ~azure.core.credentials_async.AsyncTokenCredential or None :keyword api_version: Specifies the version of the operation to use for this request. Default value - is "2019-02-02". Note that overriding this default value may result in unsupported behavior. - :paramtype api_version: str + is "2019-02-02". + :paramtype api_version: str or None :returns: None """ if not table_name: @@ -124,7 +124,8 @@ def from_table_url( :param str table_url: The full URI to the table, including SAS token if used. :keyword credential: The credentials with which to authenticate. This is optional if the - table URL already has a SAS token. + table URL already has a SAS token. The value can be one of AzureNamedKeyCredential (azure-core), + AzureSasCredential (azure-core), or a TokenCredential implementation from azure-identity. :paramtype credential: ~azure.core.credentials.AzureNamedKeyCredential or ~azure.core.credentials.AzureSasCredential or None @@ -155,11 +156,10 @@ def from_table_url( @distributed_trace_async async def get_table_access_policy(self, **kwargs) -> Mapping[str, Optional[TableAccessPolicy]]: - """ - Retrieves details about any stored access policies specified on the table that may be + """Retrieves details about any stored access policies specified on the table that may be used with Shared Access Signatures. - :return: Dictionary of SignedIdentifiers + :return: Dictionary of SignedIdentifiers. :rtype: dict[str, ~azure.data.tables.TableAccessPolicy] or dict[str, None] :raises: :class:`~azure.core.exceptions.HttpResponseError` """ @@ -190,8 +190,8 @@ async def set_table_access_policy( ) -> None: """Sets stored access policies for the table that may be used with Shared Access Signatures. - :param signed_identifiers: Access policies to set for the table - :type signed_identifiers: dict[str, ~azure.data.tables.TableAccessPolicy] + :param signed_identifiers: Access policies to set for the table. + :type signed_identifiers: Mapping[str, Optional[~azure.data.tables.TableAccessPolicy]] :return: None :raises: :class:`~azure.core.exceptions.HttpResponseError` """ @@ -225,8 +225,8 @@ async def create_table(self, **kwargs) -> TableItem: .. admonition:: Example: .. literalinclude:: ../samples/async_samples/sample_create_delete_table_async.py - :start-after: [START create_table] - :end-before: [END create_table] + :start-after: [START create_table_from_table_client] + :end-before: [END create_table_from_table_client] :language: python :dedent: 8 :caption: Creating a table from the TableClient object. @@ -244,8 +244,7 @@ async def create_table(self, **kwargs) -> TableItem: @distributed_trace_async async def delete_table(self, **kwargs) -> None: - """Deletes the table under the current account. No error will be raised if - the given table name is not found. + """Deletes the table under the current account. No error will be raised if the table does not exist. :return: None :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -253,8 +252,8 @@ async def delete_table(self, **kwargs) -> None: .. admonition:: Example: .. literalinclude:: ../samples/async_samples/sample_create_delete_table_async.py - :start-after: [START delete_from_table_client] - :end-before: [END delete_from_table_client] + :start-after: [START delete_table_from_table_client] + :end-before: [END delete_table_from_table_client] :language: python :dedent: 8 :caption: Deleting a table from the TableClient object. @@ -285,11 +284,12 @@ async def delete_entity( :param str partition_key: The partition key of the entity. :param str row_key: The row key of the entity. - :keyword str etag: Etag of the entity + :keyword etag: Etag of the entity. + :paramtype etag: str or None :keyword match_condition: The condition under which to perform the operation. Supported values include: MatchConditions.IfNotModified, MatchConditions.Unconditionally. The default value is Unconditionally. - :paramtype match_condition: ~azure.core.MatchConditions + :paramtype match_condition: ~azure.core.MatchConditions or None :return: None :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -299,7 +299,7 @@ async def delete_entity( :start-after: [START delete_entity] :end-before: [END delete_entity] :language: python - :dedent: 8 + :dedent: 12 :caption: Adding an entity to a Table """ @@ -315,13 +315,13 @@ async def delete_entity( """Deletes the specified entity in a table. No error will be raised if the entity or PartitionKey-RowKey pairing is not found. - :param entity: The entity to delete + :param entity: The entity to delete. :type entity: Union[TableEntity, Mapping[str, Any]] - :keyword str etag: Etag of the entity + :keyword etag: Etag of the entity. + :paramtype etag: str or None :keyword match_condition: The condition under which to perform the operation. Supported values include: MatchConditions.IfNotModified, MatchConditions.Unconditionally. - The default value is Unconditionally. - :paramtype match_condition: ~azure.core.MatchConditions + :paramtype match_condition: ~azure.core.MatchConditions or None :return: None :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -332,7 +332,7 @@ async def delete_entity( :end-before: [END delete_entity] :language: python :dedent: 8 - :caption: Adding an entity to a Table + :caption: Deleting an entity to a Table """ @distributed_trace_async @@ -375,11 +375,11 @@ async def delete_entity(self, *args: Union[EntityType, str], **kwargs: Any) -> N @distributed_trace_async async def create_entity(self, entity: EntityType, **kwargs) -> Mapping[str, Any]: - """Insert entity in a table. + """Inserts entity in a table. :param entity: The properties for the table entity. :type entity: ~azure.data.tables.TableEntity or Mapping - :return: Dictionary mapping operation metadata returned from the service + :return: Dictionary mapping operation metadata returned from the service. :rtype: dict[str, Any] :raises: :class:`~azure.core.exceptions.ResourceExistsError` If the entity already exists @@ -390,8 +390,8 @@ async def create_entity(self, entity: EntityType, **kwargs) -> Mapping[str, Any] :start-after: [START create_entity] :end-before: [END create_entity] :language: python - :dedent: 8 - :caption: Adding an entity to a Table + :dedent: 12 + :caption: Creating and adding an entity to a Table """ entity_json = _add_entity_properties(entity) try: @@ -422,18 +422,18 @@ async def update_entity( match_condition: Optional[MatchConditions] = None, **kwargs, ) -> Mapping[str, Any]: - """Update entity in a table. + """Updates an entity in a table. :param entity: The properties for the table entity. :type entity: ~azure.data.tables.TableEntity or dict[str, Any] - :param mode: Merge or Replace entity + :param mode: Merge or Replace entity. :type mode: ~azure.data.tables.UpdateMode - :keyword str etag: Etag of the entity + :keyword etag: Etag of the entity. + :paramtype etag: str or None :keyword match_condition: The condition under which to perform the operation. Supported values include: MatchConditions.IfNotModified, MatchConditions.Unconditionally. - The default value is Unconditionally. - :paramtype match_condition: ~azure.core.MatchCondition - :return: Dictionary of operation metadata returned from service + :paramtype match_condition: ~azure.core.MatchConditions or None + :return: Dictionary of operation metadata returned from service. :rtype: dict[str, Any] :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -444,7 +444,7 @@ async def update_entity( :end-before: [END update_entity] :language: python :dedent: 16 - :caption: Querying entities from a TableClient + :caption: Updating an already existing entity in a Table """ if match_condition and not etag and isinstance(entity, TableEntity): etag = entity.metadata.get("etag") @@ -500,9 +500,10 @@ def list_entities( ) -> AsyncItemPaged[TableEntity]: """Lists entities in a table. - :keyword int results_per_page: Number of entities returned per service request. + :keyword results_per_page: Number of entities returned per service request. + :paramtype results_per_page: int or None :keyword select: Specify desired properties of an entity to return. - :paramtype select: str or list[str] + :paramtype select: str or list[str] or None :return: An async iterator of :class:`~azure.data.tables.TableEntity` :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.data.tables.TableEntity] :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -514,7 +515,7 @@ def list_entities( :end-before: [END list_entities] :language: python :dedent: 16 - :caption: Querying entities from a TableClient + :caption: Listing all entities held within a table """ if select and not isinstance(select, str): select = ",".join(select) @@ -539,15 +540,16 @@ def query_entities( **kwargs, ) -> AsyncItemPaged[TableEntity]: # pylint: disable=line-too-long - """Lists entities in a table. + """Queries entities in a table. :param str query_filter: Specify a filter to return certain entities. For more information on filter formatting, see the `samples documentation `_. - :keyword int results_per_page: Number of entities returned per service request. + :keyword results_per_page: Number of entities returned per service request. + :paramtype results_per_page: int or None :keyword select: Specify desired properties of an entity to return. - :paramtype select: str or list[str] + :paramtype select: str or list[str] or None :keyword parameters: Dictionary for formatting query with additional, user defined parameters - :paramtype parameters: dict[str, Any] + :paramtype parameters: dict[str, Any] or None :return: An async iterator of :class:`~azure.data.tables.TableEntity` :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.data.tables.TableEntity] :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -559,7 +561,7 @@ def query_entities( :end-before: [END query_entities] :language: python :dedent: 8 - :caption: Querying entities from a TableClient + :caption: Querying entities held within a table """ query_filter = _parameter_filter_substitution(parameters, query_filter) if select and not isinstance(select, str): @@ -584,15 +586,15 @@ async def get_entity( select: Optional[Union[str, List[str]]] = None, **kwargs, ) -> TableEntity: - """Get a single entity in a table. + """Gets a single entity in a table. :param partition_key: The partition key of the entity. :type partition_key: str :param row_key: The row key of the entity. :type row_key: str :keyword select: Specify desired properties of an entity to return. - :paramtype select: str or list[str] - :return: Dictionary mapping operation metadata returned from the service + :paramtype select: str or list[str] or None + :return: Dictionary mapping operation metadata returned from the service. :rtype: ~azure.data.tables.TableEntity :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -603,7 +605,7 @@ async def get_entity( :end-before: [END get_entity] :language: python :dedent: 16 - :caption: Getting an entity from PartitionKey and RowKey + :caption: Getting an entity with PartitionKey and RowKey from a table """ user_select = None if select and not isinstance(select, str): @@ -627,13 +629,13 @@ async def get_entity( async def upsert_entity( self, entity: EntityType, mode: Union[str, UpdateMode] = UpdateMode.MERGE, **kwargs ) -> Mapping[str, Any]: - """Update/Merge or Insert entity into table. + """Updates (merge or replace) an entity into a table. :param entity: The properties for the table entity. :type entity: ~azure.data.tables.TableEntity or dict[str, Any] - :param mode: Merge or Replace entity + :param mode: Merge or Replace entity. :type mode: ~azure.data.tables.UpdateMode - :return: Dictionary mapping operation metadata returned from the service + :return: Dictionary mapping operation metadata returned from the service. :rtype: dict[str, Any] :raises: :class:`~azure.core.exceptions.HttpResponseError` @@ -644,7 +646,7 @@ async def upsert_entity( :end-before: [END upsert_entity] :language: python :dedent: 16 - :caption: Update/Merge or Insert an entity into a table + :caption: Replacing/Merging or Inserting an entity into a table """ partition_key = entity["PartitionKey"] @@ -688,7 +690,7 @@ async def upsert_entity( async def submit_transaction( self, operations: Union[Iterable[TransactionOperationType], AsyncIterable[TransactionOperationType]], **kwargs ) -> List[Mapping[str, Any]]: - """Commit a list of operations as a single transaction. + """Commits a list of operations as a single transaction. If any one of these operations fails, the entire transaction will be rejected. @@ -700,10 +702,10 @@ async def submit_transaction( - ('upsert', {'PartitionKey': 'A', 'RowKey': 'B'}, {'mode': UpdateMode.REPLACE}) :type operations: - Union[Iterable[Tuple[str, Entity, Mapping[str, Any]]],AsyncIterable[Tuple[str, Entity, Mapping[str, Any]]]] + Union[Iterable[Tuple[str, Entity, Mapping[str, Any]]],AsyncIterable[Tuple[str, Entity, Mapping[str, Any]]]] :return: A list of mappings with response metadata for each operation in the transaction. :rtype: list[Mapping[str, Any]] - :raises ~azure.data.tables.TableTransactionError: + :raises: :class:` ~azure.data.tables.TableTransactionError` .. admonition:: Example: diff --git a/sdk/tables/azure-data-tables/pyproject.toml b/sdk/tables/azure-data-tables/pyproject.toml index e00361912969..2bfa3fda6bf7 100644 --- a/sdk/tables/azure-data-tables/pyproject.toml +++ b/sdk/tables/azure-data-tables/pyproject.toml @@ -1,2 +1,3 @@ [tool.azure-sdk-build] pyright = false +strict_sphinx = true diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py index 52c677636df4..3c0d09b16b76 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_batching_async.py @@ -42,65 +42,51 @@ def __init__(self): self.connection_string = f"DefaultEndpointsProtocol=https;AccountName={self.account_name};AccountKey={self.access_key};EndpointSuffix={self.endpoint_suffix}" self.table_name = "sampleTransactionAsync" - async def _create_entities(self): - from azure.core.exceptions import ResourceExistsError - - self.entity1 = {"PartitionKey": "pk001", "RowKey": "rk001", "Value": 4, "day": "Monday", "float": 4.003} - self.entity2 = {"PartitionKey": "pk001", "RowKey": "rk002", "Value": 4, "day": "Tuesday", "float": 4.003} - self.entity3 = {"PartitionKey": "pk001", "RowKey": "rk003", "Value": 4, "day": "Wednesday", "float": 4.003} - self.entity4 = {"PartitionKey": "pk001", "RowKey": "rk004", "Value": 4, "day": "Thursday", "float": 4.003} - - entities = [self.entity2, self.entity3, self.entity4] - - for entity in entities: - try: - await self.table_client.create_entity(entity) - except ResourceExistsError: - print("entity already exists") - pass - async def sample_transaction(self): - # Instantiate a TableServiceClient using a connection string - # [START batching] from azure.data.tables.aio import TableClient from azure.data.tables import TableTransactionError from azure.core.exceptions import ResourceExistsError - self.table_client = TableClient.from_connection_string( + entity1 = {"PartitionKey": "pk001", "RowKey": "rk001", "Value": 4, "day": "Monday", "float": 4.003} + entity2 = {"PartitionKey": "pk001", "RowKey": "rk002", "Value": 4, "day": "Tuesday", "float": 4.003} + entity3 = {"PartitionKey": "pk001", "RowKey": "rk003", "Value": 4, "day": "Wednesday", "float": 4.003} + entity4 = {"PartitionKey": "pk001", "RowKey": "rk004", "Value": 4, "day": "Thursday", "float": 4.003} + + # Instantiate a TableServiceClient using a connection string + async with TableClient.from_connection_string( conn_str=self.connection_string, table_name=self.table_name - ) - - try: - await self.table_client.create_table() - print("Created table") - except ResourceExistsError: - print("Table already exists") - - await self._create_entities() - - operations: List[TransactionOperationType] = [ - ("create", self.entity1), - ("delete", self.entity2), - ("upsert", self.entity3), - ("update", self.entity4, {"mode": "replace"}), - ] - try: - await self.table_client.submit_transaction(operations) - except TableTransactionError as e: - print("There was an error with the transaction operation") - print(f"Error: {e}") - # [END batching] - - async def clean_up(self): - await self.table_client.delete_table() - await self.table_client.__aexit__() + ) as table_client: + + try: + await table_client.create_table() + print("Created table") + except ResourceExistsError: + print("Table already exists") + + await table_client.upsert_entity(entity2) + await table_client.upsert_entity(entity3) + await table_client.upsert_entity(entity4) + + operations: List[TransactionOperationType] = [ + ("create", entity1), + ("delete", entity2), + ("upsert", entity3), + ("update", entity4, {"mode": "replace"}), + ] + try: + await table_client.submit_transaction(operations) + except TableTransactionError as e: + print("There was an error with the transaction operation") + print(f"Error: {e}") + # [END batching] + + await table_client.delete_table() async def main(): sample = CreateClients() await sample.sample_transaction() - await sample.clean_up() if __name__ == "__main__": diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py index 3224b6fdd82b..753891adbdea 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_create_delete_table_async.py @@ -85,13 +85,13 @@ async def create_from_table_client(self): async def delete_from_table_client(self): from azure.data.tables.aio import TableClient - # [START delete_from_table_client] + # [START delete_table_from_table_client] async with TableClient.from_connection_string( conn_str=self.connection_string, table_name=self.table_name ) as table_client: await table_client.delete_table() print(f"Deleted table {table_client.table_name}!") - # [END delete_from_table_client] + # [END delete_table_from_table_client] async def main(): diff --git a/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py b/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py index 4cb7f7843a95..d2b02251ea9f 100644 --- a/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py +++ b/sdk/tables/azure-data-tables/samples/async_samples/sample_insert_delete_entities_async.py @@ -70,19 +70,19 @@ async def create_entity(self): table_client = TableClient.from_connection_string(self.connection_string, self.table_name) # Create a table in case it does not already exist - # [START create_entity] async with table_client: try: await table_client.create_table() except HttpResponseError: print("Table already exists") + # [START create_entity] try: resp = await table_client.create_entity(entity=self.entity) print(resp) except ResourceExistsError: print("Entity already exists") - # [END create_entity] + # [END create_entity] async def delete_entity(self): from azure.data.tables.aio import TableClient @@ -92,16 +92,16 @@ async def delete_entity(self): credential = AzureNamedKeyCredential(self.account_name, self.access_key) table_client = TableClient(endpoint=self.endpoint, table_name=self.table_name, credential=credential) - # [START delete_entity] async with table_client: try: - resp = await table_client.create_entity(entity=self.entity) + await table_client.create_entity(entity=self.entity) except ResourceExistsError: print("Entity already exists!") + # [START delete_entity] await table_client.delete_entity(row_key=self.entity["RowKey"], partition_key=self.entity["PartitionKey"]) print("Successfully deleted!") - # [END delete_entity] + # [END delete_entity] async def clean_up(self): from azure.data.tables.aio import TableServiceClient diff --git a/sdk/tables/azure-data-tables/samples/sample_batching.py b/sdk/tables/azure-data-tables/samples/sample_batching.py index 5fdab66532cd..28d8c69f1d54 100644 --- a/sdk/tables/azure-data-tables/samples/sample_batching.py +++ b/sdk/tables/azure-data-tables/samples/sample_batching.py @@ -42,51 +42,46 @@ def __init__(self): self.table_name = "sampleTransaction" def sample_transaction(self): - # Instantiate a TableClient using a connection string + # [START batching] + from azure.data.tables import TableClient, TableTransactionError + from azure.core.exceptions import ResourceExistsError + entity1 = {"PartitionKey": "pk001", "RowKey": "rk001", "Value": 4, "day": "Monday", "float": 4.003} entity2 = {"PartitionKey": "pk001", "RowKey": "rk002", "Value": 4, "day": "Tuesday", "float": 4.003} entity3 = {"PartitionKey": "pk001", "RowKey": "rk003", "Value": 4, "day": "Wednesday", "float": 4.003} entity4 = {"PartitionKey": "pk001", "RowKey": "rk004", "Value": 4, "day": "Thursday", "float": 4.003} - # [START batching] - from azure.data.tables import TableClient, TableTransactionError - from azure.core.exceptions import ResourceExistsError - - self.table_client = TableClient.from_connection_string( + # Instantiate a TableClient using a connection string + with TableClient.from_connection_string( conn_str=self.connection_string, table_name=self.table_name - ) - - try: - self.table_client.create_table() - print("Created table") - except ResourceExistsError: - print("Table already exists") - - self.table_client.upsert_entity(entity2) - self.table_client.upsert_entity(entity3) - self.table_client.upsert_entity(entity4) - - operations: List[TransactionOperationType] = [ - ("upsert", entity1), - ("delete", entity2), - ("upsert", entity3), - ("update", entity4, {"mode": "replace"}), - ] - try: - self.table_client.submit_transaction(operations) - except TableTransactionError as e: - print("There was an error with the transaction operation") - print(f"Error: {e}") - # [END batching] - - def clean_up(self): - self.table_client.delete_table() - self.table_client.__exit__() + ) as table_client: + + try: + table_client.create_table() + print("Created table") + except ResourceExistsError: + print("Table already exists") + + table_client.upsert_entity(entity2) + table_client.upsert_entity(entity3) + table_client.upsert_entity(entity4) + + operations: List[TransactionOperationType] = [ + ("create", entity1), + ("delete", entity2), + ("upsert", entity3), + ("update", entity4, {"mode": "replace"}), + ] + try: + table_client.submit_transaction(operations) + except TableTransactionError as e: + print("There was an error with the transaction operation") + print(f"Error: {e}") + # [END batching] + + table_client.delete_table() if __name__ == "__main__": sample = CreateClients() - try: - sample.sample_transaction() - finally: - sample.clean_up() + sample.sample_transaction() diff --git a/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py b/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py index d6eb950a50be..0a285cd2bd19 100644 --- a/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py +++ b/sdk/tables/azure-data-tables/samples/sample_insert_delete_entities.py @@ -81,7 +81,7 @@ def create_entity(self): print(resp) except ResourceExistsError: print("Entity already exists") - # [END create_entity] + # [END create_entity] def delete_entity(self): from azure.data.tables import TableClient @@ -91,7 +91,7 @@ def delete_entity(self): credential = AzureNamedKeyCredential(self.account_name, self.access_key) with TableClient(endpoint=self.endpoint, table_name=self.table_name, credential=credential) as table_client: - # Create entity to delete (to showcase etag) + # Create an entity to delete (to showcase etag) try: table_client.create_entity(entity=self.entity) except ResourceExistsError: diff --git a/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py b/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py index f0f7775deb44..b309b84d36e7 100644 --- a/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py +++ b/sdk/tables/azure-data-tables/samples/sample_update_upsert_merge_entities.py @@ -70,10 +70,8 @@ def create_and_get_entities(self): "barcode": b"135aefg8oj0ld58", # cspell:disable-line } try: - # [START create_entity] created_entity = table.create_entity(entity=my_entity) print(f"Created entity: {created_entity}") - # [END create_entity] # [START get_entity] # Get Entity by partition and row key diff --git a/sdk/tables/azure-data-tables/tests/test_table_service_stats.py b/sdk/tables/azure-data-tables/tests/test_table_service_stats.py index ec9d9eded00b..f8ab3e19245c 100644 --- a/sdk/tables/azure-data-tables/tests/test_table_service_stats.py +++ b/sdk/tables/azure-data-tables/tests/test_table_service_stats.py @@ -9,6 +9,7 @@ from _shared.testcase import TableTestCase from preparers import tables_decorator + # --Test Class ----------------------------------------------------------------- class TestTableServiceStats(AzureRecordedTestCase, TableTestCase): # --Test cases per service --------------------------------------- diff --git a/sdk/timeseriesinsights/azure-mgmt-timeseriesinsights/pyproject.toml b/sdk/timeseriesinsights/azure-mgmt-timeseriesinsights/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/timeseriesinsights/azure-mgmt-timeseriesinsights/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/trafficmanager/azure-mgmt-trafficmanager/pyproject.toml b/sdk/trafficmanager/azure-mgmt-trafficmanager/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/trafficmanager/azure-mgmt-trafficmanager/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/sdk/voiceservices/azure-mgmt-voiceservices/pyproject.toml b/sdk/voiceservices/azure-mgmt-voiceservices/pyproject.toml new file mode 100644 index 000000000000..556e80ea236e --- /dev/null +++ b/sdk/voiceservices/azure-mgmt-voiceservices/pyproject.toml @@ -0,0 +1,2 @@ +[tool.azure-sdk-build] +strict_sphinx = true diff --git a/tools/azure-sdk-tools/devtools_testutils/__init__.py b/tools/azure-sdk-tools/devtools_testutils/__init__.py index 8e953daba685..0d4d4af7280a 100644 --- a/tools/azure-sdk-tools/devtools_testutils/__init__.py +++ b/tools/azure-sdk-tools/devtools_testutils/__init__.py @@ -23,6 +23,7 @@ from .proxy_testcase import recorded_by_proxy from .sanitizers import ( add_api_version_transform, + add_batch_sanitizers, add_body_key_sanitizer, add_body_regex_sanitizer, add_body_string_sanitizer, @@ -40,6 +41,7 @@ add_uri_string_sanitizer, add_uri_subscription_id_sanitizer, PemCertificate, + Sanitizer, set_bodiless_matcher, set_custom_default_matcher, set_default_function_settings, @@ -56,6 +58,7 @@ __all__ = [ "add_api_version_transform", + "add_batch_sanitizers", "add_body_key_sanitizer", "add_body_regex_sanitizer", "add_body_string_sanitizer", @@ -79,6 +82,7 @@ "FakeResource", "ReservedResourceNameError", "ResourceGroupPreparer", + "Sanitizer", "StorageAccountPreparer", "BlobAccountPreparer", "CachedStorageAccountPreparer", diff --git a/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py b/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py index 4234b45bcc45..1a5bc332b3f2 100644 --- a/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py +++ b/tools/azure-sdk-tools/devtools_testutils/azure_recorded_testcase.py @@ -20,6 +20,7 @@ get_resource_name, get_qualified_method_name, ) +from .fake_credentials import SANITIZED from .fake_credentials_async import AsyncFakeCredential from .helpers import is_live, trim_kwargs_from_test_function from .sanitizers import add_general_string_sanitizer @@ -257,12 +258,12 @@ def generate_sas(self, *args, **kwargs): :keyword fake_parameters: A dictionary with token parameter names as keys, and the values to sanitize these keys with as values. For example: {"sktid": "00000000-0000-0000-0000-000000000000", "sig": "sanitized"} :paramtype fake_parameters: Dict[str, str] - :keyword str fake_value: The value used to sanitize `sig`. Defaults to "fake_token_value". + :keyword str fake_value: The value used to sanitize `sig`. Defaults to "Sanitized". """ sas_func = args[0] sas_func_pos_args = args[1:] - fake_value = kwargs.pop("fake_value", "fake_token_value") + fake_value = kwargs.pop("fake_value", SANITIZED) fake_parameters = kwargs.pop("fake_parameters", {}) token = sas_func(*sas_func_pos_args, **kwargs) diff --git a/tools/azure-sdk-tools/devtools_testutils/fake_credentials.py b/tools/azure-sdk-tools/devtools_testutils/fake_credentials.py index e0956db37836..8c3e92e4087f 100644 --- a/tools/azure-sdk-tools/devtools_testutils/fake_credentials.py +++ b/tools/azure-sdk-tools/devtools_testutils/fake_credentials.py @@ -1,12 +1,20 @@ from azure.core.credentials import AccessToken +# General-use placeholder values +SANITIZED = "Sanitized" # General-use fake credentials +FAKE_ACCESS_TOKEN = "eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJlbWFpbCI6IkJvYkBjb250b3NvLmNvbSIsImdpdmVuX25hbWUiOiJCb2I" \ + "iLCJpc3MiOiJodHRwOi8vRGVmYXVsdC5Jc3N1ZXIuY29tIiwiYXVkIjoiaHR0cDovL0RlZmF1bHQuQXVkaWVuY2UuY29tIiwiaWF0IjoiMTYwNz" \ + "k3ODY4MyIsIm5iZiI6IjE2MDc5Nzg2ODMiLCJleHAiOiIxNjA3OTc4OTgzIn0." +FAKE_ID = "00000000-0000-0000-0000-000000000000" FAKE_LOGIN_PASSWORD = "F4ke_L0gin_P4ss" # Service-specific fake credentials BATCH_TEST_PASSWORD = "kt#_gahr!@aGERDXA" MGMT_HDINSIGHT_FAKE_KEY = "qFmud5LfxcCxWUvWcGMhKDp0v0KuBRLsO/AIddX734W7lzdInsVMsB5ILVoOrF+0fCfk/IYYy5SJ9Q+2v4aihQ==" +SERVICEBUS_FAKE_SAS = "SharedAccessSignature sr=https%3A%2F%2Ffoo.servicebus.windows.net&sig=dummyValue%3D&se=168726" \ + "7490&skn=dummyKey" STORAGE_ACCOUNT_FAKE_KEY = "NzhL3hKZbJBuJ2484dPTR+xF30kYaWSSCbs2BzLgVVI1woqeST/1IgqaLm6QAOTxtGvxctSNbIR/1hW8yH+bJg==" diff --git a/tools/azure-sdk-tools/devtools_testutils/proxy_startup.py b/tools/azure-sdk-tools/devtools_testutils/proxy_startup.py index 8eb3431cf0c0..e0b3e3aa4a22 100644 --- a/tools/azure-sdk-tools/devtools_testutils/proxy_startup.py +++ b/tools/azure-sdk-tools/devtools_testutils/proxy_startup.py @@ -24,8 +24,13 @@ from ci_tools.variables import in_ci from .config import PROXY_URL +from .fake_credentials import FAKE_ACCESS_TOKEN, FAKE_ID, SERVICEBUS_FAKE_SAS, SANITIZED from .helpers import get_http_client, is_live_and_not_recording -from .sanitizers import add_oauth_response_sanitizer, add_remove_header_sanitizer, set_custom_default_matcher +from .sanitizers import ( + add_batch_sanitizers, + Sanitizer, + set_custom_default_matcher, +) load_dotenv(find_dotenv()) @@ -280,6 +285,157 @@ def prepare_local_tool(repo_root: str) -> str: ) +def set_common_sanitizers() -> None: + """Register sanitizers that will apply to all recordings throughout the SDK.""" + batch_sanitizers = {} + + # Remove headers from recordings if we don't need them, and ignore them if present + # Authorization, for example, can contain sensitive info and can cause matching failures during challenge auth + headers_to_ignore = "Authorization, x-ms-client-request-id, x-ms-request-id" + set_custom_default_matcher(excluded_headers=headers_to_ignore) + batch_sanitizers[Sanitizer.REMOVE_HEADER] = [{"headers": headers_to_ignore}] + + # Remove OAuth interactions, which can contain client secrets and aren't necessary for playback testing + batch_sanitizers[Sanitizer.OAUTH_RESPONSE] = [None] + + # Body key sanitizers for sensitive fields in JSON requests/responses + batch_sanitizers[Sanitizer.BODY_KEY] = [ + {"json_path": "$..access_token", "value": FAKE_ACCESS_TOKEN}, + {"json_path": "$..AccessToken", "value": FAKE_ACCESS_TOKEN}, + {"json_path": "$..targetModelLocation", "value": SANITIZED}, + {"json_path": "$..targetResourceId", "value": SANITIZED}, + {"json_path": "$..urlSource", "value": SANITIZED}, + {"json_path": "$..azureBlobSource.containerUrl", "value": SANITIZED}, + {"json_path": "$..source", "value": SANITIZED}, + {"json_path": "$..resourceLocation", "value": SANITIZED}, + {"json_path": "Location", "value": SANITIZED}, + {"json_path": "$..to", "value": SANITIZED}, + {"json_path": "$..from", "value": SANITIZED}, + {"json_path": "$..sasUri", "value": SANITIZED}, + {"json_path": "$..containerUri", "value": SANITIZED}, + {"json_path": "$..inputDataUri", "value": SANITIZED}, + {"json_path": "$..outputDataUri", "value": SANITIZED}, + # {"json_path": "$..id", "value": SANITIZED}, + {"json_path": "$..token", "value": SANITIZED}, + {"json_path": "$..appId", "value": SANITIZED}, + {"json_path": "$..userId", "value": SANITIZED}, + {"json_path": "$..storageAccount", "value": SANITIZED}, + {"json_path": "$..resourceGroup", "value": SANITIZED}, + {"json_path": "$..guardian", "value": SANITIZED}, + {"json_path": "$..scan", "value": SANITIZED}, + {"json_path": "$..catalog", "value": SANITIZED}, + {"json_path": "$..lastModifiedBy", "value": SANITIZED}, + {"json_path": "$..managedResourceGroupName", "value": SANITIZED}, + {"json_path": "$..friendlyName", "value": SANITIZED}, + {"json_path": "$..createdBy", "value": SANITIZED}, + {"json_path": "$..credential", "value": SANITIZED}, + {"json_path": "$..aliasPrimaryConnectionString", "value": SANITIZED}, + {"json_path": "$..aliasSecondaryConnectionString", "value": SANITIZED}, + {"json_path": "$..connectionString", "value": SANITIZED}, + {"json_path": "$..primaryConnectionString", "value": SANITIZED}, + {"json_path": "$..secondaryConnectionString", "value": SANITIZED}, + {"json_path": "$..sshPassword", "value": SANITIZED}, + {"json_path": "$..primaryKey", "value": SANITIZED}, + {"json_path": "$..secondaryKey", "value": SANITIZED}, + {"json_path": "$..runAsPassword", "value": SANITIZED}, + {"json_path": "$..adminPassword", "value": SANITIZED}, + {"json_path": "$..adminPassword.value", "value": SANITIZED}, + {"json_path": "$..administratorLoginPassword", "value": SANITIZED}, + {"json_path": "$..accessSAS", "value": SANITIZED}, + {"json_path": "$..WEBSITE_AUTH_ENCRYPTION_KEY", "value": SANITIZED}, + {"json_path": "$..storageContainerWriteSas", "value": SANITIZED}, + {"json_path": "$..storageContainerUri", "value": SANITIZED}, + {"json_path": "$..storageContainerReadListSas", "value": SANITIZED}, + {"json_path": "$..storageAccountPrimaryKey", "value": SANITIZED}, + {"json_path": "$..uploadUrl", "value": SANITIZED}, + {"json_path": "$..secondaryReadonlyMasterKey", "value": SANITIZED}, + {"json_path": "$..primaryMasterKey", "value": SANITIZED}, + {"json_path": "$..primaryReadonlyMasterKey", "value": SANITIZED}, + {"json_path": "$..secondaryMasterKey", "value": SANITIZED}, + {"json_path": "$..scriptUrlSasToken", "value": SANITIZED}, + {"json_path": "$..privateKey", "value": SANITIZED}, + {"json_path": "$..password", "value": SANITIZED}, + {"json_path": "$..logLink", "value": SANITIZED}, + {"json_path": "$..keyVaultClientSecret", "value": SANITIZED}, + {"json_path": "$..httpHeader", "value": SANITIZED}, + {"json_path": "$..functionKey", "value": SANITIZED}, + {"json_path": "$..fencingClientPassword", "value": SANITIZED}, + {"json_path": "$..encryptedCredential", "value": SANITIZED}, + {"json_path": "$..clientSecret", "value": SANITIZED}, + {"json_path": "$..certificatePassword", "value": SANITIZED}, + {"json_path": "$..authHeader", "value": SANITIZED}, + {"json_path": "$..atlasKafkaSecondaryEndpoint", "value": SANITIZED}, + {"json_path": "$..atlasKafkaPrimaryEndpoint", "value": SANITIZED}, + {"json_path": "$..appkey", "value": SANITIZED}, + {"json_path": "$..acrToken", "value": SANITIZED}, + {"json_path": "$..accountKey", "value": SANITIZED}, + {"json_path": "$..accountName", "value": SANITIZED}, + {"json_path": "$..decryptionKey", "value": SANITIZED}, + {"json_path": "$..applicationId", "value": SANITIZED}, + {"json_path": "$..apiKey", "value": SANITIZED}, + {"json_path": "$..userName", "value": SANITIZED}, + {"json_path": "$.properties.DOCKER_REGISTRY_SERVER_PASSWORD", "value": SANITIZED}, + {"json_path": "$.value[*].key", "value": SANITIZED}, + # {"json_path": "$.key", "value": SANITIZED}, + {"json_path": "$..clientId", "value": FAKE_ID}, + {"json_path": "$..principalId", "value": FAKE_ID}, + {"json_path": "$..tenantId", "value": FAKE_ID}, + ] + + # Body regex sanitizers for sensitive patterns in request/response bodies + batch_sanitizers[Sanitizer.BODY_REGEX] = [ + {"regex": "(client_id=)[^&]+", "value": "$1sanitized"}, + {"regex": "(client_secret=)[^&]+", "value": "$1sanitized"}, + {"regex": "(client_assertion=)[^&]+", "value": "$1sanitized"}, + {"regex": "(?:[\\?&](sv|sig|se|srt|ss|sp)=)(?(([^&\\s]*)))", "value": SANITIZED}, + {"regex": "refresh_token=(?.*?)(?=&|$)", "group_for_replace": "group", "value": SANITIZED}, + {"regex": "access_token=(?.*?)(?=&|$)", "group_for_replace": "group", "value": SANITIZED}, + {"regex": "token=(?[^\\u0026]+)($|\\u0026)", "group_for_replace": "token", "value": SANITIZED}, + {"regex": "-----BEGIN PRIVATE KEY-----\\n(.+\\n)*-----END PRIVATE KEY-----\\n", "value": SANITIZED}, + {"regex": "(?<=).*?(?:)(.*)(?:)", "value": SANITIZED}, + {"regex": "(?<=).*?(?:)(.*)(?:)", "value": SANITIZED}, + {"regex": "(?<=).*?(?:)(.*)(?:)", "value": SANITIZED}, + {"regex": "(?:Password=)(.*?)(?:;)", "value": SANITIZED}, + {"regex": "(?:User ID=)(.*?)(?:;)", "value": SANITIZED}, + {"regex": "(?:)(.*)(?:)", "value": SANITIZED}, + {"regex": "(?:)(.*)(?:)", "value": SANITIZED}, + ] + + # General regex sanitizers for sensitive patterns throughout interactions + batch_sanitizers[Sanitizer.GENERAL_REGEX] = [ + {"regex": "SharedAccessKey=(?[^;\\\"]+)", "group_for_replace": "key", "value": SANITIZED}, + {"regex": "AccountKey=(?[^;\\\"]+)", "group_for_replace": "key", "value": SANITIZED}, + {"regex": "accesskey=(?[^;\\\"]+)", "group_for_replace": "key", "value": SANITIZED}, + {"regex": "Accesskey=(?[^;\\\"]+)", "group_for_replace": "key", "value": SANITIZED}, + {"regex": "Secret=(?[^;\\\"]+)", "group_for_replace": "key", "value": SANITIZED}, + ] + + # Header regex sanitizers for sensitive patterns in request/response headers + batch_sanitizers[Sanitizer.HEADER_REGEX] = [ + {"key": "subscription-key", "value": SANITIZED}, + {"key": "x-ms-encryption-key", "value": SANITIZED}, + {"key": "x-ms-rename-source", "value": SANITIZED}, + {"key": "x-ms-file-rename-source", "value": SANITIZED}, + {"key": "x-ms-copy-source", "value": SANITIZED}, + {"key": "x-ms-copy-source-authorization", "value": SANITIZED}, + {"key": "x-ms-file-rename-source-authorization", "value": SANITIZED}, + {"key": "x-ms-encryption-key-sha256", "value": SANITIZED}, + {"key": "api-key", "value": SANITIZED}, + {"key": "aeg-sas-token", "value": SANITIZED}, + {"key": "aeg-sas-key", "value": SANITIZED}, + {"key": "aeg-channel-name", "value": SANITIZED}, + {"key": "SupplementaryAuthorization", "value": SERVICEBUS_FAKE_SAS}, + ] + + # URI regex sanitizers for sensitive patterns in request/response URLs + batch_sanitizers[Sanitizer.URI_REGEX] = [ + {"regex": "sig=(?[^&]+)", "group_for_replace": "sig", "value": SANITIZED} + ] + + # Send all the above sanitizers to the test proxy in a single, batch request + add_batch_sanitizers(sanitizers=batch_sanitizers) + + def start_test_proxy(request) -> None: """Starts the test proxy and returns when the proxy server is ready to receive requests. @@ -334,12 +490,7 @@ def start_test_proxy(request) -> None: # Wait for the proxy server to become available check_proxy_availability() - # Remove headers from recordings if we don't need them, and ignore them if present - # Authorization, for example, can contain sensitive info and can cause matching failures during challenge auth - headers_to_ignore = "Authorization, x-ms-client-request-id, x-ms-request-id" - add_remove_header_sanitizer(headers=headers_to_ignore) - set_custom_default_matcher(excluded_headers=headers_to_ignore) - add_oauth_response_sanitizer() + set_common_sanitizers() def stop_test_proxy() -> None: diff --git a/tools/azure-sdk-tools/devtools_testutils/sanitizers.py b/tools/azure-sdk-tools/devtools_testutils/sanitizers.py index 1650c7a3892a..7c4327b17004 100644 --- a/tools/azure-sdk-tools/devtools_testutils/sanitizers.py +++ b/tools/azure-sdk-tools/devtools_testutils/sanitizers.py @@ -3,14 +3,30 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- +from enum import Enum import json -from typing import TYPE_CHECKING +from typing import Dict, List, Optional from .config import PROXY_URL from .helpers import get_http_client, get_recording_id, is_live, is_live_and_not_recording -if TYPE_CHECKING: - from typing import Optional + +class Sanitizer(str, Enum): + """Sanitizers that can be applied to recordings.""" + + BODY_KEY = "BodyKeySanitizer" + BODY_REGEX = "BodyRegexSanitizer" + BODY_STRING = "BodyStringSanitizer" + CONTINUATION = "ContinuationSanitizer" + GENERAL_REGEX = "GeneralRegexSanitizer" + GENERAL_STRING = "GeneralStringSanitizer" + HEADER_REGEX = "HeaderRegexSanitizer" + HEADER_STRING = "HeaderStringSanitizer" + OAUTH_RESPONSE = "OAuthResponseSanitizer" + REMOVE_HEADER = "RemoveHeaderSanitizer" + URI_REGEX = "UriRegexSanitizer" + URI_STRING = "UriStringSanitizer" + URI_SUBSCRIPTION_ID = "UriSubscriptionIdSanitizer" # This file contains methods for adjusting many aspects of test proxy behavior: @@ -416,6 +432,46 @@ def add_uri_subscription_id_sanitizer(**kwargs) -> None: _send_sanitizer_request("UriSubscriptionIdSanitizer", request_args, {"x-recording-id": x_recording_id}) +def add_batch_sanitizers(sanitizers: Dict[str, List[Optional[Dict[str, str]]]], headers: Optional[Dict] = None) -> None: + """Registers a batch of sanitizers at once. + + If live tests are being run with recording turned off via the AZURE_SKIP_LIVE_RECORDING environment variable, no + request will be sent. + + :param sanitizers: A group of sanitizers to add, as a dictionary. Keys should be sanitizer names (from the Sanitizer + enum) and values should be lists containing dictionaries of sanitizer constructor parameters. The parameters + should be formatted as key-value pairs aligning with keyword-only arguments to sanitizer methods. + :type sanitizers: dict[str, list[Optional[dict]]] + """ + + if is_live_and_not_recording(): + return + + data = [] # Body content to populate with multiple sanitizer definitions + + for sanitizer in sanitizers: + # Iterate over each instance of the particular sanitizer (e.g. each body regex sanitizer) + for sanitizer_instance in sanitizers[sanitizer]: + sanitizer_definition = {"Name": sanitizer} + if sanitizer_instance: + sanitizer_definition.update({"Body": _get_request_args(**sanitizer_instance)}) + data.append(sanitizer_definition) + + headers_to_send = {"Content-Type": "application/json"} + if headers is not None: + for key in headers: + if headers[key] is not None: + headers_to_send[key] = headers[key] + + http_client = get_http_client() + http_client.request( + method="POST", + url="{}/Admin/AddSanitizers".format(PROXY_URL), + headers=headers_to_send, + body=json.dumps(data).encode("utf-8"), + ) + + # ----------TRANSFORMS---------- # # A transform extends functionality of the test proxy by applying to responses just before they are returned during @@ -538,7 +594,7 @@ def __init__(self, data: str, key: str) -> None: # ----------HELPERS---------- -def _get_recording_option_args(**kwargs) -> dict: +def _get_recording_option_args(**kwargs) -> Dict: """Returns a dictionary of recording option request arguments, formatted for test proxy consumption.""" certificates = kwargs.pop("certificates", None) @@ -564,7 +620,7 @@ def _get_recording_option_args(**kwargs) -> dict: return request_args -def _get_request_args(**kwargs) -> dict: +def _get_request_args(**kwargs) -> Dict: """Returns a dictionary of request arguments, formatted for test proxy consumption.""" request_args = {} @@ -605,7 +661,7 @@ def _get_request_args(**kwargs) -> dict: return request_args -def _send_matcher_request(matcher: str, headers: dict, parameters: "Optional[dict]" = None) -> None: +def _send_matcher_request(matcher: str, headers: Dict, parameters: Optional[Dict] = None) -> None: """Sends a POST request to the test proxy endpoint to register the specified matcher. If live tests are being run, no request will be sent. @@ -633,7 +689,7 @@ def _send_matcher_request(matcher: str, headers: dict, parameters: "Optional[dic ) -def _send_recording_options_request(parameters: dict, headers: "Optional[dict]" = None) -> None: +def _send_recording_options_request(parameters: Dict, headers: Optional[Dict] = None) -> None: """Sends a POST request to the test proxy endpoint to set the specified recording options. If live tests are being run with recording turned off via the AZURE_SKIP_LIVE_RECORDING environment variable, no @@ -661,7 +717,7 @@ def _send_recording_options_request(parameters: dict, headers: "Optional[dict]" ) -def _send_reset_request(headers: dict) -> None: +def _send_reset_request(headers: Dict) -> None: """Sends a POST request to the test proxy endpoint to reset setting customizations. If live tests are being run with recording turned off via the AZURE_SKIP_LIVE_RECORDING environment variable, no @@ -682,7 +738,7 @@ def _send_reset_request(headers: dict) -> None: http_client.request(method="POST", url=f"{PROXY_URL}/Admin/Reset", headers=headers_to_send) -def _send_sanitizer_request(sanitizer: str, parameters: dict, headers: "Optional[dict]" = None) -> None: +def _send_sanitizer_request(sanitizer: str, parameters: Dict, headers: Optional[Dict] = None) -> None: """Sends a POST request to the test proxy endpoint to register the specified sanitizer. If live tests are being run with recording turned off via the AZURE_SKIP_LIVE_RECORDING environment variable, no @@ -709,7 +765,7 @@ def _send_sanitizer_request(sanitizer: str, parameters: dict, headers: "Optional ) -def _send_transform_request(transform: str, parameters: dict, headers: "Optional[dict]" = None) -> None: +def _send_transform_request(transform: str, parameters: Dict, headers: Optional[Dict] = None) -> None: """Sends a POST request to the test proxy endpoint to register the specified transform. If live tests are being run, no request will be sent. diff --git a/tools/azure-sdk-tools/setup.py b/tools/azure-sdk-tools/setup.py index e3f9e3c1e413..7f1a30f4b826 100644 --- a/tools/azure-sdk-tools/setup.py +++ b/tools/azure-sdk-tools/setup.py @@ -58,7 +58,7 @@ extras_require={ ":python_version>='3.5'": ["pytest-asyncio>=0.9.0"], ":python_version<'3.11'": ["tomli==2.0.1"], - "build": ["six", "setuptools", "pyparsing", "certifi", "cibuildwheel"], + "build": ["six", "setuptools==67.6.0", "pyparsing", "certifi", "cibuildwheel"], "conda": ["beautifulsoup4"], "systemperf": ["aiohttp>=3.0", "requests>=2.0", "tornado==6.0.3", "httpx>=0.21", "azure-core"], "ghtools": ["GitPython", "PyGithub>=1.59.0", "requests>=2.0"],