Skip to content

Commit a5ac068

Browse files
Merge pull request Backblaze#274 from reef-technologies/apiver-v2
Apiver v2
2 parents 6c82a85 + 9b281c6 commit a5ac068

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+370
-398
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Changed
10+
* apiver `v2` interface released. `from b2sdk.v2 import ...` is now the recommended import,
11+
but `from b2sdk.v1 import ...` works as before
12+
913
## [1.10.0] - 2021-06-23
1014

1115
### Added

b2sdk/account_info/abstract.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def save_bucket(self, bucket):
7373
"""
7474
Remember the ID for the given bucket name.
7575
76-
:param b2sdk.v1.Bucket bucket: a Bucket object
76+
:param b2sdk.v2.Bucket bucket: a Bucket object
7777
"""
7878

7979
@abstractmethod
@@ -129,7 +129,7 @@ def is_same_account(self, account_id: str, realm: str) -> bool:
129129
@abstractmethod
130130
def get_account_id(self):
131131
"""
132-
Return account ID or raises :class:`~b2sdk.v1.exception.MissingAccountData` exception.
132+
Return account ID or raises :class:`~b2sdk.v2.exception.MissingAccountData` exception.
133133
134134
:rtype: str
135135
"""
@@ -145,39 +145,39 @@ def get_application_key_id(self):
145145
@abstractmethod
146146
def get_account_auth_token(self):
147147
"""
148-
Return account_auth_token or raises :class:`~b2sdk.v1.exception.MissingAccountData` exception.
148+
Return account_auth_token or raises :class:`~b2sdk.v2.exception.MissingAccountData` exception.
149149
150150
:rtype: str
151151
"""
152152

153153
@abstractmethod
154154
def get_api_url(self):
155155
"""
156-
Return api_url or raises :class:`~b2sdk.v1.exception.MissingAccountData` exception.
156+
Return api_url or raises :class:`~b2sdk.v2.exception.MissingAccountData` exception.
157157
158158
:rtype: str
159159
"""
160160

161161
@abstractmethod
162162
def get_application_key(self):
163163
"""
164-
Return application_key or raises :class:`~b2sdk.v1.exception.MissingAccountData` exception.
164+
Return application_key or raises :class:`~b2sdk.v2.exception.MissingAccountData` exception.
165165
166166
:rtype: str
167167
"""
168168

169169
@abstractmethod
170170
def get_download_url(self):
171171
"""
172-
Return download_url or raises :class:`~b2sdk.v1.exception.MissingAccountData` exception.
172+
Return download_url or raises :class:`~b2sdk.v2.exception.MissingAccountData` exception.
173173
174174
:rtype: str
175175
"""
176176

177177
@abstractmethod
178178
def get_realm(self):
179179
"""
180-
Return realm or raises :class:`~b2sdk.v1.exception.MissingAccountData` exception.
180+
Return realm or raises :class:`~b2sdk.v2.exception.MissingAccountData` exception.
181181
182182
:rtype: str
183183
"""
@@ -213,7 +213,7 @@ def get_allowed(self):
213213
@abstractmethod
214214
def get_s3_api_url(self):
215215
"""
216-
Return s3_api_url or raises :class:`~b2sdk.v1.exception.MissingAccountData` exception.
216+
Return s3_api_url or raises :class:`~b2sdk.v2.exception.MissingAccountData` exception.
217217
218218
:rtype: str
219219
"""

