Example #1
0
File: api.py Project: rapid7/lecli
def _url(provided_path_parts=()):
    """
    Get rest query url of account resource id.
    """
    ordered_path_parts = ['management', 'accounts', api_utils.get_account_resource_id()]
    ordered_path_parts.extend(provided_path_parts)
    return api_utils.build_url(ordered_path_parts)
Example #2
0
File: api.py Project: rapid7/lecli
def _url(provided_parts=()):
    """
    Get rest query "path" and "url" respectively
    """
    ordered_path_parts = ['management', 'accounts', api_utils.get_account_resource_id(), 'apikeys']
    ordered_path_parts.extend(provided_parts)
    return api_utils.build_url(ordered_path_parts)
Example #3
0
def test_get_invalid_account_resource_id(capsys):
    with patch.object(ConfigParser.ConfigParser, 'get',
                      return_value=ID_WITH_INVALID_LENGTH):
        with pytest.raises(SystemExit):
            result = api_utils.get_account_resource_id()
            out, err = capsys.readouterr()

            assert result is None
            assert ID_WITH_INVALID_LENGTH in out
            assert 'is not of correct length' in out
Example #4
0
def list_users():
    """
    List users that is in the current account.
    """
    action = 'management/accounts/%s/users' % api_utils.get_account_resource_id(
    )
    try:
        response = requests.request('GET',
                                    _url('user'),
                                    headers=api_utils.generate_headers(
                                        'owner', 'GET', action, ''))
        handle_userlist_response(response)
    except requests.exceptions.RequestException as error:
        print error
        exit(1)
Example #5
0
File: api.py Project: rapid7/lecli
def _url():
    """
    Get rest query url of account resource id.
    """
    ordered_path_parts = ['usage', 'accounts', api_utils.get_account_resource_id()]
    return api_utils.build_url(ordered_path_parts)
Example #6
0
def _url():
    """
    Get rest query url of account resource id.
    """
    return 'https://rest.logentries.com/management/accounts/%s/teams' % \
           api_utils.get_account_resource_id()
Example #7
0
def test_get_valid_account_resource_id():
    with patch.object(ConfigParser.ConfigParser, 'get', return_value=ID_WITH_VALID_LENGTH):
        account_resource_id = api_utils.get_account_resource_id()

        assert account_resource_id == ID_WITH_VALID_LENGTH