Ejemplo n.º 1
0
print('API version is: %d' % api_version)
print(f'API version is: {api_version}')
print('API version is {}'.format(api_version))

# conditional logic
if api_version > 10:
    print('we are good')

if api_version < 20:
    print('we are good')
else:
    print('what is going on in Ottawa?')

print('we are good\n') if api_version > 20 else print(
    'I am on the wrong version\n')

if api_version > 0 and api_version <= 5:
    print('we are on old school version')
elif 5 > api_version < 10:  #chained comparison
    print('we are on 2nd gen 3b apis')
elif 19 >= api_version < 30:
    print('we are living in present day')

cloud_accounts = dsm.get_cloudaccounts()
print(type(cloud_accounts))

# looping mechanisms: for loop
for account in cloud_accounts['ListCloudAccountsResponse']['cloudAccount']:
    print(account)

dsm.end_session()
Ejemplo n.º 2
0
They needed to add 300 aws accounts to the DSM

https://help.deepsecurity.trendmicro.com/Add-Computers/add-aws.html

Add by AK/SAK
https://help.deepsecurity.trendmicro.com/Add-Computers/add-aws.html#Add5

Add by cross account role
https://help.deepsecurity.trendmicro.com/Add-Computers/add-aws.html#Add2


run file from project root dir as:
python -m app.customer_examples.add_aws_account

'''

username, password, tenant = utils.parse_dsas_crendentials()
access_key, secret_key = utils.parse_aws_crendentials()
dsm = Manager(username=username, password=password, tenant=tenant)

print(dsm.get_cloudaccounts(), end='\n')

dsm.add_aws_cloud_account_with_keys(access_key=access_key,
                                    secret_key=secret_key)

# or

#dsm.add_aws_cloud_account_with_cross_account_role('randomsecret2', 'arn:aws:iam::5385xvxv281:role/DS_Cross_account')

print(dsm.get_cloudaccounts(), end='\n')
dsm.end_session()