Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

policy api PUT api does not change bpns #694

Closed
ds-mmaul opened this issue Jun 13, 2024 · 7 comments
Closed

policy api PUT api does not change bpns #694

ds-mmaul opened this issue Jun 13, 2024 · 7 comments

Comments

@ds-mmaul
Copy link
Contributor

Description

Current behaviour

  • policy api PUT method does not update the field businessPartnerNumber

Expected behavior

  • policy api PUT method does apply businessPartnerNumber changes from request

Steps to reproduce the Bug

exampl request to PUT:
{
"validUntil": "2029-05-15T09:19:57.074412585Z",
"businessPartnerNumber": [
"BPNL1234567890CD",
// add BPN here and see if change affects data
],
"policyIds": [
"abc"
]
}

policy is not added to the added bpn when requesting getPolicies

@dsmf
Copy link
Contributor

dsmf commented Jun 13, 2024

@ds-mmaul : which env? cannot reproduce on DEV:

Policy:

{
	"validUntil": "2025-12-12T23:59:59.999Z",
	"businessPartnerNumber": "BPNL1234567890AB",
	"payload":
		{
			"@context": {
				"odrl": "http://www.w3.org/ns/odrl/2/"
			},
			"@id": "test-policy",
			"policy": {
				"odrl:permission": [
					{
						"odrl:action": "use",
						"odrl:constraint": {
							"odrl:and": [
								{
									"odrl:leftOperand": "Membership",
									"odrl:operator": {
										"@id": "odrl:eq"
									},
									"odrl:rightOperand": "active"
								},
								{
									"odrl:leftOperand": "PURPOSE",
									"odrl:operator": {
										"@id": "odrl:eq"
									},
									"odrl:rightOperand": "ID 3.1 Trace"
								}
							]
						}
					}
				]
			}
		}
}

Update:

PUT /irs/policies

{
  "validUntil": "2025-12-12T23:59:59.999Z",
	"businessPartnerNumbers": [
		"BPNL00000001CRHK", "BPNL00000001ABCD"
	],
	"policyIds": [
		"test-policy"
	]
}

Get all policies:

GET /irs/policies 

=>

{
	"BPNL00000001CRHK": [
		{
			"validUntil": "2025-12-12T23:59:59.999Z",
			"payload": {
				"@context": {
					"odrl": "http://www.w3.org/ns/odrl/2/"
				},
				"@id": "test-policy",
				"policy": {
					"policyId": "test-policy",
					"createdOn": "2024-06-13T10:11:35.206518778Z",
					"validUntil": "2025-12-12T23:59:59.999Z",
					"permissions": [
						{
							"action": "use",
							"constraint": {
								"and": [
									{
										"leftOperand": "Membership",
										"operator": {
											"@id": "eq"
										},
										"odrl:rightOperand": "active"
									},
									{
										"leftOperand": "PURPOSE",
										"operator": {
											"@id": "eq"
										},
										"odrl:rightOperand": "ID 3.1 Trace"
									}
								],
								"or": null
							}
						}
					]
				}
			}
		}
	],
	"BPNL00000001ABCD": [
		{
			"validUntil": "2025-12-12T23:59:59.999Z",
			"payload": {
				"@context": {
					"odrl": "http://www.w3.org/ns/odrl/2/"
				},
				"@id": "test-policy",
				"policy": {
					"policyId": "test-policy",
					"createdOn": "2024-06-13T10:11:35.206518778Z",
					"validUntil": "2025-12-12T23:59:59.999Z",
					"permissions": [
						{
							"action": "use",
							"constraint": {
								"and": [
									{
										"leftOperand": "Membership",
										"operator": {
											"@id": "eq"
										},
										"odrl:rightOperand": "active"
									},
									{
										"leftOperand": "PURPOSE",
										"operator": {
											"@id": "eq"
										},
										"odrl:rightOperand": "ID 3.1 Trace"
									}
								],
								"or": null
							}
						}
					]
				}
			}
		}
	],
       ....
}

Get policies for BPN:

GET https://irs.dev.demo.catena-x.net/irs/policies?businessPartnerNumbers=BPNL00000001CRHK&businessPartnerNumbers=BPNL00000001ABCD

=>same result as above, only limited to the given businessPartnerNumbers

@ds-mmaul
Copy link
Contributor Author

ds-mmaul commented Jun 13, 2024

Hi @dsmf ,
thanks for having a look on this issue.
I have retried it on the irs dev environment and the behaviour seems to be, that when a BPN should get updated, no matter how many or which BPNs, the policy will always be assigned to the "default" BPN array. Any update to the bpn field of a policy results it to be changed to "default":

request was:
{
"validUntil": "2029-05-08T09:19:57.074412585Z",
"businessPartnerNumber": [
"BPNL1234567890CD",
"BPNL00000003CML1"
],
"policyIds": [
"default-policy3342"
]
}

@dsmf
Copy link
Contributor

dsmf commented Jun 13, 2024

@ds-mmaul: still cannot reproduce. There is also a test https://jira.catena-x.net/browse/TRI-1953 that covers updating.

I assume that you CREATE the policy initially without a businessPartnerNumber. In this case the policy becomes the default policy. When you create the policy you need to create it with one initial businessPartnerNumber. Otherwise it becomes the default policy. Unfortunately that is how the API was defined. I know this is inconvenient which is why we have an improvement story here: #561. But I am not sure when this will be implemented.

Example:

POST /irs/policies

{
	"validUntil": "2025-12-12T23:59:59.999Z",
	"businessPartnerNumber": "BPNL1234567890CD",
	"payload":
		{
			"@context": {
				"odrl": "http://www.w3.org/ns/odrl/2/"
			},
			"@id": "the-policy-id",
			"policy": {
				...
		}
}

Afterwards you can update.

@ds-mmaul
Copy link
Contributor Author

Error was in the structure of request, closing issue. Thank you.

@mkanal mkanal moved this from inbox to done in IRS Jun 13, 2024
@mkanal
Copy link
Contributor

mkanal commented Jun 13, 2024

wontdo

@dsmf
Copy link
Contributor

dsmf commented Jun 14, 2024

For the sake of documentation: The error was that in the update request the attribute should be plural "businessPartnerNumbers" and not singluar "businessPartnerNumber".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: done
Development

No branches or pull requests

3 participants