Skip to content

Commit

Permalink
Update autorest.python to 6.13.16 (#293)
Browse files Browse the repository at this point in the history
* Update Autorest to 6.13.16

* lint fix

* lint

* fix mocked-tests

* bring python down to 3.8

* poetry lock

* re-generate
  • Loading branch information
danaelhe authored May 28, 2024
1 parent d2f40e9 commit 9912278
Show file tree
Hide file tree
Showing 18 changed files with 89,886 additions and 73,752 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LOCAL_SPEC_FILE=./DigitalOcean-public.v2.yaml
MODELERFOUR_VERSION="4.23.6"
AUTOREST_PYTHON_VERSION="6.0.1"
AUTOREST_PYTHON_VERSION="6.13.16"
POETRY_VERSION:=$(shell poetry version)
PACKAGE_VERSION:=$(lastword $(POETRY_VERSION))
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
Expand Down
1,786 changes: 941 additions & 845 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ classifiers = [
]

[tool.poetry.dependencies]
python = "^3.7.2"
python = "^3.8.0"
azure-core = ">=1.24.0"
azure-identity = ">=1.5.0"
isodate = ">=0.6.1"
Expand Down
8 changes: 5 additions & 3 deletions src/pydo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.0, generator: @autorest/python@6.0.1)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.0, generator: @autorest/python@6.13.16)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

Expand All @@ -11,12 +11,14 @@

try:
from ._patch import __all__ as _patch_all
from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import
from ._patch import * # pylint: disable=unused-wildcard-import
except ImportError:
_patch_all = []
from ._patch import patch_sdk as _patch_sdk

__all__ = ["GeneratedClient"]
__all__ = [
"GeneratedClient",
]
__all__.extend([p for p in _patch_all if p not in __all__])

_patch_sdk()
109 changes: 64 additions & 45 deletions src/pydo/_client.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.0, generator: @autorest/python@6.0.1)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.0, generator: @autorest/python@6.13.16)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import Any, TYPE_CHECKING

from azure.core import PipelineClient
from azure.core.pipeline import policies
from azure.core.rest import HttpRequest, HttpResponse

from ._configuration import GeneratedClientConfiguration
Expand Down Expand Up @@ -51,8 +52,6 @@

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

from azure.core.credentials import TokenCredential


