Skip to content

Commit

Permalink
[Storage] Re-generate all packages from existing Swagger with latest …
Browse files Browse the repository at this point in the history
…autorest (Azure#23497)
  • Loading branch information
jalauzon-msft authored and rakshith91 committed Apr 10, 2022
1 parent 9a16139 commit 476ff7f
Show file tree
Hide file tree
Showing 114 changed files with 28,299 additions and 16,783 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def __init__(
self._raw_credential = credential if credential else sas_token
self._query_str, credential = self._format_query_string(sas_token, credential, snapshot=self.snapshot)
super(BlobClient, self).__init__(parsed_url, service='blob', credential=credential, **kwargs)
self._client = AzureBlobStorage(self.url, pipeline=self._pipeline)
self._client = AzureBlobStorage(self.url, base_url=self.url, pipeline=self._pipeline)
self._client._config.version = get_api_version(kwargs) # pylint: disable=protected-access

def _format_url(self, hostname):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def __init__(
_, sas_token = parse_query(parsed_url.query)
self._query_str, credential = self._format_query_string(sas_token, credential)
super(BlobServiceClient, self).__init__(parsed_url, service='blob', credential=credential, **kwargs)
self._client = AzureBlobStorage(self.url, pipeline=self._pipeline)
self._client = AzureBlobStorage(self.url, base_url=self.url, pipeline=self._pipeline)
self._client._config.version = get_api_version(kwargs) # pylint: disable=protected-access

def _format_url(self, hostname):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def __init__(
self._raw_credential = credential if credential else sas_token
self._query_str, credential = self._format_query_string(sas_token, credential)
super(ContainerClient, self).__init__(parsed_url, service='blob', credential=credential, **kwargs)
self._client = AzureBlobStorage(self.url, pipeline=self._pipeline)
self._client = AzureBlobStorage(self.url, base_url=self.url, pipeline=self._pipeline)
self._client._config.version = get_api_version(kwargs) # pylint: disable=protected-access

def _format_url(self, hostname):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
from ._azure_blob_storage import AzureBlobStorage
__all__ = ['AzureBlobStorage']

try:
from ._patch import patch_sdk # type: ignore
patch_sdk()
except ImportError:
pass
# `._patch.py` 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
from ._patch import patch_sdk
patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,22 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import TYPE_CHECKING

from azure.core import PipelineClient
from msrest import Deserializer, Serializer

from azure.core import PipelineClient

from . import models
from ._configuration import AzureBlobStorageConfiguration
from .operations import AppendBlobOperations, BlobOperations, BlockBlobOperations, ContainerOperations, PageBlobOperations, ServiceOperations

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from typing import Any

from azure.core.pipeline.transport import HttpRequest, HttpResponse

from ._configuration import AzureBlobStorageConfiguration
from .operations import ServiceOperations
from .operations import ContainerOperations
from .operations import BlobOperations
from .operations import PageBlobOperations
from .operations import AppendBlobOperations
from .operations import BlockBlobOperations
from . import models

from azure.core.rest import HttpRequest, HttpResponse

class AzureBlobStorage(object):
"""AzureBlobStorage.
Expand All @@ -42,55 +38,64 @@ class AzureBlobStorage(object):
:vartype append_blob: azure.storage.blob.operations.AppendBlobOperations
:ivar block_blob: BlockBlobOperations operations
:vartype block_blob: azure.storage.blob.operations.BlockBlobOperations
:param url: The URL of the service account, container, or blob that is the target of the desired operation.
:param url: The URL of the service account, container, or blob that is the target of the
desired operation.
:type url: str
:param base_url: Service URL. Default value is "".
:type base_url: str
:keyword version: Specifies the version of the operation to use for this request. Default value
is "2021-04-10". Note that overriding this default value may result in unsupported behavior.
:paramtype version: str
"""

def __init__(
self,
url, # type: str
base_url="", # type: str
**kwargs # type: Any
):
# type: (...) -> None
base_url = '{url}'
self._config = AzureBlobStorageConfiguration(url, **kwargs)
self._config = AzureBlobStorageConfiguration(url=url, **kwargs)
self._client = PipelineClient(base_url=base_url, config=self._config, **kwargs)

client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)}
self._serialize = Serializer(client_models)
self._serialize.client_side_validation = False
self._deserialize = Deserializer(client_models)
self._serialize.client_side_validation = False
self.service = ServiceOperations(self._client, self._config, self._serialize, self._deserialize)
self.container = ContainerOperations(self._client, self._config, self._serialize, self._deserialize)
self.blob = BlobOperations(self._client, self._config, self._serialize, self._deserialize)
self.page_blob = PageBlobOperations(self._client, self._config, self._serialize, self._deserialize)
self.append_blob = AppendBlobOperations(self._client, self._config, self._serialize, self._deserialize)
self.block_blob = BlockBlobOperations(self._client, self._config, self._serialize, self._deserialize)


self.service = ServiceOperations(
self._client, self._config, self._serialize, self._deserialize)
self.container = ContainerOperations(
self._client, self._config, self._serialize, self._deserialize)
self.blob = BlobOperations(
self._client, self._config, self._serialize, self._deserialize)
self.page_blob = PageBlobOperations(
self._client, self._config, self._serialize, self._deserialize)
self.append_blob = AppendBlobOperations(
self._client, self._config, self._serialize, self._deserialize)
self.block_blob = BlockBlobOperations(
self._client, self._config, self._serialize, self._deserialize)

def _send_request(self, http_request, **kwargs):
# type: (HttpRequest, Any) -> HttpResponse
def _send_request(
self,
request, # type: HttpRequest
**kwargs # type: Any
):
# type: (...) -> HttpResponse
"""Runs the network request through the client's chained policies.
:param http_request: The network request you want to make. Required.
:type http_request: ~azure.core.pipeline.transport.HttpRequest
:keyword bool stream: Whether the response payload will be streamed. Defaults to True.
>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = client._send_request(request)
<HttpResponse: 200 OK>
For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart
: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.pipeline.transport.HttpResponse
:rtype: ~azure.core.rest.HttpResponse
"""
path_format_arguments = {
'url': self._serialize.url("self._config.url", self._config.url, 'str', skip_quote=True),
}
http_request.url = self._client.format_url(http_request.url, **path_format_arguments)
stream = kwargs.pop("stream", True)
pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs)
return pipeline_response.http_response

request_copy = deepcopy(request)
request_copy.url = self._client.format_url(request_copy.url)
return self._client.send_request(request_copy, **kwargs)

def close(self):
# type: () -> None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@

VERSION = "unknown"

class AzureBlobStorageConfiguration(Configuration):
class AzureBlobStorageConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
"""Configuration for AzureBlobStorage.
Note that all parameters used to create this instance are saved as instance
attributes.
:param url: The URL of the service account, container, or blob that is the target of the desired operation.
:param url: The URL of the service account, container, or blob that is the target of the
desired operation.
:type url: str
:keyword version: Specifies the version of the operation to use for this request. Default value
is "2021-04-10". Note that overriding this default value may result in unsupported behavior.
:paramtype version: str
"""

def __init__(
Expand All @@ -33,12 +37,14 @@ def __init__(
**kwargs # type: Any
):
# type: (...) -> None
super(AzureBlobStorageConfiguration, self).__init__(**kwargs)
version = kwargs.pop('version', "2021-04-10") # type: str

if url is None:
raise ValueError("Parameter 'url' must not be None.")
super(AzureBlobStorageConfiguration, self).__init__(**kwargs)

self.url = url
self.version = "2021-04-10"
self.version = version
kwargs.setdefault('sdk_moniker', 'azureblobstorage/{}'.format(VERSION))
self._configure(**kwargs)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# coding=utf-8
# --------------------------------------------------------------------------
#
# 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.
#
# --------------------------------------------------------------------------

# 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# --------------------------------------------------------------------------
# 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

def _format_url_section(template, **kwargs):
components = template.split("/")
while components:
try:
return template.format(**kwargs)
except KeyError as key:
formatted_components = template.split("/")
components = [
c for c in formatted_components if "{}".format(key.args[0]) not in c
]
template = "/".join(components)
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@

from ._azure_blob_storage import AzureBlobStorage
__all__ = ['AzureBlobStorage']

# `._patch.py` 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
from ._patch import patch_sdk
patch_sdk()
Loading

0 comments on commit 476ff7f

Please sign in to comment.