Skip to main content

An API client for interacting with the underlying data in Find Caselaw.

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

PyPI Libraries.io dependency status for latest release

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:

poetry install
poetry run 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:

  1. Update the version number in pyproject.toml
  2. Create a branch release/v{major}.{minor}.{patch}
  3. Update CHANGELOG.md for the release
  4. Commit and push
  5. Open a PR from that branch to main
  6. Get approval on the PR
  7. Merge the PR to main and push
  8. Tag the merge commit on main with v{major}.{minor}.{patch} and push the tag
  9. Create a release in Github releases using the created tag

Project details


Release history Release notifications | RSS feed

This version

7.0.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ds_caselaw_marklogic_api_client-7.0.0.tar.gz (19.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file ds_caselaw_marklogic_api_client-7.0.0.tar.gz.

File metadata

File hashes

Hashes for ds_caselaw_marklogic_api_client-7.0.0.tar.gz
Algorithm Hash digest
SHA256 98e4eb36200badd1c58c62d88d254b5a0e07152fa7c69d182cdbbeb3096430c5
MD5 f2a1d1f5a7111bb427bb66e7e8186eb1
BLAKE2b-256 35c2535aeb31dfa154fc31d335158ad1f8c07d4b7416ecb0597082ac57f0ecb4

See more details on using hashes here.

File details

Details for the file ds_caselaw_marklogic_api_client-7.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ds_caselaw_marklogic_api_client-7.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1096fe4656ddc84409ace4771d640cbb7a71cb96a850954cf267b46bf0870456
MD5 bcddb32c818bf4143122289dc3e07080
BLAKE2b-256 e4203ec027c46902b5feb9a02f2e151d2482ee237a42353a59185203cc1e3c77

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page