def _get_base(role, **conn): """ Determine whether the boto get_role call needs to be made or if we already have all that data in the role object. :param role: dict containing (at the very least) role_name and/or arn. :param conn: dict containing enough information to make a connection to the desired account. :return: Camelized dict describing role containing all all base_fields. """ base_fields = frozenset(['Arn', 'AssumeRolePolicyDocument', 'Path', 'RoleId', 'RoleName', 'CreateDate']) needs_base = False for field in base_fields: if field not in role: needs_base = True break if needs_base: role_name = _get_name_from_structure(role, 'RoleName') role = CloudAux.go('iam.client.get_role', RoleName=role_name, **conn) role = role['Role'] # cast CreateDate from a datetime to something JSON serializable. role.update(dict(CreateDate=str(role['CreateDate']))) return role
def _get_base(user, **conn): base_fields = frozenset(['Arn', 'CreateDate', 'Path', 'UserId', 'UserName']) needs_base = False for field in base_fields: if field not in user: needs_base = True break if needs_base: user_name = _get_name_from_structure(user, 'UserName') user = CloudAux.go('iam.client.get_user', UserName=user_name, **conn) user = user['User'] # cast CreateDate from a datetime to something JSON serializable. user.update(dict(CreateDate=str(user['CreateDate']))) if 'PasswordLastUsed' in user: user.update(dict(PasswordLastUsed=str(user['PasswordLastUsed']))) user['_version'] = 1 return user