Skip to content

Commit 8c2ee4a

Browse files
author
Charles Larivier
committed
docs(README): add new using parameter in .list(), .get() and .create() methods
Signed-off-by: Charles Larivier <charles@dribbble.com>
1 parent 0d6c30a commit 8c2ee4a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ pip install metabase-python
1616
This 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
2221
from 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
3535
from 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
4444
if user.is_active:
@@ -52,6 +52,7 @@ user.delete()
5252

5353
# create an object
5454
new_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
6869
from metabase import User
6970

70-
user = User.get(1)
71+
user = User.get(1, using=metabase)
7172

7273
user.reactivate() # Reactivate user
7374
user.send_invite() # Resend the user invite email for a given user.
@@ -78,11 +79,12 @@ Here's a slightly more advanced example:
7879
from 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

8384
for 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.
9496
from metabase import Dataset
9597

9698
dataset = Dataset.create(
99+
using.metabase,
97100
database=1,
98101
type="query",
99102
query={

0 commit comments

Comments
 (0)