Expand Down Expand Up @@ -190,9 +189,9 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too
if a collection was processed.
For example, if you send a GET request to ``/v2/droplets/$DROPLET_ID`` you
will get back an object with a key called "\ ``droplet``\ ". However, if you send
the GET request to the general collection at ``/v2/droplets``\ , you will get
back an object with a key called "\ ``droplets``\ ".
will get back an object with a key called "\\ ``droplet``\\ ". However, if you send
the GET request to the general collection at ``/v2/droplets``\\ , you will get
back an object with a key called "\\ ``droplets``\\ ".
The value of these keys will generally be a JSON object for a request on a
single object and an array of objects for a request on a collection of
Expand Down Expand Up @@ -240,7 +239,7 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too
The ``meta`` object will only be displayed when it has a value. Currently, the
``meta`` object will have a value when a request is made on a collection (like
``droplets`` or ``domains``\ ).
``droplets`` or ``domains``\\ ).
Sample Meta Object
^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -276,10 +275,10 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too
following:
* **first**\ : The URI of the first page of results.
* **prev**\ : The URI of the previous sequential page of results.
* **next**\ : The URI of the next sequential page of results.
* **last**\ : The URI of the last page of results.
* **first**\\ : The URI of the first page of results.
* **prev**\\ : The URI of the previous sequential page of results.
* **next**\\ : The URI of the next sequential page of results.
* **last**\\ : The URI of the last page of results.
The ``pages`` object will only include the links that make sense. So for the
first page of results, no ``first`` or ``prev`` links will ever be set. This
Expand Down Expand Up @@ -318,17 +317,17 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too
each request. The relevant headers are:
* **ratelimit-limit**\ : The number of requests that can be made per hour.
* **ratelimit-remaining**\ : The number of requests that remain before you hit your request
* **ratelimit-limit**\\ : The number of requests that can be made per hour.
* **ratelimit-remaining**\\ : The number of requests that remain before you hit your request
limit. See the information below for how the request limits expire.
* **ratelimit-reset**\ : This represents the time when the oldest request will expire. The
* **ratelimit-reset**\\ : This represents the time when the oldest request will expire. The
value is given in `Unix epoch time <http://en.wikipedia.org/wiki/Unix_time>`_. See below for
more information about how request limits expire.
More rate limiting information is returned only within burst limit error response headers:
* **retry-after**\ : The number of seconds to wait before making another request when rate
* **retry-after**\\ : The number of seconds to wait before making another request when rate
limited.
As long as the ``ratelimit-remaining`` count is above zero, you will be able
Expand Down Expand Up @@ -369,8 +368,8 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too
* Only 10 ``GET`` requests to the ``/v2/account/keys`` endpoint to list SSH keys can be made
per 60 seconds.
* Only 5 requests to any and all ``v2/cdn/endpoints`` can be made per 10 seconds. This includes
``v2/cdn/endpoints``\ ,
``v2/cdn/endpoints/$ENDPOINT_ID``\ , and ``v2/cdn/endpoints/$ENDPOINT_ID/cache``.
``v2/cdn/endpoints``\\ ,
``v2/cdn/endpoints/$ENDPOINT_ID``\\ , and ``v2/cdn/endpoints/$ENDPOINT_ID/cache``.
* Only 50 strings within the ``files`` json struct in the
``v2/cdn/endpoints/$ENDPOINT_ID/cache`` `payload
<https://docs.digitalocean.com/reference/api/api-reference/#operation/cdn_purge_cache>`_
Expand Down Expand Up @@ -424,20 +423,20 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too
*
For cmd.exe, use the ``set VAR=VALUE`` `syntax
<https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/set_1>`_
to define environment variables, call them with ``%VAR%``\ , then replace all backslashes (\
``\``\ ) in the examples with carets (\ ``^``\ ).
to define environment variables, call them with ``%VAR%``\\ , then replace all backslashes
(\\ ``\\``\\ ) in the examples with carets (\\ ``^``\\ ).
*
For PowerShell, use the ``$Env:VAR = "VALUE"`` `syntax
<https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables?view=powershell-7.2>`_
to define environment variables, call them with ``$Env:VAR``\ , then replace ``curl`` with
``curl.exe`` and all backslashes (\ ``\``\ ) in the examples with backticks (\ ``` ``\ ).
to define environment variables, call them with ``$Env:VAR``\\ , then replace ``curl`` with
``curl.exe`` and all backslashes (\\ ``\\``\\ ) in the examples with backticks (\\ ``` ``\\ ).
*
WSL is a compatibility layer that allows you to emulate a Linux terminal on a Windows
machine.
Install WSL with our `community tutorial
<https://www.digitalocean.com/community/tutorials/how-to-install-the-windows-subsystem-for-linux-2-on-microsoft-windows-10>`_\
<https://www.digitalocean.com/community/tutorials/how-to-install-the-windows-subsystem-for-linux-2-on-microsoft-windows-10>`_\\
,
then follow this API documentation normally.
Expand Down Expand Up @@ -465,7 +464,7 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too
If you are following along, make sure you use a Droplet ID that you control
so that your commands will execute correctly.
If you need access to the headers of a response through ``curl``\ , you can pass
If you need access to the headers of a response through ``curl``\\ , you can pass
the ``-i`` flag to display the header information along with the body. If you
are only interested in the header, you can instead pass the ``-I`` flag, which
will exclude the response body entirely.
Expand Down Expand Up @@ -511,18 +510,18 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too
.. code-block::
curl -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "example.com", "ip_address": "127.0.0.1"}' \
curl -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \\
-H "Content-Type: application/json" \\
-d '{"name": "example.com", "ip_address": "127.0.0.1"}' \\
-X POST "https://api.digitalocean.com/v2/domains"
Pass Filter Parameters as a Query String
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block::
curl -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
-X GET \
curl -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \\
-X GET \\
"https://api.digitalocean.com/v2/images?private=true"
Cross Origin Resource Sharing
Expand All @@ -548,16 +547,16 @@ class GeneratedClient: # pylint: disable=client-accepts-api-version-keyword,too
that will be set to show the constraints are:
* **Access-Control-Allow-Origin**\ : This is the domain that is sent by the client or browser
* **Access-Control-Allow-Origin**\\ : This is the domain that is sent by the client or browser
as the origin of the request. It is set through an ``Origin`` header.
* **Access-Control-Allow-Methods**\ : This specifies the allowed options for requests from that
domain. This will generally be all available methods.
* **Access-Control-Expose-Headers**\ : This will contain the headers that will be available to
* **Access-Control-Allow-Methods**\\ : This specifies the allowed options for requests from
that domain. This will generally be all available methods.
* **Access-Control-Expose-Headers**\\ : This will contain the headers that will be available to
requests from the origin domain.
* **Access-Control-Max-Age**\ : This is the length of time that the access is considered valid.
After this expires, a new preflight should be sent.
* **Access-Control-Allow-Credentials**\ : This will be set to ``true``. It basically allows you
to send your OAuth token for authentication.
* **Access-Control-Max-Age**\\ : This is the length of time that the access is considered
valid. After this expires, a new preflight should be sent.
* **Access-Control-Allow-Credentials**\\ : This will be set to ``true``. It basically allows
you to send your OAuth token for authentication.
You should not need to be concerned with the details of these headers,
because the browser will typically do all of the work for you.
Expand Down Expand Up @@ -644,7 +643,28 @@ def __init__(
**kwargs: Any
) -> None:
self._config = GeneratedClientConfiguration(credential=credential, **kwargs)
self._client = PipelineClient(base_url=endpoint, config=self._config, **kwargs)
_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [
policies.RequestIdPolicy(**kwargs),
self._config.headers_policy,
self._config.user_agent_policy,
self._config.proxy_policy,
policies.ContentDecodePolicy(**kwargs),
self._config.redirect_policy,
self._config.retry_policy,
self._config.authentication_policy,
self._config.custom_hook_policy,
self._config.logging_policy,
policies.DistributedTracingPolicy(**kwargs),
policies.SensitiveHeaderCleanupPolicy(**kwargs)
if self._config.redirect_policy
else None,
self._config.http_logging_policy,
]
self._client: PipelineClient = PipelineClient(
base_url=endpoint, policies=_policies, **kwargs
)

