This is an asynchronous python client for metablock API.
This is a simple python package you can install via pip:
pip install metablock
Create the client
from metablock import Metablock
cli = Metablock()
# get the user associated with the API token
user = await cli.user.get()For the authentication token, you can use the METABLOCK_API_TOKEN environment variable,
alternatively, you can pass it to the client constructor:
cli = Metablock(auth_key="your-token")Most endpoints act within an organization, which is selected by the
x-metablock-org-id header rather than by the URL. Set it via the
METABLOCK_ORG_ID environment variable or pass it to the constructor:
cli = Metablock(auth_key="your-token", org_id="your-org-id")The client exposes a manager per resource. Managers hold the behaviour and
return plain data models, which are generated from the API's OpenAPI spec and
live in metablock.schema:
# spaces, blocks and extensions are scoped to the org set on the client
spaces = await cli.spaces.get_list()
space = await cli.spaces.get("my-space")
blocks = await cli.spaces.blocks(space.id)
block = await cli.blocks.get(block_id)
await cli.blocks.ship(block.id, "path/to/bundle.zip", env="prod")
extensions = await cli.org_extensions.get_list()
org = await cli.orgs.get("my-org")You can also use the client from the command line, to do so, install the package with the cli extra:
pip install metablock[cli]Then you can use the metablock command:
metablock --help