diff --git a/README.md b/README.md index 817439c..05f7815 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,9 @@ n = nomad.Nomad(host="172.16.100.10", secure=True, timeout=5, verify=True, cert= # For HTTPS Nomad instances with cert file and key n = nomad.Nomad(host="https://172.16.100.10", secure=True, timeout=5, verify=True, cert=("/path/to/certfile", "/path/to/key")) # See http://docs.python-requests.org/en/master/user/advanced/#ssl-cert-verification +# For HTTPS Nomad instance with cert file and key and CA file +n = nomad.Nomad(host="https://172.16.100.10", secure=True, timeout=5, verify="/path/to/cacert", cert=("/path/to/certfile", "/path/to/key")) + # For HTTPS Nomad instances with namespace and acl token n = nomad.Nomad(host="172.16.100.10", secure=True, timeout=5, verify=False, namespace='Namespace-example',token='3f4a0fcd-7c42-773c-25db-2d31ba0c05fe') diff --git a/nomad/__init__.py b/nomad/__init__.py index 406d2db..43437c5 100644 --- a/nomad/__init__.py +++ b/nomad/__init__.py @@ -1,7 +1,7 @@ """Nomad Python library""" import os -from typing import Optional +from typing import Optional, Union import requests @@ -25,7 +25,7 @@ def __init__( # pylint: disable=too-many-arguments timeout: int = 5, region: Optional[str] = None, version: str = "v1", - verify: bool = False, + verify: Union[bool, str] = False, cert: tuple = (), session: requests.Session = None, ): @@ -39,8 +39,8 @@ def __init__( # pylint: disable=too-many-arguments - user_agent (defaults None), custom user agent for requests to Nomad. - secure (defaults False), define if the protocol is secured or not (https or http) - version (defaults v1), version of the api of nomad. - - verify (defaults False), verify the certificate when tls/ssl is enabled - at nomad. + - verify (defaults False), verify SSL certificates for HTTPS requests. Can be a boolean to enable/disable + verification, or a string path to a CA certificate file. - cert (defaults empty), cert, or key and cert file to validate the certificate configured at nomad. - region (defaults None), version of the region to use. It will be used then diff --git a/nomad/api/base.py b/nomad/api/base.py index 209899b..ef340fe 100644 --- a/nomad/api/base.py +++ b/nomad/api/base.py @@ -1,6 +1,6 @@ """Requester""" -from typing import Optional +from typing import Optional, Union import requests @@ -24,7 +24,7 @@ def __init__( # pylint: disable=too-many-arguments token: Optional[str] = None, timeout: int = 5, version: str = "v1", - verify: bool = False, + verify: Union[bool, str] = False, cert: tuple = (), region: Optional[str] = None, session: requests.Session = None,