This project automates the import and update process of device information into a Snipe-IT asset management system using data from an external API. It is designed to run periodically with a cron job, ensuring that the Snipe-IT system stays up-to-date with the latest device information.
- Clone the repository:
git clone https://github.com/your-username/project-name.git
cd project-name
- Install the required dependencies:
pip install -r requirements.txt
- Set up the configuration file:
cp .env.example .env
Update the values in the .env file with your specific configurations.
Run the main script to start the import and update process:
python main.py
The script will fetch device information from microsft graph api, process the data, and update the Snipe-IT asset management system accordingly.
Configure the application by modifying the .env file. This file contains environment variables necessary for the proper functioning of the script. Update the following variables:
- SNIPE_API_KEY: API key for authenticating with the Snipe-IT API.
- MICROSOFT_CLIENT_ID: Client ID for authenticating with the Microsoft API.
- MICROSOFT_CLIENT_SECRET: Client secret for authenticating with the Microsoft API.
- SNIPE_URL: URL of the Snipe-IT instance.
- SNIPE_API_URL: Snipe-IT API URL.
- MICROSOFT_URL: Microsoft API URL.
- SLACK_URL: Slack webhook URL for sending notifications.
- DEVICE_PREFIX: Prefixes of supported devices, separated by commas.
To set up a cron job for periodic execution, add the following line to your crontab file:
0 0 * * * /path/to/python /path/to/project-name/main.py
This example runs the script every day at midnight. Adjust the timing as needed.
requests: HTTP library for making API requests.
dotenv: Loads environment variables from a file.