bcf.v3.bcfapi

Module Contents

class bcf.v3.bcfapi.BcfClient(foundation_client: FoundationClient)
create_comments(project_id: str = '', topic_id: str = '', data: Any = None, params: Any = None) Tuple[int, str]
create_document(project_id: str = '', topic_id: str = '', guid: str | None = None, files: Any = None, data: Any = None) int
create_document_reference(project_id: str = '', topic_id: str = '', data: Any = None) Tuple[int, str]
create_topic(project_id: str = '', data: Any = None) Tuple[int, str]
create_viewpoints(project_id: str = '', topic_id: str = '', data: Any = None) Tuple[int, str]
delete(endpoint: str, params: Any = None) Tuple[int, str]
delete_comment(project_id: str = '', topic_id: str = '', comment_id: str = '') Tuple[int, str]
delete_topic(project_id: str = '', topic_id: str = '') Tuple[int, str]
delete_viewpoint(project_id: str = '', topic_id: str = '', viewpoint_id: str = '') Tuple[int, str]
get(endpoint: str, params: Any = None, is_auth_required: bool = False) Any
get_bitmap(project_id: str = '', topic_id: str = '', viewpoint_id: str = '', bitmap_id: str = '') str
get_coloring(project_id: str = '', topic_id: str = '', viewpoint_id: str = '') dict[str, Any]
get_comment(project_id: str = '', topic_id: str = '', comment_id: str = '') dict[str, Any]
get_comment_events(project_id: str = '', topic_id: str = '', comment_id: str = '') list[Any]
get_comments(project_id: str = '', topic_id: str = '') None
get_comments_events(project_id: str = '') list[Any]
get_document(project_id: str = '', topic_id: str = '', document_id: str = '') Tuple[int, str]
get_document_references(project_id: str = '', topic_id: str = '') list[Any]
get_documents(project_id: str = '', topic_id: str = '') list[Any]
get_extensions(project_id: str = '') dict[str, Any]
get_files(project_id: str = '', topic_id: str = '') list[Any]
get_files_information(project_id: str = '') list[Any]
get_project(project_id: str = '') dict[str, Any]
get_projects() list[Any]
get_selection(project_id: str = '', topic_id: str = '', viewpoint_id: str = '') dict[str, Any]
get_snapshot(project_id: str = '', topic_id: str = '', viewpoint_id: str = '') str
get_snippet(project_id: str = '', topic_id: str = '') Tuple[int, str]
get_topic(project_id: str = '', topic_id: str = '') dict[str, Any]
get_topic_events(project_id: str = '', topic_id: str = '') list[Any]
get_topics(project_id: str = '', topics: str = '', query_string: str | None = None) list[Any]
get_topics_events(project_id: str = '') list[Any]
get_viewpoint(project_id: str = '', topic_id: str = '', viewpoint_id: str = '') dict[str, Any]
get_viewpoints(project_id: str = '', topic_id: str = '') list[Any]
get_visibility(project_id: str = '', topic_id: str = '', viewpoint_id: str = '') dict[str, Any]
post(endpoint: str, data: Any = None, params: Any = None) Tuple[int, str]
put(endpoint: str, data: Any = None, params: Any = None) Tuple[int, str]
set_version(version: dict[str, str]) None
update_comment(project_id: str = '', topic_id: str = '', comment_id: str = '', data: Any = None) Tuple[int, str]
update_document_references(project_id: str = '', topic_id: str = '', document_reference_id: str = '', data: Any = None) Tuple[int, str]
update_files(project_id: str = '', topic_id: str = '', data: Any = None, params: Any = None) Tuple[int, str]
update_project(project_id: str = '', data: Any = None) Tuple[int, str]
update_snippet(project_id: str = '', topic_id: str = '', files: Any = None, data: Any = None) int
update_topic(project_id: str = '', topic_id: str = '', data: Any = None) Tuple[int, str]
baseurl: str | None = None
filepath
foundation_client
version_id: str | None = None
class bcf.v3.bcfapi.FoundationClient(client_id: str, client_secret: str, base_url: str | None = None, redirect_subdir: str | None = None)
get_access_token() str
get_auth_methods() list[Any]
get_new_access_token() None
get_refresh_token() None
get_versions() list[Any]
login() None
set_auth_method(method: str = 'authorization_code_grant') None
set_tokens_from_response(response: requests.Response) None
access_token = ''
access_token_expires_on
auth_method: str | None = None
baseurl
client_id
client_secret
redirect_subdir
refresh_token = ''
refresh_token_expires_on
token_endpoint = ''
class bcf.v3.bcfapi.OAuthReceiver

Bases: http.server.BaseHTTPRequestHandler

HTTP request handler base class.

The following explanation of HTTP serves to guide you through the code as well as to expose any misunderstandings I may have about HTTP (so you don’t need to read the code to figure out I’m wrong :-).

HTTP (HyperText Transfer Protocol) is an extensible protocol on top of a reliable stream transport (e.g. TCP/IP). The protocol recognizes three parts to a request:

  1. One line identifying the request type and path

  2. An optional set of RFC-822-style headers

  3. An optional data part

The headers and data are separated by a blank line.

The first line of the request has the form

<command> <path> <version>

where <command> is a (case-sensitive) keyword such as GET or POST, <path> is a string containing path information for the request, and <version> should be the string “HTTP/1.0” or “HTTP/1.1”. <path> is encoded using the URL encoding scheme (using %xx to signify the ASCII character with hex code xx).

The specification specifies that lines are separated by CRLF but for compatibility with the widest range of clients recommends servers also handle LF. Similarly, whitespace in the request line is treated sensibly (allowing multiple spaces between components and allowing trailing whitespace).

Similarly, for output, lines ought to be separated by CRLF pairs but most clients grok LF characters just fine.

If the first line of the request has the form

<command> <path>

(i.e. <version> is left out) then this is assumed to be an HTTP 0.9 request; this form has no optional headers and data part and the reply consists of just the data.

The reply form of the HTTP 1.x protocol again has three parts:

  1. One line giving the response code

  2. An optional set of RFC-822-style headers

  3. The data

Again, the headers and data are separated by a blank line.

The response code line has the form

<version> <responsecode> <responsestring>

where <version> is the protocol version (“HTTP/1.0” or “HTTP/1.1”), <responsecode> is a 3-digit response code indicating success or failure of the request, and <responsestring> is an optional human-readable string explaining what the response code means.

This server parses the request and the headers, and then calls a function specific to the request type (<command>). Specifically, a request SPAM will be handled by a method do_SPAM(). If no such method exists the server sends an error response to the client. If it exists, it is called with no arguments:

do_SPAM()

Note that the request name is case sensitive (i.e. SPAM and spam are different requests).

The various request details are stored in instance variables:

  • client_address is the client IP address in the form (host,

port);

  • command, path and version are the broken-down request line;

  • headers is an instance of email.message.Message (or a derived

class) containing the header information;

  • rfile is a file object open for reading positioned at the

start of the optional input data part;

  • wfile is a file object open for writing.

IT IS IMPORTANT TO ADHERE TO THE PROTOCOL FOR WRITING!

The first thing to be written must be the response line. Then follow 0 or more header lines, then a blank line, and then the actual data (if any). The meaning of the header lines depends on the command executed by the server; in most cases, when data is returned, there should be at least one header line of the form

Content-type: <type>/<subtype>

where <type> and <subtype> should be registered MIME types, e.g. “text/html” or “text/plain”.

do_GET() None