|
21 | 21 | "FRA": "FRA"
|
22 | 22 | }
|
23 | 23 |
|
| 24 | +regions = ['SJC/DAL/WDC/TOR/MON', 'AMS/LON/MAD/PAR', 'SNG/HKG/OSA/TOK', 'SYD', 'MEX', 'SAO', 'CHE', 'MIL', 'SEO', 'FRA'] |
| 25 | +help_stmt = "Ex: 'HKG' or 'SNG/HKG/OSA/TOK'" |
| 26 | + |
| 27 | +def check_region_param(ctx,param,value): |
| 28 | + """Check if provided region is region group or part of region""" |
| 29 | + #:params string value: Region or Region-Groups |
| 30 | + # return string Region-Groups |
| 31 | + |
| 32 | + region_group = None |
| 33 | + for key in location_groups.keys(): |
| 34 | + if value in key or value is key: |
| 35 | + region_group = key |
| 36 | + else: |
| 37 | + continue |
| 38 | + |
| 39 | + if region_group: |
| 40 | + return region_group |
| 41 | + else: |
| 42 | + raise click.BadParameter(f"{value} is not a region or part of any region. \nAvailable Choices: \033[1;32m{regions}") |
24 | 43 |
|
25 | 44 | @click.command(cls=SLCommand)
|
26 | 45 | @click.option('--name', required=True, help="Pool name")
|
27 | 46 | @click.option('--region', required=True,
|
28 |
| - type=click.Choice(['SJC/DAL/WDC/TOR/MON', 'AMS/LON/MAD/PAR', 'SNG/HKG/OSA/TOK', |
29 |
| - 'SYD', 'MEX', 'SAO', 'CHE', 'MIL', 'SEO', 'FRA']), |
30 |
| - help="Region selected") |
| 47 | + help=f"Choose Region/Region-Group {regions}", callback=check_region_param) |
| 48 | +@click.help_option('--help','-h',help=f"Specify Region or Region group - \033[1;32m{help_stmt}") |
31 | 49 | @environment.pass_env
|
32 | 50 | def cli(env, name, region):
|
33 | 51 | """Create bandwidth pool."""
|
|
0 commit comments