|
| 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 | + "workload-orchestration artifcat generate", |
| 16 | + is_preview=False, |
| 17 | +) |
| 18 | +class ShowConfig(AAZCommand): |
| 19 | + """To get a configurations available at specified hierarchical entity |
| 20 | + :example: Show a Configuration |
| 21 | + az workload-orchestration configuration show -g rg1 --target-name target1 --solution-template-name solutionTemplate1 |
| 22 | + """ |
| 23 | + |
| 24 | + _aaz_info = { |
| 25 | + "version": "2024-08-01-preview", |
| 26 | + "resources": [ |
| 27 | + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/Microsoft.Edge/solutions/{}", "2024-08-01-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 | + _args_schema = cls._args_schema |
| 47 | + _args_schema.resource_group = AAZResourceGroupNameArg( |
| 48 | + required=True, |
| 49 | + ) |
| 50 | + _args_schema.solution_name = AAZStrArg( |
| 51 | + options=["--solution-template-name"], |
| 52 | + help="The name of the Solution, This is required only to get solution configurations", |
| 53 | + # required=True, |
| 54 | + id_part="name", |
| 55 | + fmt=AAZStrArgFormat( |
| 56 | + pattern="^[a-zA-Z0-9-]{3,24}$", |
| 57 | + ), |
| 58 | + ) |
| 59 | + |
| 60 | + _args_schema = cls._args_schema |
| 61 | + _args_schema.level_name = AAZStrArg( |
| 62 | + options=["--target-name"], |
| 63 | + help="The Target or Site name at which values needs to be set", |
| 64 | + |
| 65 | + required = True, |
| 66 | + fmt=AAZStrArgFormat( |
| 67 | + pattern="^[a-zA-Z0-9-]{3,24}$", |
| 68 | + ), |
| 69 | + ) |
| 70 | + |
| 71 | + # define Arg Group "Resource |
| 72 | + |
| 73 | + # |
| 74 | + # _args_schema.properties = AAZFreeFormDictArg( |
| 75 | + # options=["--properties"], |
| 76 | + # arg_group="Resource", |
| 77 | + # help="The resource-specific properties for this resource.", |
| 78 | + # nullable=True, |
| 79 | + # ) |
| 80 | + return cls._args_schema |
| 81 | + |
| 82 | + def _execute_operations(self): |
| 83 | + self.pre_operations() |
| 84 | + config_name = str(self.ctx.args.level_name) |
| 85 | + if len(config_name) > 18: |
| 86 | + config_name = config_name[:18] + "Config" |
| 87 | + else: |
| 88 | + config_name = config_name + "Config" |
| 89 | + self.ctx.args.level_name = config_name |
| 90 | + self.SolutionsGet(ctx=self.ctx)() |
| 91 | + self.post_operations() |
| 92 | + |
| 93 | + @register_callback |
| 94 | + def pre_operations(self): |
| 95 | + pass |
| 96 | + |
| 97 | + @register_callback |
| 98 | + def post_operations(self): |
| 99 | + pass |
| 100 | + |
| 101 | + def _output(self, *args, **kwargs): |
| 102 | + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) |
| 103 | + print(result["properties"]["values"]) |
| 104 | + pass |
| 105 | + |
| 106 | + class SolutionsGet(AAZHttpOperation): |
| 107 | + CLIENT_TYPE = "MgmtClient" |
| 108 | + |
| 109 | + def __call__(self, *args, **kwargs): |
| 110 | + request = self.make_request() |
| 111 | + session = self.client.send_request(request=request, stream=False, **kwargs) |
| 112 | + if session.http_response.status_code in [200]: |
| 113 | + return self.on_200(session) |
| 114 | + config = dict() |
| 115 | + config["properties"] = dict() |
| 116 | + config["properties"]["values"] = "{}" |
| 117 | + # # config.config = AAZStrType() |
| 118 | + # # config.config = "[]" |
| 119 | + if session.http_response.status_code in [404]: |
| 120 | + self.ctx.set_var( |
| 121 | + "instance", |
| 122 | + config, |
| 123 | + schema_builder=self._build_schema_on_404 |
| 124 | + ) |
| 125 | + # return |
| 126 | + else: |
| 127 | + return self.on_error(session.http_response) |
| 128 | + |
| 129 | + |
| 130 | + @property |
| 131 | + def url(self): |
| 132 | + return self.client.format_url( |
| 133 | + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Edge/configurations/{configName}/DynamicConfigurations/{solutionName}/versions/version1", |
| 134 | + **self.url_parameters |
| 135 | + ) |
| 136 | + |
| 137 | + @property |
| 138 | + def method(self): |
| 139 | + return "GET" |
| 140 | + |
| 141 | + @property |
| 142 | + def error_format(self): |
| 143 | + return "MgmtErrorFormat" |
| 144 | + |
| 145 | + @property |
| 146 | + def url_parameters(self): |
| 147 | + sol_name = "common" |
| 148 | + if has_value(self.ctx.args.solution_name): |
| 149 | + sol_name = self.ctx.args.solution_name |
| 150 | + |
| 151 | + parameters = { |
| 152 | + **self.serialize_url_param( |
| 153 | + "resourceGroupName", self.ctx.args.resource_group, |
| 154 | + required=True, |
| 155 | + ), |
| 156 | + **self.serialize_url_param( |
| 157 | + "solutionName", sol_name, |
| 158 | + required=True, |
| 159 | + ), |
| 160 | + **self.serialize_url_param( |
| 161 | + "configName", self.ctx.args.level_name, |
| 162 | + required=True, |
| 163 | + ), |
| 164 | + **self.serialize_url_param( |
| 165 | + "subscriptionId", self.ctx.subscription_id, |
| 166 | + required=True, |
| 167 | + ), |
| 168 | + } |
| 169 | + return parameters |
| 170 | + |
| 171 | + @property |
| 172 | + def query_parameters(self): |
| 173 | + parameters = { |
| 174 | + **self.serialize_query_param( |
| 175 | + "api-version", "2024-06-01-preview", |
| 176 | + required=True, |
| 177 | + ), |
| 178 | + } |
| 179 | + return parameters |
| 180 | + |
| 181 | + @property |
| 182 | + def header_parameters(self): |
| 183 | + parameters = { |
| 184 | + **self.serialize_header_param( |
| 185 | + "Accept", "application/json", |
| 186 | + ), |
| 187 | + } |
| 188 | + return parameters |
| 189 | + |
| 190 | + def on_200(self, session): |
| 191 | + data = self.deserialize_http_content(session) |
| 192 | + self.ctx.set_var( |
| 193 | + "instance", |
| 194 | + data, |
| 195 | + schema_builder=self._build_schema_on_200 |
| 196 | + ) |
| 197 | + |
| 198 | + _schema_on_200 = None |
| 199 | + |
| 200 | + @classmethod |
| 201 | + def _build_schema_on_404(cls): |
| 202 | + cls._schema_on_200 = AAZObjectType() |
| 203 | + _schema_on_200 = cls._schema_on_200 |
| 204 | + _schema_on_200.properties = AAZFreeFormDictType() |
| 205 | + return cls._schema_on_200 |
| 206 | + |
| 207 | + |
| 208 | + @classmethod |
| 209 | + def _build_schema_on_200(cls): |
| 210 | + if cls._schema_on_200 is not None: |
| 211 | + return cls._schema_on_200 |
| 212 | + |
| 213 | + cls._schema_on_200 = AAZObjectType() |
| 214 | + |
| 215 | + _schema_on_200 = cls._schema_on_200 |
| 216 | + _schema_on_200.id = AAZStrType( |
| 217 | + flags={"read_only": True}, |
| 218 | + ) |
| 219 | + _schema_on_200.location = AAZStrType( |
| 220 | + flags={"required": True}, |
| 221 | + ) |
| 222 | + _schema_on_200.name = AAZStrType( |
| 223 | + flags={"read_only": True}, |
| 224 | + ) |
| 225 | + _schema_on_200.properties = AAZFreeFormDictType() |
| 226 | + _schema_on_200.system_data = AAZObjectType( |
| 227 | + serialized_name="systemData", |
| 228 | + flags={"read_only": True}, |
| 229 | + ) |
| 230 | + _schema_on_200.tags = AAZDictType() |
| 231 | + _schema_on_200.type = AAZStrType( |
| 232 | + flags={"read_only": True}, |
| 233 | + ) |
| 234 | + |
| 235 | + |
| 236 | + |
| 237 | + |
| 238 | + system_data = cls._schema_on_200.system_data |
| 239 | + system_data.created_at = AAZStrType( |
| 240 | + serialized_name="createdAt", |
| 241 | + ) |
| 242 | + system_data.created_by = AAZStrType( |
| 243 | + serialized_name="createdBy", |
| 244 | + ) |
| 245 | + system_data.created_by_type = AAZStrType( |
| 246 | + serialized_name="createdByType", |
| 247 | + ) |
| 248 | + system_data.last_modified_at = AAZStrType( |
| 249 | + serialized_name="lastModifiedAt", |
| 250 | + ) |
| 251 | + system_data.last_modified_by = AAZStrType( |
| 252 | + serialized_name="lastModifiedBy", |
| 253 | + ) |
| 254 | + system_data.last_modified_by_type = AAZStrType( |
| 255 | + serialized_name="lastModifiedByType", |
| 256 | + ) |
| 257 | + |
| 258 | + tags = cls._schema_on_200.tags |
| 259 | + tags.Element = AAZStrType() |
| 260 | + |
| 261 | + return cls._schema_on_200 |
| 262 | + |
| 263 | + |
| 264 | +class _ShowHelper: |
| 265 | + """Helper class for Show""" |
| 266 | + |
| 267 | + |
| 268 | +__all__ = ["ShowConfig"] |
0 commit comments