Skip to content

Commit 61ae742

Browse files
authored
Merge pull request #143 from Kinto/119-parameters3
Make the update_* methods more consistent.
2 parents 9ce74a6 + 0c5be02 commit 61ae742

File tree

8 files changed

+444
-393
lines changed

8 files changed

+444
-393
lines changed

.travis.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
11
language: python
2-
python: 2.7
3-
addons:
4-
apt:
5-
sources:
6-
- deadsnakes # source required so it finds the package definition below
7-
packages:
8-
- python3.5
9-
- python3.5-dev
2+
python: 3.5
103
env:
11-
- TOX_ENV=py27
12-
- TOX_ENV=py34
134
- TOX_ENV=py35
145
- TOX_ENV=py35 SERVER=development
15-
- TOX_ENV=flake8
166
before_install:
17-
- VIRTUAL_ENV=.venv make VIRTUALENV="virtualenv --python python3.5" install-dev
18-
- VIRTUAL_ENV=.venv make VIRTUALENV="virtualenv --python python3.5" runkinto &
19-
- if [[ $SERVER == development ]]; then .venv/bin/pip install https://github.com/Kinto/kinto/tarball/master; fi
7+
- make install-dev
8+
- make runkinto &
9+
- if [[ $SERVER == development ]]; then pip install https://github.com/Kinto/kinto/tarball/master; fi
2010
install:
2111
- pip install tox
2212
script:
@@ -25,3 +15,13 @@ after_success:
2515
# Report coverage results to coveralls.io
2616
- pip install coveralls
2717
- coveralls
18+
matrix:
19+
include:
20+
- python: 3.6
21+
env: TOX_ENV=py36
22+
- python: 3.6
23+
env: TOX_ENV=py36 SERVER=development
24+
- env:
25+
- TOX_ENV=flake8
26+
before_install:
27+
- python --version

CHANGELOG.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ This document describes changes between each past release.
77
7.3.0 (unreleased)
88
==================
99

