|
24 | 24 | Create as _AFDProfileCreate, Update as _AFDProfileUpdate |
25 | 25 | from azure.cli.command_modules.cdn.aaz.latest.afd.endpoint import Show as _AFDEndpointShow, \ |
26 | 26 | Create as _AFDEndpointCreate, Update as _AFDEndpointUpdate |
| 27 | +from azure.cli.command_modules.cdn.aaz.latest.afd.origin_group import Show as _AFDOriginGroupShow, \ |
| 28 | + Create as _AFDOriginGroupCreate, Update as _AFDOriginGroupUpdate |
27 | 29 | from azure.cli.core.aaz import AAZStrArg, AAZBoolArg, AAZListArg, AAZDateArg |
28 | 30 | from knack.log import get_logger |
29 | 31 | from .custom_rule_util import (create_condition, create_action, |
@@ -183,6 +185,63 @@ def pre_operations(self): |
183 | 185 | args.location = existing_location |
184 | 186 |
|
185 | 187 |
|
| 188 | +class AFDOriginGroupCreate(_AFDOriginGroupCreate): |
| 189 | + @classmethod |
| 190 | + def _build_arguments_schema(cls, *args, **kwargs): |
| 191 | + args_schema = super()._build_arguments_schema(*args, **kwargs) |
| 192 | + args_schema.enable_health_probe = AAZBoolArg( |
| 193 | + options=['--enable-health-probe'], |
| 194 | + help='Indicates whether to enable probe on the origin group.', |
| 195 | + blank=True, |
| 196 | + ) |
| 197 | + return args_schema |
| 198 | + |
| 199 | + def pre_operations(self): |
| 200 | + args = self.ctx.args |
| 201 | + if not has_value(args.enable_health_probe) or args.enable_health_probe.to_serialized_data() is False: |
| 202 | + args.probe_path = None |
| 203 | + args.probe_protocol = None |
| 204 | + args.probe_interval_in_seconds = None |
| 205 | + args.probe_request_type = None |
| 206 | + |
| 207 | + |
| 208 | +class AFDOriginGroupUpdate(_AFDOriginGroupUpdate): |
| 209 | + @classmethod |
| 210 | + def _build_arguments_schema(cls, *args, **kwargs): |
| 211 | + args_schema = super()._build_arguments_schema(*args, **kwargs) |
| 212 | + args_schema.enable_health_probe = AAZBoolArg( |
| 213 | + options=['--enable-health-probe'], |
| 214 | + help='Indicates whether to enable probe on the origin group.', |
| 215 | + blank=True, |
| 216 | + ) |
| 217 | + return args_schema |
| 218 | + |
| 219 | + def pre_operations(self): |
| 220 | + args = self.ctx.args |
| 221 | + existing = _AFDOriginGroupShow(cli_ctx=self.cli_ctx)(command_args={ |
| 222 | + 'resource_group': args.resource_group, |
| 223 | + 'profile_name': args.profile_name, |
| 224 | + 'origin_group_name': args.origin_group_name |
| 225 | + }) |
| 226 | + if not has_value(args.enable_health_probe): |
| 227 | + if existing['healthProbeSettings'] is not None: |
| 228 | + if 'probePath' in existing['healthProbeSettings'] \ |
| 229 | + or 'probeProtocol' in existing['healthProbeSettings'] \ |
| 230 | + or 'probeIntervalInSeconds' in existing['healthProbeSettings'] \ |
| 231 | + or 'probeRequestType' in existing['healthProbeSettings']: |
| 232 | + args.enable_health_probe = True |
| 233 | + else: |
| 234 | + args.enable_health_probe = False |
| 235 | + else: |
| 236 | + args.enable_health_probe = False |
| 237 | + |
| 238 | + if args.enable_health_probe.to_serialized_data() is False: |
| 239 | + args.probe_path = None |
| 240 | + args.probe_protocol = None |
| 241 | + args.probe_interval_in_seconds = None |
| 242 | + args.probe_request_type = None |
| 243 | + |
| 244 | + |
186 | 245 | class AFDOriginCreate(_AFDOriginCreate): |
187 | 246 | @classmethod |
188 | 247 | def _build_arguments_schema(cls, *args, **kwargs): |
|
0 commit comments