From 830632e2bedb19ea782e7db62dbd48ec2694d972 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Tue, 15 Oct 2019 09:57:32 -0700 Subject: [PATCH 1/2] moves protocol in gen_sas to kwargs --- .../azure/storage/file/file_client.py | 9 +++++---- .../azure/storage/file/file_service_client.py | 5 +++-- .../azure/storage/file/share_client.py | 11 +++++------ .../azure/storage/queue/queue_client.py | 8 ++++---- .../azure/storage/queue/queue_service_client.py | 8 ++++---- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/sdk/storage/azure-storage-file/azure/storage/file/file_client.py b/sdk/storage/azure-storage-file/azure/storage/file/file_client.py index f09cd06a39cd..3d4fd0d0eab1 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/file_client.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/file_client.py @@ -244,12 +244,12 @@ def generate_shared_access_signature( start=None, # type: Optional[Union[datetime, str]] policy_id=None, # type: Optional[str] ip=None, # type: Optional[str] - protocol=None, # type: Optional[str] cache_control=None, # type: Optional[str] content_disposition=None, # type: Optional[str] content_encoding=None, # type: Optional[str] content_language=None, # type: Optional[str] - content_type=None # type: Optional[str] + content_type=None, # type: Optional[str] + ** kwargs # type: Any ): # type: (...) -> str """Generates a shared access signature for the file. @@ -288,8 +288,6 @@ def generate_shared_access_signature( 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. - :param str protocol: - Specifies the protocol permitted for a request made. The default value is https. :param str cache_control: Response header value for Cache-Control when resource is accessed using this shared access signature. @@ -305,9 +303,12 @@ def generate_shared_access_signature( :param str content_type: Response header value for Content-Type when resource is accessed using this shared access signature. + :keyword str protocol: + Specifies the protocol permitted for a request made. The default value is https. :return: A Shared Access Signature (sas) token. :rtype: str """ + protocol = kwargs.pop('protocol', None) if not hasattr(self.credential, 'account_key') or not self.credential.account_key: raise ValueError("No account SAS key available.") sas = FileSharedAccessSignature(self.credential.account_name, self.credential.account_key) diff --git a/sdk/storage/azure-storage-file/azure/storage/file/file_service_client.py b/sdk/storage/azure-storage-file/azure/storage/file/file_service_client.py index 434de64c3654..45310e860b6c 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/file_service_client.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/file_service_client.py @@ -143,7 +143,7 @@ def generate_shared_access_signature( expiry, # type: Optional[Union[datetime, str]] start=None, # type: Optional[Union[datetime, str]] ip=None, # type: Optional[str] - protocol=None # type: Optional[str] + **kwargs # type: Any ): # type: (...) -> str """Generates a shared access signature for the file service. @@ -179,7 +179,7 @@ def generate_shared_access_signature( 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. - :param str protocol: + :keyword str protocol: Specifies the protocol permitted for a request made. The default value is https. :return: A Shared Access Signature (sas) token. :rtype: str @@ -193,6 +193,7 @@ def generate_shared_access_signature( :dedent: 8 :caption: Generate a sas token. """ + protocol = kwargs.pop('protocol', None) if not hasattr(self.credential, 'account_key') and not self.credential.account_key: raise ValueError("No account SAS key available.") diff --git a/sdk/storage/azure-storage-file/azure/storage/file/share_client.py b/sdk/storage/azure-storage-file/azure/storage/file/share_client.py index dc19e6b9aaa6..5f458ad8362a 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/share_client.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/share_client.py @@ -174,12 +174,12 @@ def generate_shared_access_signature( start=None, # type: Optional[Union[datetime, str]] policy_id=None, # type: Optional[str] ip=None, # type: Optional[str] - protocol=None, # type: Optional[str] cache_control=None, # type: Optional[str] content_disposition=None, # type: Optional[str] content_encoding=None, # type: Optional[str] content_language=None, # type: Optional[str] - content_type=None + content_type=None, + **kwargs # type: Any ): # type: (...) -> str """Generates a shared access signature for the share. Use the returned signature with the credential parameter of any FileServiceClient, @@ -216,10 +216,6 @@ def generate_shared_access_signature( 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. - :param str protocol: - Specifies the protocol permitted for a request made. Possible values are - both HTTPS and HTTP (https,http) or HTTPS only (https). The default value - is https,http. Note that HTTP only is not a permitted value. :param str cache_control: Response header value for Cache-Control when resource is accessed using this shared access signature. @@ -235,9 +231,12 @@ def generate_shared_access_signature( :param str content_type: Response header value for Content-Type when resource is accessed using this shared access signature. + :keyword str protocol: + Specifies the protocol permitted for a request made. The default value is https. :return: A Shared Access Signature (sas) token. :rtype: str """ + protocol = kwargs.pop('protocol', None) if not hasattr(self.credential, 'account_key') or not self.credential.account_key: raise ValueError("No account SAS key available.") sas = FileSharedAccessSignature(self.credential.account_name, self.credential.account_key) 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 d71f729c2482..e9b35f28af0e 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 @@ -169,7 +169,7 @@ def generate_shared_access_signature( start=None, # type: Optional[Union[datetime, str]] policy_id=None, # type: Optional[str] ip=None, # type: Optional[str] - protocol=None # type: Optional[str] + **kwargs # type: Any ): # type: (...) -> str """Generates a shared access signature for the queue. @@ -205,9 +205,8 @@ def generate_shared_access_signature( 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. - :param str protocol: - Specifies the protocol permitted for a request made. The default value - is https,http. + :keyword str protocol: + Specifies the protocol permitted for a request made. The default value is https. :return: A Shared Access Signature (sas) token. :rtype: str @@ -220,6 +219,7 @@ def generate_shared_access_signature( :dedent: 12 :caption: Generate a sas token. """ + protocol = kwargs.pop('protocol', None) if not hasattr(self.credential, 'account_key') and not self.credential.account_key: raise ValueError("No account SAS key available.") sas = QueueSharedAccessSignature( 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 edd0c4f0ed33..8da73516c3dc 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 @@ -155,7 +155,7 @@ def generate_shared_access_signature( expiry, # type: Optional[Union[datetime, str]] start=None, # type: Optional[Union[datetime, str]] ip=None, # type: Optional[str] - protocol=None # type: Optional[str] + **kwargs # type: Any ): # type: (...) -> str """Generates a shared access signature for the queue service. @@ -187,12 +187,12 @@ def generate_shared_access_signature( 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. - :param str protocol: - Specifies the protocol permitted for a request made. The default value - is https,http. + :keyword str protocol: + Specifies the protocol permitted for a request made. The default value is https. :return: A Shared Access Signature (sas) token. :rtype: str """ + protocol = kwargs.pop('protocol', None) if not hasattr(self.credential, 'account_key') and not self.credential.account_key: raise ValueError("No account SAS key available.") From b633ea170296b2bab784ccf55d9594fe593cda34 Mon Sep 17 00:00:00 2001 From: Krista Pratico Date: Tue, 15 Oct 2019 10:02:01 -0700 Subject: [PATCH 2/2] delete whitespace --- .../azure-storage-file/azure/storage/file/file_client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/storage/azure-storage-file/azure/storage/file/file_client.py b/sdk/storage/azure-storage-file/azure/storage/file/file_client.py index 3d4fd0d0eab1..551bbec22466 100644 --- a/sdk/storage/azure-storage-file/azure/storage/file/file_client.py +++ b/sdk/storage/azure-storage-file/azure/storage/file/file_client.py @@ -249,7 +249,7 @@ def generate_shared_access_signature( content_encoding=None, # type: Optional[str] content_language=None, # type: Optional[str] content_type=None, # type: Optional[str] - ** kwargs # type: Any + **kwargs # type: Any ): # type: (...) -> str """Generates a shared access signature for the file.