Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
from .__cmd_group import *
from ._create import *
from ._delete import *
from ._link import *
from ._list import *
from ._remove_version import *
from ._show import *
from ._unlink import *
from ._wait import *
from . import hierarchy
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
# --------------------------------------------------------------------------------------------
# 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 aaz-dev-tools
# --------------------------------------------------------------------------------------------

# pylint: skip-file
# flake8: noqa

from azure.cli.core.aaz import *

@register_command(
"workload-orchestration config-template link",
)
class Link(AAZCommand):
"""Link a Config Template to hierarchies
:example: Link a Config Template to hierarchies
az workload-orchestration config-template link -g rg1 -n configTemplatename --hierarchy-ids "/subscriptions/sub1/resourceGroups/rg1/providers/Microsoft.Edge/sites/site1" --context-id "context123"
"""

_aaz_info = {
"version": "2025-08-01",
"resources": [
["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/Microsoft.Edge/configtemplates/{}/linktohierarchies", "2025-08-01"],
]
}

AZ_SUPPORT_NO_WAIT = True

def _handler(self, command_args):
super()._handler(command_args)
return self.build_lro_poller(self._execute_operations, self._output)

_args_schema = None

@classmethod
def _build_arguments_schema(cls, *args, **kwargs):
if cls._args_schema is not None:
return cls._args_schema
cls._args_schema = super()._build_arguments_schema(*args, **kwargs)

# define Arg Group ""
_args_schema = cls._args_schema
_args_schema.config_template_name = AAZStrArg(
options=["-n", "--name", "--config-template-name"],
help="The name of the ConfigTemplate",
required=True,
fmt=AAZStrArgFormat(
pattern="^[a-zA-Z0-9-]{3,24}$",
),
)
_args_schema.resource_group = AAZResourceGroupNameArg(
required=True,
)

_args_schema.hierarchy_ids = AAZListArg(
options=["--hierarchy-ids"],
help="List of hierarchy IDs to link to the config template",
required=True,
)
_args_schema.hierarchy_ids.Element = AAZStrArg()

_args_schema.context_id = AAZStrArg(
options=["--context-id"],
help="Context ID for the link operation",
required=True,
)

return cls._args_schema

def _execute_operations(self):
self.pre_operations()
yield self.ConfigTemplatesLinkToHierarchies(ctx=self.ctx)()
self.post_operations()

@register_callback
def pre_operations(self):
pass

@register_callback
def post_operations(self):
pass

def _output(self, *args, **kwargs):
result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True)
return result

class ConfigTemplatesLinkToHierarchies(AAZHttpOperation):
CLIENT_TYPE = "MgmtClient"

def __call__(self, *args, **kwargs):
request = self.make_request()
session = self.client.send_request(request=request, stream=False, **kwargs)
if session.http_response.status_code in [202]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_200_202,
self.on_error,
lro_options={"final-state-via": "location"},
path_format_arguments=self.url_parameters,
)
if session.http_response.status_code in [200]:
return self.client.build_lro_polling(
self.ctx.args.no_wait,
session,
self.on_200_202,
self.on_error,
lro_options={"final-state-via": "location"},
path_format_arguments=self.url_parameters,
)

return self.on_error(session.http_response)

@property
def url(self):
return self.client.format_url(
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/configTemplates/{configTemplateName}/linkToHierarchies",
**self.url_parameters
)

@property
def method(self):
return "POST"

@property
def error_format(self):
return "MgmtErrorFormat"

@property
def url_parameters(self):
parameters = {
**self.serialize_url_param(
"configTemplateName", self.ctx.args.config_template_name,
required=True,
),
**self.serialize_url_param(
"resourceGroupName", self.ctx.args.resource_group,
required=True,
),
**self.serialize_url_param(
"subscriptionId", self.ctx.subscription_id,
required=True,
),
}
return parameters

@property
def query_parameters(self):
parameters = {
**self.serialize_query_param(
"api-version", "2025-08-01",
required=True,
),
}
return parameters

@property
def header_parameters(self):
parameters = {
**self.serialize_header_param(
"Content-Type", "application/json",
),
**self.serialize_header_param(
"Accept", "application/json",
),
}
return parameters

@property
def content(self):
_content_value, _builder = self.new_content_builder(
self.ctx.args,
typ=AAZObjectType,
typ_kwargs={"flags": {"required": True, "client_flatten": True}}
)
_builder.set_prop("hierarchyIds", AAZListType, ".hierarchy_ids", typ_kwargs={"flags": {"required": True}})
_builder.set_prop("contextId", AAZStrType, ".context_id", typ_kwargs={"flags": {"required": True}})

hierarchy_ids = _builder.get(".hierarchyIds")
if hierarchy_ids is not None:
hierarchy_ids.set_elements(AAZStrType, ".")

return self.serialize_content(_content_value)

def on_200_202(self, session):
data = self.deserialize_http_content(session)
self.ctx.set_var(
"instance",
data,
schema_builder=self._build_schema_on_200_202
)

_schema_on_200_202 = None

@classmethod
def _build_schema_on_200_202(cls):
if cls._schema_on_200_202 is not None:
return cls._schema_on_200_202

cls._schema_on_200_202 = AAZObjectType()
_schema_on_200_202 = cls._schema_on_200_202

# Standard response fields
_schema_on_200_202.message = AAZStrType()
_schema_on_200_202.status = AAZStrType()

return cls._schema_on_200_202


class _LinkHelper:
"""Helper class for Link"""


__all__ = ["Link"]
Loading
Loading