Skip to content

Commit e63b732

Browse files
[Network] az network vnet-gateway: Support VNET Gateway insights (#31984)
1 parent ca969f7 commit e63b732

File tree

5 files changed

+3724
-0
lines changed

5 files changed

+3724
-0
lines changed

src/azure-cli/azure/cli/command_modules/network/aaz/latest/network/vnet_gateway/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from ._create import *
1313
from ._delete import *
1414
from ._disconnect_vpn_connections import *
15+
from ._get_resiliency_information import *
16+
from ._get_routes_information import *
1517
from ._list import *
1618
from ._list_advertised_routes import *
1719
from ._list_bgp_peer_status import *
Lines changed: 241 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
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+
"network vnet-gateway get-resiliency-information",
16+
)
17+
class GetResiliencyInformation(AAZCommand):
18+
"""This operation retrieves the resiliency information for an Express Route Gateway, including the gateway's current resiliency score and recommendations to further improve the score
19+
20+
:example: GetVirtualNetworkGatewayResiliencyInformation
21+
az network vnet-gateway get-resiliency-information --resource-group rg1 --virtual-network-gateway-name vpngw --attempt-refresh True
22+
"""
23+
24+
_aaz_info = {
25+
"version": "2024-07-01",
26+
"resources": [
27+
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.network/virtualnetworkgateways/{}/getresiliencyinformation", "2024-07-01"],
28+
]
29+
}
30+
31+
AZ_SUPPORT_NO_WAIT = True
32+
33+
def _handler(self, command_args):
34+
super()._handler(command_args)
35+
return self.build_lro_poller(self._execute_operations, self._output)
36+
37+
_args_schema = None
38+
39+
@classmethod
40+
def _build_arguments_schema(cls, *args, **kwargs):
41+
if cls._args_schema is not None:
42+
return cls._args_schema
43+
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)
44+
45+
# define Arg Group ""
46+
47+
_args_schema = cls._args_schema
48+
_args_schema.resource_group = AAZResourceGroupNameArg(
49+
required=True,
50+
)
51+
_args_schema.virtual_network_gateway_name = AAZStrArg(
52+
options=["--virtual-network-gateway-name", "--name"],
53+
help="The name of the virtual network gateway.",
54+
required=True,
55+
id_part="name",
56+
)
57+
_args_schema.attempt_refresh = AAZBoolArg(
58+
options=["--attempt-refresh"],
59+
help="Attempt to recalculate the Resiliency Information for the gateway",
60+
)
61+
return cls._args_schema
62+
63+
def _execute_operations(self):
64+
self.pre_operations()
65+
yield self.VirtualNetworkGatewaysGetResiliencyInformation(ctx=self.ctx)()
66+
self.post_operations()
67+
68+
@register_callback
69+
def pre_operations(self):
70+
pass
71+
72+
@register_callback
73+
def post_operations(self):
74+
pass
75+
76+
def _output(self, *args, **kwargs):
77+
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
78+
return result
79+
80+
class VirtualNetworkGatewaysGetResiliencyInformation(AAZHttpOperation):
81+
CLIENT_TYPE = "MgmtClient"
82+
83+
def __call__(self, *args, **kwargs):
84+
request = self.make_request()
85+
session = self.client.send_request(request=request, stream=False, **kwargs)
86+
if session.http_response.status_code in [202]:
87+
return self.client.build_lro_polling(
88+
self.ctx.args.no_wait,
89+
session,
90+
self.on_200,
91+
self.on_error,
92+
lro_options={"final-state-via": "location"},
93+
path_format_arguments=self.url_parameters,
94+
)
95+
if session.http_response.status_code in [200]:
96+
return self.client.build_lro_polling(
97+
self.ctx.args.no_wait,
98+
session,
99+
self.on_200,
100+
self.on_error,
101+
lro_options={"final-state-via": "location"},
102+
path_format_arguments=self.url_parameters,
103+
)
104+
105+
return self.on_error(session.http_response)
106+
107+
@property
108+
def url(self):
109+
return self.client.format_url(
110+
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getResiliencyInformation",
111+
**self.url_parameters
112+
)
113+
114+
@property
115+
def method(self):
116+
return "POST"
117+
118+
@property
119+
def error_format(self):
120+
return "ODataV4Format"
121+
122+
@property
123+
def url_parameters(self):
124+
parameters = {
125+
**self.serialize_url_param(
126+
"resourceGroupName", self.ctx.args.resource_group,
127+
required=True,
128+
),
129+
**self.serialize_url_param(
130+
"subscriptionId", self.ctx.subscription_id,
131+
required=True,
132+
),
133+
**self.serialize_url_param(
134+
"virtualNetworkGatewayName", self.ctx.args.virtual_network_gateway_name,
135+
required=True,
136+
),
137+
}
138+
return parameters
139+
140+
@property
141+
def query_parameters(self):
142+
parameters = {
143+
**self.serialize_query_param(
144+
"attemptRefresh", self.ctx.args.attempt_refresh,
145+
),
146+
**self.serialize_query_param(
147+
"api-version", "2024-07-01",
148+
required=True,
149+
),
150+
}
151+
return parameters
152+
153+
@property
154+
def header_parameters(self):
155+
parameters = {
156+
**self.serialize_header_param(
157+
"Accept", "application/json",
158+
),
159+
}
160+
return parameters
161+
162+
def on_200(self, session):
163+
data = self.deserialize_http_content(session)
164+
self.ctx.set_var(
165+
"instance",
166+
data,
167+
schema_builder=self._build_schema_on_200
168+
)
169+
170+
_schema_on_200 = None
171+
172+
@classmethod
173+
def _build_schema_on_200(cls):
174+
if cls._schema_on_200 is not None:
175+
return cls._schema_on_200
176+
177+
cls._schema_on_200 = AAZObjectType()
178+
179+
_schema_on_200 = cls._schema_on_200
180+
_schema_on_200.components = AAZListType()
181+
_schema_on_200.last_computed_time = AAZStrType(
182+
serialized_name="lastComputedTime",
183+
)
184+
_schema_on_200.max_score_from_recommendations = AAZStrType(
185+
serialized_name="maxScoreFromRecommendations",
186+
)
187+
_schema_on_200.min_score_from_recommendations = AAZStrType(
188+
serialized_name="minScoreFromRecommendations",
189+
)
190+
_schema_on_200.next_eligible_compute_time = AAZStrType(
191+
serialized_name="nextEligibleComputeTime",
192+
)
193+
_schema_on_200.overall_score = AAZStrType(
194+
serialized_name="overallScore",
195+
)
196+
_schema_on_200.score_change = AAZStrType(
197+
serialized_name="scoreChange",
198+
)
199+
200+
components = cls._schema_on_200.components
201+
components.Element = AAZObjectType()
202+
203+
_element = cls._schema_on_200.components.Element
204+
_element.current_score = AAZStrType(
205+
serialized_name="currentScore",
206+
)
207+
_element.max_score = AAZStrType(
208+
serialized_name="maxScore",
209+
)
210+
_element.name = AAZStrType()
211+
_element.recommendations = AAZListType()
212+
213+
recommendations = cls._schema_on_200.components.Element.recommendations
214+
recommendations.Element = AAZObjectType()
215+
216+
_element = cls._schema_on_200.components.Element.recommendations.Element
217+
_element.call_to_action_link = AAZStrType(
218+
serialized_name="callToActionLink",
219+
)
220+
_element.call_to_action_text = AAZStrType(
221+
serialized_name="callToActionText",
222+
)
223+
_element.recommendation_id = AAZStrType(
224+
serialized_name="recommendationId",
225+
)
226+
_element.recommendation_text = AAZStrType(
227+
serialized_name="recommendationText",
228+
)
229+
_element.recommendation_title = AAZStrType(
230+
serialized_name="recommendationTitle",
231+
)
232+
_element.severity = AAZStrType()
233+
234+
return cls._schema_on_200
235+
236+
237+
class _GetResiliencyInformationHelper:
238+
"""Helper class for GetResiliencyInformation"""
239+
240+
241+
__all__ = ["GetResiliencyInformation"]

0 commit comments

Comments
 (0)