How to use the pynetbox.models.ipam function in pynetbox

To help you get started, we’ve selected a few pynetbox 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 digitalocean / pynetbox / tests / test_dcim.py View on Github external
def test_get(self, mock):
        ret = getattr(nb, self.name).get(1)
        self.assertTrue(ret)
        self.assertTrue(isinstance(ret, self.ret))
        self.assertTrue(isinstance(ret.primary_ip, pynetbox.models.ipam.IpAddresses))
        self.assertTrue(isinstance(ret.primary_ip4, pynetbox.models.ipam.IpAddresses))
        self.assertTrue(isinstance(ret.config_context, dict))
        self.assertTrue(isinstance(ret.custom_fields, dict))
        mock.assert_called_with(
            'http://localhost:8000/api/{}/{}/1/'.format(
                self.app,
                self.name.replace('_', '-')
            ),
            headers=HEADERS,
            verify=True
        )
github digitalocean / pynetbox / tests / test_dcim.py View on Github external
def test_get(self, mock):
        ret = getattr(nb, self.name).get(1)
        self.assertTrue(ret)
        self.assertTrue(isinstance(ret, self.ret))
        self.assertTrue(isinstance(ret.primary_ip, pynetbox.models.ipam.IpAddresses))
        self.assertTrue(isinstance(ret.primary_ip4, pynetbox.models.ipam.IpAddresses))
        self.assertTrue(isinstance(ret.config_context, dict))
        self.assertTrue(isinstance(ret.custom_fields, dict))
        mock.assert_called_with(
            'http://localhost:8000/api/{}/{}/1/'.format(
                self.app,
                self.name.replace('_', '-')
            ),
            headers=HEADERS,
            verify=True
        )
github digitalocean / pynetbox / pynetbox / api.py View on Github external
Calls to attributes are returned as Endpoint objects.

    :returns: :py:class:`.Endpoint` matching requested attribute.
    :raises: :py:class:`.RequestError`
        if requested endpoint doesn't exist.
    """
    def __init__(self, api, name):
        self.api = api
        self.name = name
        self._choices = None
        self._setmodel()

    models = {
        "dcim": dcim,
        "ipam": ipam,
        "circuits": circuits,
        "virtualization": virtualization,
        "extras": extras
    }

    def _setmodel(self):
        self.model = App.models[self.name] if self.name in App.models else None

    def __getstate__(self):
        return {
            'api': self.api,
            'name': self.name,
            '_choices': self._choices
        }

    def __setstate__(self, d):