Beispiel #1
0
def create_batch(count):
    """Create batch IAM profile v2 objects."""

    if count < 1:
        raise click.BadParameter('count needs to be > 0')

    factory = V2ProfileFactory()
    output = factory.create_batch(count, export_json=True)
    click.echo(output)
Beispiel #2
0
def export_json(count, filename):
    """Create batch IAM profile v2 objects and insert them in the database."""

    path = os.path.dirname(os.path.abspath(__file__))
    if not filename.endswith('.json'):
        filename = '{0}.json'.format(filename)

    click.echo('Creating file {0}'.format(filename))
    users = V2ProfileFactory().create_batch(count, export_json=True)
    with open(os.path.join(path, filename), 'w') as f:
        f.write(users)

    click.echo('Added {0} profiles into file {1}.'.format(count, filename))
Beispiel #3
0
def populate_db(count, dbname):
    """Create batch IAM profile v2 objects and insert them in the database."""

    path = os.path.dirname(os.path.abspath(__file__))

    if not dbname.endswith('.json'):
        dbname = '{0}.json'.format(dbname)

    click.echo('Creating database {0}'.format(dbname))

    db = TinyDB(os.path.join(path, dbname))
    users = V2ProfileFactory().create_batch(count, export_json=False)
    db.insert_multiple(users)

    click.echo('Added {0} profiles in database {1}.'.format(count, dbname))
 def get(self, export_json=True):
     return V2ProfileFactory().create(export_json=export_json)
 def get(self, count=100, export_json=True):
     factory = V2ProfileFactory()
     return factory.create_batch(count, export_json=True)
Beispiel #6
0
def create(*args, **kwargs):
    """Create single IAM profile v2 object."""

    factory = V2ProfileFactory()
    output = factory.create(export_json=True)
    click.echo(output)