qbraid_core.QbraidSessionV1
- class qbraid_core.QbraidSessionV1(api_key=None, access_token=None, **kwargs)
Custom session with handling of request urls and authentication.
This is a child class of
qbraid_core.sessions.Session. It handles qbraid authentication with custom headers. TLS certificates are verified (therequests.Sessiondefault).This class uses the v1 API endpoints.
- __init__(api_key=None, access_token=None, **kwargs)
Initialize custom session with default base_url and auth_headers.
- Parameters:
api_key (optional, str) – Authenticated qBraid API key.
access_token (optional, str) – qBraid access token.
Methods
__init__([api_key, access_token])Initialize custom session with default base_url and auth_headers.
add_user_agent(user_agent)Updates the User-Agent header with additional information.
client(service_name[, api_key])Return a client for the specified service.
close()Closes all adapters and as such the session
delete(url, **kwargs)Sends a DELETE request.
get(url[, params])Send a GET request.
get_adapter(url)Returns the appropriate connection adapter for the given URL.
get_available_services()Get a list of available services that can be loaded as low-level clients via
Session.client().get_config(config_name)Returns the config value of specified config.
get_current_user_owner()Get current user info for environment ownership.
get_redirect_target(resp)Receives a Response.
get_user_auth_metadata()Get user metadata.
head(url, **kwargs)Sends a HEAD request.
initialize_retry([total, connect, ...])Set the session retry policy.
is_admin()Check if the current user has admin privileges.
merge_environment_settings(url, proxies, ...)Check the environment and merge it with some settings.
mount(prefix, adapter)Registers a connection adapter to a prefix.
options(url, **kwargs)Send an OPTIONS request.
patch(url[, data])Sends a PATCH request.
post(url[, data, json])Sends a POST request.
prepare_request(request)Constructs a
PreparedRequestfor transmission and returns it.put(url[, data])Sends a PUT request.
rebuild_auth(prepared_request, response)Also drop the client tokens on a redirect hop away from this API's origin.
rebuild_method(prepared_request, response)When being redirected we may want to change the method of the request based on certain specs or browser behavior.
rebuild_proxies(prepared_request, proxies)This method re-evaluates the proxy configuration by considering the environment variables.
refresh_access_token()Extend the session's access token by 24 hours.
request(method, url, *args, **kwargs)Construct, prepare, and send a
Request.resolve_redirects(resp, req[, stream, ...])Receives a Response.
save_config([verify, overwrite])Create or update qbraidrc file.
send(request, **kwargs)Send a prepared request, unless it is a redirect hop marked as refused.
should_strip_auth(old_url, new_url)Strip credentials on any redirect that leaves the original origin.
Attributes
access_tokenReturn the access token.
api_keyReturn the api key.
base_urlReturn the base URL.
headersA case-insensitive dictionary of headers to be sent on each
Requestsent from thisSession.authDefault Authentication tuple or object to attach to
Request.proxiesDictionary mapping protocol or protocol and host to the URL of the proxy (e.g. {'http': 'foo.bar:3128', 'http://host.name': 'foo.bar:4012'}) to be used on each
Request.hooksEvent-handling hooks.
paramsDictionary of querystring data to attach to each
Request.streamStream response content default.
verifySSL Verification default.
certSSL client certificate default, if String, path to ssl client cert file (.pem).
max_redirectsMaximum number of redirects allowed.
trust_envTrust environment settings for proxy configuration, default authentication and similar.
cookiesA CookieJar containing all currently outstanding cookies set on this session.
adapters