How to use the dnacentersdk.api.authentication.Authentication function in dnacentersdk

To help you get started, we’ve selected a few dnacentersdk 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 cisco-en-programmability / dnacentersdk / tests / test_dnacentersdk.py View on Github external
def test_api_object_creation(self, api):
        assert isinstance(api.authentication, Authentication)
        assert isinstance(api.custom_caller, CustomCaller)
        if api.version == '1.2.10':
            assert isinstance(api.clients, Clients_v1_2_10)
            assert isinstance(api.command_runner, CommandRunner_v1_2_10)
            assert isinstance(api.devices, Devices_v1_2_10)
            assert isinstance(api.fabric_wired, FabricWired_v1_2_10)
            assert isinstance(api.file, File_v1_2_10)
            assert isinstance(api.network_discovery, NetworkDiscovery_v1_2_10)
            assert isinstance(api.networks, Networks_v1_2_10)
            assert isinstance(api.non_fabric_wireless, NonFabricWireless_v1_2_10)
            assert isinstance(api.path_trace, PathTrace_v1_2_10)
            assert isinstance(api.pnp, Pnp_v1_2_10)
            assert isinstance(api.swim, Swim_v1_2_10)
            assert isinstance(api.site_profile, SiteProfile_v1_2_10)
            assert isinstance(api.sites, Sites_v1_2_10)
            assert isinstance(api.tag, Tag_v1_2_10)
github cisco-en-programmability / dnacentersdk / dnacentersdk / api / __init__.py View on Github external
check_type(verify, (bool, basestring), may_be_none=False)
        check_type(version, basestring, may_be_none=False)

        if version not in ['1.2.10', '1.3.0', '1.3.1', '1.3.3', '2.1.1']:
            raise VersionError(
                'Unknown API version, '
                + 'known versions are {}'.format(
                    '1.2.10, 1.3.0, 1.3.1, 1.3.3 and 2.1.1.'
                )
            )

        if isinstance(debug, str):
            debug = 'true' in debug.lower()

        # Init Authentication wrapper early to use for basicAuth requests
        self.authentication = Authentication(
            base_url, object_factory,
            single_request_timeout=single_request_timeout,
            verify=verify,
        )

        # Check if the user has provided the required basicAuth parameters
        if encoded_auth is None and (username is None or password is None):
            raise AccessTokenError(
                "You need an access token to interact with the DNA Center"
                " APIs. DNA Center uses HTTP Basic Auth to create an access"
                " token. You must provide the username and password or just"
                " the encoded_auth, either by setting each parameter or its"
                " environment variable counterpart ("
                "DNA_CENTER_USERNAME, DNA_CENTER_PASSWORD,"
                " DNA_CENTER_ENCODED_AUTH)."
            )
github cisco-en-programmability / dnacentersdk / dnacentersdk / api / authentication.py View on Github external
Python objects from the returned DNA Center JSON data objects.
            single_request_timeout(int): Timeout in seconds for the API
                requests.
            verify(bool,basestring): Controls whether we verify the server's
                TLS certificate, or a string, in which case it must be a path
                to a CA bundle to use.

        Raises:
            TypeError: If the parameter types are incorrect.

        """
        check_type(base_url, basestring, may_be_none=False)
        check_type(single_request_timeout, int)
        check_type(verify, (bool, basestring), may_be_none=False)

        super(Authentication, self).__init__()

        self._base_url = str(validate_base_url(base_url))
        self._single_request_timeout = single_request_timeout
        self._verify = verify
        self._request_kwargs = {"timeout": single_request_timeout,
                                "verify": verify}
        self._object_factory = object_factory