Skip to main content

Opengate-data

Opengate-data is a Python library (requires Python 3.10+) that helps you integrate OpenGate into your Python projects.

Installation

To install the library, run:

pip install opengate-data

Or, if you are using uv:

uv add opengate-data

Quick Start: Searching Entities

Here is a simple example of how to search for entities using the EntitiesSearchBuilder:

from opengate_data import OpenGateClient

# Initialize the client
client = OpenGateClient(url="https://api.opengate.es", api_key="YOUR_API_KEY")

# Create a search builder
search = client.new_entities_search_builder()

# Build the query with filters and selection
search.with_filter(
    client.new_filter_builder().eq("provision.administration.organization", "your_org").build()
).with_select(
    client.new_select_builder().add("provision.device.identifier", ["value"]).build()
).with_limit(10, 0)

# Execute the search
results = search.execute()
print(results)

Basic use with user and password

To initialize the OpenGateClient using a username and password:

client = OpenGateClient(url="Url", user="User", password="Password")

Basic use with api-key

To initialize the client using an api_key:

client = OpenGateClient(url="Url", api_key="Api_Key")

Basic use token_jwt with .env

To initialize the client using a token_jwt with a .env file.

  1. Create a .env file with the following content: TOKEN_JWT="token_jwt"

  2. Load the environment variable and initialize the client:

    client = OpenGateClient()
    

By default, if you use OpenGateClient without parameters, and you set the environment variable TOKEN_JWT, OpenGateClient will be created with this value. If you want to use TOKEN_JWT from environment, you may delete the OPENGATE_API_KEY environment variable.

Basic use with environment variables

The most professional way to initialize the client is by using standard environment variables. If you set these, you can simply call OpenGateClient():

# export OPENGATE_URL="https://api.opengate.es"
# export OPENGATE_API_KEY="YOUR_API_KEY"

client = OpenGateClient()

Basic use of token_jwt with an environment variable

To initialize the client using a token_jwt from an environment variable, you can set the token_jwt directly in your environment without relying on a .env:

  1. Create environment variable

    • On UNIX systems, use:

      export TOKEN_JWT="token_jwt"
      
    • On Windows, use:

      set TOKEN_JWT="token_jwt"
      
  2. Initialize the client.

    client = OpenGateClient()
    

Similar to the previous example, if you use OpenGateClient without parameters, and you set the environment variable TOKEN_JWT, OpenGateClient will be created with this value. If you want to use TOKEN_JWT from environment, you may delete API_KEY variable environment.

Basic use without url for services K8s

To initialize the OpenGateClient without specifying a URL, you can either omit the url parameter or set it to None.

client = OpenGateClient(api_key="Api_Key")
# or
client = OpenGateClient(url=None, api_key="Api_Key")

Similar to the previous examples, you have the option to provide the api_key directly, set it to None, or omit it altogether. If you choose to omit it, the client will automatically retrieve the api_key from the environment variable if it is set. Additionally, you can also authenticate using a username and password by specifying those credentials instead.

Features

The library consists of the following modules:

  • IA
    • Models
    • Pipelines
    • Transformers
  • Collection
    • Collection
    • Bulk Collection
    • Pandas Collection
  • Provision
    • Asset
    • Bulk
    • Devices
    • Processor
  • Rules
    • Rules
  • Searching
    • Datapoints
    • Data sets
    • Entities
    • Operations
    • Rules
    • Timeseries
  • File Connector
    • File Connector

Documentation

The full API documentation for all modules is available at docs/documentation_single.md

Basic Examples of the OpenGate-Data Modules

The examples of the different modules can be found in the unit tests which demonstrate various configurations and use cases.

Additional Documentation

For more details and examples about each of the modules, consult the complete documentation.

Generate Version and Upload to PyPI

