Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: Restructure package to accomodate both RPC and REST clients #995

Draft
wants to merge 60 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
db085e6
First commit
edgarrmondragon Sep 20, 2023
ae858b1
Tweak experimental API language
edgarrmondragon Sep 20, 2023
0ca58d3
XFail on 5.x
edgarrmondragon Sep 20, 2023
1178cc1
Do not try to create REST client in unsupported versions
edgarrmondragon Sep 20, 2023
615da6e
Implement survey detail
edgarrmondragon Sep 20, 2023
6f84092
Add unit tests
edgarrmondragon Sep 20, 2023
9501d17
Do not pull MarkupSafe binary for PyPy
edgarrmondragon Sep 20, 2023
5f36be5
Add missing test
edgarrmondragon Sep 20, 2023
026c697
Fix mypy
edgarrmondragon Sep 20, 2023
4051b8e
Use TypeAlias
edgarrmondragon Sep 20, 2023
3323ab9
Add context manager to REST client
edgarrmondragon Sep 20, 2023
48ab537
Add change file
edgarrmondragon Sep 20, 2023
0d930f4
Merge branch 'main' into feat/rest-api
edgarrmondragon Sep 20, 2023
5709d88
Skip docs for citric._rest.client
edgarrmondragon Sep 21, 2023
6ce6894
Move to citric.rest
edgarrmondragon Sep 21, 2023
f939fee
Abstract away request logic
edgarrmondragon Sep 21, 2023
6596774
refactor!: Restructure package to accomodate both RPC and REST clients
edgarrmondragon Sep 20, 2023
caf1505
Skip docs for deprecated modules
edgarrmondragon Sep 20, 2023
be86b23
Merge branch 'main' into feat/rest-api
edgarrmondragon Sep 26, 2023
d12a57e
Merge branch 'main' into feat/rest-api
edgarrmondragon Sep 26, 2023
e70274d
Merge branch 'main' into feat/rest-api
edgarrmondragon Oct 5, 2023
7f53369
Merge branch 'feat/rest-api' into break/restructure-package-both-clients
edgarrmondragon Oct 5, 2023
15727c4
[pre-commit.ci] auto fixes
pre-commit-ci[bot] Oct 5, 2023
d8aa57c
Update lockfile
edgarrmondragon Oct 6, 2023
fa387cc
Skip binary wheel for MarkupSafe in python 3.13
edgarrmondragon Oct 6, 2023
b1fe1df
Merge branch 'feat/rest-api' into break/restructure-package-both-clients
edgarrmondragon Oct 6, 2023
234ad9f
Fix typo
edgarrmondragon Oct 6, 2023
8a69da5
Document REST coverage
edgarrmondragon Oct 6, 2023
6a2dec8
Merge branch 'feat/rest-api' into break/restructure-package-both-clients
edgarrmondragon Oct 6, 2023
c31302a
Document REST coverage
edgarrmondragon Oct 6, 2023
4c76d3c
Merge branch 'feat/rest-api' into break/restructure-package-both-clients
edgarrmondragon Oct 6, 2023
fc97615
Document REST coverage
edgarrmondragon Oct 6, 2023
9431d12
Merge branch 'feat/rest-api' into break/restructure-package-both-clients
edgarrmondragon Oct 6, 2023
98e87be
Make RESTClient.authenticate a side effect
edgarrmondragon Oct 7, 2023
0d3152e
Merge branch 'main' into feat/rest-api
edgarrmondragon Oct 7, 2023
a720687
Sort tags lexicographically
edgarrmondragon Oct 7, 2023
8c0b185
Remove unnecessary classifiers
edgarrmondragon Oct 7, 2023
672ca69
Add async client
edgarrmondragon Oct 7, 2023
a0e3a26
Merge branch 'main' into feat/rest-api
edgarrmondragon Nov 29, 2023
aab6e68
Revert "Add async client"
edgarrmondragon Nov 29, 2023
c9893dd
Make REST module private
edgarrmondragon Nov 29, 2023
9e1cc91
Update expection for PATCH `survey-detail`
edgarrmondragon Nov 29, 2023
1f26d51
Document REST client
edgarrmondragon Nov 29, 2023
8ee061e
Update integration tests list
edgarrmondragon Nov 29, 2023
c75b83c
Merge branch 'feat/rest-api' into break/restructure-package-both-clients
edgarrmondragon Nov 29, 2023
df4c88a
Merge branch 'main' into break/restructure-package-both-clients
edgarrmondragon Nov 29, 2023
e0b60cf
Consolidate pytest warning filters
edgarrmondragon Nov 29, 2023
8567d24
Fix docstring
edgarrmondragon Nov 29, 2023
d20e923
Move files
edgarrmondragon Nov 29, 2023
6da84ff
Remove unwanted docstrings
edgarrmondragon Nov 29, 2023
7963252
Merge branch 'main' into break/restructure-package-both-clients
edgarrmondragon Nov 29, 2023
344b301
Merge branch 'main' into break/restructure-package-both-clients
edgarrmondragon Nov 29, 2023
bf2f16d
Fix docstring
edgarrmondragon Nov 29, 2023
a933d02
Merge branch 'main' into break/restructure-package-both-clients
edgarrmondragon Jan 3, 2024
93a9a93
Merge branch 'main' into break/restructure-package-both-clients
edgarrmondragon Jan 5, 2024
ad903d5
Merge branch 'main' into break/restructure-package-both-clients
edgarrmondragon Jan 25, 2024
24b8afa
Merge branch 'main' into break/restructure-package-both-clients
edgarrmondragon Jan 25, 2024
7817601
Merge branch 'main' into break/restructure-package-both-clients
edgarrmondragon Sep 18, 2024
d4e2954
Fix docs
edgarrmondragon Sep 18, 2024
f63cdaf
Fix some links
edgarrmondragon Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code_samples/auth_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from __future__ import annotations

