Skip to content

hac-client-core

Python client library for the SAP Commerce HAC (Hybris Administration Console) HTTP API.

Execute Groovy scripts, run FlexibleSearch queries, import Impex data, and trigger system updates — all from Python, with automatic session management and CSRF handling.


Features

  • Groovy script execution — run arbitrary Groovy in commit or rollback mode
  • FlexibleSearch queries — execute queries with typed result objects
  • Impex import — import Impex content with configurable validation
  • System update — trigger updates, select patches/parameters, poll logs
  • Session management — automatic login, CSRF tokens, session caching across runs
  • Pluggable authentication — ships with Basic Auth; extend AuthHandler for OAuth, JWT, API keys, etc.
  • Fully typed — complete type annotations with a py.typed marker (PEP 561)

Quick start

from hac_client_core import HacClient, BasicAuthHandler

auth = BasicAuthHandler("admin", "nimda")
client = HacClient(
    base_url="https://localhost:9002",
    auth_handler=auth,
    ignore_ssl=True,
)

client.login()

result = client.execute_groovy("return 'Hello from HAC'")
print(result.execution_result)  # "Hello from HAC"

See the Getting started guide for installation instructions and a walkthrough.

Architecture overview

graph TD
    A["Your code"] --> B["HacClient"]
    B --> C["Groovy"]
    B --> D["FlexSearch"]
    B --> E["Impex"]
    C & D & E --> F["HTTP layer"]
    F --> G["AuthHandler
    (pluggable)"]
    F --> H["SessionManager
    (CSRF + cookie cache)"]

The client is structured around a few key design decisions:

  • Pluggable authAuthHandler is an abstract class. BasicAuthHandler ships built-in; implement your own for OAuth, JWT, mTLS, etc.
  • Automatic sessions — Login is performed lazily on the first API call. Sessions (including CSRF tokens and route cookies) are cached to disk so subsequent runs skip the login round-trip.
  • Typed results — Every API method returns a typed dataclass (GroovyScriptResult, FlexibleSearchResult, …) instead of raw dicts.

License

MIT