Exemplo n.º 1
0
def cli(env, identifier):
    """Display details for a specified email."""

    email_manager = EmailManager(env.client)
    result = email_manager.get_instance(identifier)

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'

    table.add_row(['id', result.get('id')])
    table.add_row(['username', result.get('username')])
    table.add_row(['email_address', result.get('emailAddress')])
    table.add_row(['create_date', result.get('createDate')])
    table.add_row(
        ['category_code',
         utils.lookup(result, 'billingItem', 'categoryCode')])
    table.add_row(
        ['description',
         utils.lookup(result, 'billingItem', 'description')])
    table.add_row(
        ['type_description',
         utils.lookup(result, 'type', 'description')])
    table.add_row(['type', utils.lookup(result, 'type', 'keyName')])
    table.add_row(['vendor', utils.lookup(result, 'vendor', 'keyName')])

    statistics = email_manager.get_statistics(identifier)

    for statistic in statistics:
        table.add_row(['statistics', build_statistics_table(statistic)])

    env.fout(table)
Exemplo n.º 2
0
def cli(env):
    """Lists Email Delivery Service """
    manager = AccountManager(env.client)
    email_manager = EmailManager(env.client)
    result = manager.get_network_message_delivery_accounts()

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'r'
    table.align['value'] = 'l'
    table_information = formatting.KeyValueTable(
        ['id', 'username', 'hostname', 'description', 'vendor'])
    table_information.align['id'] = 'r'
    table_information.align['username'] = '******'

    for email in result:
        table_information.add_row([
            email.get('id'),
            email.get('username'),
            email.get('emailAddress'),
            utils.lookup(email, 'type', 'description'),
            utils.lookup(email, 'vendor', 'keyName')
        ])

        overview_table = _build_overview_table(
            email_manager.get_account_overview(email.get('id')))
        statistics = email_manager.get_statistics(email.get('id'))

        table.add_row(['email_information', table_information])
        table.add_row(['email_overview', overview_table])
        for statistic in statistics:
            table.add_row(['statistics', build_statistics_table(statistic)])

    env.fout(table)
Exemplo n.º 3
0
class EmailManagerTests(testing.TestCase):
    def test_get_AccountOverview(self):
        self.manager = EmailManager(self.client)
        self.manager.get_account_overview(1232123)
        self.assert_called_with(
            'SoftLayer_Network_Message_Delivery_Email_Sendgrid',
            'getAccountOverview')

    def test_get_statistics(self):
        self.manager = EmailManager(self.client)
        self.manager.get_statistics(1232123, 6)
        self.assert_called_with(
            'SoftLayer_Network_Message_Delivery_Email_Sendgrid',
            'getStatistics')

    def test_get_object(self):
        self.manager = EmailManager(self.client)
        self.manager.get_instance(1232123)
        self.assert_called_with(
            'SoftLayer_Network_Message_Delivery_Email_Sendgrid', 'getObject')

    def test_update_email_address(self):
        self.manager = EmailManager(self.client)
        self.manager.update_email(1232123, '*****@*****.**')
        self.assert_called_with(
            'SoftLayer_Network_Message_Delivery_Email_Sendgrid',
            'updateEmailAddress')
Exemplo n.º 4
0
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')
Exemplo n.º 5
0
 def test_update_email_address(self):
     self.manager = EmailManager(self.client)
     self.manager.update_email(1232123, '*****@*****.**')
     self.assert_called_with(
         'SoftLayer_Network_Message_Delivery_Email_Sendgrid',
         'updateEmailAddress')
Exemplo n.º 6
0
 def test_get_object(self):
     self.manager = EmailManager(self.client)
     self.manager.get_instance(1232123)
     self.assert_called_with(
         'SoftLayer_Network_Message_Delivery_Email_Sendgrid', 'getObject')
Exemplo n.º 7
0
 def test_get_statistics(self):
     self.manager = EmailManager(self.client)
     self.manager.get_statistics(1232123, 6)
     self.assert_called_with(
         'SoftLayer_Network_Message_Delivery_Email_Sendgrid',
         'getStatistics')
Exemplo n.º 8
0
 def test_get_AccountOverview(self):
     self.manager = EmailManager(self.client)
     self.manager.get_account_overview(1232123)
     self.assert_called_with(
         'SoftLayer_Network_Message_Delivery_Email_Sendgrid',
         'getAccountOverview')