Skip to content

Commit

Permalink
feat(impl):[eclipse-tractusx#750] get policy by id - update / correct…
Browse files Browse the repository at this point in the history
… documentation
  • Loading branch information
dsmf committed Jul 15, 2024
1 parent 497a415 commit a8fb24d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
46 changes: 44 additions & 2 deletions docs/src/api/irs-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ paths:
content:
application/json:
examples:
error:
success:
$ref: '#/components/examples/get-policies-paged-result'
schema:
$ref: '#/components/schemas/Page'
Expand Down Expand Up @@ -1088,9 +1088,11 @@ paths:
"200":
content:
application/json:
examples:
success:
$ref: '#/components/examples/get-policies-by-id'
schema:
type: string
description: List of policies
description: Returns the policies as list of policies.
"401":
content:
Expand Down Expand Up @@ -1558,6 +1560,46 @@ components:
relationships: []
submodels: []
tombstones: []
get-policies-by-id:
value:
- bpn: BPNL1234567890AB
policy:
createdOn: 2024-07-08T12:01:19.4677109+02:00
permissions:
- action: use
constraint:
and: []
or:
- leftOperand: Membership
operator:
'@id': eq
rightOperand: active
- leftOperand: FrameworkAgreement.traceability
operator:
'@id': eq
rightOperand: active
- leftOperand: PURPOSE
operator:
'@id': eq
rightOperand: ID 3.1 Trace
- action: access
constraint:
and: []
or:
- leftOperand: Membership
operator:
'@id': eq
rightOperand: active
- leftOperand: FrameworkAgreement.traceability
operator:
'@id': eq
rightOperand: active
- leftOperand: PURPOSE
operator:
'@id': eq
rightOperand: ID 3.1 Trace
policyId: 13a8523f-c80a-40b8-9e43-faab47fbceaa
validUntil: 2025-07-08T12:01:19.4677109+02:00
get-policies-paged-result:
value:
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ public void createExamples(final Components components) {
components.addExamples("complete-job-list-processing-state", createJobListProcessingState());
components.addExamples("aspect-models-list", createAspectModelsResult());
components.addExamples("get-policies-paged-result", createPageOfPolicies());
components.addExamples("get-policies-by-id", createListOfPolicies());
}

private Example createPageOfPolicies() {
Expand All @@ -166,6 +167,19 @@ private Example createPageOfPolicies() {
return toExample(page);
}

private Example createListOfPolicies() {
final List<PolicyWithBpn> policyWithBpn = List.of( //
new PolicyWithBpn("BPNL1234567890AB", Policy.builder()
.policyId("13a8523f-c80a-40b8-9e43-faab47fbceaa")
.createdOn(OffsetDateTime.parse(
"2024-07-08T12:01:19.4677109+02:00"))
.validUntil(OffsetDateTime.parse(
"2025-07-08T12:01:19.4677109+02:00"))
.permissions(createPermissions())
.build()));
return toExample(policyWithBpn);
}

private List<Permission> createPermissions() {
return List.of(new Permission(PolicyType.USE, createConstraints()),
new Permission(PolicyType.ACCESS, createConstraints()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,10 @@ public CreatePoliciesResponse registerAllowedPolicy(@Valid @RequestBody final Cr
@ApiResponses(
value = { @ApiResponse(responseCode = "200", description = "Returns the policies as list of policies.",
content = { @Content(mediaType = APPLICATION_JSON_VALUE,
// TODO examples = @ExampleObject(PolicyResponse.BPN_TO_POLICY_MAP_EXAMPLE),
schema = @Schema(description = "List of policies"))
schema = @Schema(description = "List of policies",
implementation = List.class),
examples = @ExampleObject(name = "success",
ref = "#/components/examples/get-policies-by-id")),
}),
@ApiResponse(responseCode = "401", description = UNAUTHORIZED_DESC,
content = { @Content(mediaType = APPLICATION_JSON_VALUE,
Expand Down Expand Up @@ -280,7 +282,7 @@ public Map<String, List<PolicyResponse>> getPolicies(//
description = "Successfully retrieved the paged policies",
content = @Content(mediaType = APPLICATION_JSON_VALUE,
schema = @Schema(implementation = Page.class),
examples = @ExampleObject(name = "error",
examples = @ExampleObject(name = "success",
ref = "#/components/examples/get-policies-paged-result"))),

@ApiResponse(responseCode = "401", description = UNAUTHORIZED_DESC,
Expand Down

0 comments on commit a8fb24d

Please sign in to comment.