docs(readme): document custom configuration usage in library API
Update the Python API Usage section in README.md to demonstrate how to initialize MdrsClient with InMemoryConfig to avoid creating local config files.
This commit is contained in:
@@ -213,15 +213,21 @@ You can also use this package as a Python library to programmatically interact w
|
||||
```python
|
||||
from mdrsclient.client import MdrsClient
|
||||
from mdrsclient.cache import InMemoryCache
|
||||
from mdrsclient.config import InMemoryConfig
|
||||
|
||||
# 1. Setup in-memory configuration and cache to avoid local state files (e.g., config.ini, cache/*.json)
|
||||
config = InMemoryConfig("neurodata")
|
||||
config.url = "https://neurodata.riken.jp/api"
|
||||
|
||||
# 1. Setup client with an in-memory cache to avoid local `.mdrsclient` state files
|
||||
cache = InMemoryCache()
|
||||
client = MdrsClient.from_remote("neurodata", cache=cache)
|
||||
|
||||
# 2. Login to the remote server
|
||||
# 2. Initialize client with custom configuration and cache
|
||||
client = MdrsClient.from_remote("neurodata", cache=cache, config=config)
|
||||
|
||||
# 3. Login to the remote server
|
||||
client.login("username", "password")
|
||||
|
||||
# 3. Use service methods
|
||||
# 4. Use service methods
|
||||
labs = client.get_laboratories()
|
||||
metadata = client.metadata("neurodata:/NIU/Repository/")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user