|
| 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 | + "cdn profile deployment-version approve", |
| 16 | +) |
| 17 | +class Approve(AAZCommand): |
| 18 | + """Approve the deployment of the version |
| 19 | +
|
| 20 | + :example: DeploymentVersions_Approve |
| 21 | + az cdn profile deployment-version approve --resource-group RG --profile-name profile1 --version-name dv1 |
| 22 | + """ |
| 23 | + |
| 24 | + _aaz_info = { |
| 25 | + "version": "2025-05-01-preview", |
| 26 | + "resources": [ |
| 27 | + ["mgmt-plane", "/subscriptions/{}/resourcegroups/{}/providers/microsoft.cdn/profiles/{}/deploymentversions/{}/approve", "2025-05-01-preview"], |
| 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.profile_name = AAZStrArg( |
| 49 | + options=["--profile-name"], |
| 50 | + help="Name of the Azure Front Door Standard or Azure Front Door Premium which is unique within the resource group.", |
| 51 | + required=True, |
| 52 | + id_part="name", |
| 53 | + fmt=AAZStrArgFormat( |
| 54 | + pattern="^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", |
| 55 | + max_length=260, |
| 56 | + min_length=1, |
| 57 | + ), |
| 58 | + ) |
| 59 | + _args_schema.resource_group = AAZResourceGroupNameArg( |
| 60 | + required=True, |
| 61 | + ) |
| 62 | + _args_schema.version_name = AAZStrArg( |
| 63 | + options=["--version-name"], |
| 64 | + help="Name of the DeploymentVersion under the profile.", |
| 65 | + required=True, |
| 66 | + id_part="child_name_1", |
| 67 | + fmt=AAZStrArgFormat( |
| 68 | + pattern="^[a-zA-Z0-9]+(-*[a-zA-Z0-9])*$", |
| 69 | + max_length=260, |
| 70 | + min_length=1, |
| 71 | + ), |
| 72 | + ) |
| 73 | + return cls._args_schema |
| 74 | + |
| 75 | + def _execute_operations(self): |
| 76 | + self.pre_operations() |
| 77 | + yield self.DeploymentVersionsApprove(ctx=self.ctx)() |
| 78 | + self.post_operations() |
| 79 | + |
| 80 | + @register_callback |
| 81 | + def pre_operations(self): |
| 82 | + pass |
| 83 | + |
| 84 | + @register_callback |
| 85 | + def post_operations(self): |
| 86 | + pass |
| 87 | + |
| 88 | + def _output(self, *args, **kwargs): |
| 89 | + result = self.deserialize_output(self.ctx.vars.instance, client_flatten=True) |
| 90 | + return result |
| 91 | + |
| 92 | + class DeploymentVersionsApprove(AAZHttpOperation): |
| 93 | + CLIENT_TYPE = "MgmtClient" |
| 94 | + |
| 95 | + def __call__(self, *args, **kwargs): |
| 96 | + request = self.make_request() |
| 97 | + session = self.client.send_request(request=request, stream=False, **kwargs) |
| 98 | + if session.http_response.status_code in [202]: |
| 99 | + return self.client.build_lro_polling( |
| 100 | + self.ctx.args.no_wait, |
| 101 | + session, |
| 102 | + self.on_200, |
| 103 | + self.on_error, |
| 104 | + lro_options={"final-state-via": "location"}, |
| 105 | + path_format_arguments=self.url_parameters, |
| 106 | + ) |
| 107 | + if session.http_response.status_code in [200]: |
| 108 | + return self.client.build_lro_polling( |
| 109 | + self.ctx.args.no_wait, |
| 110 | + session, |
| 111 | + self.on_200, |
| 112 | + self.on_error, |
| 113 | + lro_options={"final-state-via": "location"}, |
| 114 | + path_format_arguments=self.url_parameters, |
| 115 | + ) |
| 116 | + |
| 117 | + return self.on_error(session.http_response) |
| 118 | + |
| 119 | + @property |
| 120 | + def url(self): |
| 121 | + return self.client.format_url( |
| 122 | + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Cdn/profiles/{profileName}/deploymentVersions/{versionName}/approve", |
| 123 | + **self.url_parameters |
| 124 | + ) |
| 125 | + |
| 126 | + @property |
| 127 | + def method(self): |
| 128 | + return "POST" |
| 129 | + |
| 130 | + @property |
| 131 | + def error_format(self): |
| 132 | + return "MgmtErrorFormat" |
| 133 | + |
| 134 | + @property |
| 135 | + def url_parameters(self): |
| 136 | + parameters = { |
| 137 | + **self.serialize_url_param( |
| 138 | + "profileName", self.ctx.args.profile_name, |
| 139 | + required=True, |
| 140 | + ), |
| 141 | + **self.serialize_url_param( |
| 142 | + "resourceGroupName", self.ctx.args.resource_group, |
| 143 | + required=True, |
| 144 | + ), |
| 145 | + **self.serialize_url_param( |
| 146 | + "subscriptionId", self.ctx.subscription_id, |
| 147 | + required=True, |
| 148 | + ), |
| 149 | + **self.serialize_url_param( |
| 150 | + "versionName", self.ctx.args.version_name, |
| 151 | + required=True, |
| 152 | + ), |
| 153 | + } |
| 154 | + return parameters |
| 155 | + |
| 156 | + @property |
| 157 | + def query_parameters(self): |
| 158 | + parameters = { |
| 159 | + **self.serialize_query_param( |
| 160 | + "api-version", "2025-05-01-preview", |
| 161 | + required=True, |
| 162 | + ), |
| 163 | + } |
| 164 | + return parameters |
| 165 | + |
| 166 | + @property |
| 167 | + def header_parameters(self): |
| 168 | + parameters = { |
| 169 | + **self.serialize_header_param( |
| 170 | + "Accept", "application/json", |
| 171 | + ), |
| 172 | + } |
| 173 | + return parameters |
| 174 | + |
| 175 | + def on_200(self, session): |
| 176 | + data = self.deserialize_http_content(session) |
| 177 | + self.ctx.set_var( |
| 178 | + "instance", |
| 179 | + data, |
| 180 | + schema_builder=self._build_schema_on_200 |
| 181 | + ) |
| 182 | + |
| 183 | + _schema_on_200 = None |
| 184 | + |
| 185 | + @classmethod |
| 186 | + def _build_schema_on_200(cls): |
| 187 | + if cls._schema_on_200 is not None: |
| 188 | + return cls._schema_on_200 |
| 189 | + |
| 190 | + cls._schema_on_200 = AAZObjectType() |
| 191 | + |
| 192 | + _schema_on_200 = cls._schema_on_200 |
| 193 | + _schema_on_200.id = AAZStrType( |
| 194 | + flags={"read_only": True}, |
| 195 | + ) |
| 196 | + _schema_on_200.name = AAZStrType( |
| 197 | + flags={"read_only": True}, |
| 198 | + ) |
| 199 | + _schema_on_200.properties = AAZObjectType( |
| 200 | + flags={"client_flatten": True}, |
| 201 | + ) |
| 202 | + _schema_on_200.system_data = AAZObjectType( |
| 203 | + serialized_name="systemData", |
| 204 | + flags={"read_only": True}, |
| 205 | + ) |
| 206 | + _schema_on_200.type = AAZStrType( |
| 207 | + flags={"read_only": True}, |
| 208 | + ) |
| 209 | + |
| 210 | + properties = cls._schema_on_200.properties |
| 211 | + properties.approval_status = AAZStrType( |
| 212 | + serialized_name="approvalStatus", |
| 213 | + flags={"read_only": True}, |
| 214 | + ) |
| 215 | + properties.approved_at = AAZStrType( |
| 216 | + serialized_name="approvedAt", |
| 217 | + flags={"read_only": True}, |
| 218 | + ) |
| 219 | + properties.created_at = AAZStrType( |
| 220 | + serialized_name="createdAt", |
| 221 | + flags={"read_only": True}, |
| 222 | + ) |
| 223 | + properties.deployment_status = AAZStrType( |
| 224 | + serialized_name="deploymentStatus", |
| 225 | + flags={"read_only": True}, |
| 226 | + ) |
| 227 | + properties.description = AAZStrType() |
| 228 | + properties.provisioning_state = AAZStrType( |
| 229 | + serialized_name="provisioningState", |
| 230 | + flags={"read_only": True}, |
| 231 | + ) |
| 232 | + properties.stages = AAZObjectType( |
| 233 | + flags={"read_only": True}, |
| 234 | + ) |
| 235 | + |
| 236 | + stages = cls._schema_on_200.properties.stages |
| 237 | + stages.preview = AAZStrType( |
| 238 | + flags={"read_only": True}, |
| 239 | + ) |
| 240 | + stages.production = AAZStrType( |
| 241 | + flags={"read_only": True}, |
| 242 | + ) |
| 243 | + |
| 244 | + system_data = cls._schema_on_200.system_data |
| 245 | + system_data.created_at = AAZStrType( |
| 246 | + serialized_name="createdAt", |
| 247 | + ) |
| 248 | + system_data.created_by = AAZStrType( |
| 249 | + serialized_name="createdBy", |
| 250 | + ) |
| 251 | + system_data.created_by_type = AAZStrType( |
| 252 | + serialized_name="createdByType", |
| 253 | + ) |
| 254 | + system_data.last_modified_at = AAZStrType( |
| 255 | + serialized_name="lastModifiedAt", |
| 256 | + ) |
| 257 | + system_data.last_modified_by = AAZStrType( |
| 258 | + serialized_name="lastModifiedBy", |
| 259 | + ) |
| 260 | + system_data.last_modified_by_type = AAZStrType( |
| 261 | + serialized_name="lastModifiedByType", |
| 262 | + ) |
| 263 | + |
| 264 | + return cls._schema_on_200 |
| 265 | + |
| 266 | + |
| 267 | +class _ApproveHelper: |
| 268 | + """Helper class for Approve""" |
| 269 | + |
| 270 | + |
| 271 | +__all__ = ["Approve"] |
0 commit comments