welkin.client ============= .. py:module:: welkin.client .. autoapi-nested-parse:: Client. This module provides a Client object to interface with the Welkin Health API. Attributes ---------- .. autoapisummary:: welkin.client.logger Classes ------- .. autoapisummary:: welkin.client.Client welkin.client.TimeoutHTTPAdapter Module Contents --------------- .. py:data:: logger .. py:class:: Client(tenant, instance, api_client, secret_key, timeout=5, total=5, backoff_factor=0.5) Bases: :py:obj:`requests.Session` Welkin Health Client. Constructs a :obj:`requests.Session` for Welkin Health API requests with authorization, base URL, request timeouts, and request retries. :param tenant: Name of the organization. :type tenant: str :param instance: Name of the database inside a customer space. :type instance: str :param api_client: API client name. :type api_client: str :param secret_key: API client secret key. :type secret_key: str :param timeout: :obj:`TimeoutHTTPAdapter` timeout value. Defaults to 5. :type timeout: int, optional :param total: :obj:`Retry` total value. Defaults to 5. :type total: int, optional :param backoff_factor: :obj:`Retry` backoff_factor value. Defaults to 0.5. :type backoff_factor: float, optional Usage:: from welkin import Client welkin = Client( tenant="gh", instance="sb-demo", api_client="VBOPNRYRWJIP", secret_key="+}B{KGTG6#zG%P;tQm0C", ) ### Patient methods patient = welkin.Patient(firstName="Foo", lastName="Bar").create() # Create patient = welkin.Patient(id="6801d498-26f4-4aee-961b-5daffcf193c8").get() # Read patients = welkin.Patients().get() # Read all/list patient.update(firstName="Baz") # Update patient.delete() # Delete ### User methods user = client.User(username="bar", email="bar@foo.com").create() # Create user = welkin.User(id="301b2895-cbf0-4cac-b4cf-1d082faee95c").get() # Read users = welkin.Users().get() # Read all/list uasers = welkin.Users().get( search="foo", region="east-coast", seat_assigned=True, user_state="ACTIVE" ) # Filtered read all/list user.update(firstName="Baz") # Update user.delete() # Delete .. py:attribute:: Assessment .. py:attribute:: AssessmentRecord .. py:attribute:: AssessmentRecordAnswers .. py:attribute:: AssessmentRecords .. py:attribute:: Assessments .. py:attribute:: CalendarEvent .. py:attribute:: CalendarEvents .. py:attribute:: CarePlan .. py:attribute:: CarePlanOverview .. py:attribute:: CDT .. py:attribute:: CDTRecordsExport .. py:attribute:: CDTs .. py:attribute:: Chat .. py:attribute:: Chats .. py:attribute:: DocumentSummaries .. py:attribute:: DocumentSummary .. py:attribute:: DocumentSummaryFile .. py:attribute:: DocumentSummaryFiles .. py:attribute:: Email .. py:attribute:: Emails .. py:attribute:: Encounter .. py:attribute:: EncounterDisposition .. py:attribute:: Encounters .. py:attribute:: Formation .. py:attribute:: Patient .. py:attribute:: PatientProgram .. py:attribute:: PatientPrograms .. py:attribute:: Patients .. py:attribute:: ProgramPhase .. py:attribute:: ProgramPhases .. py:attribute:: Schedules .. py:attribute:: SearchChats .. py:attribute:: SMS .. py:attribute:: SMSes .. py:attribute:: User .. py:attribute:: Users .. py:attribute:: WorkHours .. py:attribute:: host :value: 'https://api.live.welkincloud.io/Uninferable/' .. py:attribute:: auth .. py:attribute:: instance .. py:method:: prepare_request(request) Constructs a :class:`PreparedRequest ` for transmission and returns it. The :class:`PreparedRequest` has settings merged from the :class:`Request ` instance and those of the :class:`Session`. :param request: :class:`Request` instance to prepare with this session's settings. :rtype: requests.PreparedRequest .. py:method:: request(method: str, path: str, meta_key: str | None = None, meta_dict: dict | None = None, *args, **kwargs) Override :obj:`Session` request method to add retries and output JSON. :param method: Method for the new Request object. :type method: str :param path: Path from host for the new Request object. :type path: str :param meta_key: Key for metadata in the response JSON. Defaults to None. :type meta_key: str | None, optional :param meta_dict: Metadata dictionary for the response JSON. Defaults to None. :type meta_dict: dict | None, optional :param \*args: Arguments to pass to `Session.request`. :param \*\*kwargs: Keyword arguments to pass to `Session.request`. :returns: Response JSON :rtype: dict .. py:method:: get_token() -> dict .. py:class:: TimeoutHTTPAdapter(timeout, *args, **kwargs) Bases: :py:obj:`requests.adapters.HTTPAdapter` The built-in HTTP Adapter for urllib3. Provides a general-case interface for Requests sessions to contact HTTP and HTTPS urls by implementing the Transport Adapter interface. This class will usually be created by the :class:`Session ` class under the covers. :param pool_connections: The number of urllib3 connection pools to cache. :param pool_maxsize: The maximum number of connections to save in the pool. :param max_retries: The maximum number of retries each connection should attempt. Note, this applies only to failed DNS lookups, socket connections and connection timeouts, never to requests where data has made it to the server. By default, Requests does not retry failed connections. If you need granular control over the conditions under which we retry a request, import urllib3's ``Retry`` class and pass that instead. :param pool_block: Whether the connection pool should block for connections. Usage:: >>> import requests >>> s = requests.Session() >>> a = requests.adapters.HTTPAdapter(max_retries=3) >>> s.mount('http://', a) .. py:attribute:: timeout .. py:method:: send(request, **kwargs) Override :obj:`HTTPAdapter` send method to add a default timeout.