Page tree
Skip to end of metadata
Go to start of metadata

list all users members of a suborg

import zeep
platform = zeep.Client('https://api.rosettahub.com/public/PlatformServices?wsdl').service
session = platform.newSession("{your_login}", "{your_password}", 0 )
users = platform.cpocGetFederatedUsers(session, False, False, False, {'organizationName':'BTS-AC-CAEN'} );
for user in users:
    print(user.login)

List all suborg admin, then add a new admin

import zeep
platform = zeep.Client('https://api.rosettahub.com/public/PlatformServices?wsdl').service
session = platform.newSession("cpoc.bts", "{your_password}", 0 )
orgs = platform.cpocGetFederatedOrganizations(session, False, True, False, {'organizationName':'*LOUIS ARMAND*'} );(orgs[0].organizationManagers)
print(orgs[0].organizationManagers)
platform.adminAssignAdminsToOrganization(session, 
orgs[0].organizationName, ['{new_admin_login}'], False)
print('---------')
orgs = platform.cpocGetFederatedOrganizations(session, False, True, 
False, {'organizationName':'*LOUIS ARMAND*'} 
);(orgs[0].organizationManagers)
print(orgs[0].organizationManagers)

List all users, masquerade a individual users, retireve an STS session to access the user AWS account and list all EC2 instances

Masquerade
import zeep
import boto3
client = zeep.Client('https://api.rosettahub.com/public/PlatformServices?wsdl')
platform = client.service
session = platform.newSession("{your_login}", "{your_password}", 0 )
users = platform.cpocGetFederatedUsers(session, False, False, False, {'organizationName':'WASHINGTON-Master of Science in Data Science'} );
for user in users:
    if user.enabled:
        platform.suMasquerade(session,user.login)  
        try:          
            stsSession=platform.getFederatedIamUserStsSession(session, user.login, 60*60) ;                
            client = boto3.resource(
                'ec2',
                aws_access_key_id=stsSession.stsAccessKeyId,
                aws_secret_access_key=stsSession.stsSecretAccessKey,
                aws_session_token=stsSession.sessionToken,
                
                region_name='eu-west-1'
            )
            instances = client.instances.all()
            for instance in instances: 
                print(user.login+' : '+str(instance))
        except:
            print(user.login+' : '+'Failed to create STS')
                                     
        platform.suUnmasquerade(session)


  • No labels