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

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-11.0.1.tar.gz (23.5 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-11.0.1.tar.gz.

File metadata

File hashes

Hashes for ds_caselaw_marklogic_api_client-11.0.1.tar.gz
Algorithm Hash digest
SHA256 d5c07f5126786206505f487e0370a79ac9658bd27004115963d84422d57e1021
MD5 eadc2ccf331f8af1bac1833362589055
BLAKE2b-256 3d35d6e168da5e1dbd2b0a28fe38a1cc96a11a0a696c07604c2b2106c5768155

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ds_caselaw_marklogic_api_client-11.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05f9150da4059fc6521594489fc3d0965c3abeb18bc5d51efdf5bd9a60bd8fad
MD5 168a67fa182e35b6462365f9691aeeec
BLAKE2b-256 7718b844a2b5de9b8c78b88868a5f1077d87b184f4ba58de089fe04934cac0d1

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