BigBlueButton API reference¶
Servers and server groups¶
Data structures to handle BigBlueButton servers.
This module also contains group handling support and the implementation
of the communication with the API itself. Meetings and attendees manage
themselves by talking to the BigBlueButton
object linked to them. All
other methods should be called on a BigBlueButtonGroup
, which takes care
of routing to the appropriate server(s).
One BigBlueButton server.
A BigBlueButton instance holds the information needed to communicate with the BigBlueButton server. When creating meetings, it passes itself to the
Meeting
object, and provides methods for the Meeting object to manage itself.A BigBlueButton server always belongs to a
BigBlueButtonGroup
, which it gets passed in the constructor and it registers itself with.- Parameters
group (
BigBlueButtonGroup
) – Reference to theBigBlueButtonGroup
this server belongs toname (
str
) – Descriptive name of this serverurl (
str
) – Full URL to the API endpoint of this BigBlueButton server (with trailing /)salt (
str
) – API secret, as reported by bbb-conf on the serverhost (
Optional
[str
]) – Hostname of the server, e.g. for SSH access (guessed from URL if unset)request_timeout (
Union
[float
,Tuple
[float
,float
]]) – Timeout for API requests, either one value or a two-tuple defining TCP and HTTP request timeouts
- Return type
None
Create a meeting on thie BigBlueButton server.
args and kwargs are passed verbatim into the
Meeting
constructor. The additional parameter do_create determines whether the API is actually called to create the meeting. If it is False, tje object is returned but the meeting is not transferred to the BigBlueButton server.This method first looks up whether a meeting with the passed meeting_id and reuse that object if a meeting is found. If none is found, a new object is created and the create API call sent to the server (if do_create is not set to False).
The BigBlueButton API guarantees that the create call is idempotent, so calling this method on a meeting ID of an existing meeting is safe. But, as every server is part of a server group, consumers should always call create_meeting on a
BigBlueButtonGroup
instead (or use its meeting property to make use of caching).
Get all meetings known on the BigBlueButton server.
This method calls the getMeetings API call on the BigBlueButton server and constructs Meeting objects from all meetings in the result. For meetings that are already known as objects, the appropriate object is returned; for all unknown meetings, new objects are created.
As every server is part of a server group, consumers should always call
BigBlueButtonGroup.create_meeting()
instead.
Get the output of the sadf/sar command (from the sysstat package) through SSH.
The result is used when load-balancing API requests.
To use this functaionality, the sadf Python package (in the “sysstat” extra) must be installed.
- Return type
Optional
[SadfReport
]
Refresh various aspects of this server.
Meetings
Sysstat data
- Return type
None
Compute the checksum needed to authenticate API requests to a BigBlueButton server.
The checksum has to be sent with every API request and is constructed like this:
Build the full query string (already done when passed into this method)
Prepend the name of the API call, without delimiter
Append the API salt (shared secret, key,…) provided by the BBB server
Calculate the SHA1 sum of the resulting string
>>> BigBlueButton.request_checksum("isMeetingRunning", "meetingID=Foo", "MyTestSalt") 'f59b73c5cf1db387da4ca7d937049420d4c50a12'
The resulting checksum is added tothe original query string as a parameter called checksum.
Execute a shell command through an SSH connection to the server.
This method constructs an ssh command and runs it as a subprocess, without shell expansion. However, shell expansion WILL take place on the server side.
The subprocess result is returned verbatim.
- Parameters
- Return type
- Returns
The verbatim subprocess object (including stdout, stderr, and return code)
A set of BigBlueButton servers.
All API operations should be called on this object, instead of a single server. It takes care of aggregating results from the backend servers (e.g. for getMeetings) and of routing requests to the correct server (e.g. for loadbalancing on create).
Servers (
BigBlueButton
objects) register themselves to the group passed as first argument on instantiation.If only one server has to be handled, still place it in a group.
- Parameters
name (
str
) – Descriptive name of this server groupworkers (
int
) – Number of servers to operate on parallely, e.g. when retrieving meetings or running SSH commands)logout_url (
Optional
[str
]) – Default URL to redirect clients to on meeting endorigin (
str
) – Name of the origin software passed as meeting meta-dataorigin_server_name (
str
) – Hostname of the origin, passed as meeting meta-data; defaults to the systems’s local FQDNgenerate_meeting_id_cb (
Optional
[Callable
[[],str
]]) – Callable to run for generating meeting IDs
- Return type
None
Create a new meeting on one of the backend servers.
For the arguments, see the documentation on
Meeting
.This method first tries to find an existing meeting. The original create API method in BigBlueButton is idempotent, so we must ensure we also fulfill this requirement when handling several servers. If this group already has a list of known meetings, and the meeting is found in it, the call is redirected to the backend server it is linked to. If it is not found,
get_meetings()
is called to refresh the cache to be certain.If all attempts to find a meeting with the ID fail, or no ID is passed, a backend server is selected using
select_api()
and the create call routed there.- Return type
End a meeting determined from the passed ID.
If the meeting is not found, this method silently does nothing.
If a password is passed as second argument, it is compared against the moderarotr password of the meeting before the end request is even sent to the backend.
- Return type
None
Generate a unique meeting ID.
By default, this returns a GUID, unless a callback was defined in the generate_meeting_id_cb attribute.
- Return type
Update meeting information on all server objects.
It is aggregated into the meetings attribute.
If forcefully updating the metting information cache is not intended, the meeting property should be used instead.
Get sysstat information from all backend servers.
For the arguments and behaviour, see the documentation of
BigBlueButton.get_sysstat()
.The result is a dictionary with the server name as key and the result of the server’s get_sysstat method as values.
Handle an API call from a method, a dict of parameters, and a text body.
This method is useful to pass on structures like HTTP requests on to the library, e.g. when writing a proxy or load balancer. The method name and parameter dictionary are expected to match the official BigBlueButton API.
The return value is a dictionary representation of the XML document as would be returned by a BigBlueButton server when called with the same parameters.
Determine whether a meeting with a given ID is running on any backend server.
- Return type
All meetings known on all servers in the group.
Each meeting will reference the backend server it is actually running on, so calling methods on the Meeting objects returned in this property always does “the right thing”.
Createa new
BigBlueButton
server object in this group.The server object will register itself in this group.
For the arguments, see the documentation of
BigBlueButton
.- Return type
Refresh all backend servers.
For a description of the behaviour, see the documentation of
BigBlueButton.refresh()
.- Return type
None
Select a target server in the group by some creiteria.
This method runs a ranking algorithm on all servers in the group, then returns the server with the highest ranking. This can be used for load-balancing and similar tasks.
The ranking algorithm works like this:
Start with giving each server a ranking of N points.
Apply a list of checkers on each server. Each checker returns a factor by which to multiply the last known ranking (between 0 and 1).
Return the server with the highest ranking. If multiple servers share the same highest ranking, fall back to round robin.
A ranking of 0 means a server is unavailable. Servers with a ranking of 0 are never returned.
- Parameters
criteria (
Optional
[Dict
[str
,Any
]]) – A dictionary of criteria taken into account by each checker. See the documentation of the checkers in the :module:`bigbluebutton.api.loadbalancing` module for details on what criteria exist and how they influence server selection.- Return type
- Returns
One BigBlueButton server that best matches the criteria
Call an SSH command on each backend server in this group.
For the arguments and behaviour, see the documentation of
BigBlueButton.ssh_command()
.The return value is a dictionary with the server name as key and the result of the server’s ssh_command method as value.
- Return type
Meetings¶
Data structures for BigBLueButton meetings and handling code
Define the meta-data of a meeting and its state.
The meeting is always linked to one
BigBlueButton
, on which it executes any API calls.- Return type
None
Create the meeting on the linked BigBlueButton server.
- Return type
None
Ask the server to forcefully end the meeting.
This only sends the end API call to the server. According to the BigBlueButton documentation, the call imemdiately returns, but it can take several seconds for all componentes to pick up the request and actually end the meeting. Accordingly, it is is up to the developer to track the progress by calling
is_meeting_running()
orget_meeting_info()
again later on.- Return type
None
Construct a dictionary suitable for passing as kwargs to the constructor.
The passed urlargs are expected to be a dictionary of URL arguments following the BigBlueButton HTTP API schema.
This is useful to generate a meeting object from a URL call from a foreign BBB client, an API reply, or comparable things.
Update the meeting information from the server.
The results are cached in the corresponding attributes.
- Return type
- Returns
the Meeting object itself, after being updated
Call the isMeetingRunning API method.
The result is cached in the running attribute and immediately returned.
- Return type
- Returns
True if the server reports the meeting as running, False if not
Origin of the meeting
Derived from the meta-data values bbb-origin and bbb-origin-server-name, which are de facto standard fields.
- Return type
Return relevant data of this meeting as a dictionary.
The dictionary can be used to build an XML document compatible with BigBlueButton API clients.
If names of attributes are passed as positional arguments, only these attributes are returned in the dictionary.
If attribute names are passed as names of keyword arguments, they are renamed to the string passed as value in the dictionary.
Attendees¶
Data structures for manageing meeting attendees
One attendee that participates in one meeting.
This object holds the information about one participant and is linked to exactly one meeting.
- Return type
None
Construct a dictionary suitable for passing as kwargs to the constructor.
The passed urlargs are expected to be a dictionary of URL arguments following the BigBlueButton HTTP API schema.
This is useful to generate an attendee object from a URL call from a foreign BBB client, an API reply, or comparable things.
Join an attendee corresponding to this object into the meeting it is linked to.
To request the join, this method can either call the API directly and return the URL to the (HTML5) client, or only construct the API call URL and then hand it off to the default browser (if the browser argument is set to True) or return it plain without calling (if the do_join argument is set to False).
In BigBlueButton’s default configuration, in addition to the session token in the client URL, a valid JSESSIONID cookie is required, so using the client URL outside the original request scope only works if the server supports it.
Return relevant data of this attendee as a dictionary.
The dictionary can be used to build an XML document compatible with BigBlueButton API clients.
If names of attributes are passed as positional arguments, only these attributes are returned in the dictionary.
If attribute names are passed as names of keyword arguments, they are renamed to the string passed as value in the dictionary.
Enumeration of roles an attendee can have
Utilities¶
Utility functions used by different parts of bigbluebutton2
Convert camel or lower camel case name to PEP-8 compliant snake case used in our classes.
>>> camel_to_snake("meetingID") 'meeting_id'
- Return type
Guess the type of a field in a class by looking at its type annotation.
It either returns the type hint itself, or the first type argument if it is a composite (e.g. int for a typing.Union[int, float] or a typing.Optional[int].
WARNING: This is not generic code, but tailored to the use cases in the specific data classes in this code base.
- Return type
Convert PEP-8 complicant snake case name to special lower camel case.
>>> snake_to_camel("test_string") 'testString' >>> snake_to_camel("meeting_id") 'meetingID'
- Return type
Convert a string value to a type fitting the type of a field by looking at its type hint.
- Return type