def validate_regions(self, regions, action_name, ):
action_properties = actions.get_action_properties(action_name)
service_name = action_properties[actions.ACTION_SERVICE]
if self.service_is_regional(service_name) and action_properties.get(actions.ACTION_MULTI_REGION, True):
if regions is None or len(regions) == 0:
return [boto3.Session().region_name]
else:
available_regions = self.service_regions(service_name)
if len(regions) == 1 and list(regions)[0] == "*":
return available_regions
for region in regions:
if region not in available_regions:
raise ValueError(MSG_BAD_REGION.format(region, service_name, ",".join(available_regions)))
return list(regions)
else:
if regions is not None and len(regions) != 0:
msg = WARN_NOT_REGIONAL_SERVICE.format(",".join(regions), service_name, action_name)
self._warn(msg)
return []
评论列表
文章目录