How to use the pypuppetdb.api.BaseAPI 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 / test_baseapi.py View on Github external
def test_ssl_cert(self):
        api = pypuppetdb.api.BaseAPI(ssl_cert='/d/e/f.pem')
        assert api.ssl_cert == '/d/e/f.pem'
        assert api.protocol == 'http'
github voxpupuli / pypuppetdb / tests / test_baseapi.py View on Github external
def test_ssl_verify(self):
        api = pypuppetdb.api.BaseAPI(ssl_verify=False)
        assert api.ssl_verify is False
        assert api.protocol == 'http'
github voxpupuli / pypuppetdb / tests / test_baseapi.py View on Github external
def test_url_path_longer_with_both_slashes(self):
        api = pypuppetdb.api.BaseAPI(url_path='/puppet/db/')
        assert api.url_path == '/puppet/db'
github voxpupuli / pypuppetdb / tests / test_baseapi.py View on Github external
def test_username_and_password(self):
        api = pypuppetdb.api.BaseAPI(username='puppetdb',  # nosec
                                     password='password123')
        assert api.username == 'puppetdb'
        assert api.password == 'password123'
github voxpupuli / pypuppetdb / tests / test_baseapi.py View on Github external
def test_init_defaults(self):
        v4 = pypuppetdb.api.BaseAPI()
        assert v4.api_version == 'v4'
github voxpupuli / pypuppetdb / tests / test_baseapi.py View on Github external
def test_url_path_trailing_slash(self):
        api = pypuppetdb.api.BaseAPI(url_path='puppetdb/')
        assert api.url_path == '/puppetdb'
github voxpupuli / pypuppetdb / tests / test_baseapi.py View on Github external
def test_password(self):
        api = pypuppetdb.api.BaseAPI(password='password123')  # nosec
        assert api.username is None
        assert api.password is None
github voxpupuli / pypuppetdb / pypuppetdb / api / v2.py View on Github external
from __future__ import unicode_literals
from __future__ import absolute_import

import logging

from pypuppetdb.api import BaseAPI
from pypuppetdb.types import (
    Node, Fact, Resource,
    )

log = logging.getLogger(__name__)


class API(BaseAPI):
    """The API object for version 2 of the PuppetDB API. This object contains
    all v2 specific methods and ways of doing things.

    :param \*\*kwargs: Rest of the keywoard arguments passed on to our parent\
            :class:`~pypuppetdb.api.BaseAPI`.
    """

    def __init__(self, *args, **kwargs):
        """Initialise the API object."""
        super(API, self).__init__(api_version=2, **kwargs)
        log.debug('API initialised with {0}'.format(kwargs))

    def node(self, name):
        """Gets a single node from PuppetDB."""
        nodes = self.nodes(name=name)
        return next(node for node in nodes)
github voxpupuli / pypuppetdb / pypuppetdb / api / v4.py View on Github external
from __future__ import absolute_import

import logging

from pypuppetdb.api import BaseAPI
from pypuppetdb.utils import json_to_datetime
from datetime import datetime, timedelta
from pypuppetdb.types import (
    Node, Fact, Resource,
    Report, Event, Catalog
)

log = logging.getLogger(__name__)


class API(BaseAPI):
    """The API object for version 4 of the PuppetDB API. This object contains
    all v4 specific methods and ways of doing things.

    :param \*\*kwargs: Rest of the keywoard arguments passed on to our parent\
            :class:`~pypuppetdb.api.BaseAPI`.
    """

    def __init__(self, *args, **kwargs):
        """Initialise the API object."""
        super(API, self).__init__(api_version=4, **kwargs)
        log.debug('API initialised with {0}.'.format(kwargs))

    def node(self, name):
        """Gets a single node from PuppetDB.

        :param name: The name of the node search.
github voxpupuli / pypuppetdb / pypuppetdb / __init__.py View on Github external
:param url_path: (Default: '/') The URL path where PuppetDB is served
    :type url_path: :obj:`None` or :obj:`string`

    :param username: (optional) The username to use for HTTP basic
            authentication
    :type username: :obj:`None` or :obj:`string`

    :param password: (optional) The password to use for HTTP basic
            authentication
    :type password: :obj:`None` or :obj:`string`

    :param token: (optional) The x-auth token to use for X-Authentication
    :type token: :obj:`None` or :obj:`string`
    """
    return BaseAPI(host=host, port=port,
                   timeout=timeout, ssl_verify=ssl_verify, ssl_key=ssl_key,
                   ssl_cert=ssl_cert, protocol=protocol, url_path=url_path,
                   username=username, password=password, token=token)