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 [200 , 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+
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.Edge/configTemplates/{configTemplateName}/linkToHierarchies" ,
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 "MgmtErrorFormat"
121+
122+ @property
123+ def url_parameters (self ):
124+ parameters = {
125+ ** self .serialize_url_param (
126+ "configTemplateName" , self .ctx .args .config_template_name ,
127+ required = True ,
128+ ),
129+ ** self .serialize_url_param (
130+ "resourceGroupName" , self .ctx .args .resource_group ,
131+ required = True ,
132+ ),
133+ ** self .serialize_url_param (
134+ "subscriptionId" , self .ctx .subscription_id ,
135+ required = True ,
136+ ),
137+ }
138+ return parameters
139+
140+ @property
141+ def query_parameters (self ):
142+ parameters = {
143+ ** self .serialize_query_param (
144+ "api-version" , "2025-08-01" ,
145+ required = True ,
146+ ),
147+ }
148+ return parameters
149+
150+ @property
151+ def header_parameters (self ):
152+ parameters = {
153+ ** self .serialize_header_param (
154+ "Content-Type" , "application/json" ,
155+ ),
156+ ** self .serialize_header_param (
157+ "Accept" , "application/json" ,
158+ ),
159+ }
160+ return parameters
161+
162+ @property
163+ def content (self ):
164+ _content_value , _builder = self .new_content_builder (
165+ self .ctx .args ,
166+ typ = AAZObjectType ,
167+ typ_kwargs = {"flags" : {"required" : True , "client_flatten" : True }}
168+ )
169+ _builder .set_prop ("hierarchyIds" , AAZListType , ".hierarchy_ids" , typ_kwargs = {"flags" : {"required" : True }})
170+ _builder .set_prop ("contextId" , AAZStrType , ".context_id" , typ_kwargs = {"flags" : {"required" : True }})
171+
172+ hierarchy_ids = _builder .get (".hierarchyIds" )
173+ if hierarchy_ids is not None :
174+ hierarchy_ids .set_elements (AAZStrType , "." )
175+
176+ return self .serialize_content (_content_value )
177+
178+ def on_200_202 (self , session ):
179+ data = self .deserialize_http_content (session )
180+ self .ctx .set_var (
181+ "instance" ,
182+ data ,
183+ schema_builder = self ._build_schema_on_200_202
184+ )
185+
186+ _schema_on_200_202 = None
187+
188+ @classmethod
189+ def _build_schema_on_200_202 (cls ):
190+ if cls ._schema_on_200_202 is not None :
191+ return cls ._schema_on_200_202
192+
193+ cls ._schema_on_200_202 = AAZObjectType ()
194+ _schema_on_200_202 = cls ._schema_on_200_202
195+
196+ # Standard response fields
197+ _schema_on_200_202 .message = AAZStrType ()
198+ _schema_on_200_202 .status = AAZStrType ()
199+
200+ return cls ._schema_on_200_202
201+
202+
203+ class _LinkHelper :
204+ """Helper class for Link"""
205+
206+
207+ __all__ = ["Link" ]
0 commit comments