This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
pylynk is a command-line utility for interfacing with Interlynk's SAAS platform. It provides functionality to manage products, versions, and SBOMs (Software Bill of Materials) through a GraphQL API.
pip3 install -r requirements.txtpython3 pylynk.py --helpdocker build -t pylynk .
docker run -e INTERLYNK_SECURITY_TOKEN ghcr.io/interlynk-io/pylynk <command>The codebase is now organized into a modular structure:
pylynk/
├── __main__.py # Main entry point
├── cli/
│ ├── parser.py # Argument parsing logic
│ └── commands/ # Individual command implementations
│ ├── products.py # Products listing
│ ├── versions.py # Versions listing
│ ├── status.py # SBOM status
│ ├── upload.py # SBOM upload
│ └── download.py # SBOM download
├── api/
│ ├── client.py # API client (refactored from LynkContext)
│ ├── queries.py # GraphQL query definitions
│ └── mutations.py # GraphQL mutation definitions
├── formatters/
│ ├── json_formatter.py # JSON output formatting
│ └── table_formatter.py # Table output formatting
├── utils/
│ ├── time.py # Time conversion utilities
│ ├── config.py # Configuration management
│ └── validators.py # Input validation
└── constants.py # Constants and defaults
-
API Layer (
api/):client.py: Clean API client interface with methods for all operationsqueries.py: GraphQL queries separated for maintainabilitymutations.py: GraphQL mutations for upload operations
-
CLI Layer (
cli/):parser.py: Centralized argument parsingcommands/: Separate modules for each subcommand
-
Utilities (
utils/):config.py: Configuration management from args and environmentvalidators.py: Input validation logictime.py: Time formatting utilities
-
Formatters (
formatters/):- Separate modules for JSON and table output formatting
INTERLYNK_SECURITY_TOKEN- Required for authenticationINTERLYNK_API_URL- Override API endpoint (default: https://api.interlynk.io/lynkapi)
- Add the subcommand parser in
cli/parser.py - Create a new command module in
cli/commands/ - Add any required GraphQL queries to
api/queries.pyor mutations toapi/mutations.py - Implement the API interaction method in
api/client.py - Add the command execution in
__main__.py
- API errors are logged using the logging module
- HTTP status codes are checked for all requests
- GraphQL errors are extracted from response JSON
- Input validation is handled in
utils/validators.py
export INTERLYNK_API_URL=http://localhost:3000/lynkapi
export INTERLYNK_SECURITY_TOKEN=your_test_token
python3 pylynk.py prods --verboseThe modular structure allows for clean imports:
from pylynk.api.client import LynkAPIClient
from pylynk.utils.config import Config
from pylynk.formatters.json_formatter import format_json