b2sdk/account_info/upload_url_pool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def clear_for_key(self, key):
6868
class UrlPoolAccountInfo(AbstractAccountInfo):
6969
"""
7070
Implement part of :py:class:`AbstractAccountInfo` for upload URL pool management
71-
with a simple, key-value storage, such as :py:class:`b2sdk.v1.UploadUrlPool`.
71+
with a simple, key-value storage, such as :py:class:`b2sdk.v2.UploadUrlPool`.
7272
"""
7373
# staticmethod is necessary here to avoid the first argument binding to the first argument (like ``partial(fun, arg)``)
7474
BUCKET_UPLOAD_POOL_CLASS = staticmethod(

b2sdk/api.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(self, api, max_upload_workers=10, max_copy_workers=10):
5555
"""
5656
Initialize Services object using given session.
5757
58-
:param b2sdk.v1.B2Api api:
58+
:param b2sdk.v2.B2Api api:
5959
:param int max_upload_workers: a number of upload threads
6060
:param int max_copy_workers: a number of copy threads
6161
"""
@@ -72,7 +72,7 @@ class B2Api(metaclass=B2TraceMeta):
7272
"""
7373
Provide file-level access to B2 services.
7474
75-
While :class:`b2sdk.v1.B2RawHTTPApi` provides direct access to the B2 web APIs, this
75+
While :class:`b2sdk.v2.B2RawHTTPApi` provides direct access to the B2 web APIs, this
7676
class handles several things that simplify the task of uploading
7777
and downloading files:
7878
@@ -107,7 +107,7 @@ def __init__(
107107
Initialize the API using the given account info.
108108
109109
:param account_info: To learn more about Account Info objects, see here
110-
:class:`~b2sdk.v1.SqliteAccountInfo`
110+
:class:`~b2sdk.v2.SqliteAccountInfo`
111111
112112
:param cache: It is used by B2Api to cache the mapping between bucket name and bucket ids.
113113
default is :class:`~b2sdk.cache.DummyCache`
@@ -189,10 +189,10 @@ def create_bucket(
189189
:param dict bucket_info: additional bucket info to store with the bucket
190190
:param dict cors_rules: bucket CORS rules to store with the bucket
191191
:param dict lifecycle_rules: bucket lifecycle rules to store with the bucket
192-
:param b2sdk.v1.EncryptionSetting default_server_side_encryption: default server side encryption settings (``None`` if unknown)
192+
:param b2sdk.v2.EncryptionSetting default_server_side_encryption: default server side encryption settings (``None`` if unknown)
193193
:param bool is_file_lock_enabled: boolean value specifies whether bucket is File Lock-enabled
194194
:return: a Bucket object
195-
:rtype: b2sdk.v1.Bucket
195+
:rtype: b2sdk.v2.Bucket
196196
"""
197197
account_id = self.account_info.get_account_id()
198198

@@ -269,7 +269,7 @@ def update_file_legal_hold(
269269
def get_bucket_by_id(self, bucket_id: str) -> Bucket:
270270
"""
271271
Return the Bucket matching the given bucket_id.
272-
:raises b2sdk.v1.exception.NonExistentBucket: if the bucket does not exist in the account
272+
:raises b2sdk.v2.exception.BucketIdNotFound: if the bucket does not exist in the account
273273
"""
274274
# Give a useful warning if the current application key does not
275275
# allow access to bucket.
@@ -294,8 +294,8 @@ def get_bucket_by_name(self, bucket_name):
294294
295295
:param str bucket_name: the name of the bucket to return
296296
:return: a Bucket object
297-
:rtype: b2sdk.v1.Bucket
298-
:raises b2sdk.v1.exception.NonExistentBucket: if the bucket does not exist in the account
297+
:rtype: b2sdk.v2.Bucket
298+
:raises b2sdk.v2.exception.NonExistentBucket: if the bucket does not exist in the account
299299
"""
300300
# Give a useful warning if the current application key does not
301301
# allow access to the named bucket.
@@ -318,7 +318,7 @@ def delete_bucket(self, bucket):
318318
"""
319319
Delete a chosen bucket.
320320
321-
:param b2sdk.v1.Bucket bucket: a :term:`bucket` to delete
321+
:param b2sdk.v2.Bucket bucket: a :term:`bucket` to delete
322322
:rtype: None
323323
"""
324324
account_id = self.account_info.get_account_id()
@@ -336,7 +336,7 @@ def list_buckets(self, bucket_name=None, bucket_id=None):
336336
337337
:param str bucket_name: the name of the one bucket to return
338338
:param str bucket_id: the ID of the one bucket to return
339-
:rtype: list[b2sdk.v1.Bucket]
339+
:rtype: list[b2sdk.v2.Bucket]
340340
"""
341341
# Give a useful warning if the current application key does not
342342
# allow access to the named bucket.
@@ -367,7 +367,7 @@ def list_buckets(self, bucket_name=None, bucket_id=None):
367367

368368
def list_parts(self, file_id, start_part_number=None, batch_size=None):
369369
"""
370-
Generator that yields a :py:class:`b2sdk.v1.Part` for each of the parts that have been uploaded.
370+
Generator that yields a :py:class:`b2sdk.v2.Part` for each of the parts that have been uploaded.
371371
372372
:param str file_id: the ID of the large file that is not finished
373373
:param int start_part_number: the first part number to return; defaults to the first part
@@ -507,9 +507,9 @@ def check_bucket_name_restrictions(self, bucket_name: str):
507507
Check to see if the allowed field from authorize-account has a bucket restriction.
508508
509509
If it does, checks if the bucket_name for a given api call matches that.
510-
If not, it raises a :py:exc:`b2sdk.v1.exception.RestrictedBucket` error.
510+
If not, it raises a :py:exc:`b2sdk.v2.exception.RestrictedBucket` error.
511511
512-
:raises b2sdk.v1.exception.RestrictedBucket: if the account is not allowed to use this bucket
512+
:raises b2sdk.v2.exception.RestrictedBucket: if the account is not allowed to use this bucket
513513
"""
514514
self._check_bucket_restrictions('bucketName', bucket_name)
515515

@@ -518,9 +518,9 @@ def check_bucket_id_restrictions(self, bucket_id: str):
518518
Check to see if the allowed field from authorize-account has a bucket restriction.
519519
520520
If it does, checks if the bucket_id for a given api call matches that.
521-
If not, it raises a :py:exc:`b2sdk.v1.exception.RestrictedBucket` error.
521+
If not, it raises a :py:exc:`b2sdk.v2.exception.RestrictedBucket` error.
522522
523-
:raises b2sdk.v1.exception.RestrictedBucket: if the account is not allowed to use this bucket
523+
:raises b2sdk.v2.exception.RestrictedBucket: if the account is not allowed to use this bucket
524524
"""
525525
self._check_bucket_restrictions('bucketId', bucket_id)
526526

0 commit comments

Comments
 (0)