Metadata-Version: 2.4
Name: chart_image_clients
Version: 1.2.1
Summary: E360 Chart Image Client for Python
Author-email: IQVIA <e360pypi@iqvia.com>
License: Copyright 2026 IQVIA Ltd
        
           Licensed under the Apache License, Version 2.0 (the "License");
           you may not use this file except in compliance with the License.
           You may obtain a copy of the License at
        
             http://www.apache.org/licenses/LICENSE-2.0
        
           Unless required by applicable law or agreed to in writing, software
           distributed under the License is distributed on an "AS IS" BASIS,
           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
           See the License for the specific language governing permissions and
           limitations under the License.
License-File: LICENSE.txt
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Requires-Python: >=3.12
Requires-Dist: clients-core<5,>=4.0.3
Requires-Dist: pydantic<3,>=2
Description-Content-Type: text/markdown

E360 Chart Image Client
===

[![pipeline status](https://rwes-gitlab01.internal.imsglobal.com/python-microservice-clients/e360-chart-image-client/badges/master/pipeline.svg)](https://rwes-gitlab01.internal.imsglobal.com/python-microservice-clients/e360-chart-image-client/commits/master)


E360 Chart Image Client for Python

**Requires Python 3.12+.** Packaging uses [uv](https://docs.astral.sh/uv/) and `pyproject.toml`.

## Development

Requires **Python 3.12+** and [**uv**](https://docs.astral.sh/uv/).

This package depends on **`clients_core`**, resolved from the internal **e360-pypi** index (see `[tool.uv.index]` / `[tool.uv.sources]` in `pyproject.toml`). On a machine that can reach Artifactory, sync dependencies—for example with **`UV_INDEX_URL`** set to `https://rwes-artifactory01.internal.imsglobal.com/artifactory/api/pypi/e360-pypi/simple` if your tooling needs it (see **clients-core** README for the same pattern):

```bash
uv sync --group dev
```

Run tests and lint:

```bash
uv run pytest
uv run ruff check chart_image_clients tests
```

## Introduction

Utilises the **E360-ChartImage-Service** microservice.


## Features

- Uses the **Plotly** endpoint to send requests to.
- Returns an chart content as bytes.


## Usage

An example of a full implementation

```python
from clients_core.authentication.token_handler import OIDCTokenHandler
from clients_core.api_match_client import ApiMatchClient, MatchSpec
from clients_core.secured_rest_client import SecuredRestClient
from sd_clients.service_directory_client import ServiceDirectoryClient
from chart_image_clients import ChartImageServicePlotlyClient


token_handler = OIDCTokenHandler(
    "https://e360-identity-dev.internal.imsglobal.com:20001/connect/token",
    "<CLIENT_ID>", "<CLIENT_SECRET>", False)

rest_client = SecuredRestClient(
    "https://e360-service-directory-service-dev.internal.imsglobal.com/",
    ["service-directory-service"], token_handler, verify_ssl=False)

sd_client = ServiceDirectoryClient(rest_client)

match_client = ApiMatchClient(sd_client)

match_spec = MatchSpec("E360-ChartImage-Service", "Plotly", 1, 0, 0, ["e360_chart_image_service"])

service_rest_client = match_client.get_secured_client(
    match_spec, token_handler, extra_headers=ChartImageServicePlotlyClient.extra_headers, verify_ssl=False)

ci = ChartImageServicePlotlyClient(service_rest_client, user_id='<USER_GUID>')

payload = {
    "data": [
        {
            "x": [
                "giraffes",
                "orangutans",
                "monkeys"
            ],
            "y": [
                20,
                14,
                23
            ],
            "type": "bar"
        }
    ]
}

image_bytes = ci.get_chart_bytes(payload)
```
