Metadata-Version: 2.4
Name: cmem-client
Version: 1.1.0
Summary: Next generation eccenca Corporate Memory client library.
License: Apache-2.0
License-File: LICENSE
Keywords: eccenca Corporate Memory,client
Author: eccenca GmbH
Author-email: cmempy-developer@eccenca.com
Requires-Python: >=3.13,<4
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: httpx (>=0.27.0,<0.28.0)
Requires-Dist: license-expression (>=30.4.4,<31.0.0)
Requires-Dist: pycountry (>=26.2.16,<27.0.0)
Requires-Dist: pydantic-extra-types (>=2.10.4,<3.0.0)
Requires-Dist: pydantic[email] (>=2.12.5,<3.0.0)
Requires-Dist: pyjwt (>=2.8.0,<3.0.0)
Requires-Dist: pyparsing (>=3.0.0,<4.0.0)
Requires-Dist: rdflib (>=7.4.0,<8.0.0)
Requires-Dist: semver (>=3.0.4,<4.0.0)
Requires-Dist: xdg-base-dirs (>=6.0.2,<7.0.0)
Description-Content-Type: text/markdown

<!-- markdownlint-disable MD013 -->
# cmem-client

Next generation eccenca Corporate Memory client library.

[![pypi version](https://img.shields.io/pypi/v/cmem-client)](https://pypi.org/project/cmem-client) [![python versions](https://img.shields.io/pypi/pyversions/cmem-client)](https://pypi.org/project/cmem-client) [![license](https://img.shields.io/pypi/l/cmem-client)](https://pypi.org/project/cmem-client)

`cmem-client` is the Python client library for [eccenca Corporate Memory](https://eccenca.com/).
Corporate Memory exposes its functionality through several services - DataIntegration
(*build*), DataPlatform (*explore*), Keycloak and the Marketplace. This library hides that
split behind a single typed and validated Python object: the client.

## Features

- **Validated responses.** Every response is parsed into a [Pydantic](https://docs.pydantic.dev/)
  model, so a typo in a server field becomes an error instead of a `KeyError` three frames
  later.
- **Proper typing.** The whole package is type annotated and checked with
  [mypy](https://www.mypy-lang.org/), so your editor can complete and check your code.
- **Dict-like collections.** Repositories such as `client.graphs` behave like read-only
  dictionaries: `len()`, `in`, `[]` and iteration all work, and data is fetched lazily on
  first access.
- **Structured logging** through the standard library, configured with one call on the
  client, including a `TRACE` level below `DEBUG` which logs the arguments and the result of
  the methods carrying the decorator.
- **Built on [httpx](https://www.python-httpx.org/)**, which would also allow asynchronous
  calls. The exposed client API is synchronous.

## Installation

```shell
pip install cmem-client
```

The package requires Python 3.13 or newer.

## Getting started

Point the client at your Corporate Memory deployment and give it credentials:

```shell
export CMEM_BASE_URI="https://mycmem.example.com/"
export OAUTH_GRANT_TYPE="client_credentials"
export OAUTH_CLIENT_ID="cmem-service-account"
export OAUTH_CLIENT_SECRET="my-secret"
```

Then create a client and ask the deployment how it is doing:

```python
from cmem_client.client import Client

client = Client.from_env()

print(client.store.self_information.type)      # GRAPHDB
print(client.deployment.get_status().health)   # UP
print(len(client.graphs))                      # 6
```

That is the whole setup. Besides `Client.from_env()` there are `Client.from_dict()` for
settings you hold yourself, `Client.from_context()` for use inside a Corporate Memory Python
plugin, and `Client.from_cmempy()` to reuse an already configured cmempy environment.

## What you can reach

Everything hangs off the client:

```python
client.graphs           # RDF graphs in the store, a read-only mapping
client.projects         # DataIntegration projects
client.store.sparql     # SPARQL query and update
client.marketplace      # Marketplace packages
```

Further repositories cover datasets, workflows, queries, files, variables, schedulers,
vocabularies, graph imports and insights, validations, access conditions, user and client
accounts, Python packages and installed marketplace packages. The documentation lists them
all.

## Coming from cmem-cmempy

`cmem-client` succeeds [cmem-cmempy](https://pypi.org/project/cmem-cmempy/), but it is not a
drop-in replacement. Where cmempy offers module-level functions returning parsed JSON, this
library gives you a client object whose responses are validated models:

```python
# cmem-cmempy
from cmem.cmempy.dp.proxy.graph import get_graphs_list
graphs = get_graphs_list()                # list of dicts

# cmem-client
graphs = list(client.graphs.values())     # list of Graph models
```

If a cmempy environment is already configured in your process, reuse it directly with
`Client.from_cmempy()`.

## Documentation

The full API documentation, including the complete configuration reference and the migration
notes, lives at
[documentation.eccenca.com](https://documentation.eccenca.com/latest/develop/cmem-client-api/).

