This API manages a database of cyber assets, such as networking equipment, servers, personal computers, etc.
Before running the API, ensure you have the following installed:
- Python 3.x
- Flask
- Flask-Restful
- SQLite3
-
Clone the repository to your local machine:
git clone https://github.com/C02022/cyber-asset-management-api.git
-
Navigate to the project directory:
cd cyber-asset-management-api
-
Create a virtual environment (optional but recommended):
python -m venv venv
-
Activate the virtual environment:
-
On Windows:
venv\Scripts\activate
-
On macOS/Linux:
source venv/bin/activate
-
-
Install the required dependencies:
pip install -r requirements.txt
-
Start the API server and intialize the SQLite database:
python server.py
-
The API will be accessible at
http://localhost:5000
.
-
Returns a list of all cyber assets in the database.
Query Parameters:
type
: Filter assets by type.
Example:
GET /assets?type=Laptop
-
Adds a new cyber asset to the database.
Request Body (JSON):
{ "NAME": "Asset Name", "TYPE": "Asset Type", "SERIAL_NUMBER": "ABC123", "OPERATING_SYSTEM": "Windows" }
-
Returns details of a specific cyber asset by ID.
Example:
GET /assets/1
-
Updates details of a specific asset by ID.
Request Body (JSON):
{ "NAME": "Updated Asset Name", "TYPE": "Updated Asset Type", "SERIAL_NUMBER": "XYZ789", "OPERATING_SYSTEM": "Linux" }
-
Deletes a specific asset by ID.
Example:
DELETE /assets/1
You can test the API using tools like Postman or by making HTTP requests from your code. Here are some sample requests:
-
Create a new asset:
POST /assets Request Body: { "NAME": "Asset Name", "TYPE": "Asset Type", "SERIAL_NUMBER": "ABC123", "OPERATING_SYSTEM": "Windows" }
-
Retrieve all assets:
GET /assets
-
Retrieve assets filtered by type:
GET /assets?type=Router
-
Update an asset:
PUT /assets/1 Request Body: { "NAME": "Updated Asset Name", "TYPE": "Updated Asset Type", "SERIAL_NUMBER": "XYZ789", "OPERATING_SYSTEM": "Linux" }
-
Delete an asset:
DELETE /assets/1
- Christopher Obando