eclipse-tractusx / item-relationship-service

https://eclipse-tractusx.github.io/item-relationship-service/docs/
Apache License 2.0
7 stars 21 forks source link

(Uncommitted) Usage of EDC EDR API (in case current E2E with EDC is not working) #575

Open ds-jhartmann opened 4 months ago

ds-jhartmann commented 4 months ago

As a developer, I want to switch to the EDC EDR API, so that the EDC flow gets simpler and more resilient.

Hints / Details

Acceptance Criteria

Technical stuff

Testing

Out of Scope

ds-jhartmann commented 4 months ago

Planning 2:

EDR Negotiation request:

{
    "@context": [
        "https://w3id.org/tractusx/policy/v1.0.0",
        "http://www.w3.org/ns/odrl.jsonld",
        {
            "@vocab": "https://w3id.org/edc/v0.0.1/ns/"
        }
    ],
    "@type": "ContractRequest",
    "counterPartyAddress": "{{ _.PROVIDER_CONTROLPLANE_1 }}/api/v1/dsp",
    "protocol": "dataspace-protocol-http",
    "policy": {
        "@id": "YTYxMjJlNTUtZWY2Ni00MWM4LWFjMjgtZDA5ODhlMmQ2YzRi:dXJuOnV1aWQ6ZWEzMmY2ZjctYzg4NC00YmZkLWFmNGEtNzc4NjY2YTFmZmZi:YjZkMzMzYWItZGI0Zi00M2MzLWE3YjAtM2I4Yjc3NWQzMmRh",
        "@type": "Offer",
        "assigner": "BPNL00000001CRHK",
        "odrl:permission": {
            "odrl:action": {
                "odrl:type": "USE"
            },
            "odrl:constraint": {
                "odrl:or": {
                    "odrl:leftOperand": "PURPOSE",
                    "odrl:operator": {
                        "@id": "odrl:eq"
                    },
                    "odrl:rightOperand": "ID 3.1 Trace"
                }
            }
        },
        "prohibition": [],
        "obligation": [],
        "target": "urn:uuid:ea32f6f7-c884-4bfd-af4a-778666a1fffb"
    },
    "callbackAddresses": []
}

Query for EDR negotiation by edc asset id:

{
    "@context": {
        "@vocab": "https://w3id.org/edc/v0.0.1/ns/"
    },
    "@type": "QuerySpec",
    "filterExpression": [
        {
            "operandLeft": "assetId",
            "operator": "=",
            "operandRight": "urn:uuid:ea32f6f7-c884-4bfd-af4a-778666a1fffb"
        }
    ]
}
dsmf commented 2 months ago

Notes how to get token:

get catalog: EDC Req Get Catalog

then id from asset "registry-asset"

start EDR negotiation

id "registry-asset" goes into the field target

the id of the policy:

id: MjA1MTFkNzEtM2M5ZS00OTg1LTg4MjYtYjcwYjA4ODIzYzYx:cmVnaXN0cnktYXNzZXQ=:ZDQ0N2IwNGItYzEyOS00NTAzLTgwNmUtMDYyOTJlNWMxZDNh

permission:

    "odrl:permission": {
                    "odrl:action": {
                        "odrl:type": "use"
                    },
                    "odrl:constraint": {
                        "odrl:and": [
                            {
                                "odrl:leftOperand": "cx-policy:FrameworkAgreement",
                                "odrl:operator": {
                                    "@id": "odrl:eq"
                                },
                                "odrl:rightOperand": "traceability:1.0"
                            },
                            {
                                "odrl:leftOperand": "cx-policy:UsagePurpose",
                                "odrl:operator": {
                                    "@id": "odrl:eq"
                                },
                                "odrl:rightOperand": "cx.core.industrycore:1"
                            }
                        ]
                    }
                },

=>

{
    "@type": "IdResponse",
    "@id": "04713a04-b394-4f7d-b5a7-120111cc861f",
    "createdAt": 1719583149759,
    "@context": {
        "@vocab": "https://w3id.org/edc/v0.0.1/ns/",
        "edc": "https://w3id.org/edc/v0.0.1/ns/",
        "tx": "https://w3id.org/tractusx/v0.0.1/ns/",
        "tx-auth": "https://w3id.org/tractusx/auth/",
        "cx-policy": "https://w3id.org/catenax/policy/",
        "odrl": "http://www.w3.org/ns/odrl/2/"
    }
}

04713a04-b394-4f7d-b5a7-120111cc861f

{
    "@context": {
        "@vocab": "https://w3id.org/edc/v0.0.1/ns/"
    },
    "@type": "QuerySpec",
    "filterExpression": [
        {
            "operandLeft": "contractNegotiationId",
            "operator": "=",
            "operandRight": "{% response 'body', 'req_3a6a7b9bc74b474b8f6d3130958145f9', 'b64::JC5gQGlk::46b', 'never', 60 %}"
        }
    ]
}

=>

[
    {
        "@id": "ea52b90b-de19-4919-b3af-109d2504a891",
        "@type": "EndpointDataReferenceEntry",
        "providerId": "BPNL00000001CRHK",
        "assetId": "registry-asset",
        "agreementId": "69651dc2-fe59-4c8b-92a3-0a835e5ef576",
        "transferProcessId": "ea52b90b-de19-4919-b3af-109d2504a891",
        "createdAt": 1719583159173,
        "contractNegotiationId": "04713a04-b394-4f7d-b5a7-120111cc861f",
        "@context": {
            "@vocab": "https://w3id.org/edc/v0.0.1/ns/",
            "edc": "https://w3id.org/edc/v0.0.1/ns/",
            "tx": "https://w3id.org/tractusx/v0.0.1/ns/",
            "tx-auth": "https://w3id.org/tractusx/auth/",
            "cx-policy": "https://w3id.org/catenax/policy/",
            "odrl": "http://www.w3.org/ns/odrl/2/"
        }
    }
]

get edr data address

"@id": "ea52b90b-de19-4919-b3af-109d2504a891", with param auto_refresh = true

=> token