Skip to content

Commit

Permalink
[Storage] Removed docstrings from Blob's helper files + slight `_shar…
Browse files Browse the repository at this point in the history
…ed` matchings (#36595)
  • Loading branch information
vincenttran-msft authored Jul 25, 2024
1 parent 2530f8f commit 4739b70
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 566 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@


def _parse_url(account_url: str) -> Tuple["ParseResult", Any]:
"""Performs initial input validation and returns the parsed URL and SAS token.
:param str account_url: The URL to the storage account.
:returns: The parsed URL and SAS token.
:rtype: Tuple[ParseResult, Any]
"""
try:
if not account_url.lower().startswith('http'):
account_url = "https://" + account_url
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,7 @@
from ._models import PremiumPageBlobTier, StandardBlobTier


def _parse_url(
account_url: str,
container_name: str,
) -> Tuple["ParseResult", Any]:
"""Performs initial input validation and returns the parsed URL and SAS token.
:param str account_url: The URL to the storage account.
:param str container_name: The name of the container.
:returns: The parsed URL and SAS token.
:rtype: Tuple[ParseResult, Any]
"""
def _parse_url(account_url: str, container_name: str) -> Tuple["ParseResult", Any]:
try:
if not account_url.lower().startswith('http'):
account_url = "https://" + account_url
Expand All @@ -47,19 +38,6 @@ def _parse_url(
return parsed_url, sas_token

def _format_url(container_name: Union[bytes, str], hostname: str, scheme: str, query_str: str) -> str:
"""Format the endpoint URL according to the current location mode hostname.
:param Union[bytes, str] container_name:
The name of the container.
:param str hostname:
The current location mode hostname.
:param str scheme:
The scheme for the current location mode hostname.
:param str query_str:
The query string of the endpoint URL being formatted.
:returns: The formatted endpoint URL according to the specified location mode hostname.
:rtype: str
"""
if isinstance(container_name, str):
container_name = container_name.encode('UTF-8')
return f"{scheme}://{hostname}/{quote(container_name)}{query_str}"
Expand All @@ -75,27 +53,6 @@ def _generate_delete_blobs_subrequest_options(
modified_access_conditions: Optional["ModifiedAccessConditions"] = None,
**kwargs
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
"""Creates a dictionary containing the options for a delete blob sub-request operation.
:param AzureBlobStorage client:
The generated Blob Storage client.
:param Optional[str] snapshot:
The snapshot data of the blob.
:param Optional[str] version_id:
The version id parameter is a value that, when present, specifies the version of the blob to delete.
:param Optional[str] delete_snapshots:
Required if the blob has associated snapshots. Values include:
- "only": Deletes only the blobs snapshots.
- "include": Deletes the blob along with all snapshots.
:param lease_access_conditions:
The access conditions associated with the lease.
:type lease_access_conditions: Optional[LeaseAccessConditions]
:param modified_access_conditions:
The modified access conditions associated with the lease.
:type modified_access_conditions: Optional[LeaseAccessConditions]
:returns: A dictionary containing the delete blobs sub-request options.
:rtype: Tuple[Dict[str, Any], Dict[str, Any]]
"""
lease_id = None
if lease_access_conditions is not None:
lease_id = lease_access_conditions.lease_id
Expand Down Expand Up @@ -157,46 +114,6 @@ def _generate_delete_blobs_options(
*blobs: Union[str, Dict[str, Any], BlobProperties],
**kwargs: Any
) -> Tuple[List[HttpRequest], Dict[str, Any]]:
"""Creates a dictionary containing the options for a delete blob operation.
:param str query_str:
The query string of the endpoint URL.
:param str container_name:
The name of the container.
:param AzureBlobStorage client:
The generated Blob Storage client.
:param blobs:
The blobs to delete. This can be a single blob, or multiple values can
be supplied, where each value is either the name of the blob (str) or BlobProperties.
.. note::
When the blob type is dict, here's a list of keys, value rules.
blob name:
key: 'name', value type: str
snapshot you want to delete:
key: 'snapshot', value type: str
version id:
key: 'version_id', value type: str
whether to delete snapshots when deleting blob:
key: 'delete_snapshots', value: 'include' or 'only'
if the blob modified or not:
key: 'if_modified_since', 'if_unmodified_since', value type: datetime
etag:
key: 'etag', value type: str
match the etag or not:
key: 'match_condition', value type: MatchConditions
tags match condition:
key: 'if_tags_match_condition', value type: str
lease:
key: 'lease_id', value type: Union[str, LeaseClient]
timeout for subrequest:
key: 'timeout', value type: int
:type blobs: Union[str, Dict[str, Any], BlobProperties]
:returns: A tuple containing the list of HttpRequests and the delete blobs options.
:rtype: Tuple[List[HttpRequest], Dict[str, Any]]
"""
timeout = kwargs.pop('timeout', None)
raise_on_any_failure = kwargs.pop('raise_on_any_failure', True)
delete_snapshots = kwargs.pop('delete_snapshots', None)
Expand Down Expand Up @@ -259,25 +176,6 @@ def _generate_set_tiers_subrequest_options(
lease_access_conditions: Optional["LeaseAccessConditions"] = None,
**kwargs: Any
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
"""Creates a dictionary containing the options for a set tiers sub-request operation.
:param AzureBlobStorage client:
The generated Blob Storage client.
:param tier:
Indicates the tier to be set on the blobs.
:type tier: Optional[Union["PremiumPageBlobTier", "StandardBlobTier", str]]
:param Optional[str] snapshot:
The snapshot data of the blob.
:param Optional[str] version_id:
The version id parameter is a value that, when present, specifies the version of the blob to delete.
:param Optional[RehydratePriority] rehydrate_priority:
Indicates the priority with which to rehydrate an archived blob.
:param lease_access_conditions:
The access conditions associated with the lease.
:type lease_access_conditions: Optional[LeaseAccessConditions]
:returns: A dictionary containing the set tiers sub-request options.
:rtype: Dict[str, Any]
"""
if not tier:
raise ValueError("A blob tier must be specified")
if snapshot and version_id:
Expand Down Expand Up @@ -321,49 +219,6 @@ def _generate_set_tiers_options(
*blobs: Union[str, Dict[str, Any], BlobProperties],
**kwargs: Any
) -> Tuple[List[HttpRequest], Dict[str, Any]]:
"""Creates a dictionary containing the options for a set tiers operation.
:param str query_str:
The query string of the endpoint URL.
:param str container_name:
The name of the container.
:param blob_tier:
Indicates the tier to be set on the blobs.
:type blob_tier: Optional[Union["PremiumPageBlobTier", "StandardBlobTier", str]]
:param AzureBlobStorage client:
The generated Blob Storage client.
:param blobs:
The blobs to delete. This can be a single blob, or multiple values can
be supplied, where each value is either the name of the blob (str) or BlobProperties.
.. note::
When the blob type is dict, here's a list of keys, value rules.
blob name:
key: 'name', value type: str
snapshot you want to delete:
key: 'snapshot', value type: str
version id:
key: 'version_id', value type: str
whether to delete snapshots when deleting blob:
key: 'delete_snapshots', value: 'include' or 'only'
if the blob modified or not:
key: 'if_modified_since', 'if_unmodified_since', value type: datetime
etag:
key: 'etag', value type: str
match the etag or not:
key: 'match_condition', value type: MatchConditions
tags match condition:
key: 'if_tags_match_condition', value type: str
lease:
key: 'lease_id', value type: Union[str, LeaseClient]
timeout for subrequest:
key: 'timeout', value type: int
:type blobs: Union[str, Dict[str, Any], BlobProperties]
:returns: A tuple containing the list of HttpRequests and the set tiers options.
:rtype: Tuple[List[HttpRequest], Dict[str, Any]]
"""
timeout = kwargs.pop('timeout', None)
raise_on_any_failure = kwargs.pop('raise_on_any_failure', True)
rehydrate_priority = kwargs.pop('rehydrate_priority', None)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from time import time
from typing import Any, Dict, Optional, TYPE_CHECKING
from urllib.parse import (
parse_qsl,
urlencode,
urlparse,
urlunparse,
parse_qsl,
urlencode,
urlparse,
urlunparse,
)
from wsgiref.handlers import format_date_time

Expand All @@ -28,7 +28,7 @@
HTTPPolicy,
NetworkTraceLoggingPolicy,
RequestHistory,
SansIOHTTPPolicy,
SansIOHTTPPolicy
)

from .authentication import StorageHttpChallenge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
from azure.core.pipeline.policies import ContentDecodePolicy

from .models import StorageErrorCode, UserDelegationKey, get_enum_value
from .models import get_enum_value, StorageErrorCode, UserDelegationKey
from .parser import _to_utc_datetime


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from azure.core.tracing.common import with_current_context

from . import encode_base64, url_quote
from .import encode_base64, url_quote
from .request_handlers import get_length
from .response_handlers import return_response_headers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from math import ceil
from typing import AsyncGenerator, Union

from . import encode_base64, url_quote
from .import encode_base64, url_quote
from .request_handlers import get_length
from .response_handlers import return_response_headers
from .uploads import SubStream, IterStreamer # pylint: disable=unused-import
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from time import time
from typing import Any, Dict, Optional, TYPE_CHECKING
from urllib.parse import (
parse_qsl,
urlencode,
urlparse,
urlunparse,
parse_qsl,
urlencode,
urlparse,
urlunparse,
)
from wsgiref.handlers import format_date_time

Expand All @@ -28,7 +28,7 @@
HTTPPolicy,
NetworkTraceLoggingPolicy,
RequestHistory,
SansIOHTTPPolicy,
SansIOHTTPPolicy
)

from .authentication import StorageHttpChallenge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
from azure.core.pipeline.policies import ContentDecodePolicy

from .models import StorageErrorCode, UserDelegationKey, get_enum_value
from .models import get_enum_value, StorageErrorCode, UserDelegationKey
from .parser import _to_utc_datetime


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from azure.core.tracing.common import with_current_context

from . import encode_base64, url_quote
from .import encode_base64, url_quote
from .request_handlers import get_length
from .response_handlers import return_response_headers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from math import ceil
from typing import AsyncGenerator, Union

from . import encode_base64, url_quote
from .import encode_base64, url_quote
from .request_handlers import get_length
from .response_handlers import return_response_headers
from .uploads import SubStream, IterStreamer # pylint: disable=unused-import
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
from time import time
from typing import Any, Dict, Optional, TYPE_CHECKING
from urllib.parse import (
parse_qsl,
urlencode,
urlparse,
urlunparse,
parse_qsl,
urlencode,
urlparse,
urlunparse,
)
from wsgiref.handlers import format_date_time

Expand All @@ -28,7 +28,7 @@
HTTPPolicy,
NetworkTraceLoggingPolicy,
RequestHistory,
SansIOHTTPPolicy,
SansIOHTTPPolicy
)

from .authentication import StorageHttpChallenge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
)
from azure.core.pipeline.policies import ContentDecodePolicy

from .models import StorageErrorCode, UserDelegationKey, get_enum_value
from .models import get_enum_value, StorageErrorCode, UserDelegationKey
from .parser import _to_utc_datetime


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from azure.core.tracing.common import with_current_context

from . import encode_base64, url_quote
from .import encode_base64, url_quote
from .request_handlers import get_length
from .response_handlers import return_response_headers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from math import ceil
from typing import AsyncGenerator, Union

from . import encode_base64, url_quote
from .import encode_base64, url_quote
from .request_handlers import get_length
from .response_handlers import return_response_headers
from .uploads import SubStream, IterStreamer # pylint: disable=unused-import
Expand Down

0 comments on commit 4739b70

Please sign in to comment.