diff --git a/README.md b/README.md index bc6ff73..458555c 100644 --- a/README.md +++ b/README.md @@ -16,8 +16,7 @@ pip install metabase-python This API is still experimental and may change significantly between minor versions. -Start by creating an instance of Metabase with your credentials. This connection will automatically be used by any -object that interacts with the Metabase API. +Start by creating an instance of Metabase with your credentials. ```python from metabase import Metabase @@ -28,17 +27,18 @@ metabase = Metabase( ) ``` -You can then interact with any of the supported endpoints through the classes included in this package. All changes -are reflected in Metabase instantly. +You can then interact with any of the supported endpoints through the classes included in this package. Methods that +instantiate an object from the Metabase API require the `using` parameter which expects an instance of `Metabase` such +as the one we just instantiated above. All changes are reflected in Metabase instantly. ```python from metabase import User # get all objects -users = User.list() +users = User.list(using=metabase) # get an object by ID -user = User.get(1) +user = User.get(1, using=metabase) # attributes are automatically loaded and available in the instance if user.is_active: @@ -52,6 +52,7 @@ user.delete() # create an object new_user = User.create( + using=metabase, first_name="", last_name="", email="", @@ -67,7 +68,7 @@ Some endpoints also support additional methods: ```python from metabase import User -user = User.get(1) +user = User.get(1, using=metabase) user.reactivate() # Reactivate user user.send_invite() # Resend the user invite email for a given user. @@ -78,11 +79,12 @@ Here's a slightly more advanced example: from metabase import User, PermissionGroup, PermissionMembership # create a new PermissionGroup -my_group = PermissionGroup.create(name="My Group") +my_group = PermissionGroup.create(name="My Group", using=metabase) for user in User.list(): # add all users to my_group PermissionMembership.create( + using=metabase, group_id=my_group.id, user_id=user.id ) @@ -94,6 +96,7 @@ the exact MBQL (i.e. Metabase Query Language) as the `query` argument. from metabase import Dataset dataset = Dataset.create( + using.metabase, database=1, type="query", query={