1"""Cancel a subnet."""
2# :license: MIT, see LICENSE for more details.
3
4import click
5
6import SoftLayer
7from SoftLayer.CLI import environment
8from SoftLayer.CLI import exceptions
9from SoftLayer.CLI import formatting
10from SoftLayer.CLI import helpers
11
12
13@click.command()
14@click.argument('identifier')
15@environment.pass_env
16def cli(env, identifier):
17    """Cancel a subnet."""
18
19    mgr = SoftLayer.NetworkManager(env.client)
20    subnet_id = helpers.resolve_id(mgr.resolve_subnet_ids, identifier,
21                                   name='subnet')
22
23    if not (env.skip_confirmations or formatting.no_going_back(subnet_id)):
24        raise exceptions.CLIAbort('Aborted')
25
26    mgr.cancel_subnet(subnet_id)
27