Skip to content

Commit

Permalink
Added SMB Multichannel protocol (Azure#13795)
Browse files Browse the repository at this point in the history
* added smb multichannel feature

* added protocol properties to desarialize

* added two more classes

* better docstrings

* added test and everything is working

* added async

* passing tests

* fixed var names
  • Loading branch information
tasherif-msft authored and xiafu-msft committed Oct 1, 2020
1 parent 8ace0b4 commit e520b37
Show file tree
Hide file tree
Showing 22 changed files with 421 additions and 284 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
Metrics,
RetentionPolicy,
CorsRule,
ShareSmbSettings,
SmbMultichannel,
ShareProtocolSettings,
AccessPolicy,
FileSasPermissions,
ShareSasPermissions,
Expand Down Expand Up @@ -52,6 +55,9 @@
'Metrics',
'RetentionPolicy',
'CorsRule',
'ShareSmbSettings',
'SmbMultichannel',
'ShareProtocolSettings',
'AccessPolicy',
'FileSasPermissions',
'ShareSasPermissions',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
from ._generated.models import Metrics as GeneratedMetrics
from ._generated.models import RetentionPolicy as GeneratedRetentionPolicy
from ._generated.models import CorsRule as GeneratedCorsRule
from ._generated.models import ShareProtocolSettings as GeneratedShareProtocolSettings
from ._generated.models import ShareSmbSettings as GeneratedShareSmbSettings
from ._generated.models import SmbMultichannel as GeneratedSmbMultichannel
from ._generated.models import AccessPolicy as GenAccessPolicy
from ._generated.models import DirectoryItem

Expand Down Expand Up @@ -134,6 +137,40 @@ def _from_generated(cls, generated):
)


class ShareSmbSettings(GeneratedShareSmbSettings):
""" Settings for the SMB protocol.
:param SmbMultichannel multichannel: Required. Sets the multichannel settings.
"""
def __init__(self, multichannel):
self.multichannel = multichannel


class SmbMultichannel(GeneratedSmbMultichannel):
""" Settings for Multichannel.
:param bool enabled: Required. If SMB Multichannel is enabled.
"""
def __init__(self, enabled):
self.enabled = enabled


class ShareProtocolSettings(GeneratedShareProtocolSettings):
"""Protocol Settings class used by the set and get service properties methods in the share service.
Contains protocol properties of the share service such as the SMB setting of the share service.
:param SmbSettings smb: Required. Sets SMB settings.
"""
def __init__(self, smb):
self.smb = smb

@classmethod
def _from_generated(cls, generated):
return cls(
smb=generated.smb)


