Skip to main content

GLPI API Abstraction Layer

Project description

GLPI API Abstraction Layer

This project provides an abstraction layer to simplify the use of the GLPI REST API, making it easier to interact with entities, tickets, and users. It offers a Python interface to streamline communication with the GLPI API in an organized and reusable way.

Repository

Github: https://github.com/Gnew-Solucoes-IP-Ltda/glpi-provider

Requirements

  • Python 3.10 +
  • Library for GLPI API communication

Structure

The project includes the GlpiProvider class in glpi_provider, which encapsulates various methods to interact with the GLPI API:

  • Authentication:

    • create_session(): Creates an authentication session with the API.
    • close_session(): Ends the authentication session.
  • Entities:

    • get_entity(entity_id: int): Retrieves a specific entity by its ID.
    • get_entities(): Retrieves all entities.
  • Tickets:

    • get_ticket(ticket_id: int): Retrieves a specific ticket by its ID.
    • get_tickets(): Retrieves all tickets.
    • get_open_tickets(): Retrieves only open tickets.
  • Users:

    • get_user(user_id: int): Retrieves a specific user by their ID.
    • get_users(): Retrieves all users.

Environment Variables

To configure the connection to the GLPI API, create a .env file in the project root directory with the following variables:

BASE_URL='BASE_URL'
USER_TOKEN='USER_TOKEN'
TICKET_STATUS=[1, 2, 3, 4]
  • BASE_URL: The base URL for the GLPI API.
  • USER_TOKEN: The user token for authenticating API requests.
  • TICKET_STATUS: A list of ticket statuses to filter tickets when calling methods like get_open_tickets().

Usage Example

Below is an example of how to use the abstraction layer to retrieve open tickets:

from glpi_provider import GlpiProvider

# Initialize the GLPI provider and create a session
provider = GlpiProvider()
provider.create_session()

# Retrieve and print the list of open tickets
tickets = provider.get_open_tickets()
print(tickets)

# Close the session with the API
provider.close_session()

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

glpi_provider-0.0.2-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

File details

Details for the file glpi_provider-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for glpi_provider-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3d48993383a2f0b2b0992272c2dd708aceec11a0f770e03b30f4d046d42a1aea
MD5 a464fc2fa7e73c657f41ecfdcece1d6e
BLAKE2b-256 68014e3a84bd2dad1d03c4ab16abbceccf3a7f6748bb4371c36c9ccf1b2651a6

See more details on using hashes here.

Supported by

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