@@ -16,8 +16,7 @@ pip install metabase-python
1616This API is still experimental and may change significantly between minor versions.
1717
1818
19- Start by creating an instance of Metabase with your credentials. This connection will automatically be used by any
20- object that interacts with the Metabase API.
19+ Start by creating an instance of Metabase with your credentials.
2120``` python
2221from metabase import Metabase
2322
@@ -28,17 +27,18 @@ metabase = Metabase(
2827)
2928```
3029
31- You can then interact with any of the supported endpoints through the classes included in this package. All changes
32- are reflected in Metabase instantly.
30+ You can then interact with any of the supported endpoints through the classes included in this package. Methods that
31+ instantiate an object from the Metabase API require the ` using ` parameter which expects an instance of ` Metabase ` such
32+ as the one we just instantiated above. All changes are reflected in Metabase instantly.
3333
3434``` python
3535from metabase import User
3636
3737# get all objects
38- users = User.list()
38+ users = User.list(using = metabase )
3939
4040# get an object by ID
41- user = User.get(1 )
41+ user = User.get(1 , using = metabase )
4242
4343# attributes are automatically loaded and available in the instance
4444if user.is_active:
@@ -52,6 +52,7 @@ user.delete()
5252
5353# create an object
5454new_user = User.create(
55+ using = metabase,
5556 first_name = " <first_name>" ,
5657 last_name = " <last_name>" ,
5758 email = " <email>" ,
@@ -67,7 +68,7 @@ Some endpoints also support additional methods:
6768``` python
6869from metabase import User
6970
70- user = User.get(1 )
71+ user = User.get(1 , using = metabase )
7172
7273user.reactivate() # Reactivate user
7374user.send_invite() # Resend the user invite email for a given user.
@@ -78,11 +79,12 @@ Here's a slightly more advanced example:
7879from metabase import User, PermissionGroup, PermissionMembership
7980
8081# create a new PermissionGroup
81- my_group = PermissionGroup.create(name = " My Group" )
82+ my_group = PermissionGroup.create(name = " My Group" , using = metabase )
8283
8384for user in User.list():
8485 # add all users to my_group
8586 PermissionMembership.create(
87+ using = metabase,
8688 group_id = my_group.id,
8789 user_id = user.id
8890 )
@@ -94,6 +96,7 @@ the exact MBQL (i.e. Metabase Query Language) as the `query` argument.
9496from metabase import Dataset
9597
9698dataset = Dataset.create(
99+ using.metabase,
97100 database = 1 ,
98101 type = " query" ,
99102 query = {
0 commit comments