1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
"""Edit details of an Delivery email account."""
# :license: MIT, see LICENSE for more details.
import click
from SoftLayer.CLI.command import SLCommand as SLCommand
from SoftLayer.CLI import environment
from SoftLayer.CLI import exceptions
from SoftLayer.managers.email import EmailManager
@click.command(cls=SLCommand)
@click.argument('identifier')
@click.option('--username', help="Sets username for this account")
@click.option('--email', help="Sets the contact email for this account")
@click.option('--password',
help="Password must be between 8 and 20 characters "
"and must contain one letter and one number.")
@environment.pass_env
def cli(env, identifier, username, email, password):
"""Edit details of an email delivery account."""
email_manager = EmailManager(env.client)
data = {}
update = False
if email:
if email_manager.update_email(identifier, email):
update = True
else:
raise exceptions.CLIAbort("Failed to Edit emailAddress account")
if username:
data['username'] = username
if password:
data['password'] = password
if len(data) != 0:
if email_manager.editObject(identifier, **data):
update = True
else:
raise exceptions.CLIAbort("Failed to Edit email account")
if update:
env.fout('Updated Successfully')
|