nimblebox logo
Docs
v2.1.0

nbox.subway

These function are meant to make jobs easier and contain the code for what I am calling Subway, which converts any OpenAPI spec into an RPC-like interface. At the end of the day, each API call is really nothing but a functional call with added steps like serialisation and networking combined. This kind of added complexity can:

  • Make code look really ugly, think try-catches and r.raise_for_request()
  • Easy to develop because information has to be packaged as different parts for each type of function call (GET, POST, ...). The true intent was always to pass it the relevant information and forget about underlying details.
  • API endpoints are just strings and it's easy to have a typo in the URL. When the Subwayis loaded with the OpenAPI spec, it will disallow incorrect URLs. while managing the parameters correctly.
  • A more pythonic way of programming where you can use the dot notation.

Based os these ideas there are three types of subways:

  • Subway: Does not load OpenAPI spec and will blindly call the API, avoid this
  • Sub30: Built for OpenAPI v3.0.0, this becomes nbox_ws_v1
  • SpecSubway: This is used with the FastAPI's OpenAPI spec, this is used in systems that use FastAPI (eg. Compute Server)

Functions

iconfunctionfilter_templates
[source]

Classes

iconclassSubway
[source]
iconfunction__init__
[source]
iconfunction__repr__
[source]
iconfunction__getattr__
[source]
iconfunctionu
[source]
iconfunction__call__
[source]
iconclassSub30
[source]
iconfunction__init__
[source]
(_url:str,_api:dict,_session:requests.Session,prefix:str,last_call_at:float)
Parameters
  • _url -

    the base url of the API.

  • _api -

    OpenAPI json dict.

  • _session -

    Session object to use for requests.

  • prefix -

    This is internal, do not use it explicitly.

  • last_call_at -

    This is internal, do not use it explicitly.

Like Subway but built for Nimblebox Webserver APIs.

Example:

Python
Loading...
iconfunction_create_keepalive
[source]

Creates a keepalive thread. Need to define this as a function because sleeping can cause it to behave unlike a normal blocking program, so use this carefully.

iconfunction_stop
[source]
iconfunction_copy_session
[source]
iconfunction__repr__
[source]
iconfunction__getattr__
[source]
iconfunctionu
[source]
iconfunction__call__
[source]
(_method:str)
Parameters
  • _method -

    if only one method is present this will be ignored else "get" will be used. Defaults to None.

Call the API.

iconclassSpecSubway
[source]
iconfunction__init__
[source]

Subway but for fastAPI OpenAPI spec.

iconfunctionfrom_openapi
[source]
iconfunction__repr__
[source]
iconfunction__getattr__
[source]
iconfunctionu
[source]
iconfunction__call__
[source]
iconclassSublimeRPCSubway
[source]
iconfunction__init__
[source]

Create an abstract for the Sublime RPC service which implements VPC secure calls for NimbleBox Monitoring and Relics

iconfunction__getattr__
[source]
iconfunction_to_sublime
[source]

function to convert the incoming message to sublime format

iconfunction__call__
[source]
nbox SDKnbox provides built in access to all the APIs and packages them in the most user friendly manner.Star 0