Skip to content

Commit

Permalink
Uploaded GitLab's contents
Browse files Browse the repository at this point in the history
  • Loading branch information
José Luís Rodrigues committed Feb 23, 2024
1 parent 273d582 commit a703075
Show file tree
Hide file tree
Showing 23 changed files with 102 additions and 821 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy Sphinx documentation to Pages

on:
push:
branches: [github] # branch to trigger deployment
branches: [main] # branch to trigger deployment

jobs:
pages:
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
files/*
examples/*
!examples/files/artifacts/default.json
!examples/files/contracts/default.json
# IDE
.idea/
.vscode/
Expand Down
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<div align="left">
<img src="/docs/source/_static/logo.png" align="middle" width="33%" height="auto">
</div>

-----------------------------------------------------
# INESC TEC Client for TNO Security Gateway (TSG) Dataspace Components (TSG-Client)

[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Version](https://img.shields.io/badge/version-0.0.1-blue.svg)]()
[![Status](https://img.shields.io/badge/status-development-brightgreen.svg)]()
[![Python](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/release/python-390/)

This document provides detailed instructions for setting up the INESC TEC Client for TNO Security Gateway (TSG-Client) environment.
Please follow these steps carefully to ensure successful configuration and deployment.

> **_NOTE:_** This library assumes that you have a running instance of the TSG Core Connector and OpenAPI Data APP. For this, please follow the [Official TSG Documentation](https://tno-tsg.gitlab.io/).

## Overview

Expand All @@ -24,19 +24,15 @@ It provides a simple and easy-to-use interface for tasks such as:
- Queries to the dataspace Metadata Broker to list registered connectors and respective self-descriptions
- Perform requests via OpenAPI Data APP

This document provides detailed instructions for setting up the INESC TEC Client for TNO Security Gateway (TSG-Client) environment.
Please follow these steps carefully to ensure successful configuration and deployment.

> **_NOTE:_** This library assumes that you have a running instance of the TSG Core Connector and OpenAPI Data APP. For this, please follow the [Official TSG Documentation](https://tno-tsg.gitlab.io/).

> **_WARNING:_** This library is under active development and is not yet recommended for production use at this time.
> **_IMPORTANT:_** This development is an internal initiative from INESC TEC within [ENERSHARE](https://enershare.eu/), and it is not officially maintained/supported by TNO team.
## Documentation & Examples

A detailed documentation is available [here](https://cpes-power-and-energy-systems.github.io/tsg-client/).
Python example scripts (and respective description) are also available in the [examples](examples/) directory of the repository.
A detailed documentation is available in the [docs](docs/) directory.
Python examples (and respective description) are available in the [examples](examples/) directory.


## Installation
Expand Down
Binary file removed docs/source/_static/logo.png
Binary file not shown.
3 changes: 1 addition & 2 deletions docs/source/contacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,5 @@ Contacts
If you encounter any issues or have questions, please feel free to reach out to the support team:

- **Carolina Catorze:** [[email protected]](mailto:[email protected])
- **Vasco Maia:** [[email protected]](mailto:[email protected])
- **José Luís Rodrigues:** [[email protected]](mailto:[email protected])
- **Vasco Guedes:** [[email protected]](mailto:[email protected])
- **José Ricardo Andrade:** [[email protected]](mailto:[email protected])
79 changes: 22 additions & 57 deletions docs/source/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,93 +3,52 @@ Getting Started with the TSG Client
====================================

## Overview
TSG Client is a Python library for interacting with the TNO Security Gateway (TSG). It provides a simple and easy-to-use interface for tasks such as:

TSG Client is a Python library for interacting with the TNO Security Gateway (TSG).
It is current version, it is a simple REST API client that interacts with [TSG Core Connector APIs](https://tno-tsg.gitlab.io/docs/core-container/api/) and [TSG OpenAPI Data APP](https://gitlab.com/tno-tsg/data-apps/openapi).
It provides a simple and easy-to-use interface for tasks such as:

- Connecting to a TSG core container (via API KEY)
- Connecting to TSG connectors
- Retrieving connector self-descriptions
- Parsing / filtering connector catalogs and artifacts, retrieved from self-descriptions
- Requesting and consuming data artifacts (via dataspace)
- Queries to the dataspace Metadata Broker to list registered connectors and respective self-descriptions
- Perform requests via OpenAPI Data APP

> **_WARNING:_** This library is under active development and is not yet recommended for production use at this time.
> **_IMPORTANT:_** This development is an internal initiative from INESC TEC within [ENERSHARE](https://enershare.eu/), and it is not officially maintained/supported by TNO team.
- Working with catalogs and artifacts
- Requesting and consuming data artifacts
- Knowing what connectors are in the dataspace
- Take advantage of the OpenAPI functionalities


## Installation steps

### Install essential tools

- **OS:** Windows, Linux, macOS

- **Install GIT:**
- Download and install GIT from [Git Download Page](https://git-scm.com/downloads)

- **Python**: Install Python (version 3.9+)
- **Python**: Install Python (tested using Python 3.9)

- **Install Python requirements:**
- Open a terminal and execute the following command:
```bash
pip install -r requirements.txt
```


### Clone the project and setup the environment

To install the TSG-Client, please follow the steps below:

1. Clone the repository.
Open a terminal and execute the following commands:

```bash
$ git clone https://github.com/CPES-Power-and-Energy-Systems/tsg-client.git
git clone https://gitlab.inesctec.pt/cpes/european-projects/enershare/tsg-client.git
cd tsg-client
```

2. (optional) Create a virtual environment and activate it.
### OR Install the Library

3. Install the required dependencies:
Open a project and execute the following commands:

```bash
$ pip install -r requirements.txt
```

4. Run the following command to install the python library:

```bash
$ pip install .
```

Once you install the library, you'll be able to use the TSG-Client in your Python projects by just importing it (see basic example below):
```python
from tsg_client import TSGController
# Set up the TSG connector:
conn = TSGController(
api_key="<your-api-key>",
connector_id="<your-connector-id>",
access_url="<your-access-url>",
agent_id="<your-agent-id>",
metadata_broker_url="<your-dataspace-metadata-broker-url>" # this one is optional
)
# Retrieve the connector self-description:
self_description = conn.get_connector_self_description()
print(self_description)
# List self-description of other connectors in the dataspace:
# Request data from DS Metadata Broker:
result = conn.query_metadata_broker()
print(result)
pip install git+https://gitlab.inesctec.pt/cpes/european-projects/enershare/tsg-client.git
```

### Set up environment variables

Ideally, you should set up the environment variables to avoid hardcoding the API key and other sensitive information in your code.
We have a `dotenv` file in the project that may work as an example for you to create your `.env` file. Start by copying that file:
Create a `.env` file with the following contents:

```bash
cp dotenv .env
Expand All @@ -103,10 +62,16 @@ Open the `.env` file in a text editor and modify the following variables with yo
- **CONNECTOR_ID**: Replace with the connector ID for your TSG instance.
- **ACCESS_URL**: Replace with the access URL for your TSG connector.
- **AGENT_ID**: Replace with the agent ID associated with your TSG connector.
- **METADATA_BROKER_URL**: Replace with the URL of the dataspace metadata broker (optional, just in case you will need to query the metadata broker)

Make sure to save the changes after updating the values.

### Examples

Follow the examples provided in the [Examples](examples) section.
Follow the examples provided in the Examples section


## Additional Information

The TSG-Client is a REST API that interacts with the connector of the dataspace of TNO, deployed following a specific tutorial. The available requests are currently being tested in `main.py`. The script demonstrates interactions with TSG OpenApi Data APP and inter-connector API.


14 changes: 0 additions & 14 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,9 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. image:: _static/logo.png
:width: 572

Welcome to TSG Client's documentation!
======================================

TSG Client is a Python library for interacting with the TNO Security Gateway (TSG). It is current version, it is a simple REST API client that interacts with TSG Core Connector APIs and TSG OpenAPI Data APP. It provides a simple and easy-to-use interface for tasks such as:

- Connecting to a TSG core container (via API KEY)
- Retrieving connector self-descriptions
- Parsing / filtering connector catalogs and artifacts, retrieved from self-descriptions
- Requesting and consuming data artifacts (via dataspace)
- Queries to the dataspace Metadata Broker to list registered connectors and respective self-descriptions
- Perform requests via OpenAPI Data APP

This document provides detailed instructions for setting up the INESC TEC Client for TNO Security Gateway (TSG-Client) environment. Please follow these steps carefully to ensure successful configuration and deployment.

.. toctree::
:maxdepth: 2
:caption: Contents:
Expand Down
7 changes: 7 additions & 0 deletions examples/delete_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@
# Load environment variables:
config = dotenv_values('.env')

# Example of external connector configs (TNO Playground)
EXTERNAL_CONNECTOR = {
"CONNECTOR_ID": 'urn:playground:tsg:connectors:TestConnector',
"ACCESS_URL": 'https://test-connector.playground.dataspac.es/selfdescription',
"AGENT_ID": 'urn:playground:tsg:TNO'
}

# Connect to our TSG connector:
conn = TSGController(
api_key=config['API_KEY'],
Expand Down
9 changes: 8 additions & 1 deletion examples/edit_artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@
# Load environment variables:
config = dotenv_values('.env')

# Example of external connector configs (TNO Playground)
EXTERNAL_CONNECTOR = {
"CONNECTOR_ID": 'urn:playground:tsg:connectors:TestConnector',
"ACCESS_URL": 'https://test-connector.playground.dataspac.es/selfdescription',
"AGENT_ID": 'urn:playground:tsg:TNO'
}

# Connect to our TSG connector:
conn = TSGController(
api_key=config['API_KEY'],
Expand All @@ -56,7 +63,7 @@
artifact_path = "<artifact_path>"
artifact_description = "<description>"
artifact_title = "<title>"
contract_offer_path = "./files/contracts/default.json"
contract_offer_path = "../files/contracts/default.json"

# Read the contract offer content from the file:
with open(contract_offer_path, 'r') as file:
Expand Down
Loading

0 comments on commit a703075

Please sign in to comment.