Skip to content

Commit 0082b03

Browse files
authored
AZ CLI confidentialledger extension update as per latest spec (Azure#8654)
* Updated confidentialledger extension as per the latest spec * Updated version and added missing example for new command * Added license header * Added examples * Deleting obsolate files as they are no longer used. * Update to resolve CI issues * Update to resolve CI errors. * Update to resolve CI errors * Updated recordings as per latest api spec changes * Updated cli tests to fix CI errors. Removed old tests.
1 parent bfb3452 commit 0082b03

37 files changed

+4013
-1899
lines changed

src/confidentialledger/HISTORY.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Release History
44
===============
55

6+
2.0.0
7+
++++++
8+
* Updated the extension as per the latest spec 2024-09-19-preview.
9+
* Added new command check-name-availability.
10+
611
1.0.0
712
++++++
813
* GA of the Azure Confidential Ledger Azure CLI extension.

src/confidentialledger/azext_confidentialledger/__init__.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,29 @@
1717
class ConfidentialLedgerCommandsLoader(AzCommandsLoader):
1818
def __init__(self, cli_ctx=None):
1919
from azure.cli.core.commands import CliCommandType
20-
from azext_confidentialledger.generated._client_factory import (
21-
cf_confidentialledger_cl,
22-
)
2320

2421
confidentialledger_custom = CliCommandType(
2522
operations_tmpl="azext_confidentialledger.custom#{}",
26-
client_factory=cf_confidentialledger_cl,
2723
)
2824
parent = super()
2925
parent.__init__(cli_ctx=cli_ctx, custom_command_type=confidentialledger_custom)
3026

3127
def load_command_table(self, args):
32-
from azext_confidentialledger.generated.commands import load_command_table
33-
34-
load_command_table(self, args)
28+
from azure.cli.core.aaz import load_aaz_command_table
3529
try:
36-
from azext_confidentialledger.manual.commands import (
37-
load_command_table as load_command_table_manual,
30+
from . import aaz
31+
except ImportError:
32+
aaz = None
33+
if aaz:
34+
load_aaz_command_table(
35+
loader=self,
36+
aaz_pkg_name=aaz.__name__,
37+
args=args
3838
)
3939

40-
load_command_table_manual(self, args)
41-
except ImportError as e:
42-
if e.name.endswith("manual.commands"):
43-
pass
44-
else:
45-
raise e
4640
return self.command_table
4741

4842
def load_arguments(self, command):
49-
from azext_confidentialledger.generated._params import load_arguments
50-
51-
load_arguments(self, command)
5243
try:
5344
from azext_confidentialledger.manual._params import (
5445
load_arguments as load_arguments_manual,

src/confidentialledger/azext_confidentialledger/_help.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
# pylint: disable=wildcard-import
1111
# pylint: disable=unused-wildcard-import
1212
# pylint: disable=unused-import
13-
from .generated._help import helps # pylint: disable=reimported
14-
1513
try:
1614
from .manual._help import helps # pylint: disable=reimported
1715
except ImportError as e:

src/confidentialledger/azext_confidentialledger/generated/_validators.py renamed to src/confidentialledger/azext_confidentialledger/aaz/__init__.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
# --------------------------------------------------------------------------
1+
# --------------------------------------------------------------------------------------------
22
# Copyright (c) Microsoft Corporation. All rights reserved.
3-
# Licensed under the MIT License. See License.txt in the project root for
4-
# license information.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
54
#
6-
# Code generated by Microsoft (R) AutoRest Code Generator.
7-
# Changes may cause incorrect behavior and will be lost if the code is
8-
# regenerated.
9-
# --------------------------------------------------------------------------
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command_group(
15+
"confidentialledger",
16+
)
17+
class __CMDGroup(AAZCommandGroup):
18+
"""Manage Confidential Ledger
19+
"""
20+
pass
21+
22+
23+
__all__ = ["__CMDGroup"]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from .__cmd_group import *
12+
from ._check_name_availability import *
13+
from ._create import *
14+
from ._delete import *
15+
from ._list import *
16+
from ._show import *
17+
from ._update import *
18+
from ._wait import *
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# --------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for license information.
4+
#
5+
# Code generated by aaz-dev-tools
6+
# --------------------------------------------------------------------------------------------
7+
8+
# pylint: skip-file
9+
# flake8: noqa
10+
11+
from azure.cli.core.aaz import *
12+
13+
14+
@register_command(
15+
"confidentialledger check-name-availability",
16+
)
17+
class CheckNameAvailability(AAZCommand):
18+
"""To check whether a resource name is available.
19+
20+
:example: CheckNameAvailability
21+
az confidentialledger check-name-availability --type Microsoft.ConfidentialLedger/ledgers --name sample-name
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2023-06-28-preview",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/providers/microsoft.confidentialledger/checknameavailability", "2023-06-28-preview"],
28+
]
29+
}
30+
31+
def _handler(self, command_args):
32+
super()._handler(command_args)
33+
self._execute_operations()
34+
return self._output()
35+
36+
_args_schema = None
37+
38+
@classmethod
39+
def _build_arguments_schema(cls, *args, **kwargs):
40+
if cls._args_schema is not None:
41+
return cls._args_schema
42+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
43+
44+
# define Arg Group ""
45+
46+
# define Arg Group "NameAvailabilityRequest"
47+
48+
_args_schema = cls._args_schema
49+
_args_schema.name = AAZStrArg(
50+
options=["--name"],
51+
arg_group="NameAvailabilityRequest",
52+
help="The name of the resource for which availability needs to be checked.",
53+
)
54+
_args_schema.type = AAZStrArg(
55+
options=["--type"],
56+
arg_group="NameAvailabilityRequest",
57+
help="The resource type.",
58+
)
59+
return cls._args_schema
60+
61+
def _execute_operations(self):
62+
self.pre_operations()
63+
self.CheckNameAvailability(ctx=self.ctx)()
64+
self.post_operations()
65+
66+
@register_callback
67+
def pre_operations(self):
68+
pass
69+
70+
@register_callback
71+
def post_operations(self):
72+
pass
73+
74+
def _output(self, *args, **kwargs):
75+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
76+
return result
77+
78+
class CheckNameAvailability(AAZHttpOperation):
79+
CLIENT_TYPE = "MgmtClient"
80+
81+
def __call__(self, *args, **kwargs):
82+
request = self.make_request()
83+
session = self.client.send_request(request=request, stream=False, **kwargs)
84+
if session.http_response.status_code in [200]:
85+
return self.on_200(session)
86+
87+
return self.on_error(session.http_response)
88+
89+
@property
90+
def url(self):
91+
return self.client.format_url(
92+
"/subscriptions/{subscriptionId}/providers/Microsoft.ConfidentialLedger/checkNameAvailability",
93+
**self.url_parameters
94+
)
95+
96+
@property
97+
def method(self):
98+
return "POST"
99+
100+
@property
101+
def error_format(self):
102+
return "MgmtErrorFormat"
103+
104+
@property
105+
def url_parameters(self):
106+
parameters = {
107+
**self.serialize_url_param(
108+
"subscriptionId", self.ctx.subscription_id,
109+
required=True,
110+
),
111+
}
112+
return parameters
113+
114+
@property
115+
def query_parameters(self):
116+
parameters = {
117+
**self.serialize_query_param(
118+
"api-version", "2023-06-28-preview",
119+
required=True,
120+
),
121+
}
122+
return parameters
123+
124+
@property
125+
def header_parameters(self):
126+
parameters = {
127+
**self.serialize_header_param(
128+
"Content-Type", "application/json",
129+
),
130+
**self.serialize_header_param(
131+
"Accept", "application/json",
132+
),
133+
}
134+
return parameters
135+
136+
@property
137+
def content(self):
138+
_content_value, _builder = self.new_content_builder(
139+
self.ctx.args,
140+
typ=AAZObjectType,
141+
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
142+
)
143+
_builder.set_prop("name", AAZStrType, ".name")
144+
_builder.set_prop("type", AAZStrType, ".type")
145+
146+
return self.serialize_content(_content_value)
147+
148+
def on_200(self, session):
149+
data = self.deserialize_http_content(session)
150+
self.ctx.set_var(
151+
"instance",
152+
data,
153+
schema_builder=self._build_schema_on_200
154+
)
155+
156+
_schema_on_200 = None
157+
158+
@classmethod
159+
def _build_schema_on_200(cls):
160+
if cls._schema_on_200 is not None:
161+
return cls._schema_on_200
162+
163+
cls._schema_on_200 = AAZObjectType()
164+
165+
_schema_on_200 = cls._schema_on_200
166+
_schema_on_200.message = AAZStrType()
167+
_schema_on_200.name_available = AAZBoolType(
168+
serialized_name="nameAvailable",
169+
)
170+
_schema_on_200.reason = AAZStrType()
171+
172+
return cls._schema_on_200
173+
174+
175+
class _CheckNameAvailabilityHelper:
176+
"""Helper class for CheckNameAvailability"""
177+
178+
179+
__all__ = ["CheckNameAvailability"]

0 commit comments

Comments
 (0)