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+ @register_command (
14+ "workload-orchestration config-template link" ,
15+ )
16+ class Link (AAZCommand ):
17+ """Link a Config Template to hierarchies
18+ :example: Link a Config Template to hierarchies
19+ az workload-orchestration config-template link -g rg1 -n configTemplatename --hierarchy-ids "/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Edge/sites/site1" --context-id "context123"
20+ """
21+
22+ _aaz_info = {
23+ "version" : "2025-08-01" ,
24+ "resources" : [
25+ ["mgmt-plane" , "/subscriptions/{}/resourcegroups/{}/providers/Microsoft.Edge/configtemplates/{}/linktohierarchies" , "2025-08-01" ],
26+ ]
27+ }
28+
29+ AZ_SUPPORT_NO_WAIT = True
30+
31+ def _handler (self , command_args ):
32+ super ()._handler (command_args )
33+ return self .build_lro_poller (self ._execute_operations , self ._output )
34+
35+ _args_schema = None
36+
37+ @classmethod
38+ def _build_arguments_schema (cls , * args , ** kwargs ):
39+ if cls ._args_schema is not None :
40+ return cls ._args_schema
41+ cls ._args_schema = super ()._build_arguments_schema (* args , ** kwargs )
42+
43+ # define Arg Group ""
44+ _args_schema = cls ._args_schema
45+ _args_schema .config_template_name = AAZStrArg (
46+ options = ["-n" , "--name" , "--config-template-name" ],
47+ help = "The name of the ConfigTemplate" ,
48+ required = True ,
49+ fmt = AAZStrArgFormat (
50+ pattern = "^[a-zA-Z0-9-]{3,24}$" ,
51+ ),
52+ )
53+ _args_schema .resource_group = AAZResourceGroupNameArg (
54+ required = True ,
55+ )
56+
57+ _args_schema .hierarchy_ids = AAZListArg (
58+ options = ["--hierarchy-ids" ],
59+ help = "List of hierarchy IDs to link to the config template" ,
60+ required = True ,
61+ )
62+ _args_schema .hierarchy_ids .Element = AAZStrArg ()
63+
64+ _args_schema .context_id = AAZStrArg (
65+ options = ["--context-id" ],
66+ help = "Context ID for the link operation" ,
67+ required = True ,
68+ )
69+
70+ return cls ._args_schema
71+
72+ def _execute_operations (self ):
73+ self .pre_operations ()
74+ yield self .ConfigTemplatesLinkToHierarchies (ctx = self .ctx )()
75+ self .post_operations ()
76+
77+ @register_callback
78+ def pre_operations (self ):
79+ pass
80+
81+ @register_callback
82+ def post_operations (self ):
83+ pass
84+
85+ def _output (self , * args , ** kwargs ):
86+ result = self .deserialize_output (self .ctx .vars .instance , client_flatten = True )
87+ return result
88+
89+ class ConfigTemplatesLinkToHierarchies (AAZHttpOperation ):
90+ CLIENT_TYPE = "MgmtClient"
91+
92+ def __call__ (self , * args , ** kwargs ):
93+ request = self .make_request ()
94+ session = self .client .send_request (request = request , stream = False , ** kwargs )
95+ if session .http_response .status_code in [202 ]:
96+ return self .client .build_lro_polling (
97+ self .ctx .args .no_wait ,
98+ session ,
99+ self .on_200_202 ,
100+ self .on_error ,
101+ lro_options = {"final-state-via" : "location" },
102+ path_format_arguments = self .url_parameters ,
103+ )
104+ if session .http_response .status_code in [200 ]:
105+ return self .client .build_lro_polling (
106+ self .ctx .args .no_wait ,
107+ session ,
108+ self .on_200_202 ,
109+ self .on_error ,
110+ lro_options = {"final-state-via" : "location" },
111+ path_format_arguments = self .url_parameters ,
112+ )
113+
114+ return self .on_error (session .http_response )
115+
116+ @property
117+ def url (self ):
118+ return self .client .format_url (
119+ "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/configTemplates/{configTemplateName}/linkToHierarchies" ,
120+ ** self .url_parameters
121+ )
122+
123+ @property
124+ def method (self ):
125+ return "POST"
126+
127+ @property
128+ def error_format (self ):
129+ return "MgmtErrorFormat"
130+
131+ @property
132+ def url_parameters (self ):
133+ parameters = {
134+ ** self .serialize_url_param (
135+ "configTemplateName" , self .ctx .args .config_template_name ,
136+ required = True ,
137+ ),
138+ ** self .serialize_url_param (
139+ "resourceGroupName" , self .ctx .args .resource_group ,
140+ required = True ,
141+ ),
142+ ** self .serialize_url_param (
143+ "subscriptionId" , self .ctx .subscription_id ,
144+ required = True ,
145+ ),
146+ }
147+ return parameters
148+
149+ @property
150+ def query_parameters (self ):
151+ parameters = {
152+ ** self .serialize_query_param (
153+ "api-version" , "2025-08-01" ,
154+ required = True ,
155+ ),
156+ }
157+ return parameters
158+
159+ @property
160+ def header_parameters (self ):
161+ parameters = {
162+ ** self .serialize_header_param (
163+ "Content-Type" , "application/json" ,
164+ ),
165+ ** self .serialize_header_param (
166+ "Accept" , "application/json" ,
167+ ),
168+ }
169+ return parameters
170+
171+ @property
172+ def content (self ):
173+ _content_value , _builder = self .new_content_builder (
174+ self .ctx .args ,
175+ typ = AAZObjectType ,
176+ typ_kwargs = {"flags" : {"required" : True , "client_flatten" : True }}
177+ )
178+ _builder .set_prop ("hierarchyIds" , AAZListType , ".hierarchy_ids" , typ_kwargs = {"flags" : {"required" : True }})
179+ _builder .set_prop ("contextId" , AAZStrType , ".context_id" , typ_kwargs = {"flags" : {"required" : True }})
180+
181+ hierarchy_ids = _builder .get (".hierarchyIds" )
182+ if hierarchy_ids is not None :
183+ hierarchy_ids .set_elements (AAZStrType , "." )
184+
185+ return self .serialize_content (_content_value )
186+
187+ def on_200_202 (self , session ):
188+ data = self .deserialize_http_content (session )
189+ self .ctx .set_var (
190+ "instance" ,
191+ data ,
192+ schema_builder = self ._build_schema_on_200_202
193+ )
194+
195+ _schema_on_200_202 = None
196+
197+ @classmethod
198+ def _build_schema_on_200_202 (cls ):
199+ if cls ._schema_on_200_202 is not None :
200+ return cls ._schema_on_200_202
201+
202+ cls ._schema_on_200_202 = AAZObjectType ()
203+ _schema_on_200_202 = cls ._schema_on_200_202
204+
205+ # Standard response fields
206+ _schema_on_200_202 .message = AAZStrType ()
207+ _schema_on_200_202 .status = AAZStrType ()
208+
209+ return cls ._schema_on_200_202
210+
211+
212+ class _LinkHelper :
213+ """Helper class for Link"""
214+
215+
216+ __all__ = ["Link" ]
0 commit comments