Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Commit 43254c7

Browse files
authored
Add migration guide (#488)
* Added migration guide to cloudant-python-sdk library * Updated README with migration guide section
1 parent f21e190 commit 43254c7

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

MIGRATION.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Migrating to the `cloudant-python-sdk` library
2+
This document is to assist in migrating from the `python-cloudant` (module: `cloudant`) to the newly supported [`cloudant-python-sdk`](https://github.com/IBM/cloudant-python-sdk) (module: `ibmcloudant`).
3+
4+
## Initializing the client connection
5+
There are several ways to create a client connection in `cloudant-python-sdk`:
6+
1. [Environment variables](https://github.com/IBM/cloudant-python-sdk#authentication-with-environment-variables)
7+
2. [External configuration file](https://github.com/IBM/cloudant-python-sdk#authentication-with-external-configuration)
8+
3. [Programmatically](https://github.com/IBM/cloudant-python-sdk#programmatic-authentication)
9+
10+
[See the README](https://github.com/IBM/cloudant-python-sdk#code-examples) for code examples on using environment variables.
11+
12+
## Other differences
13+
1. The `cloudant-python-sdk` library does not support local dictionary caching of database and document objects.
14+
1. There are no context managers in `cloudant-python-sdk`. To reproduce the behaviour of the `python-cloudant`
15+
context managers in `cloudant-python-sdk` users need to explicitly call the specific operations against the
16+
remote HTTP API. For example, in the case of the document context manager, this would mean doing both a `get_document`
17+
to fetch and a `put_document` to save.
18+
1. In `cloudant-python-sdk` View, Search, and Query (aka `_find` endpoint) operation responses contain raw JSON
19+
content like using `raw_result=True` in `python-cloudant`.
20+
21+
## Request mapping
22+
Here's a list of the top 5 most frequently used `python-cloudant` operations and the `cloudant-python-sdk` equivalent API operation documentation link:
23+
24+
| `python-cloudant` operation | `cloudant-python-sdk` API operation documentation link |
25+
|---------------------------------------|---------------------------------|
26+
|`Document('db_name', 'docid').fetch()` |[`getDocument`](https://cloud.ibm.com/apidocs/cloudant?code=python#getdocument)|
27+
|`db.get_view_result()` |[`postView`](https://cloud.ibm.com/apidocs/cloudant?code=python#postview)|
28+
|`db.get_query_result()` |[`postFind`](https://cloud.ibm.com/apidocs/cloudant?code=python#postfind)|
29+
| `doc.exists()` |[`headDocument`](https://cloud.ibm.com/apidocs/cloudant?code=python#headdocument)|
30+
|`Document('db_name', 'docid').save()` |[`putDocument`](https://cloud.ibm.com/apidocs/cloudant?code=python#putdocument)|
31+
32+
33+
[A table](#reference-table) with the whole list of operations is provided at the end of this guide.
34+
35+
The `cloudant-python-sdk` library is generated from a more complete API spec and provides a significant number of operations that do not exist in `python-cloudant`. See [the IBM Cloud API Documentation](https://cloud.ibm.com/apidocs/cloudant) to review request parameter and body options, code examples, and additional details for every endpoint.
36+
37+
## Known Issues
38+
There's an [outline of known issues](https://github.com/IBM/cloudant-python-sdk/blob/master/KNOWN_ISSUES.md) in the `cloudant-python-sdk` repository.
39+
40+
## Reference table
41+
The table below contains a list of `python-cloudant` functions and the `cloudant-python-sdk` equivalent API operation documentation link. The `cloudant-python-sdk` operation documentation link will contain the new function in a code sample e.g. `getServerInformation` link will contain a code example with `get_server_information()`.
42+
43+
**Note:** There are many API operations included in the new `cloudant-python-sdk` that are not available in the `python-cloudant` library. The [API documentation](https://cloud.ibm.com/apidocs/cloudant?code=python) contains the full list of operations.
44+
45+
| `python-cloudant` function | `cloudant-python-sdk` API operation documentation link |
46+
|-----------------|---------------------|
47+
|`metadata()`|[getServerInformation](https://cloud.ibm.com/apidocs/cloudant?code=python#getserverinformation)|
48+
|`all_dbs()`|[getAllDbs](https://cloud.ibm.com/apidocs/cloudant?code=python#getalldbs)|
49+
|`db_updates()/infinite_db_updates()`|[getDbUpdates](https://cloud.ibm.com/apidocs/cloudant?code=python#getdbupdates)|
50+
|`Replicator.create_replication()`|[postReplicate](https://cloud.ibm.com/apidocs/cloudant?code=python#postreplicate)|
51+
|`Scheduler.get_doc()`|[getSchedulerDocument](https://cloud.ibm.com/apidocs/cloudant?code=python#getschedulerdocument)|
52+
|`Scheduler.list_jobs()`|[getSchedulerJobs](https://cloud.ibm.com/apidocs/cloudant?code=python#getschedulerjobs)|
53+
|`session()`|[getSessionInformation](https://cloud.ibm.com/apidocs/cloudant?code=python#getsessioninformation)|
54+
|`uuids()`|[getUuids](https://cloud.ibm.com/apidocs/cloudant?code=python#getuuids)|
55+
|`db.delete()`|[deleteDatabase](https://cloud.ibm.com/apidocs/cloudant?code=python#deletedatabase)|
56+
|`db.metadata()`|[getDatabaseInformation](https://cloud.ibm.com/apidocs/cloudant?code=python#getdatabaseinformation)|
57+
|`db.create_document()`|[postDocument](https://cloud.ibm.com/apidocs/cloudant?code=python#postdocument)|
58+
|`db.create()`|[putDatabase](https://cloud.ibm.com/apidocs/cloudant?code=python#putdatabase)|
59+
|`db.all_docs()/db.keys()`|[postAllDocs](https://cloud.ibm.com/apidocs/cloudant?code=python#postalldocs)|
60+
|`db.bulk_docs()`|[postBulkDocs](https://cloud.ibm.com/apidocs/cloudant?code=python#postbulkdocs)|
61+
|`db.changes()/db.infinite_changes()`|[postChanges](https://cloud.ibm.com/apidocs/cloudant?code=python#postchanges)|
62+
|`DesignDocument(db, '_design/doc').delete()`|[deleteDesignDocument](https://cloud.ibm.com/apidocs/cloudant?code=python#deletedesigndocument)|
63+
|`db.get_design_document()/DesignDocument(db, '_design/doc').fetch()`|[getDesignDocument](https://cloud.ibm.com/apidocs/cloudant?code=python#getdesigndocument)|
64+
|`DesignDocument(db, '_design/doc').save()`|[putDesignDocument](https://cloud.ibm.com/apidocs/cloudant?code=python#putdesigndocument)|
65+
|`DesignDocument(db, '_design/doc').info()`|[getDesignDocumentInformation](https://cloud.ibm.com/apidocs/cloudant?code=python#getdesigndocumentinformation)|
66+
|`db.get_search_result()`|[postSearch](https://cloud.ibm.com/apidocs/cloudant?code=python#postsearch)|
67+
|`db.get_view_result()`|[postView](https://cloud.ibm.com/apidocs/cloudant?code=python#postview)|
68+
|`db.list_design_documents()`|[postDesignDocs](https://cloud.ibm.com/apidocs/cloudant?code=python#postdesigndocs)|
69+
|`db.get_query_result()`|[postFind](https://cloud.ibm.com/apidocs/cloudant?code=python#postfind)|
70+
|`db.get_query_indexes()`|[getIndexesInformation](https://cloud.ibm.com/apidocs/cloudant?code=python#getindexesinformation)|
71+
|`db.create_query_index()`|[postIndex](https://cloud.ibm.com/apidocs/cloudant?code=python#postindex)|
72+
|`db.delete_query_index()`|[deleteIndex](https://cloud.ibm.com/apidocs/cloudant?code=python#deleteindex)|
73+
|`Document(db, 'docid').delete()`|[getLocalDocument](https://cloud.ibm.com/apidocs/cloudant?code=python#getlocaldocument)|
74+
|`Document(db, 'docid').create()`|[putLocalDocument](https://cloud.ibm.com/apidocs/cloudant?code=python#putlocaldocument)|
75+
|`db.missing_revisions()`|[postMissingRevs](https://cloud.ibm.com/apidocs/cloudant?code=python#postmissingrevs)|
76+
|`db.partition_metadata()`|[getPartitionInformation](https://cloud.ibm.com/apidocs/cloudant?code=python#getpartitioninformation)|
77+
|`db.partitioned_all_docs()`|[postPartitionAllDocs](https://cloud.ibm.com/apidocs/cloudant?code=python#postpartitionalldocs)|
78+
|`db.get_partitioned_search_result()`|[postPartitionSearch](https://cloud.ibm.com/apidocs/cloudant?code=python#postpartitionsearch)|
79+
|`db.get_partitioned_view_result()`|[postPartitionView](https://cloud.ibm.com/apidocs/cloudant?code=python#postpartitionview)|
80+
|`db.get_partitioned_query_result()`|[postPartitionFind](https://cloud.ibm.com/apidocs/cloudant?code=python#postpartitionfind)|
81+
|`db.revisions_diff()`|[postRevsDiff](https://cloud.ibm.com/apidocs/cloudant?code=python#postrevsdiff)|
82+
|`db.get_security_document()/db.security_document()`|[getSecurity](https://cloud.ibm.com/apidocs/cloudant?code=python#getsecurity)|
83+
|`db.share_database()`|[putSecurity](https://cloud.ibm.com/apidocs/cloudant?code=python#putsecurity)|
84+
|`db.shards()`|[getShardsInformation](https://cloud.ibm.com/apidocs/cloudant?code=python#getshardsinformation)|
85+
|`Document(db, 'docid').delete()`|[getLocalDocument](https://cloud.ibm.com/apidocs/cloudant?code=python#getlocaldocument)|
86+
|`Document(db, 'docid').fetch()`|[getDocument](https://cloud.ibm.com/apidocs/cloudant?code=python#getdocument)|
87+
|`Document(db, 'docid').exists()`|[headDocument](https://cloud.ibm.com/apidocs/cloudant?code=python#headdocument)|
88+
|`Document(db, 'docid').save()`|[putDocument](https://cloud.ibm.com/apidocs/cloudant?code=python#putdocument)|
89+
|`Document(db, 'docid').delete_attachment()`|[deleteAttachment](https://cloud.ibm.com/apidocs/cloudant?code=python#deleteattachment)|
90+
|`Document(db, 'docid').get_attachment()`|[getAttachment](https://cloud.ibm.com/apidocs/cloudant?code=python#getattachment)|
91+
|`Document(db, 'docid').put_attachment()`|[putAttachment](https://cloud.ibm.com/apidocs/cloudant?code=python#putattachment)|
92+
|`generate_api_key()`|[postApiKeys](https://cloud.ibm.com/apidocs/cloudant?code=python#postapikeys)|
93+
|`SecurityDocument().save()`|[putCloudantSecurityConfiguration](https://cloud.ibm.com/apidocs/cloudant?code=python#putcloudantsecurityconfiguration)|
94+
|`cors_configuration()/cors_origin()`|[getCorsInformation](https://cloud.ibm.com/apidocs/cloudant?code=python#getcorsinformation)|
95+
|`update_cors_configuration()`|[putCorsConfiguration](https://cloud.ibm.com/apidocs/cloudant?code=python#putcorsconfiguration)|

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This is the official Cloudant library for Python.
1717
* [Using in Other Projects](#using-in-other-projects)
1818
* [License](#license)
1919
* [Issues](#issues)
20+
* [Migrating to `cloudant-python-sdk` library](#migrating-to-cloudant-python-sdk-library)
2021

2122
## Installation and Usage
2223

@@ -87,3 +88,7 @@ to see if the problem has already been reported. Note that the default search
8788
includes only open issues, but it may already have been closed.
8889
* Cloudant customers should contact Cloudant support for urgent issues.
8990
* When opening a new issue [here in github](../../issues) please complete the template fully.
91+
92+
## Migrating to `cloudant-python-sdk` library
93+
We have a newly supported Cloudant Python SDK named [cloudant-python-sdk](https://github.com/IBM/cloudant-python-sdk).
94+
For advice on migrating from this module see [MIGRATION.md](MIGRATION.md).

0 commit comments

Comments
 (0)