An API client for interacting with the Caselaw Marklogic instance
Project description
The National Archives: Find Case Law
This repository is part of the Find Case Law project at The National Archives. For more information on the project, check the documentation.
MarkLogic API Client
This is an API Client for connecting to Marklogic for The National Archive's Caselaw site.
This package is published on PyPI: https://pypi.org/project/ds-caselaw-marklogic-api-client/
Usage
Include the API client in your project using PIP:
pip install ds-caselaw-marklogic-api-client
or in your projects requirements.txt
with:
ds-caselaw-marklogic-api-client~=2.0.0
Using the client
The client expects the following environment variables to be set or defined in a .env
file:
MARKLOGIC_HOST
MARKLOGIC_USER
MARKLOGIC_PASSWORD
MARKLOGIC_USE_HTTPS # Optional, defaults to False
Then import api_client
from caselawclient.Client
:
from caselawclient.Client import api_client
Alternatively, you can import the base class and instantiate it with different credentials:
from caselawclient.Client import MarklogicApiClient
client = MarklogicApiClient(
host="",
username="",
password="",
use_https=False,
)
Client
also exports some exception classes:
MarklogicAPIError
MarklogicBadRequestError
MarklogicUnauthorizedError
MarklogicNotPermittedError
MarklogicResourceNotFoundError
MarklogicCommunicationError
XML Tools
There is also a small set of xml helper tools that provide some common functionality for dealing with xml:
from caselawclient import xml_tools
xml_tools.get_metadata_name_value(xml)
xml_tools.get_metadata_name_element(xml)
xml_tools.get_search_matches(element)
Testing
To run the test suite:
pip install -r requirements.txt
python -m pytest
Making changes
When making a change, update the changelog using the Keep a Changelog 1.0.0 format. Pull requests should not be merged before any relevant updates are made.
Releasing
When making a new release, update the changelog in the release pull request.
The package will only be released to PyPI if the branch is tagged. A merge to main alone will not trigger a release to PyPI.
To create a release:
- Update the version number in
setup.cfg
- Create a branch
release/v{major}.{minor}.{patch}
- Update
CHANGELOG.md
for the release - Commit and push
- Open a PR from that branch to main
- Get approval on the PR
- Merge the PR to main and push
- Tag the merge commit on
main
withv{major}.{minor}.{patch}
and push the tag - Create a release in Github releases using the created tag
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ds-caselaw-marklogic-api-client-5.2.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 614559bdf88e4744f4af7de72f06d4a6e065057b6e324309e4738c4c82823625 |
|
MD5 | e3aa152914dae96c12b8617f515bbf66 |
|
BLAKE2b-256 | ac23befe5c93fdbc5bc9c0f3955d4de79b1c4a73109d54bda7a2daf552fcecbb |
Hashes for ds_caselaw_marklogic_api_client-5.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10a5ee0ef9f2025720171c8692d67cf3bbd694015a5276c156ea432968081083 |
|
MD5 | 2c7ecbffd489c04b9abc05df5357e1bd |
|
BLAKE2b-256 | 3467ce1b5c1f396beaffbc10c7200e8002a52a151238de9eeedf13e08df5f31d |