To upload your package to PyPI, follow these steps:

  1. Configure PyPI credentials

    PyPI requires API tokens for authentication (username/password is no longer supported).

    • Recommended (Environment Variable):

      export UV_PUBLISH_TOKEN=pypi-YOUR_TOKEN_HERE
      
    • Alternative (.pypirc): Create the .pypirc file in your home directory:

      [pypi]
        username = __token__
        password = pypi-YOUR_TOKEN_HERE
      
  2. Create file .env with this format

    OPENGATE_URL="URL"
    OPENGATE_API_KEY="OPENGATE_API_KEY"
    ORGANIZATION="ORGANIZATION"
    
  3. Release from develop

    git checkout develop
    ./dist.sh
    

    dist.sh drives the whole release and is the only supported way to bump a version. It checks that develop is clean and in sync and that master holds nothing missing from develop, runs the unit and integration suites, regenerates the documentation, merges develop into master, bumps the version, tags vX.Y.Z, publishes to PyPI, creates the GitLab release, back-merges master into develop and leaves you on develop.

    Rehearse a release without touching anything remote:

    ./dist.sh --dry-run
    

    If the integration suite fails for a known, unrelated reason, --force-integration continues but requires a written justification that is recorded in the release notes.

Test

Create file .env with this format

OPENGATE_URL="URL"
OPENGATE_API_KEY="OPENGATE_API_KEY"
ORGANIZATION="ORGANIZATION"

Configure your environment

This project uses uv for dependency management. To set up your development environment and install all dependencies (including test libraries):

uv sync

This will create a virtual environment in .venv and install everything defined in pyproject.toml.

Running All Tests

If you want to run all the tests (unit and integration), simply run:

uv run pytest

This will discover and run all test files matching the pattern defined in pytest.ini.

Running All Unit Tests

Unit tests are located under:

opengate_data/test/unit/

Each subfolder corresponds to a module (e.g., search, collect, rules, etc.).

To run all unit tests:

uv run pytest -m unit -x --maxfail=1

Running One Unit Test

uv run pytest opengate_data/test/unit/searching/test_datasets.py

Running All Integration Tests

Integration tests are located under:

opengate_data/test/integration/

Each subfolder corresponds to a module (e.g., search, collect, rules, etc.).

To run all integration tests:

uv run pytest opengate_data/test/integration

or using marker:

uv run pytest -m integration -x --maxfail=1

Running One Integration Test

uv run pytest opengate_data/test/integration/steps_definitions/step_datasets.py

License

This project is licensed under the Apache License 2.0.

Metadata

Release files for opengate-data 1.15.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opengate-data 1.15.1
File Size Uploaded
opengate_data-1.15.1.tar.gz 513.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opengate-data 1.15.1
File Interpreter ABI Platform
opengate_data-1.15.1-py3-none-any.whl Python 3 none any Details

Total release size: 871.0 kB

Release files / opengate_data-1.15.1.tar.gz

Download URL opengate_data-1.15.1.tar.gz
Size 513.0 kB
Tags Source
SHA-256 checksum
How to use checksums
158f50c3f6d725048cdb425fda95af6c01f924fb99d64759e808789bc898fa46
BLAKE2b-256 checksum
How to use checksums
64b9643cefb6044a8dd8cb5dbb09758f4496b400d5ec9fe35fd79b088ee716ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.8

Release files / opengate_data-1.15.1-py3-none-any.whl

Download URL opengate_data-1.15.1-py3-none-any.whl
Size 358.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e7ed39216238c0d717806cef330bde0550ccab90bbd9923c77eb84e7f19beb32
BLAKE2b-256 checksum
How to use checksums
b21ace8a8faa2dc0550d7cc8c30adf8744d5a0c3136c0db96cbf2b516650a0b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.8

Release history Release notifications | RSS feed

1.15.3

2 release files

1.15.2

2 release files

This release

1.15.1 This release

2 release files

1.15.0

2 release files

1.14.0

2 release files

1.13.0

2 release files

1.12.0

2 release files

1.11.2

2 release files

1.10.0

2 release files

1.9.0

2 release files

1.8.0

2 release files

1.7.4

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.11

2 release files

1.1.10

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.0

2 release files

1.0.29

2 release files

1.0.28

2 release files

1.0.27

2 release files

1.0.26

2 release files

1.0.25

2 release files

1.0.24

1 release file

1.0.23

1 release file

1.0.22

2 release files

1.0.21

2 release files

1.0.20

2 release files

1.0.19

2 release files

1.0.18

1 release file

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.13

2 release files

1.0.12

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page