Skip to content

Commit

Permalink
Merge pull request #920 from eclipse-tractusx/main
Browse files Browse the repository at this point in the history
sync with upstream
  • Loading branch information
ds-jhartmann authored May 7, 2024
2 parents b5eaecd + 7249323 commit bfb4998
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
10 changes: 5 additions & 5 deletions DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,12 @@ maven/mavencentral/org.eclipse.tractusx.edc/core-spi/0.6.0, Apache-2.0, approved
maven/mavencentral/org.eclipse.tractusx.edc/edr-api/0.6.0, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.edc/edr-spi/0.6.0, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-api/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-common/2.0.0, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-edc-client/2.0.0, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-models/2.0.0, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-common/2.0.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-edc-client/2.0.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-models/2.0.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-policy-store/0.0.2-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/2.0.0, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-testing/2.0.0, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-registry-client/2.0.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.eclipse.tractusx.irs/irs-testing/2.0.1-SNAPSHOT, Apache-2.0, approved, automotive.tractusx
maven/mavencentral/org.glassfish/jakarta.json/2.0.1, EPL-2.0 OR GPL-2.0-only with Classpath-exception-2.0, approved, ee4j.jsonp
maven/mavencentral/org.hamcrest/hamcrest-core/2.2, BSD-3-Clause, approved, clearlydefined
maven/mavencentral/org.hamcrest/hamcrest/2.2, BSD-3-Clause, approved, clearlydefined
Expand Down
28 changes: 19 additions & 9 deletions local/testing/testdata/transform-and-upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
import argparse
import json
import math
import requests
import time
import uuid
from copy import copy

import requests
from requests.adapters import HTTPAdapter, Retry


Expand Down Expand Up @@ -243,7 +244,8 @@ def print_response(response_):
raise Exception("Failed to call service")


