CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
psyclone_client.http.PsycloneHttp Class Reference

Public Member Functions

 __init__ (self, base_url, timeout=10.0, headers=None, ssl_context=None)
 request (self, path, post=None, fields=None)
 request_body (self, path, post, body, content_type="application/json")
 get (self, path, post=None, query=None)

Public Attributes

 base = base_url.rstrip("/")
 timeout = timeout
 headers = dict(headers or {})
 ssl_context = ssl_context

Protected Member Functions

 _url (self, path, post, query=None)
 _send (self, method, url, body=None, content_type=None)

Detailed Description

Each request becomes one message posted as ``post`` (the ``PsyPost`` query parameter): query
parameters and form fields become string entries, a JSON/XML/text body a string entry. The reply is
what the responder put in ``JSON``/``XML``/``HTML``/``TEXT``/``BINARY`` (``ResultCode`` = status), or the
whole reply message as JSON.

::

    http = PsycloneHttp("http://host:8082")
    r = http.request("/ask", "Question", {"Text": "hello"})
    print(r.status, r.text)

Definition at line 25 of file http.py.

Constructor & Destructor Documentation

◆ __init__()

psyclone_client.http.PsycloneHttp.__init__ ( self,
base_url,
timeout = 10.0,
headers = None,
ssl_context = None )

Definition at line 38 of file http.py.

Member Function Documentation

◆ _send()

psyclone_client.http.PsycloneHttp._send ( self,
method,
url,
body = None,
content_type = None )
protected

◆ _url()

psyclone_client.http.PsycloneHttp._url ( self,
path,
post,
query = None )
protected

Definition at line 44 of file http.py.

References cmlabs::ComponentSetup.base, and base.

Referenced by get(), request(), and request_body().

◆ get()

psyclone_client.http.PsycloneHttp.get ( self,
path,
post = None,
query = None )
GET ``path`` with ``query`` parameters (each becomes an entry).

Definition at line 75 of file http.py.

References _send(), and _url().

◆ request()

psyclone_client.http.PsycloneHttp.request ( self,
path,
post = None,
fields = None )
POST ``fields`` as a form to ``path``, posted into the system as ``post``.

Definition at line 64 of file http.py.

References _send(), and _url().

◆ request_body()

psyclone_client.http.PsycloneHttp.request_body ( self,
path,
post,
body,
content_type = "application/json" )
POST a JSON (or other text) body; the service passes it on as a string entry.

Definition at line 69 of file http.py.

References _send(), and _url().

Member Data Documentation

◆ base

psyclone_client.http.PsycloneHttp.base = base_url.rstrip("/")

Definition at line 39 of file http.py.

Referenced by _url(), and test_remote_module.Probe.post().

◆ headers

psyclone_client.http.PsycloneHttp.headers = dict(headers or {})

Definition at line 41 of file http.py.

Referenced by _send().

◆ ssl_context

psyclone_client.http.PsycloneHttp.ssl_context = ssl_context

Definition at line 42 of file http.py.

Referenced by _send().

◆ timeout

psyclone_client.http.PsycloneHttp.timeout = timeout

Definition at line 40 of file http.py.

Referenced by psyclone_client.remote_module.RemoteModule._request_op(), and _send().


The documentation for this class was generated from the following file:
  • python-client/src/psyclone_client/http.py