Skip to content

[AutoPR-confidentialledger]Cadl demo #1588

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

Closed
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
6 changes: 0 additions & 6 deletions scripts/sdk_generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ export VIRTUAL_ENV
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH

# node version degrade
npm install -g n
n 16.15.0
echo "$PATH"
export PATH="/usr/local/n/versions/node/16.15.0/bin:$PATH"

TEMP_FILE="$TMPDIR/venv-sdk/auto_temp.json"
# generate code
python -m packaging_tools.sdk_generator "$1" "$TEMP_FILE" 2>&1
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"commit": "",
"repository_url": "https://github.com/openapi-env-test/azure-rest-api-specs",
"cadl_src": "confidentialledger/ConfientialLedger",
"@autorest/python": {
"version": "6.1.11",
"resolved": "https://registry.npmjs.org/@autorest/python/-/python-6.1.11.tgz",
"overridden": false
},
"@azure-tools/cadl-python": {
"version": "0.2.5",
"resolved": "https://registry.npmjs.org/@azure-tools/cadl-python/-/cadl-python-0.2.5.tgz",
"overridden": false,
"dependencies": {
"@autorest/python": {
"version": "6.1.11"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# coding=utf-8
# --------------------------------------------------------------------------
# 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) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------

from ._client import ConfidentialLedgerService
from ._version import VERSION

__version__ = VERSION

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

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

_patch_sdk()
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# coding=utf-8
# --------------------------------------------------------------------------
# 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) Python Code Generator.
# 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.rest import HttpRequest, HttpResponse

from ._configuration import ConfidentialLedgerServiceConfiguration
from ._operations import ConfidentialLedgerServiceOperationsMixin
from ._serialization import Deserializer, Serializer

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential


class ConfidentialLedgerService(
ConfidentialLedgerServiceOperationsMixin
): # pylint: disable=client-accepts-api-version-keyword
"""Service client.

:param ledger_uri: Required.
:type ledger_uri: str
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
"""

def __init__(self, ledger_uri: str, credential: "TokenCredential", **kwargs: Any) -> None:
_endpoint = "{ledgerUri}"
self._config = ConfidentialLedgerServiceConfiguration(ledger_uri=ledger_uri, credential=credential, **kwargs)
self._client = PipelineClient(base_url=_endpoint, config=self._config, **kwargs)

self._serialize = Serializer()
self._deserialize = Deserializer()
self._serialize.client_side_validation = False

def send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.

>>> 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/dpcodegen/python/send_request

: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.rest.HttpResponse
"""

request_copy = deepcopy(request)
path_format_arguments = {
"ledgerUri": self._serialize.url("self._config.ledger_uri", self._config.ledger_uri, "str"),
}

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

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

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

def __exit__(self, *exc_details):
# type: (Any) -> None
self._client.__exit__(*exc_details)
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# coding=utf-8
# --------------------------------------------------------------------------
# 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) Python Code Generator.
# 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

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential


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

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

:param ledger_uri: Required.
:type ledger_uri: str
:param credential: Credential needed for the client to connect to Azure. Required.
:type credential: ~azure.core.credentials.TokenCredential
"""

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

self.ledger_uri = ledger_uri
self.credential = credential
self.credential_scopes = kwargs.pop("credential_scopes", ["https://confidential-ledger.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "security-confidentialledger/{}".format(VERSION))
self._configure(**kwargs)

def _configure(
self, **kwargs # type: Any
):
# type: (...) -> 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.authentication_policy = kwargs.get("authentication_policy")
if self.credential and not self.authentication_policy:
self.authentication_policy = policies.BearerTokenCredentialPolicy(
self.credential, *self.credential_scopes, **kwargs
)
Loading