How to use the pypuppetdb.errors.APIError function in pypuppetdb

To help you get started, we’ve selected a few pypuppetdb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github voxpupuli / pypuppetdb / tests / baseapi / test_url.py View on Github external
def test_url_invalid_endpoint(api3):
    with pytest.raises(APIError):
        api3._url('I-will_never+exist%really')
github voxpupuli / pypuppetdb / tests / baseapi / test_url.py View on Github external
def test_url_invalid_endpoint(api2):
    with pytest.raises(APIError):
        api2._url('I-will_never+exist%really')
github voxpupuli / pypuppetdb / tests / test_baseapi.py View on Github external
def test_cmd_bad_command(self, baseapi):
        httpretty.enable()
        stub_request('http://localhost:8080/pdb/cmd/v1')
        with pytest.raises(pypuppetdb.errors.APIError):
            baseapi._cmd('incorrect command', {})
        httpretty.disable()
        httpretty.reset()
github voxpupuli / pypuppetdb / pypuppetdb / errors.py View on Github external
class ImproperlyConfiguredError(APIError):
    """This exception is thrown when the API is initialised
    and it detects incompatible configuration such as SSL turned
    on but no certificates provided."""
    pass


class EmptyResponseError(APIError):
    """Will be thrown when we did receive a response but the
    response is empty."""
    pass


class DoesNotComputeError(APIError):
    """This error will be thrown when a function is called with
    an incompatible set of optional parameters. This is the 'you are
    being a naughty developer, go read the docs' error.
    """
    pass
github voxpupuli / pypuppetdb / pypuppetdb / errors.py View on Github external
class APIError(Exception):
    """Our base exception the other errors inherit from."""
    pass


class ImproperlyConfiguredError(APIError):
    """This exception is thrown when the API is initialised
    and it detects incompatible configuration such as SSL turned
    on but no certificates provided."""
    pass


class EmptyResponseError(APIError):
    """Will be thrown when we did receive a response but the
    response is empty."""
    pass


class DoesNotComputeError(APIError):
    """This error will be thrown when a function is called with
    an incompatible set of optional parameters. This is the 'you are
    being a naughty developer, go read the docs' error.
github voxpupuli / pypuppetdb / pypuppetdb / api.py View on Github external
r = self._session.get(url, params=payload,
                                      verify=self.ssl_verify,
                                      cert=(self.ssl_cert, self.ssl_key),
                                      timeout=self.timeout,
                                      auth=auth)
            elif request_method.upper() == 'POST':
                r = self._session.post(url,
                                       data=json.dumps(payload, default=str),
                                       verify=self.ssl_verify,
                                       cert=(self.ssl_cert, self.ssl_key),
                                       timeout=self.timeout,
                                       auth=auth)
            else:
                log.error("Only GET or POST supported, {0} unsupported".format(
                    request_method))
                raise APIError
            r.raise_for_status()

            # get total number of results if requested with include-total
            # just a quick hack - needs improvement
            if 'X-Records' in r.headers:
                self.last_total = r.headers['X-Records']
            else:
                self.last_total = None

            json_body = r.json()
            if json_body is not None:
                return json_body
            else:
                del json_body
                raise EmptyResponseError
github voxpupuli / pypuppetdb / pypuppetdb / errors.py View on Github external
class APIError(Exception):
    """Our base exception the other errors inherit from."""
    pass


class ImproperlyConfiguredError(APIError):
    """This exception is thrown when the API is initialised
    and it detects incompatible configuration such as SSL turned
    on but no certificates provided."""
    pass


class EmptyResponseError(APIError):
    """Will be thrown when we did receive a response but the
    response is empty."""
    pass


class DoesNotComputeError(APIError):
    """This error will be thrown when a function is called with
    an incompatible set of optional parameters. This is the 'you are
    being a naughty developer, go read the docs' error.
    """
    pass