def check_url_args(submodel_server_upload_urls_, submodel_server_urls_, edc_upload_urls_, edc_urls_, dataplane_urls_):
def check_url_args(submodel_server_upload_urls_, submodel_server_urls_, edc_upload_urls_, edc_urls_, dataplane_urls_,
edc_bpns_):
nr_of_submodel_server_upload_urls = len(submodel_server_upload_urls_)
nr_of_submodel_server_urls = len(submodel_server_urls_)
if nr_of_submodel_server_upload_urls != nr_of_submodel_server_urls:
Expand All @@ -256,6 +258,11 @@ def check_url_args(submodel_server_upload_urls_, submodel_server_urls_, edc_uplo
raise ArgumentException(
f"Number and order of edc upload URLs '{edc_upload_urls_}' has to match number and order of edc URLs "
f"'{edc_urls_}'")
nr_of_edc_bpns = len(edc_bpns_)
if nr_of_edc_urls != nr_of_edc_bpns:
raise ArgumentException(
f"Number and order of edc URLs '{nr_of_edc_urls}' has to match number and order of edc BPNs "
f"'{nr_of_edc_bpns}'")
if nr_of_submodel_server_urls != nr_of_edc_urls:
raise ArgumentException(
f"Number and order of edc URLs '{edc_urls_}' has to match number and order of submodelserver URLS "
Expand Down Expand Up @@ -292,11 +299,12 @@ def create_policy(policy_, edc_upload_url_, edc_policy_path_, headers_, session_
print(f"Successfully created policy {response_.json()['@id']}.")


def create_registry_asset(edc_upload_urls_, edc_asset_path_, edc_contract_definition_path_, catalog_path_, header_,
def create_registry_asset(edc_upload_urls_, edc_bpns_, edc_asset_path_, edc_contract_definition_path_, catalog_path_, header_,
session_, edc_urls_, policy_, registry_asset_id_, aas_url_):
for edc_upload_url_ in edc_upload_urls_:
index = edc_upload_urls_.index(edc_upload_url_)
edc_url_ = edc_urls_[index]
edc_bpn_ = edc_bpns_[index]
print(edc_url_)
print(edc_upload_url_)

Expand All @@ -305,7 +313,7 @@ def create_registry_asset(edc_upload_urls_, edc_asset_path_, edc_contract_defini
"@context": edc_context(),
"edc:protocol": "dataspace-protocol-http",
"edc:counterPartyAddress": f"{edc_url_}/api/v1/dsp",
"edc:counterPartyId": "BPNL00000001CRHK",
"edc:counterPartyId": f"{edc_bpn_}",
"edc:querySpec": {
"edc:filterExpression": {
"@type": "edc:Criterion",
Expand All @@ -324,7 +332,7 @@ def create_registry_asset(edc_upload_urls_, edc_asset_path_, edc_contract_defini
if response_.status_code == 200 and len(catalog_response_['dcat:dataset']) >= 1:
first_offer_ = catalog_response_['dcat:dataset']
print(
f"Offer with type {first_offer_['edc:type']} already exists. Skipping creation.")
f"Offer with type {first_offer_['type']} already exists. Skipping creation.")
else:
payload_ = create_edc_registry_asset_payload(aas_url_, registry_asset_id_)
response_ = session_.request(method="POST", url=asset_url_,
Expand Down Expand Up @@ -430,6 +438,7 @@ def search_for_asset_in_catalog(edc_catalog_path_, edc_upload_url_, edc_url_, he
parser.add_argument("-au", "--aasupload", type=str, help="aas url", required=False)
parser.add_argument("-edc", "--edc", type=str, nargs="*", help="EDC provider control plane display URLs",
required=True)
parser.add_argument("--edcBPN", type=str, nargs="*", help="The BPN of the provider EDC", required=True)
parser.add_argument("-eu", "--edcupload", type=str, nargs="*", help="EDC provider control plane upload URLs",
required=False)
parser.add_argument("-k", "--apikey", type=str, help="EDC provider api key", required=True)
Expand Down Expand Up @@ -457,6 +466,7 @@ def search_for_asset_in_catalog(edc_catalog_path_, edc_upload_url_, edc_url_, he
aas_url = config.get("aas")
aas_upload_url = config.get("aasupload")
edc_urls = config.get("edc")
edc_bpns = config.get("edcBPN")
edc_upload_urls = config.get("edcupload")
edc_api_key = config.get("apikey")
esr_url = config.get("esr")
Expand Down Expand Up @@ -492,7 +502,8 @@ def search_for_asset_in_catalog(edc_catalog_path_, edc_upload_url_, edc_url_, he
if is_aas3:
registry_path = "/shell-descriptors"

check_url_args(submodel_server_upload_urls, submodel_server_urls, edc_upload_urls, edc_urls, dataplane_urls)
check_url_args(submodel_server_upload_urls, submodel_server_urls, edc_upload_urls, edc_urls, dataplane_urls,
edc_bpns)

edc_asset_path = "/management/v3/assets"
edc_policy_path = "/management/v2/policydefinitions"
Expand All @@ -517,10 +528,9 @@ def search_for_asset_in_catalog(edc_catalog_path_, edc_upload_url_, edc_url_, he
"@context": {
"odrl": "http://www.w3.org/ns/odrl/2/"
},
"@type": "odrl:Set",
"@id": "default-policy",
"policy": {
"@type": "Policy",
"@type": "odrl:Set",
"odrl:permission": []
}
}
Expand All @@ -547,7 +557,7 @@ def search_for_asset_in_catalog(edc_catalog_path_, edc_upload_url_, edc_url_, he
for url in edc_upload_urls:
create_policy(policies[policy], url, edc_policy_path, headers_with_api_key, session)

create_registry_asset(edc_upload_urls, edc_asset_path, edc_contract_definition_path, edc_catalog_path,
create_registry_asset(edc_upload_urls, edc_bpns, edc_asset_path, edc_contract_definition_path, edc_catalog_path,
headers_with_api_key, session, edc_urls, default_policy, registry_asset_id, aas_url)

if is_ess:
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
</sonar.coverage.jacoco.xmlReportPaths>

<!-- IRS Registry Client Library -->
<irs-registry-client.version>2.0.0</irs-registry-client.version>
<irs-registry-client.version>2.0.1-SNAPSHOT</irs-registry-client.version>

<!-- Dependencies -->
<springboot.version>3.1.11</springboot.version>
Expand Down

0 comments on commit bfb4998

Please sign in to comment.