# start example
from citric import Client
from citric import RPC

client = Client(
client = RPC(
"https://example.com/index.php/admin/remotecontrol",
"iamadmin",
"secret",
Expand Down
4 changes: 2 additions & 2 deletions code_samples/context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
from __future__ import annotations

# start example
from citric import Client
from citric import RPC

LS_URL = "http://localhost:8001/index.php/admin/remotecontrol"

with Client(LS_URL, "iamadmin", "secret") as client:
with RPC(LS_URL, "iamadmin", "secret") as client:
# Do stuff with the client
...
# end example
4 changes: 2 additions & 2 deletions code_samples/custom_requests_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

# start example
import requests_cache
from citric import Client
from citric import RPC

cached_session = requests_cache.CachedSession(
expire_after=60,
allowable_methods=["POST"],
)

client = Client(
client = RPC(
"https://example.com/index.php/admin/remotecontrol",
"iamadmin",
"secret",
Expand Down
2 changes: 1 addition & 1 deletion code_samples/duckdb_sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import citric
import duckdb

client = citric.Client(
client = citric.RPC(
"https://mylimeserver.com/index.php/admin/remotecontrol",
"iamadmin",
"secret",
Expand Down
4 changes: 2 additions & 2 deletions code_samples/get_surveys.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
from __future__ import annotations

# start example
from citric import Client
from citric import RPC

LS_URL = "http://localhost:8001/index.php/admin/remotecontrol"

client = Client(LS_URL, "iamadmin", "secret")
client = RPC(LS_URL, "iamadmin", "secret")

# Get all surveys from user "iamadmin"
surveys = client.list_surveys("iamadmin")
Expand Down
4 changes: 2 additions & 2 deletions code_samples/pandas_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
# start example
import io

import citric
import pandas as pd
from citric import Client

survey_id = 123456

client = Client(
client = citric.RPC(
"https://mylimeserver.com/index.php/admin/remotecontrol",
"iamadmin",
"secret",
Expand Down
4 changes: 2 additions & 2 deletions code_samples/requests_session_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

# start example
import requests
from citric import Client
from citric import RPC

session = requests.Session()

# Set to False to accept any TLS certificate presented by the server
# https://requests.readthedocs.io/en/latest/api/#requests.Session.verify
session.verify = False

client = Client(
client = RPC(
"https://mylimeserver.com/index.php/admin/remotecontrol",
"iamadmin",
"secret",
Expand Down
6 changes: 3 additions & 3 deletions code_samples/session_attr.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Example of using the Client.session attribute to call RPC methods directly."""
"""Example of using the RPC.session attribute to call RPC methods directly."""

from __future__ import annotations

from citric import Client
from citric import RPC

# start example
client = Client(
client = RPC(
"https://mylimeserver.com/index.php/admin/remotecontrol",
"iamadmin",
"secret",
Expand Down
4 changes: 2 additions & 2 deletions code_samples/upload_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

# start example
import boto3
from citric import Client
from citric import RPC

s3 = boto3.client("s3")

client = Client(
client = RPC(
"https://mylimeserver.com/index.php/admin/remotecontrol",
"iamadmin",
"secret",
Expand Down
7 changes: 6 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,12 @@ def skip_member_filter(
Returns:
Whether to skip the member.
"""
if name == "citric.rest.client":
parts = name.split(".")
if (
any(part.startswith("_") and part != "_compat" for part in parts)
or name == "citric.rest.client"
or name.startswith(("citric.client", "citric.session", "citric.method"))
):
skip = True
return skip

Expand Down
8 changes: 8 additions & 0 deletions docs/deprecations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Deprecation timeline

## v1.0.0

* `citric.Client` will be renamed to `citric.RPC`.
* `citric.client` will be moved to `citric.rpc.client`.
* `citric.session` will be moved to `citric.rpc.session`.
* `citric.method` will be moved to `citric.rpc.method`.
2 changes: 1 addition & 1 deletion docs/how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ For the full JSON-RPC reference, see the [RemoteControl 2 API docs][rc2api].
:end-before: end example
```

Otherwise, you can manually close the session with {meth}`client.close() <citric.client.Client.close>`.
Otherwise, you can manually close the session with {meth}`client.close() <citric.rpc.client.RPC.close>`.

## Get surveys and questions

Expand Down
9 changes: 8 additions & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ But also, the latest 5.x and 6.x are tested continuously and are expected to wor
- [Use a custom `requests` session](how-to.md#use-a-custom-requests-session)
- [Use a different authentication plugin](how-to.md#use-a-different-authentication-plugin)
- [Get files uploaded to a survey and move them to S3](how-to.md#get-files-uploaded-to-a-survey-and-move-them-to-s3)
- [Use the raw `Client.session` for low-level interaction](how-to.md#use-the-session-attribute-for-low-level-interaction)
- [Use the raw `RPC.session` for low-level interaction](how-to.md#use-the-session-attribute-for-low-level-interaction)
- [Notebook samples](how-to.md#notebook-samples)

```{toctree}
Expand Down Expand Up @@ -72,6 +72,13 @@ REST endpoints coverage <rest_coverage>
Python API reference <_api/index>
```

```{toctree}
:maxdepth: 2
:hidden:

Deprecations <deprecations>
```

```{toctree}
:maxdepth: 1
:hidden:
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/duckdb.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"outputs": [],
"source": [
"# Use your own server's parameters here\n",
"client = citric.Client(\n",
"client = citric.RPC(\n",
" \"http://localhost:8001/index.php/admin/remotecontrol\",\n",
" \"iamadmin\",\n",
" \"secret\",\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/notebooks/import_s3.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@
],
"source": [
"# Use your own server's parameters here\n",
"with citric.Client(\n",
"with citric.RPC(\n",
" \"http://localhost:8001/index.php/admin/remotecontrol\",\n",
" \"iamadmin\",\n",
" \"secret\",\n",
Expand Down Expand Up @@ -229,7 +229,7 @@
"s3.delete_object(Bucket=\"testing\", Key=\"survey.lss\")\n",
"s3.delete_bucket(Bucket=\"testing\")\n",
"\n",
"with citric.Client(\n",
"with citric.RPC(\n",
" \"http://localhost:8001/index.php/admin/remotecontrol\",\n",
" \"iamadmin\",\n",
" \"secret\",\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/pandas_sqlite.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"outputs": [],
"source": [
"# Use your own server's parameters here\n",
"client = citric.Client(\n",
"client = citric.RPC(\n",
" \"http://localhost:8001/index.php/admin/remotecontrol\",\n",
" \"iamadmin\",\n",
" \"secret\",\n",
Expand Down
10 changes: 5 additions & 5 deletions docs/rest_coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

| Name | Implemented |
| :----------------------------------------- | :-------------------------------------------------- |
| `POST /rest/v1/session` | [Yes](citric._rest.RESTClient.authenticate) |
| `DELETE /rest/v1/session` | [Yes](citric._rest.RESTClient.close) |
| `GET /rest/v1/survey` | [Yes](citric._rest.RESTClient.get_surveys) |
| `GET /rest/v1/survey-detail/{survey_id}` | [Yes](citric._rest.RESTClient.get_survey_details) |
| `PATCH /rest/v1/survey-detail/{survey_id}` | [Yes](citric._rest.RESTClient.update_survey_details) |
| `POST /rest/v1/session` | [Yes](citric.rest.RESTClient.authenticate) |
| `DELETE /rest/v1/session` | [Yes](citric.rest.RESTClient.close) |
| `GET /rest/v1/survey` | [Yes](citric.rest.RESTClient.get_surveys) |
| `GET /rest/v1/survey-detail/{survey_id}` | [Yes](citric.rest.RESTClient.get_survey_details) |
| `PATCH /rest/v1/survey-detail/{survey_id}` | [Yes](citric.rest.RESTClient.update_survey_details) |
Loading