class AccessPolicy(GenAccessPolicy):
"""Access Policy class used by the set and get acl methods in each service.
Expand Down Expand Up @@ -922,4 +959,5 @@ def service_properties_deserialize(generated):
'hour_metrics': Metrics._from_generated(generated.hour_metrics), # pylint: disable=protected-access
'minute_metrics': Metrics._from_generated(generated.minute_metrics), # pylint: disable=protected-access
'cors': [CorsRule._from_generated(cors) for cors in generated.cors], # pylint: disable=protected-access
'protocol': ShareProtocolSettings._from_generated(generated.protocol), # pylint: disable=protected-access
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
ShareProperties,
Metrics,
CorsRule,
ShareProtocolSettings
)


Expand Down Expand Up @@ -169,6 +170,7 @@ def set_service_properties(
self, hour_metrics=None, # type: Optional[Metrics]
minute_metrics=None, # type: Optional[Metrics]
cors=None, # type: Optional[List[CorsRule]]
protocol=None, # type: Optional[ShareProtocolSettings],
**kwargs
):
# type: (...) -> None
Expand All @@ -189,6 +191,9 @@ def set_service_properties(
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`)
:param protocol:
Sets protocol settings
:type protocol: ~azure.storage.fileshare.ShareProtocolSettings
:keyword int timeout:
The timeout parameter is expressed in seconds.
:rtype: None
Expand All @@ -206,10 +211,11 @@ def set_service_properties(
props = StorageServiceProperties(
hour_metrics=hour_metrics,
minute_metrics=minute_metrics,
cors=cors
cors=cors,
protocol=protocol
)
try:
self._client.service.set_properties(props, timeout=timeout, **kwargs)
self._client.service.set_properties(storage_service_properties=props, timeout=timeout, **kwargs)
except StorageErrorException as error:
process_storage_error(error)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
ShareProperties,
Metrics,
CorsRule,
ShareProtocolSettings,
)


Expand Down Expand Up @@ -124,6 +125,7 @@ async def set_service_properties(
self, hour_metrics=None, # type: Optional[Metrics]
minute_metrics=None, # type: Optional[Metrics]
cors=None, # type: Optional[List[CorsRule]]
protocol=None, # type: Optional[ShareProtocolSettings],
**kwargs
):
# type: (...) -> None
Expand All @@ -144,6 +146,9 @@ async def set_service_properties(
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`)
:param protocol_settings:
Sets protocol settings
:type protocol: ~azure.storage.fileshare.ShareProtocolSettings
:keyword int timeout:
The timeout parameter is expressed in seconds.
:rtype: None
Expand All @@ -161,7 +166,8 @@ async def set_service_properties(
props = StorageServiceProperties(
hour_metrics=hour_metrics,
minute_metrics=minute_metrics,
cors=cors
cors=cors,
protocol=protocol
)
try:
await self._client.service.set_properties(props, timeout=timeout, **kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,30 @@ interactions:
Connection:
- keep-alive
User-Agent:
- azsdk-python-storage-file-share/12.0.1 Python/3.7.3 (Windows-10-10.0.17763-SP0)
customer_user_agent
- customer_user_agent azsdk-python-storage-file-share/12.2.0 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Wed, 15 Jan 2020 23:51:11 GMT
- Fri, 18 Sep 2020 01:52:21 GMT
x-ms-version:
- '2019-02-02'
- '2020-02-10'
method: GET
uri: https://storagename.file.core.windows.net/?restype=service&comp=properties
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><StorageServiceProperties><HourMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>7</Days></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>false</Enabled><RetentionPolicy><Enabled>false</Enabled></RetentionPolicy></MinuteMetrics><Cors
/></StorageServiceProperties>"
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><StorageServiceProperties><HourMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>5</Days></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>5</Days></RetentionPolicy></MinuteMetrics><Cors><CorsRule><AllowedMethods>GET</AllowedMethods><AllowedOrigins>www.xyz.com</AllowedOrigins><AllowedHeaders
/><ExposedHeaders /><MaxAgeInSeconds>0</MaxAgeInSeconds></CorsRule><CorsRule><AllowedMethods>GET,PUT</AllowedMethods><AllowedOrigins>www.xyz.com,www.ab.com,www.bc.com</AllowedOrigins><AllowedHeaders>x-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*</AllowedHeaders><ExposedHeaders>x-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*</ExposedHeaders><MaxAgeInSeconds>500</MaxAgeInSeconds></CorsRule></Cors><ProtocolSettings><SMB><Multichannel><Enabled>false</Enabled></Multichannel></SMB></ProtocolSettings></StorageServiceProperties>"
headers:
content-type:
- application/xml
date:
- Wed, 15 Jan 2020 23:51:11 GMT
- Fri, 18 Sep 2020 01:52:21 GMT
server:
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
- chunked
vary:
- Origin
x-ms-version:
- '2019-02-02'
- '2020-02-10'
status:
code: 200
message: OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,30 @@ interactions:
Connection:
- keep-alive
User-Agent:
- TestApp/v1.0 azsdk-python-storage-file-share/12.0.1 Python/3.7.3 (Windows-10-10.0.17763-SP0)
- TestApp/v1.0 azsdk-python-storage-file-share/12.2.0 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Wed, 15 Jan 2020 23:51:11 GMT
- Fri, 18 Sep 2020 01:52:23 GMT
x-ms-version:
- '2019-02-02'
- '2020-02-10'
method: GET
uri: https://storagename.file.core.windows.net/?restype=service&comp=properties
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><StorageServiceProperties><HourMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>7</Days></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>false</Enabled><RetentionPolicy><Enabled>false</Enabled></RetentionPolicy></MinuteMetrics><Cors
/></StorageServiceProperties>"
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><StorageServiceProperties><HourMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>5</Days></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>5</Days></RetentionPolicy></MinuteMetrics><Cors><CorsRule><AllowedMethods>GET</AllowedMethods><AllowedOrigins>www.xyz.com</AllowedOrigins><AllowedHeaders
/><ExposedHeaders /><MaxAgeInSeconds>0</MaxAgeInSeconds></CorsRule><CorsRule><AllowedMethods>GET,PUT</AllowedMethods><AllowedOrigins>www.xyz.com,www.ab.com,www.bc.com</AllowedOrigins><AllowedHeaders>x-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*</AllowedHeaders><ExposedHeaders>x-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*</ExposedHeaders><MaxAgeInSeconds>500</MaxAgeInSeconds></CorsRule></Cors><ProtocolSettings><SMB><Multichannel><Enabled>false</Enabled></Multichannel></SMB></ProtocolSettings></StorageServiceProperties>"
headers:
content-type:
- application/xml
date:
- Wed, 15 Jan 2020 23:51:11 GMT
- Fri, 18 Sep 2020 01:52:22 GMT
server:
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
- chunked
vary:
- Origin
x-ms-version:
- '2019-02-02'
- '2020-02-10'
status:
code: 200
message: OK
Expand All @@ -44,28 +46,31 @@ interactions:
Connection:
- keep-alive
User-Agent:
- TestApp/v2.0 azsdk-python-storage-file-share/12.0.1 Python/3.7.3 (Windows-10-10.0.17763-SP0)
- TestApp/v2.0 TestApp/v1.0 azsdk-python-storage-file-share/12.2.0 Python/3.8.5
(Windows-10-10.0.19041-SP0)
x-ms-date:
- Wed, 15 Jan 2020 23:51:11 GMT
- Fri, 18 Sep 2020 01:52:23 GMT
x-ms-version:
- '2019-02-02'
- '2020-02-10'
method: GET
uri: https://storagename.file.core.windows.net/?restype=service&comp=properties
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><StorageServiceProperties><HourMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>7</Days></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>false</Enabled><RetentionPolicy><Enabled>false</Enabled></RetentionPolicy></MinuteMetrics><Cors
/></StorageServiceProperties>"
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><StorageServiceProperties><HourMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>5</Days></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>5</Days></RetentionPolicy></MinuteMetrics><Cors><CorsRule><AllowedMethods>GET</AllowedMethods><AllowedOrigins>www.xyz.com</AllowedOrigins><AllowedHeaders
/><ExposedHeaders /><MaxAgeInSeconds>0</MaxAgeInSeconds></CorsRule><CorsRule><AllowedMethods>GET,PUT</AllowedMethods><AllowedOrigins>www.xyz.com,www.ab.com,www.bc.com</AllowedOrigins><AllowedHeaders>x-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*</AllowedHeaders><ExposedHeaders>x-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*</ExposedHeaders><MaxAgeInSeconds>500</MaxAgeInSeconds></CorsRule></Cors><ProtocolSettings><SMB><Multichannel><Enabled>false</Enabled></Multichannel></SMB></ProtocolSettings></StorageServiceProperties>"
headers:
content-type:
- application/xml
date:
- Wed, 15 Jan 2020 23:51:11 GMT
- Fri, 18 Sep 2020 01:52:22 GMT
server:
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
- chunked
vary:
- Origin
x-ms-version:
- '2019-02-02'
- '2020-02-10'
status:
code: 200
message: OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,30 @@ interactions:
Connection:
- keep-alive
User-Agent:
- azsdk-python-storage-file-share/12.0.1 Python/3.7.3 (Windows-10-10.0.17763-SP0)
- azsdk-python-storage-file-share/12.2.0 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Wed, 15 Jan 2020 23:51:11 GMT
- Fri, 18 Sep 2020 01:52:23 GMT
x-ms-version:
- '2019-02-02'
- '2020-02-10'
method: GET
uri: https://storagename.file.core.windows.net/?restype=service&comp=properties
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><StorageServiceProperties><HourMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>7</Days></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>false</Enabled><RetentionPolicy><Enabled>false</Enabled></RetentionPolicy></MinuteMetrics><Cors
/></StorageServiceProperties>"
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><StorageServiceProperties><HourMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>5</Days></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>5</Days></RetentionPolicy></MinuteMetrics><Cors><CorsRule><AllowedMethods>GET</AllowedMethods><AllowedOrigins>www.xyz.com</AllowedOrigins><AllowedHeaders
/><ExposedHeaders /><MaxAgeInSeconds>0</MaxAgeInSeconds></CorsRule><CorsRule><AllowedMethods>GET,PUT</AllowedMethods><AllowedOrigins>www.xyz.com,www.ab.com,www.bc.com</AllowedOrigins><AllowedHeaders>x-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*</AllowedHeaders><ExposedHeaders>x-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*</ExposedHeaders><MaxAgeInSeconds>500</MaxAgeInSeconds></CorsRule></Cors><ProtocolSettings><SMB><Multichannel><Enabled>false</Enabled></Multichannel></SMB></ProtocolSettings></StorageServiceProperties>"
headers:
content-type:
- application/xml
date:
- Wed, 15 Jan 2020 23:51:11 GMT
- Fri, 18 Sep 2020 01:52:22 GMT
server:
- Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding:
- chunked
vary:
- Origin
x-ms-version:
- '2019-02-02'
- '2020-02-10'
status:
code: 200
message: OK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,26 @@ interactions:
Accept:
- application/xml
User-Agent:
- azsdk-python-storage-file-share/12.0.1 Python/3.7.3 (Windows-10-10.0.17763-SP0)
customer_user_agent
- customer_user_agent azsdk-python-storage-file-share/12.2.0 Python/3.8.5 (Windows-10-10.0.19041-SP0)
x-ms-date:
- Wed, 15 Jan 2020 23:51:13 GMT
- Fri, 18 Sep 2020 01:52:39 GMT
x-ms-version:
- '2019-02-02'
- '2020-02-10'
method: GET
uri: https://storagename.file.core.windows.net/?restype=service&comp=properties
response:
body:
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><StorageServiceProperties><HourMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>7</Days></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>false</Enabled><RetentionPolicy><Enabled>false</Enabled></RetentionPolicy></MinuteMetrics><Cors
/></StorageServiceProperties>"
string: "\uFEFF<?xml version=\"1.0\" encoding=\"utf-8\"?><StorageServiceProperties><HourMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>5</Days></RetentionPolicy></HourMetrics><MinuteMetrics><Version>1.0</Version><Enabled>true</Enabled><IncludeAPIs>true</IncludeAPIs><RetentionPolicy><Enabled>true</Enabled><Days>5</Days></RetentionPolicy></MinuteMetrics><Cors><CorsRule><AllowedMethods>GET</AllowedMethods><AllowedOrigins>www.xyz.com</AllowedOrigins><AllowedHeaders
/><ExposedHeaders /><MaxAgeInSeconds>0</MaxAgeInSeconds></CorsRule><CorsRule><AllowedMethods>GET,PUT</AllowedMethods><AllowedOrigins>www.xyz.com,www.ab.com,www.bc.com</AllowedOrigins><AllowedHeaders>x-ms-meta-xyz,x-ms-meta-foo,x-ms-meta-data*,x-ms-meta-target*</AllowedHeaders><ExposedHeaders>x-ms-meta-abc,x-ms-meta-bcd,x-ms-meta-data*,x-ms-meta-source*</ExposedHeaders><MaxAgeInSeconds>500</MaxAgeInSeconds></CorsRule></Cors><ProtocolSettings><SMB><Multichannel><Enabled>false</Enabled></Multichannel></SMB></ProtocolSettings></StorageServiceProperties>"
headers:
content-type: application/xml
date: Wed, 15 Jan 2020 23:51:12 GMT
date: Fri, 18 Sep 2020 01:52:38 GMT
server: Windows-Azure-File/1.0 Microsoft-HTTPAPI/2.0
transfer-encoding: chunked
x-ms-version: '2019-02-02'
vary: Origin
x-ms-version: '2020-02-10'
status:
code: 200
message: OK
url: !!python/object/new:yarl.URL
state: !!python/tuple
- !!python/object/new:urllib.parse.SplitResult
- https
- pyacrstorage43x4qoc3y4bx.file.core.windows.net
- /
- restype=service&comp=properties
- ''
url: https://seanmcccanary3.file.core.windows.net/?restype=service&comp=properties
version: 1
Loading

0 comments on commit e520b37

Please sign in to comment.