Skip to content

thangap-cloud/nexus3-python-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nexus3Client

PyPI version License Python Versions Build Status

A lightweight Python client for interacting with Sonatype Nexus3 repositories via REST API.
This package helps you search, list, and delete components from Nexus3 repositories with minimal code.


📦 Features

  • 🔍 Search for components in Nexus3 repositories
  • 🗑️ Delete components easily
  • 🧩 Supports authentication for secure Nexus3 servers
  • ⚡ Built for automation and CI/CD integration
  • ✅ Fully tested with pytest

📥 Installation

Install the package from PyPI:

pip install nexus3client

Or install from source:

git clone https://github.com/<your-username>/nexus3client.git
cd nexus3client
pip install -e .

🚀 Usage

1. Import and Initialize

from nexus3client import Nexus3Client

# Initialize the client
client = Nexus3Client()

2. Search for Components

results = client.search_components(
    base_url="http://localhost:8084",
    repository="test-repo",
    username="admin",
    password="admin123",
    verify_ssl=False,
    timeout=10,
    *fields=["id", "repository"]
)

print(results)

Example Output:

[
    {
        "id": "d2a3f2b6f3f2",
        "repository": "test-repo",
        "name": "my-artifact",
        "version": "1.0.0"
    }
]

3. Delete Components

results = client.search_components(
    "http://localhost:8084", 
    "test-repo", 
    "admin", 
    "admin123", 
    False, 
    10, 
    "id"
)

for result in results:
    component_id = result.get("id")
    client.delete_components(
        "http://localhost:8084",
        component_id,
        "admin",
        "admin123",
        False,
        10
    )

🧪 Running Tests

We use pytest for testing. To run tests locally:

pytest tests/

Example Test (tests/test_nexus3client.py):

import pytest
from nexus3client import Nexus3Client

client = Nexus3Client()

def test_nexus3_search():
    results = client.search_components(
        "http://localhost:8084", 
        "test-repo", 
        "admin", 
        "admin123", 
        False, 
        10, 
        "id", 
        "repository"
    )
    assert isinstance(results, list)
    assert len(results) >= 0

def test_nexus3_delete():
    results = client.search_components(
        "http://localhost:8084", 
        "test-repo", 
        "admin", 
        "admin123", 
        False, 
        10, 
        "id"
    )
    assert isinstance(results, list)
    assert len(results) > 0
    for result in results:
        component_id = result.get("id")
        assert component_id is not None
        client.delete_components(
            "http://localhost:8084",
            component_id,
            "admin",
            "admin123",
            False,
            10
        )

📂 Project Structure

nexus3client/
├── nexus3client/
│   ├── __init__.py
│   ├── client.py
├── tests/
│   ├── test_nexus3client.py
├── README.md
├── setup.py
├── pyproject.toml
└── LICENSE

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.


🤝 Contributing

Contributions, issues, and feature requests are welcome!
Feel free to open an issue or submit a pull request.


📧 Contact

Author: Prabhu Thangaraj
Email: thangaraj.prabhu@gmail.com
GitHub: https://github.com/thangap-cloud


🔗 References


About

nexus3 api client to search and delete components

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages