app.routes package
Submodules
app.routes.assets_routes module
Asset routes.
This module defines the API endpoints related to asset management within the EDC Studio Backend. Assets represent data resources that can be published, transferred, or managed through EDC connectors.
Each route provides an asynchronous operation to create, retrieve, update, or delete assets, interacting with the corresponding service layer (app.services.assets_service).
- async app.routes.assets_routes.create_asset_route(data)
Create a new asset in a specific EDC connector.
This endpoint registers a new asset in the database and associates it with the specified EDC connector. The asset definition includes metadata such as name, type, and data address configuration.
- Parameters:
data (Asset) – The asset data to create.
- Returns:
The identifier (@id) of the newly created asset.
- Return type:
str
Example
>>> POST /assets { "asset_id": "asset-001", "name": "Weather Dataset", "content_type": "application/json", "data_address_name": "weather-data", "data_address_type": "HttpData", "data_address_proxy": false, "base_url": "https://data.server.com/weather", "edc": "edc-provider-01" }
- async app.routes.assets_routes.list_assets_by_edc(edc_id)
Retrieve all assets associated with a specific EDC connector.
- Parameters:
edc_id (str) – Identifier of the EDC connector.
- Returns:
List of assets registered under the given connector.
- Return type:
List[Asset]
Example
>>> GET /assets/by-edc/edc-provider-01
- async app.routes.assets_routes.get_asset_by_asset_id(edc_id, asset_id)
Retrieve a specific asset by its ID within a given EDC connector.
- Parameters:
edc_id (str) – Identifier of the EDC connector.
asset_id (str) – Unique identifier of the asset.
- Returns:
The asset matching the given EDC and asset ID.
- Return type:
Example
>>> GET /assets/by-asset-id/edc-provider-01/asset-001
- async app.routes.assets_routes.update_asset_route(asset, edc_id)
Update an existing asset within a given EDC connector.
- Parameters:
asset (Asset) – The updated asset data.
edc_id (str) – Identifier of the EDC connector.
- Returns:
Confirmation message indicating successful update.
- Return type:
dict
Example
>>> PUT /assets/edc-provider-01 { "asset_id": "asset-001", "name": "Updated Weather Dataset", ... }
- async app.routes.assets_routes.delete_asset_route(asset_id, edc_id)
Delete an asset from a specific EDC connector.
- Parameters:
asset_id (str) – Identifier of the asset to delete.
edc_id (str) – Identifier of the EDC connector.
- Returns:
Confirmation message indicating successful deletion.
- Return type:
dict
Example
>>> DELETE /assets/asset-001/edc-provider-01
app.routes.connectors_routes module
Connector routes.
This module defines the API endpoints used to manage EDC connectors within the EDC Studio Backend. Each connector can act as a provider or consumer and supports lifecycle operations such as creation, startup, stop, update, and deletion.
All routes interact with the connector service layer (app.services.connectors_service) and use Pydantic models for validation.
- async app.routes.connectors_routes.create_connector_route(data)
Create a new EDC connector.
Registers a new connector in the database. The connector can later be started or stopped through its lifecycle endpoints.
- Parameters:
data (Connector) – The connector data to be created.
- Returns:
The identifier of the newly created connector.
- Return type:
dict
- Raises:
HTTPException – If the connector cannot be created due to a server error.
Example
>>> POST /connectors { "name": "EDC Provider 01", "type": "provider", "state": "stopped", "mode": "managed" }
- async app.routes.connectors_routes.start_edc(id)
Start an EDC connector.
Launches the connector process (Docker or local instance) and sets its state to running.
- Parameters:
id (str) – Identifier of the connector to start.
- Returns:
Confirmation message indicating successful start.
- Return type:
dict
- Raises:
HTTPException –
404: If the connector does not exist. - 500: If startup fails unexpectedly.
Example
>>> POST /connectors/edc-provider-01/start
- async app.routes.connectors_routes.stop_edc(id)
Stop a running EDC connector.
Gracefully stops a managed connector process and updates its state to stopped.
- Parameters:
id (str) – Identifier of the connector to stop.
- Returns:
Confirmation message indicating successful stop.
- Return type:
dict
- Raises:
HTTPException –
404: If the connector does not exist. - 500: If the stop operation fails.
Example
>>> POST /connectors/edc-provider-01/stop
- async app.routes.connectors_routes.list_connectors()
Retrieve all registered connectors.
- Returns:
List of all connectors stored in the system.
- Return type:
List[ConnectorResponse]
Example
>>> GET /connectors
- async app.routes.connectors_routes.get_connector(id)
Retrieve a specific connector by its identifier.
- Parameters:
id (str) – Identifier of the connector.
- Returns:
The connector matching the given ID.
- Return type:
- Raises:
HTTPException – 404 if the connector is not found.
Example
>>> GET /connectors/edc-provider-01
- async app.routes.connectors_routes.update_connector_route(id, data=Body(PydanticUndefined))
Update a connector’s configuration.
- Parameters:
id (str) – Identifier of the connector to update.
data (ConnectorUpdate) – Fields to be modified.
- Returns:
Confirmation message indicating successful update.
- Return type:
dict
- Raises:
HTTPException – 404 if the connector does not exist.
Example
>>> PUT /connectors/edc-provider-01 { "description": "Updated provider connector" }
- async app.routes.connectors_routes.delete_connector_route(id)
Delete a connector from the system.
- Parameters:
id (str) – Identifier of the connector to delete.
- Returns:
Confirmation message indicating successful deletion.
- Return type:
dict
- Raises:
HTTPException – 404 if the connector does not exist.
Example
>>> DELETE /connectors/edc-provider-01
app.routes.contracts_routes module
Contract routes.
This module defines the API endpoints for managing contract definitions within the EDC Studio Backend. A contract links assets with their corresponding access and usage policies, enabling regulated data exchange between provider and consumer connectors.
All endpoints in this module interact with the service layer (app.services.contracts_service) to perform database operations.
- async app.routes.contracts_routes.create_contract_route(data)
Create a new contract definition for a specific EDC connector.
- Parameters:
data (Contract) – The contract data to be created, including asset selection and policy references.
- Returns:
The identifier (@id) of the newly created contract.
- Return type:
str
Example
>>> POST /contracts { "edc": "edc-provider-01", "contract_id": "contract-001", "accessPolicyId": "policy-access-01", "contractPolicyId": "policy-contract-01", "assetsSelector": ["asset-001"] }
- async app.routes.contracts_routes.list_contracts_by_edc(edc_id)
Retrieve all contracts associated with a specific EDC connector.
- Parameters:
edc_id (str) – Identifier of the EDC connector.
- Returns:
List of contract definitions belonging to the connector.
- Return type:
List[Contract]
Example
>>> GET /contracts/by-edc/edc-provider-01
- async app.routes.contracts_routes.get_contract_by_contract_id(edc_id, contract_id)
Retrieve a specific contract by its identifier and associated EDC.
- Parameters:
edc_id (str) – Identifier of the EDC connector.
contract_id (str) – Identifier of the contract definition.
- Returns:
The contract definition that matches the provided identifiers.
- Return type:
Example
>>> GET /contracts/by-contract-id/edc-provider-01/contract-001
- async app.routes.contracts_routes.update_contract_route(contract, edc_id)
Update an existing contract definition.
- Parameters:
contract (Contract) – The updated contract data.
edc_id (str) – Identifier of the EDC connector associated with the contract.
- Returns:
Confirmation message indicating successful update.
- Return type:
dict
- Raises:
HTTPException – 404 if the contract does not exist or cannot be updated.
Example
>>> PUT /contracts/edc-provider-01 { "contract_id": "contract-001", "accessPolicyId": "policy-access-02", "contractPolicyId": "policy-contract-02", "assetsSelector": ["asset-002"] }
- async app.routes.contracts_routes.delete_contract_route(contract_id, edc_id)
Delete a contract definition.
- Parameters:
contract_id (str) – Identifier of the contract to delete.
edc_id (str) – Identifier of the EDC connector associated with the contract.
- Returns:
Confirmation message indicating successful deletion.
- Return type:
dict
- Raises:
HTTPException – 404 if the contract does not exist or cannot be deleted.
Example
>>> DELETE /contracts/contract-001/edc-provider-01
app.routes.policies_routes module
Policy routes.
This module defines the API endpoints for managing policies in the EDC Studio Backend. Policies are based on the ODRL (Open Digital Rights Language) specification and describe permissions, prohibitions, and obligations for data usage between connectors.
All endpoints in this module interact with the service layer (app.services.policies_service) to perform CRUD operations on EDC policy definitions.
- async app.routes.policies_routes.create_policy_route(data)
Create a new policy definition for a given EDC connector.
- Parameters:
data (Policy) – The policy data to create, including permissions, prohibitions, obligations, and context.
- Returns:
The identifier (@id) of the newly created policy.
- Return type:
str
Example
>>> POST /policies { "edc": "edc-provider-01", "policy_id": "policy-001", "policy": { "permission": [ {"action": "USE"} ], "context": "http://www.w3.org/ns/odrl.jsonld", "type": "Set" } }
- async app.routes.policies_routes.list_policies_by_edc(edc_id)
Retrieve all policies associated with a specific EDC connector.
- Parameters:
edc_id (str) – Identifier of the EDC connector.
- Returns:
List of policy definitions registered under the given connector.
- Return type:
List[Policy]
Example
>>> GET /policies/by-edc/edc-provider-01
- async app.routes.policies_routes.get_policy_by_policy_id(edc_id, policy_id)
Retrieve a specific policy by its identifier within a given EDC connector.
- Parameters:
edc_id (str) – Identifier of the EDC connector.
policy_id (str) – Identifier of the policy definition.
- Returns:
The policy that matches the given EDC and policy ID.
- Return type:
Example
>>> GET /policies/by-policy-id/edc-provider-01/policy-001
- async app.routes.policies_routes.delete_asset_route(policy_id, edc_id)
Delete a policy definition associated with a specific EDC connector.
- Parameters:
policy_id (str) – Identifier of the policy to delete.
edc_id (str) – Identifier of the EDC connector.
- Returns:
Confirmation message indicating successful deletion.
- Return type:
dict
- Raises:
HTTPException – 404 if the policy does not exist or cannot be deleted.
Example
>>> DELETE /policies/policy-001/edc-provider-01
app.routes.transfers_routes module
Transfer routes.
This module defines the API endpoints responsible for managing data transfers between EDC connectors in the EDC Studio Backend. Transfers can follow both push and pull models, with full support for contract negotiation, catalog retrieval, and data flow monitoring.
All endpoints interact with the EDC connectors via the service layer (app.services.transfers_service) and facilitate end-to-end data exchange orchestration.
- async app.routes.transfers_routes.catalog_request(data)
Request the data catalog from a provider connector.
- Parameters:
data (RequestCatalog) – Contains consumer and provider identifiers.
- Returns:
The catalog data returned by the provider connector.
- Return type:
dict
- Raises:
HTTPException –
404: If the provider connector is not found. - 500: If the catalog request fails.
Example
>>> POST /transfers/catalog_request { "consumer": "edc-consumer-01", "provider": "edc-provider-01" }
- async app.routes.transfers_routes.negotiate_contract(data)
Negotiate a data-sharing contract between consumer and provider connectors.
- Parameters:
data (NegotitateContract) – Contains consumer, provider, contract offer ID, and associated asset.
- Returns:
Contract negotiation response from the EDC provider.
- Return type:
dict
- Raises:
HTTPException –
404: If the connectors or contract offer are not found. - 500: If negotiation fails.
Example
>>> POST /transfers/negotiate_contract { "consumer": "edc-consumer-01", "provider": "edc-provider-01", "contract_offer_id": "offer-123", "asset": "asset-001" }
- async app.routes.transfers_routes.contract_agreement(data)
Retrieve the contract agreement details for a specific negotiation.
- Parameters:
data (ContractAgreement) – Contains consumer ID and contract negotiation ID.
- Returns:
Contract agreement details.
- Return type:
dict
- Raises:
HTTPException –
404: If the contract negotiation ID is invalid. - 500: If fetching the agreement fails.
Example
>>> POST /transfers/contract_agreement { "consumer": "edc-consumer-01", "id_contract_negotiation": "negotiation-001" }
- async app.routes.transfers_routes.start_http_server()
Start a local HTTP server to log incoming data requests.
- Returns:
Confirmation message upon successful start.
- Return type:
dict
- Raises:
HTTPException – 500 if the server cannot be started.
- async app.routes.transfers_routes.stop_http_server()
Stop the HTTP server used for logging data transfer requests.
- Returns:
Confirmation message upon successful stop.
- Return type:
dict
- Raises:
HTTPException – 500 if stopping the server fails.
- async app.routes.transfers_routes.start_transfer(data)
Start a data transfer in push mode.
- Parameters:
data (StartTransfer) – Contains consumer, provider, and contract agreement ID.
- Returns:
Transfer process details.
- Return type:
dict
- Raises:
HTTPException –
404: If connectors or contracts are invalid. - 500: If transfer start fails.
- async app.routes.transfers_routes.check_transfer(data)
Check the status of an ongoing transfer process.
- Parameters:
data (CheckTransfer) – Contains consumer and transfer process ID.
- Returns:
Transfer process state details.
- Return type:
dict
- Raises:
HTTPException –
404: If the transfer ID is invalid. - 500: If status retrieval fails.
- async app.routes.transfers_routes.new_transfer(data)
Register a completed transfer in the database.
- Parameters:
data (Transfer) – Transfer metadata including consumer, provider, asset, and process IDs.
- Returns:
The ID of the newly created transfer record.
- Return type:
dict
- async app.routes.transfers_routes.get_all_transfers()
Retrieve all registered transfers from the database.
- Returns:
List of all completed transfers.
- Return type:
List[Transfer]
- async app.routes.transfers_routes.start_transfer_pull(data)
Start a data transfer in pull mode.
- Parameters:
data (StartTransfer) – Contains consumer, provider, and contract agreement ID.
- Returns:
Transfer process details for pull operation.
- Return type:
dict
- Raises:
HTTPException –
404: If connectors or contracts are invalid. - 500: If transfer start fails.
- async app.routes.transfers_routes.check_data_pull(data)
Check the data availability for pull-based transfers.
- Parameters:
data (CheckTransfer) – Contains consumer and transfer process ID.
- Returns:
Pull data status from the provider.
- Return type:
dict
- app.routes.transfers_routes.proxy_http_logger()
Proxy endpoint to retrieve logs from the HTTP logger.
- Returns:
Logged HTTP requests captured during data transfer.
- Return type:
JSONResponse
- app.routes.transfers_routes.proxy_pull(uri, authorization=Header(PydanticUndefined))
Proxy endpoint for pull transfers.
Fetches data directly from the provider using the provided URI and authorization header.
- Parameters:
uri (str) – Data URI to pull from the provider.
authorization (str) – Authorization token header.
- Returns:
Raw content fetched from the provider.
- Return type:
Response
- Raises:
HTTPException – If the provider returns an error.