tiled.client.context.Context

class tiled.client.context.Context(uri, *, headers=None, api_key=None, cache=None, offline=False, timeout=None, verify=True, token_cache=None, app=None, raise_server_exceptions=True)[source]

Wrap an httpx.Client with an optional cache and authentication functionality.

__init__(uri, *, headers=None, api_key=None, cache=None, offline=False, timeout=None, verify=True, token_cache=None, app=None, raise_server_exceptions=True)[source]

Methods

__init__(uri, *[, headers, api_key, cache, ...])

authenticate([username, provider, ...])

See login.

close()

create_api_key([scopes, expires_in, note])

Generate a new API for the currently-authenticated user.

delete_content(path, content[, headers, params])

disable_cache([allow_read, allow_write])

force_auth_refresh()

Execute refresh flow.

from_any_uri(uri, *[, headers, api_key, ...])

Accept a URI to a specific node.

from_app(app, *[, cache, offline, ...])

Construct a Context around a FastAPI app.

get_content(path[, accept, stream, revalidate])

get_json(path[, stream])

login([username, provider])

Depending on the server's authentication method, this will prompt for username/password:

logout()

Log out of the current session (if any).

post_json(path, content)

put_content(path, content[, headers, params])

put_json(path, content)

revalidation(revalidate)

Temporarily change the 'revalidate' property in a context.

revoke_api_key(first_eight)

revoke_session(session_id)

Revoke a Session so it cannot be refreshed.

which_api_key()

A 'who am I' for API keys

whoami()

Return information about the currently-authenticated user or service.

Attributes

api_key

app

base_url

cache

event_hooks

httpx.Client event hooks.

offline

revalidate

This controls how aggressively to check whether cache entries are out of date.

tokens

A view of the current access and refresh tokens.