MCPcopy Create free account
hub / github.com/dwavesystems/dwave-cloud-client / DWaveAPIClient

Class DWaveAPIClient

dwave/cloud/api/client.py:771–1061  ·  view source on GitHub ↗

Low-level client for D-Wave APIs. A thin wrapper around `requests.Session` that handles API specifics such as authentication, response and error parsing, retrying, etc. Note: To make sure the session is closed, call :meth:`.close`, or use the context manager form (as sho

Source from the content-addressed store, hash-verified

769
770
771class DWaveAPIClient:
772 """Low-level client for D-Wave APIs. A thin wrapper around
773 `requests.Session` that handles API specifics such as authentication,
774 response and error parsing, retrying, etc.
775
776 Note:
777 To make sure the session is closed, call :meth:`.close`, or use the
778 context manager form (as show in the example below).
779
780 Note:
781 Since :class:`requests.Session` is **not thread-safe**, neither is
782 :class:`DWaveAPIClient`. It's best to create (and dispose) a new client
783 on demand, in each thread.
784
785 Example:
786 >>> with DWaveAPIClient(endpoint='...', timeout=(5, 600)) as client: # doctest: +SKIP
787 ... client.session.get('...')
788
789 """
790
791 class DefaultSession(VersionedAPISessionMixin,
792 DeprecationAwareSessionMixin,
793 PayloadCompressingSessionMixin,
794 BaseUrlSessionMixin,
795 CachingSessionMixin,
796 LoggingSessionMixin,
797 requests.Session):
798 """Default session class is based on `requests.Session` extended with
799 base url, logging, compressing, API versioning and caching mixins.
800 """
801
802 DEFAULTS = {
803 'session_class': DefaultSession,
804
805 'endpoint': None,
806 'token': None,
807 'cert': None,
808
809 # (connect, read) timeout in sec
810 'timeout': (60, 120),
811
812 # urllib3.Retry options
813 'retry': dict(total=10, backoff_factor=0.01, backoff_max=60),
814
815 # optional additional headers
816 'headers': None,
817
818 # ssl verify
819 'verify': True,
820
821 # proxy urls, see :attr:`requests.Session.proxies`
822 'proxies': None,
823
824 # number of most recent request records to keep in :attr:`.session.history`
825 'history_size': 0,
826
827 # preemptive payload compression on upload requests, see :class:`PayloadCompressingSession`
828 'compress': False,

Callers 15

test_defaultsMethod · 0.90
test_initMethod · 0.90
test_requestMethod · 0.90
test_pathsMethod · 0.90
test_session_historyMethod · 0.90
setUpMethod · 0.90
test_jsonMethod · 0.90
test_plain_text_errorMethod · 0.90
test_unknown_errorsMethod · 0.90
test_configMethod · 0.90

Calls

no outgoing calls

Tested by 15

test_defaultsMethod · 0.72
test_initMethod · 0.72
test_requestMethod · 0.72
test_pathsMethod · 0.72
test_session_historyMethod · 0.72
setUpMethod · 0.72
test_jsonMethod · 0.72
test_plain_text_errorMethod · 0.72
test_unknown_errorsMethod · 0.72
test_configMethod · 0.72