10+
**Breaking changes**
11+
12+
- Make client methods API consistent by forcing keyword parameters (#119)
13+
- Deduce the ``id`` of a resource with the value of ``id`` in ``data`` if present (#143)
14+
- Drop Python 2.7 support. Now supports Python 3.5+
15+
1016
**New Features**
1117

1218
- Keep tracks of Backoff headers and raise an ``BackoffException`` if

README.rst

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -136,25 +136,25 @@ If no specific bucket name is provided, the "default" bucket is used.
136136
auth=credentials)
137137
138138
# To create a bucket.
139-
client.create_bucket('payments')
139+
client.create_bucket(id='payments')
140140
141141
# To get an existing bucket
142-
bucket = client.get_bucket('payments')
142+
bucket = client.get_bucket(id='payments')
143143
144144
# Or retrieve all readable buckets.
145145
buckets = client.get_buckets()
146146
147147
# To create or replace an existing bucket.
148-
client.update_bucket('payments', data={'description': 'My payments data.'})
148+
client.update_bucket(id='payments', data={'description': 'My payments data.'})
149149
150150
# Or modify some fields in an existing bucket.
151-
client.patch_bucket('payments', data={'status': 'updated'})
151+
client.patch_bucket(id='payments', data={'status': 'updated'})
152152
153153
# It is also possible to manipulate bucket permissions (see later)
154-
client.patch_bucket('payments', permissions={})
154+
client.patch_bucket(id='payments', permissions={})
155155
156156
# Or delete a bucket and everything under.
157-
client.delete_bucket('payment')
157+
client.delete_bucket(id='payment')
158158
159159
# Or even every writable buckets.
160160
client.delete_buckets()
@@ -168,22 +168,22 @@ A group associates a name to a list of principals. It is useful in order to hand
168168
.. code-block:: python
169169
170170
# To create a group.
171-
client.create_group('receipts', bucket='payments', data={'members': ['blah', 'foo']})
171+
client.create_group(id='receipts', bucket='payments', data={'members': ['blah', 'foo']})
172172
173173
# Or get an existing one.
174-
group = client.get_group('receipts', bucket='payments')
174+
group = client.get_group(id='receipts', bucket='payments')
175175
176176
# Or retrieve all groups in the bucket.
177177
groups = client.get_groups(bucket='payments')
178178
179179
# To create or replace an existing bucket.
180-
client.update_group('receipts', bucket='payments', data={'members': ['foo']})
180+
client.update_group(id='receipts', bucket='payments', data={'members': ['foo']})
181181
182182
# Or modify some fields in an existing group.
183-
client.patch_group('receipts', bucket='payments', data={'description': 'my group'})
183+
client.patch_group(id='receipts', bucket='payments', data={'description': 'my group'})
184184
185185
# To delete an existing group.
186-
client.delete_group('receipts', bucket='payments')
186+
client.delete_group(id='receipts', bucket='payments')
187187
188188
# Or all groups in a bucket.
189189
client.delete_groups(bucket='payments')
@@ -197,22 +197,22 @@ A collection is where records are stored.
197197
.. code-block:: python
198198
199199
# To create a collection.
200-
client.create_collection('receipts', bucket='payments')
200+
client.create_collection(id='receipts', bucket='payments')
201201
202202
# Or get an existing one.
203-
collection = client.get_collection('receipts', bucket='payments')
203+
collection = client.get_collection(id='receipts', bucket='payments')
204204
205205
# Or retrieve all of them inside a bucket.
206206
collections = client.get_collections(bucket='payments')
207207
208208
# To create or replace an exiting collection.
209-
client.update_collection(bucket='payments', data={'description':'bleeh'})
209+
client.update_collection(id='receipts', bucket='payments', data={'description':'bleeh'})
210210
211211
# Or modify some fields of an existing collection.
212-
client.patch_collection(bucket='payments', data={'status':'updated'})
212+
client.patch_collection(id='receipts', bucket='payments', data={'status':'updated'})
213213
214214
# To delete an existing collection.
215-
client.delete_collection('receipts', bucket='payments')
215+
client.delete_collection(id='receipts', bucket='payments')
216216
217217
# Or every collections in a bucket.
218218
client.delete_collections(bucket='payments')
@@ -236,7 +236,7 @@ A record is a dict with the "permissions" and "data" keys.
236236
collection='todos', bucket='default')
237237
238238
# Or get an existing one by its id.
239-
record = client.get_record('todo2', collection='todos', bucket='default')
239+
record = client.get_record(id='todo2', collection='todos', bucket='default')
240240
241241
# Or retrieve all records.
242242
records = client.get_records(collection='todos', bucket='default')
@@ -245,16 +245,13 @@ A record is a dict with the "permissions" and "data" keys.
245245
records_timestamp = client.get_records_timestamp(collection='todos', bucket='default')
246246
247247
# To replace a record using a previously fetched record
248-
client.update_record(record, collection='todos', bucket='default')
248+
client.update_record(data=record, collection='todos', bucket='default')
249249
250250
# Or create or replace it by its id.
251-
client.update_record({'status': 'unknown'}, id='todo2', collection='todos', bucket='default')
251+
client.update_record(data={'status': 'unknown'}, id='todo2', collection='todos', bucket='default')
252252
253253
# Or modify some fields in an existing record.
254-
client.patch_record({'assignee': 'bob'}, id='todo2', collection='todos', bucket='default')
255-
256-
# Or update multiple records at once.
257-
client.update_records(records, collection='todos')
254+
client.patch_record(data={'assignee': 'bob'}, id='todo2', collection='todos', bucket='default')
258255
259256
# To delete an existing record.
260257
client.delete_record(id='89881454-e4e9-4ef0-99a9-404d95900352',
@@ -302,7 +299,7 @@ In some cases, you might want to create a bucket, collection, group or record on
302299
it doesn't exist already. To do so, you can pass the ``if_not_exists=True``
303300
to the ``create_*`` methods::
304301

305-
client.create_bucket('bucket', if_not_exists=True)
302+
client.create_bucket(id='bucket', if_not_exists=True)
306303

307304
Delete
308305
------
@@ -311,7 +308,7 @@ In some cases, you might want to delete a bucket, collection, group or record on
311308
it exists already. To do so, you can pass the ``if_exists=True``
312309
to the ``delete_*`` methods::
313310

314-
client.delete_bucket('bucket', if_exists=True)
311+
client.delete_bucket(id='bucket', if_exists=True)
315312

316313
Overwriting existing objects
317314
----------------------------

0 commit comments

Comments
 (0)