self._serialize = Serializer()
self._deserialize = Deserializer()
Expand Down Expand Up @@ -752,7 +772,9 @@ def __init__(
self._client, self._config, self._serialize, self._deserialize
)

def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
def send_request(
self, request: HttpRequest, *, stream: bool = False, **kwargs: Any
) -> HttpResponse:
"""Runs the network request through the client's chained policies.
>>> from azure.core.rest import HttpRequest
Expand All @@ -772,17 +794,14 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:

request_copy = deepcopy(request)
request_copy.url = self._client.format_url(request_copy.url)
return self._client.send_request(request_copy, **kwargs)
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore

def close(self):
# type: () -> None
def close(self) -> None:
self._client.close()

def __enter__(self):
# type: () -> GeneratedClient
def __enter__(self) -> "GeneratedClient":
self._client.__enter__()
return self

def __exit__(self, *exc_details):
# type: (Any) -> None
def __exit__(self, *exc_details: Any) -> None:
self._client.__exit__(*exc_details)
16 changes: 5 additions & 11 deletions src/pydo/_configuration.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# coding=utf-8
# --------------------------------------------------------------------------
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.0, generator: @autorest/python@6.0.1)
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.9.0, generator: @autorest/python@6.13.16)
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from typing import Any, TYPE_CHECKING

from azure.core.configuration import Configuration
from azure.core.pipeline import policies

from ._version import VERSION
Expand All @@ -16,9 +15,7 @@
from azure.core.credentials import TokenCredential


class GeneratedClientConfiguration(
Configuration
): # pylint: disable=too-many-instance-attributes
class GeneratedClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
"""Configuration for GeneratedClient.
Note that all parameters used to create this instance are saved as instance
Expand All @@ -29,7 +26,6 @@ class GeneratedClientConfiguration(
"""

def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None:
super(GeneratedClientConfiguration, self).__init__(**kwargs)
if credential is None:
raise ValueError("Parameter 'credential' must not be None.")

Expand All @@ -38,12 +34,10 @@ def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None:
"credential_scopes", ["https://api.digitalocean.com"]
)
kwargs.setdefault("sdk_moniker", "generatedclient/{}".format(VERSION))
self.polling_interval = kwargs.get("polling_interval", 30)
self._configure(**kwargs)

def _configure(
self, **kwargs # type: Any
):
# type: (...) -> None
def _configure(self, **kwargs: Any) -> None:
self.user_agent_policy = kwargs.get(
"user_agent_policy"
) or policies.UserAgentPolicy(**kwargs)
Expand All @@ -57,13 +51,13 @@ def _configure(
self.http_logging_policy = kwargs.get(
"http_logging_policy"
) or policies.HttpLoggingPolicy(**kwargs)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.custom_hook_policy = kwargs.get(
"custom_hook_policy"
) or policies.CustomHookPolicy(**kwargs)
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(
**kwargs
)
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
self.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.BearerTokenCredentialPolicy(
Expand Down
Loading

0 comments on commit 9912278

Please sign in to comment.