Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[recoveryservicesbackup] fix multiple pages paging #23089

Merged
merged 9 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 4.1.1 (2022-02-18)

**Bug Fixes**

- Fix multi-page paging #23089

## 4.1.0 (2022-02-15)

**Features**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "4.1.0"
VERSION = "4.1.1"
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,56 @@
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------
from typing import Any, List, TYPE_CHECKING
import importlib
import urllib.parse
from ._recovery_services_backup_client import RecoveryServicesBackupClient as RecoveryServicesBackupClientGenerated
from azure.core.pipeline.policies import SansIOHTTPPolicy

if TYPE_CHECKING:
from azure.core.credentials import TokenCredential

class RemoveDuplicateParamsPolicy(SansIOHTTPPolicy):
def __init__(self, duplicate_param_names):
# type: (List[str]) -> None
self.duplicate_param_names = duplicate_param_names

def on_request(self, request):
parsed_url = urllib.parse.urlparse(request.http_request.url)
query_params = urllib.parse.parse_qs(parsed_url.query)
filtered_query_params = {
k: v[-1:] if k in self.duplicate_param_names else v
for k, v in query_params.items()
}
request.http_request.url = request.http_request.url.replace(parsed_url.query, "") + urllib.parse.urlencode(filtered_query_params, doseq=True)
return super().on_request(request)

DUPLICATE_PARAMS_POLICY = RemoveDuplicateParamsPolicy(duplicate_param_names=["$filter", "$skiptoken", "api-version"])

class RecoveryServicesBackupClient(RecoveryServicesBackupClientGenerated):
__doc__ = RecoveryServicesBackupClientGenerated.__doc__
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
per_call_policies = kwargs.pop("per_call_policies", [])
try:
per_call_policies.append(DUPLICATE_PARAMS_POLICY)
except AttributeError:
per_call_policies = [per_call_policies, DUPLICATE_PARAMS_POLICY]
super().__init__(
credential=credential,
subscription_id=subscription_id,
base_url=base_url,
per_call_policies=per_call_policies,
**kwargs
)

# This file is used for handwritten extensions to the generated code. Example:
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
def patch_sdk():
pass
curr_package = importlib.import_module("azure.mgmt.recoveryservicesbackup.activestamp")
curr_package.RecoveryServicesBackupClient = RecoveryServicesBackupClient
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "4.1.0"
VERSION = "4.1.1"
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,38 @@
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------
from typing import Any, TYPE_CHECKING
import importlib
from .._patch import DUPLICATE_PARAMS_POLICY
from ._recovery_services_backup_client import RecoveryServicesBackupClient as RecoveryServicesBackupClientGenerated

if TYPE_CHECKING:
from azure.core.credentials_async import AsyncTokenCredential

class RecoveryServicesBackupClient(RecoveryServicesBackupClientGenerated):
__doc__ = RecoveryServicesBackupClientGenerated.__doc__
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
per_call_policies = kwargs.pop("per_call_policies", [])
try:
per_call_policies.append(DUPLICATE_PARAMS_POLICY)
except AttributeError:
per_call_policies = [per_call_policies, DUPLICATE_PARAMS_POLICY]
super().__init__(
credential=credential,
subscription_id=subscription_id,
base_url=base_url,
per_call_policies=per_call_policies,
**kwargs
)

# This file is used for handwritten extensions to the generated code. Example:
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
def patch_sdk():
pass
curr_package = importlib.import_module("azure.mgmt.recoveryservicesbackup.activestamp.aio")
curr_package.RecoveryServicesBackupClient = RecoveryServicesBackupClient
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,56 @@
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------
from typing import TYPE_CHECKING, Any, List, TYPE_CHECKING
import importlib
import urllib.parse
from ._recovery_services_backup_passive_client import RecoveryServicesBackupPassiveClient as RecoveryServicesBackupPassiveClientGenerated
from azure.core.pipeline.policies import SansIOHTTPPolicy

if TYPE_CHECKING:
from azure.core.credentials import TokenCredential

class RemoveDuplicateParamsPolicy(SansIOHTTPPolicy):
def __init__(self, duplicate_param_names):
# type: (List[str]) -> None
self.duplicate_param_names = duplicate_param_names

def on_request(self, request):
parsed_url = urllib.parse.urlparse(request.http_request.url)
query_params = urllib.parse.parse_qs(parsed_url.query)
filtered_query_params = {
k: v[-1:] if k in self.duplicate_param_names else v
for k, v in query_params.items()
}
request.http_request.url = request.http_request.url.replace(parsed_url.query, "") + urllib.parse.urlencode(filtered_query_params, doseq=True)
return super().on_request(request)

DUPLICATE_PARAMS_POLICY = RemoveDuplicateParamsPolicy(duplicate_param_names=["$filter", "$skiptoken", "api-version"])

class RecoveryServicesBackupPassiveClient(RecoveryServicesBackupPassiveClientGenerated):
__doc__ = RecoveryServicesBackupPassiveClientGenerated.__doc__
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
per_call_policies = kwargs.pop("per_call_policies", [])
try:
per_call_policies.append(DUPLICATE_PARAMS_POLICY)
except AttributeError:
per_call_policies = [per_call_policies, DUPLICATE_PARAMS_POLICY]
super().__init__(
credential=credential,
subscription_id=subscription_id,
base_url=base_url,
per_call_policies=per_call_policies,
**kwargs
)

# This file is used for handwritten extensions to the generated code. Example:
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
def patch_sdk():
pass
curr_package = importlib.import_module("azure.mgmt.recoveryservicesbackup.passivestamp")
curr_package.RecoveryServicesBackupPassiveClient = RecoveryServicesBackupPassiveClient
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

VERSION = "4.1.0"
VERSION = "4.1.1"
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,38 @@
# IN THE SOFTWARE.
#
# --------------------------------------------------------------------------
from typing import Any, TYPE_CHECKING
import importlib
from .._patch import DUPLICATE_PARAMS_POLICY
from ._recovery_services_backup_passive_client import RecoveryServicesBackupPassiveClient as RecoveryServicesBackupPassiveClientGenerated

if TYPE_CHECKING:
from azure.core.credentials_async import AsyncTokenCredential

class RecoveryServicesBackupPassiveClient(RecoveryServicesBackupPassiveClientGenerated):
__doc__ = RecoveryServicesBackupPassiveClientGenerated.__doc__
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
per_call_policies = kwargs.pop("per_call_policies", [])
try:
per_call_policies.append(DUPLICATE_PARAMS_POLICY)
except AttributeError:
per_call_policies = [per_call_policies, DUPLICATE_PARAMS_POLICY]
super().__init__(
credential=credential,
subscription_id=subscription_id,
base_url=base_url,
per_call_policies=per_call_policies,
**kwargs
)

# This file is used for handwritten extensions to the generated code. Example:
# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md
def patch_sdk():
pass
curr_package = importlib.import_module("azure.mgmt.recoveryservicesbackup.passivestamp.aio")
curr_package.RecoveryServicesBackupPassiveClient = RecoveryServicesBackupPassiveClient