Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generating Python sdk for ACL API version 2024-08-22 #38959

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wrong-import-position

from ._client import ConfidentialLedgerClient
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from ._patch import * # pylint: disable=unused-wildcard-import

from ._client import ConfidentialLedgerClient # type: ignore
from ._version import VERSION

__version__ = VERSION

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

__all__ = ["ConfidentialLedgerClient"]
__all__.extend([p for p in _patch_all if p not in __all__])
__all__ = [
"ConfidentialLedgerClient",
]
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore

_patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,59 @@
# --------------------------------------------------------------------------

from copy import deepcopy
from typing import Any, TYPE_CHECKING
from typing import Any
from typing_extensions import Self

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

from ._configuration import ConfidentialLedgerClientConfiguration
from ._operations import ConfidentialLedgerClientOperationsMixin
from ._serialization import Deserializer, Serializer

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


class ConfidentialLedgerClient(
ConfidentialLedgerClientOperationsMixin
): # pylint: disable=client-accepts-api-version-keyword
class ConfidentialLedgerClient(ConfidentialLedgerClientOperationsMixin):
"""The ConfidentialLedgerClient writes and retrieves ledger entries against the Confidential
Ledger service.

:param ledger_endpoint: The Confidential Ledger URL, for example
:param endpoint: The Confidential Ledger URL, for example
https://contoso.confidentialledger.azure.com. Required.
:type ledger_endpoint: str
:keyword api_version: Api Version. Default value is "2022-05-13". Note that overriding this
default value may result in unsupported behavior.
:type endpoint: str
:keyword api_version: Api Version. Default value is "2024-08-22-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__( # pylint: disable=missing-client-constructor-parameter-credential
self, ledger_endpoint: str, **kwargs: Any
self, endpoint: str, **kwargs: Any
) -> None:
_endpoint = "{ledgerEndpoint}"
self._config = ConfidentialLedgerClientConfiguration(ledger_endpoint=ledger_endpoint, **kwargs)
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)
_endpoint = "{endpoint}"
self._config = ConfidentialLedgerClientConfiguration(endpoint=endpoint, **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()
self._serialize.client_side_validation = False

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 @@ -66,23 +79,18 @@ def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:

request_copy = deepcopy(request)
path_format_arguments = {
"ledgerEndpoint": self._serialize.url(
"self._config.ledger_endpoint", self._config.ledger_endpoint, "str", skip_quote=True
),
"endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
}

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
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: () -> ConfidentialLedgerClient
def __enter__(self) -> Self:
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)
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,44 @@

from typing import Any

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

from ._version import VERSION


class ConfidentialLedgerClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes
class ConfidentialLedgerClientConfiguration: # pylint: disable=too-many-instance-attributes
"""Configuration for ConfidentialLedgerClient.

Note that all parameters used to create this instance are saved as instance
attributes.

:param ledger_endpoint: The Confidential Ledger URL, for example
:param endpoint: The Confidential Ledger URL, for example
https://contoso.confidentialledger.azure.com. Required.
:type ledger_endpoint: str
:keyword api_version: Api Version. Default value is "2022-05-13". Note that overriding this
default value may result in unsupported behavior.
:type endpoint: str
:keyword api_version: Api Version. Default value is "2024-08-22-preview". Note that overriding
this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, ledger_endpoint: str, **kwargs: Any) -> None:
super(ConfidentialLedgerClientConfiguration, self).__init__(**kwargs)
api_version = kwargs.pop("api_version", "2022-05-13") # type: str
def __init__(self, endpoint: str, **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2024-08-22-preview")

if ledger_endpoint is None:
raise ValueError("Parameter 'ledger_endpoint' must not be None.")
if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")

self.ledger_endpoint = ledger_endpoint
self.endpoint = endpoint
self.api_version = api_version
kwargs.setdefault("sdk_moniker", "confidentialledger/{}".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)
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
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")
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wrong-import-position

from ._operations import ConfidentialLedgerClientOperationsMixin
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from ._patch import * # pylint: disable=unused-wildcard-import

from ._operations import ConfidentialLedgerClientOperationsMixin # type: ignore

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

__all__ = [
"ConfidentialLedgerClientOperationsMixin",
]
__all__.extend([p for p in _patch_all if p not in __all__])
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
_patch_sdk()
Loading
Loading