openedx.core.lib.blockstore_api package#
Subpackages#
Submodules#
openedx.core.lib.blockstore_api.db_routers module#
Blockstore database router.
Blockstore started life as an IDA, but is now a Django app plugin within edx-platform. This router exists to smooth blockstore’s transition into edxapp.
- class openedx.core.lib.blockstore_api.db_routers.BlockstoreRouter#
Bases:
objectA Database Router that uses the
blockstoredatabase, if it’s configured in settings.- DATABASE_NAME = 'blockstore'#
- ROUTE_APP_LABELS = {'bundles'}#
- allow_migrate(db, app_label, model_name=None, **hints)#
Ensure the blockstore tables only appear in the blockstore database.
- allow_relation(obj1, obj2, **hints)#
Allow relations if both objects are blockstore app models.
- db_for_read(model, **hints)#
Use the BlockstoreRouter.DATABASE_NAME when reading blockstore app tables.
- db_for_write(model, **hints)#
Use the BlockstoreRouter.DATABASE_NAME when writing to blockstore app tables.
openedx.core.lib.blockstore_api.methods module#
API Client methods for working with Blockstore bundles and drafts
- openedx.core.lib.blockstore_api.methods.api_request(method, url, **kwargs)#
Helper method for making a request to the Blockstore REST API
- openedx.core.lib.blockstore_api.methods.api_url(*path_parts)#
- openedx.core.lib.blockstore_api.methods.commit_draft(draft_uuid)#
Commit all of the pending changes in the draft, creating a new version of the associated bundle.
Does not return any value.
- openedx.core.lib.blockstore_api.methods.create_bundle(collection_uuid, slug, title='New Bundle', description='')#
Create a new bundle.
Note that description is currently required.
- openedx.core.lib.blockstore_api.methods.create_collection(title)#
Create a new collection.
- openedx.core.lib.blockstore_api.methods.delete_bundle(bundle_uuid)#
Delete a bundle
- openedx.core.lib.blockstore_api.methods.delete_collection(collection_uuid)#
Delete a collection
- openedx.core.lib.blockstore_api.methods.delete_draft(draft_uuid)#
Delete the specified draft, removing any staged changes/files/deletes.
Does not return any value.
- openedx.core.lib.blockstore_api.methods.force_browser_url(blockstore_file_url)#
Ensure that the given devstack URL is a URL accessible from the end user’s browser.
- openedx.core.lib.blockstore_api.methods.get_bundle(bundle_uuid)#
Retrieve metadata about the specified bundle
Raises BundleNotFound if the bundle does not exist
- openedx.core.lib.blockstore_api.methods.get_bundle_file_data(bundle_uuid, path, use_draft=None)#
Read all the data in the given bundle file and return it as a binary string.
Do not use this for large files!
- openedx.core.lib.blockstore_api.methods.get_bundle_file_metadata(bundle_uuid, path, use_draft=None)#
Get the metadata of the specified file.
- openedx.core.lib.blockstore_api.methods.get_bundle_files(bundle_uuid, use_draft=None)#
Get an iterator over all the files in the specified bundle or draft.
- openedx.core.lib.blockstore_api.methods.get_bundle_files_dict(bundle_uuid, use_draft=None)#
Get a dict of all the files in the specified bundle.
Returns a dict where the keys are the paths (strings) and the values are BundleFileData or DraftFileData tuples.
- openedx.core.lib.blockstore_api.methods.get_bundle_links(bundle_uuid, use_draft=None)#
Get a dict of all the links in the specified bundle.
Returns a dict where the keys are the link names (strings) and the values are BundleLinkData or DraftLinkData tuples.
- openedx.core.lib.blockstore_api.methods.get_bundle_version(bundle_uuid, version_number)#
Get the details of the specified bundle version
- openedx.core.lib.blockstore_api.methods.get_bundle_version_files(bundle_uuid, version_number)#
Get a list of the files in the specified bundle version
- openedx.core.lib.blockstore_api.methods.get_bundle_version_links(bundle_uuid, version_number)#
Get a dictionary of the links in the specified bundle version
- openedx.core.lib.blockstore_api.methods.get_bundles(uuids=None, text_search=None)#
Get the details of all bundles
- openedx.core.lib.blockstore_api.methods.get_collection(collection_uuid)#
Retrieve metadata about the specified collection
Raises CollectionNotFound if the collection does not exist
- openedx.core.lib.blockstore_api.methods.get_draft(draft_uuid)#
Retrieve metadata about the specified draft. If you don’t know the draft’s UUID, look it up using get_bundle()
- openedx.core.lib.blockstore_api.methods.get_or_create_bundle_draft(bundle_uuid, draft_name)#
Retrieve metadata about the specified draft.
- openedx.core.lib.blockstore_api.methods.set_draft_link(draft_uuid, link_name, bundle_uuid, version)#
Create or replace the link with the given name in the specified draft so that it points to the specified bundle version. To delete a link, pass bundle_uuid=None, version=None.
If you don’t know the draft’s UUID, look it up using get_or_create_bundle_draft()
Does not return anything.
- openedx.core.lib.blockstore_api.methods.toggle_blockstore_api(func)#
Decorator function to toggle usage of the Blockstore service and the in-built Blockstore app dependency.
- openedx.core.lib.blockstore_api.methods.update_bundle(bundle_uuid, **fields)#
Update a bundle’s title, description, slug, or collection.
- openedx.core.lib.blockstore_api.methods.update_collection(collection_uuid, title)#
Update a collection’s title
- openedx.core.lib.blockstore_api.methods.write_draft_file(draft_uuid, path, contents)#
Create or overwrite the file at ‘path’ in the specified draft with the given contents. To delete a file, pass contents=None.
If you don’t know the draft’s UUID, look it up using get_or_create_bundle_draft()
Does not return anything.
Module contents#
API Client for Blockstore
This API does not do any caching; consider using BundleCache or (in openedx.core.djangolib.blockstore_cache) together with these API methods for improved performance.