in src/aaz_dev/command/model/configuration/_http.py [0:0]
def generate_args(self, path, ref_args, has_subresource, var_prefix=None):
try:
id_parts = parse_resource_id(path)
resource_id(**id_parts)
except KeyError:
# not a valid resource id
id_parts = {}
resource_name = id_parts.pop("resource_name", None)
if resource_name and (not path.endswith(resource_name) or has_subresource):
resource_name = None
args = []
if self.params:
if var_prefix:
if not var_prefix.endswith("$"):
var_prefix += '.'
var_prefix += CMDArgBuildPrefix.Path[1:] # PATH
else:
var_prefix = CMDArgBuildPrefix.Path
for param in self.params:
id_part = None
placeholder = '{' + param.name + '}'
for part, name in id_parts.items():
if name == placeholder:
id_part = part
break
if id_part == 'subscription' or param.name == 'subscriptionId':
arg = CMDSubscriptionIdArg({
'var': f'{var_prefix}.subscriptionId',
'options': ['subscription'],
})
param.arg = arg.var
arg.ref_schema = param
elif id_part == 'resource_group' or param.name == 'resourceGroupName':
arg = CMDResourceGroupNameArg({
'var': f'{var_prefix}.resourceGroupName',
'options': ['resource-group', 'g'],
})
param.arg = arg.var
arg.ref_schema = param
elif param.name == 'location':
arg = CMDResourceLocationArg({
'var': f'{var_prefix}.location',
'options': ['location', 'l'],
})
param.arg = arg.var
arg.ref_schema = param
else:
builder = CMDArgBuilder.new_builder(
schema=param, var_prefix=var_prefix, ref_args=ref_args
)
result = builder.get_args()
assert len(result) == 1
arg = result[0]
if resource_name == placeholder and not builder._ref_arg:
arg.options = list({*arg.options, "name", "n"})
arg.required = True
arg.id_part = id_part # id_part should not be generated for create command or commands for subresource
args.append(arg)
return args