Skip to main content

Python wrappers for working with the Sierra ILS

Project description

sierra-ils-utils

Python wrappers for working with the Sierra ILS

Sierra API Client Documentation

Introduction

This documentation provides an overview of the design approach for extending the Sierra API client. The primary objective is to create a flexible and extensible structure that allows for easy integration of new endpoints, response models, and HTTP methods.

The Approach

The core of this approach revolves around three main components:

  1. Data Models
  2. Endpoint Configuration (ENDPOINTS dictionary)
  3. Generic Request Method

1. Data Models

Data models represent the structure of the response data we expect from the Sierra API. These are Python classes that map to the expected JSON response structure.

For example, for the GET bibs/ endpoint, the BibResultSet data model represents the expected structure of the response. Each attribute of this model corresponds to a key in the JSON response. Nested JSON structures are represented by nested data models. Benefits of Data Models:

  • Type Safety: Provides a clear understanding of the data types and structure expected in the response.
  • Code Readability: Named data models make the code more readable and self-documenting.
  • Flexibility: Easy to modify and extend when the API response changes or when new fields are introduced.

2. Endpoint Configuration (ENDPOINTS Dictionary)

The ENDPOINTS dictionary provides a centralized place to define the configuration for each API endpoint. Each key in this dictionary represents an endpoint and the associated value provides details such as the HTTP path, method, and expected response models for various HTTP status codes.

Example:

ENDPOINTS = {
    "bibs": {
        "GET": {
            "path": "bibs/",
            "responses": {
                200: BibResultSet,
                400: ErrorCode,
                # ... other status codes ...
            }
        },
        # ... other HTTP methods ...
    }
}

Benefits of the ENDPOINTS Configuration:

  • Centralized Configuration: All endpoint configurations are in one place, making it easier to manage and update.
  • Flexibility: Can easily accommodate different response models for different HTTP status codes.
  • Scalability: New endpoints or methods can be added without modifying the core logic of the API client.

3. Generic Request Method

The request_endpoint method is a generic function that can handle requests to any endpoint defined in the ENDPOINTS dictionary. By passing the endpoint name, HTTP method, and any required parameters or path variables, this method can construct the appropriate URL, send the request, and return the parsed response using the associated data model. Benefits of the Generic Request Method:

  • Code Reusability: One method to handle requests for all endpoints.
  • Maintainability: Changes to the request logic can be made in one place, benefiting all endpoints.
  • Extensibility: Easy to support new HTTP methods or endpoints by extending the ENDPOINTS dictionary without changing the core request logic.

Future Considerations

Extend Support for Other HTTP Methods:

As the Sierra API evolves or as you require more functionality, you can extend support for other HTTP methods (like DELETE, PUT, etc.) following the same pattern.

Error Handling:

The current approach provides a basic structure for handling different response models based on HTTP status codes. This can be extended to provide more advanced error handling and logging mechanisms.

Project details


Download files

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

Source Distribution

sierra-ils-utils-0.0.1a20231125.tar.gz (17.2 kB view details)

Uploaded Source

Built Distribution

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

sierra_ils_utils-0.0.1a20231125-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file sierra-ils-utils-0.0.1a20231125.tar.gz.

File metadata

File hashes

Hashes for sierra-ils-utils-0.0.1a20231125.tar.gz
Algorithm Hash digest
SHA256 2ed3e790b006b1f3b82c872368554bfe8e8e8c2e487271352f45c6fa9cfcf0a6
MD5 79125e3542e940730beee890cc82b473
BLAKE2b-256 6121c7b77d04161e2a22b75b396ef45ea98c2cb3d3891cd0803502deba80dca3

See more details on using hashes here.

File details

Details for the file sierra_ils_utils-0.0.1a20231125-py3-none-any.whl.

File metadata

File hashes

Hashes for sierra_ils_utils-0.0.1a20231125-py3-none-any.whl
Algorithm Hash digest
SHA256 33af145d436db4279673fec41b33041c2111745e87441507010c0ac81e98a52c
MD5 60b164da88b8c356f80c5f89d2c05394
BLAKE2b-256 130865afefe6be180873f40c20ccc2a1987ef8615f5fa47a46cfdcff3d1260a8

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