Skip to content

Commit

Permalink
chore: update to support EDC release v0.2.0
Browse files Browse the repository at this point in the history
* fix: typo

* fix: specification issues

* fix: missing descriptions from 200 response codes

* fix: assets updated to match returned json

* fix: retrieve catalog

* fix: negotiate contract

* fix: removed depreciated endpoint calls

* fix: changed policy definition format

* fix: transfer process

* fix: allow different policies

* fixed for connector v0.1.3

* add endpoint versions to service classes

---------

Co-authored-by: Ty Gross <[email protected]>
  • Loading branch information
tygross025 and Ty Gross committed Jul 28, 2023
1 parent c3ec34f commit b27e97f
Show file tree
Hide file tree
Showing 43 changed files with 389 additions and 306 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Developer documentation can be found under [docs/developer](docs/developer/), wh

## Generate client code for EDC REST APIs

1. [optional] copy the current version of EDC's `openapi.yaml` file to `openapi/`. There is one checked in, so this is not required.
1. [optional] copy the current version of EDC's `management-api.yaml` file to `openapi/`. There is one checked in, so this is not required.
2. in a shell execute
```shell
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate -i /local/openapi/openapi.yaml -g typescript-angular -o /local/src/modules/edc-dmgmt-client/
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli generate -i /local/openapi/management-api.yaml -g typescript-angular -o /local/src/modules/edc-dmgmt-client/
```
This re-generates the service and model classes.

Expand Down
26 changes: 21 additions & 5 deletions openapi/management-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ paths:
type: string
responses:
"200":
description: Successfully retrieved all contract negotiations
content:
application/json:
schema:
Expand Down Expand Up @@ -83,6 +84,7 @@ paths:
$ref: '#/components/schemas/QuerySpecDto'
responses:
"200":
description: Successfully retrieved all contract agreements
content:
application/json:
schema:
Expand Down Expand Up @@ -113,7 +115,7 @@ paths:
type: string
responses:
"200":
description: The contract agreement
description: Successfully retrieved the contract agreement
content:
application/json:
schema:
Expand Down Expand Up @@ -183,6 +185,7 @@ paths:
type: string
responses:
"200":
description: Successfully retrieved all contract negotiations
content:
application/json:
schema:
Expand Down Expand Up @@ -245,6 +248,7 @@ paths:
$ref: '#/components/schemas/QuerySpecDto'
responses:
"200":
description: Successfully retrieved all contract negotiations
content:
application/json:
schema:
Expand Down Expand Up @@ -275,7 +279,7 @@ paths:
type: string
responses:
"200":
description: The contract negotiation
description: Successfully retrieved the contract negotiation
content:
application/json:
schema:
Expand Down Expand Up @@ -501,6 +505,7 @@ paths:
type: string
responses:
"200":
description: Successfully retrieved all transfer processes
content:
application/json:
schema:
Expand Down Expand Up @@ -562,6 +567,7 @@ paths:
$ref: '#/components/schemas/QuerySpecDto'
responses:
"200":
description: Successfully retrieved all transfer processes
content:
application/json:
schema:
Expand Down Expand Up @@ -592,7 +598,7 @@ paths:
type: string
responses:
"200":
description: The transfer process
description: Successfully retrieved the transfer process
content:
application/json:
schema:
Expand Down Expand Up @@ -870,6 +876,7 @@ paths:
type: string
responses:
"200":
description: Successfully retrieved all policy definitions
content:
application/json:
schema:
Expand Down Expand Up @@ -933,6 +940,7 @@ paths:
$ref: '#/components/schemas/QuerySpecDto'
responses:
"200":
description: Successfully retrieved all policy definitions
content:
application/json:
schema:
Expand Down Expand Up @@ -963,7 +971,7 @@ paths:
type: string
responses:
"200":
description: The policy definition
description: Successfully retrieved the policy definition
content:
application/json:
schema:
Expand Down Expand Up @@ -1038,6 +1046,7 @@ paths:
operationId: checkHealth
responses:
"200":
description: Runtime status description
content:
application/json:
schema:
Expand All @@ -1053,6 +1062,7 @@ paths:
operationId: getLiveness
responses:
"200":
description: Runtime is working
content:
application/json:
schema:
Expand All @@ -1068,6 +1078,7 @@ paths:
operationId: getReadiness
responses:
"200":
description: Runtime is ready
content:
application/json:
schema:
Expand All @@ -1083,6 +1094,7 @@ paths:
operationId: getStartup
responses:
"200":
description: Runtime has completed startup
content:
application/json:
schema:
Expand Down Expand Up @@ -1138,6 +1150,7 @@ paths:
type: string
responses:
"200":
description: Successfully retrieved all contract definitions
content:
application/json:
schema:
Expand Down Expand Up @@ -1201,6 +1214,7 @@ paths:
$ref: '#/components/schemas/QuerySpecDto'
responses:
"200":
description: Successfully retrieved all contract definitions
content:
application/json:
schema:
Expand Down Expand Up @@ -1415,6 +1429,7 @@ paths:
type: string
responses:
"200":
description: Successfully retrieved all assets
content:
application/json:
schema:
Expand Down Expand Up @@ -1478,6 +1493,7 @@ paths:
$ref: '#/components/schemas/QuerySpecDto'
responses:
"200":
description: Successfully retrieved all assets
content:
application/json:
schema:
Expand Down Expand Up @@ -1637,7 +1653,7 @@ components:
format: int64
id:
type: string
properties:
"edc:properties":
type: object
additionalProperties:
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class AssetViewerComponent implements OnInit {
this.filteredAssets$ = this.fetch$
.pipe(
switchMap(() => {
const assets$ = this.assetService.getAllAssets().pipe(map(assets => assets.map(asset => new Asset(asset.properties!))));
const assets$ = this.assetService.requestAssets().pipe(map(assets => assets.map(asset => new Asset(asset["edc:properties"]!))));
return !!this.searchText ?
assets$.pipe(map(assets => assets.filter(asset => asset.name.includes(this.searchText))))
:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class CatalogBrowserComponent implements OnInit {
switchMap(() => {
const contractOffers$ = this.apiService.getContractOffers();
return !!this.searchText ?
contractOffers$.pipe(map(contractOffers => contractOffers.filter(contractOffer => contractOffer.asset.name.toLowerCase().includes(this.searchText))))
contractOffers$.pipe(map(contractOffers => contractOffers.filter(contractOffer => contractOffer.id.toLowerCase().includes(this.searchText))))
:
contractOffers$;
}));
Expand All @@ -56,20 +56,23 @@ export class CatalogBrowserComponent implements OnInit {

onNegotiateClicked(contractOffer: ContractOffer) {
const initiateRequest: NegotiationInitiateRequestDto = {
connectorAddress: contractOffer.asset.originator,

connectorAddress: contractOffer["edc:originator"],
"@context": {
"edc": "https://w3id.org/edc/v0.0.1/ns/",
"odrl": "http://www.w3.org/ns/odrl/2/"
},
offer: {
offerId: contractOffer.id,
assetId: contractOffer.asset.id,
policy: contractOffer.policy,
},
connectorId: 'yomama',
protocol: 'ids-multipart'
connectorId: 'connector',
protocol: 'dataspace-protocol-http'
};

const finishedNegotiationStates = [
"CONFIRMED",
"DECLINED",
"VERIFIED",
"TERMINATED",
"ERROR"];

this.apiService.initiateNegotiation(initiateRequest).subscribe(negotiationId => {
Expand All @@ -86,10 +89,10 @@ export class CatalogBrowserComponent implements OnInit {

for (const negotiation of this.runningNegotiations.values()) {
this.apiService.getNegotiationState(negotiation.id).subscribe(updatedNegotiation => {
if (finishedNegotiationStates.includes(updatedNegotiation.state!)) {
if (finishedNegotiationStates.includes(updatedNegotiation["edc:state"]!)) {
let offerId = negotiation.offerId;
this.runningNegotiations.delete(offerId);
if (updatedNegotiation.state === "CONFIRMED") {
if (updatedNegotiation["edc:state"] === "VERIFIED") {
this.finishedNegotiations.set(offerId, updatedNegotiation);
this.notificationService.showInfo("Contract Negotiation complete!", "Show me!", () => {
this.router.navigate(['/contracts'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<mat-label>Access policy</mat-label>
<mat-select [(ngModel)]="accessPolicy" required>
<mat-option *ngFor="let policy of policies" [value]="policy">
{{policy.id}}
{{policy['@id']}}
</mat-option>
</mat-select>
</mat-form-field>
Expand All @@ -19,7 +19,7 @@
<mat-label>Contract policy</mat-label>
<mat-select [(ngModel)]="contractPolicy" required>
<mat-option *ngFor="let policy of policies" [value]="policy">
{{policy.id}}
{{policy['@id']}}
</mat-option>
</mat-select>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,31 @@ export class ContractDefinitionEditorDialog implements OnInit {
}

ngOnInit(): void {
this.policyService.getAllPolicies().subscribe(policyDefinitions => {
this.policyService.queryAllPolicies().subscribe(policyDefinitions => {
this.policies = policyDefinitions;
this.accessPolicy = this.policies.find(policy => policy.id === this.contractDefinition.accessPolicyId);
this.contractPolicy = this.policies.find(policy => policy.id === this.contractDefinition.contractPolicyId);
this.accessPolicy = this.policies.find(policy => policy['@id'] === this.contractDefinition.accessPolicyId);
this.contractPolicy = this.policies.find(policy => policy['@id'] === this.contractDefinition.contractPolicyId);
});
this.assetService.getAllAssets().pipe(map(asset => asset.map(a => new Asset(a.properties!)))).subscribe(assets => {
this.assetService.requestAssets().pipe(map(asset => asset.map(a => new Asset(a["edc:properties"]!)))).subscribe(assets => {
this.availableAssets = assets;
// preselection
if (this.contractDefinition) {
const assetIds = this.contractDefinition.criteria.map((c: CriterionDto) => c.operandRight?.toString());
const assetIds = this.contractDefinition.criteria.map((c: CriterionDto) => c['edc:operandRight']?.toString());
this.assets = this.availableAssets.filter(asset => assetIds.includes(asset.id));
}
})
}

onSave() {
this.contractDefinition.accessPolicyId = this.accessPolicy!.id!;
this.contractDefinition.contractPolicyId = this.contractPolicy!.id!;
this.contractDefinition.accessPolicyId = this.accessPolicy!['@id']!;
this.contractDefinition.contractPolicyId = this.contractPolicy!['@id']!;
this.contractDefinition.criteria = [];

const ids = this.assets.map(asset => asset.id);
this.contractDefinition.criteria = [...this.contractDefinition.criteria, {
operandLeft: 'asset:prop:id',
operator: 'in',
operandRight: ids,
'edc:operandLeft': 'asset:prop:id',
'edc:operator': 'in',
'edc:operandRight': ids,
}];

this.dialogRef.close({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
<mat-card *ngFor="let contractDefinition of contractDefinitions" class="contract-definition-card">
<mat-card-header>
<mat-icon mat-card-avatar>policy</mat-icon>
<mat-card-title>{{contractDefinition.id}}</mat-card-title>
<mat-card-title>{{contractDefinition['@id']}}</mat-card-title>
</mat-card-header>
<mat-card-content>
<mat-list dense>
<mat-list-item>
<mat-icon mat-list-icon>policy</mat-icon>
<div class="policy-name" mat-line>Access policy</div>
<div mat-line>{{contractDefinition.accessPolicyId}}</div>
<div mat-line>{{contractDefinition['edc:accessPolicyId']}}</div>
</mat-list-item>
<mat-list-item>
<mat-icon mat-list-icon>policy</mat-icon>
<div class="policy-name" mat-line>Contract policy</div>
<div mat-line>{{contractDefinition.contractPolicyId}}</div>
<div mat-line>{{contractDefinition['edc:contractPolicyId']}}</div>
</mat-list-item>
</mat-list>

Expand All @@ -47,9 +47,9 @@
</mat-panel-title>
</mat-expansion-panel-header>
<mat-list dense>
<mat-list-item *ngFor="let criterion of contractDefinition.criteria">
<mat-list-item *ngFor="let criterion of contractDefinition['edc:assetsSelector']">
<mat-icon mat-list-icon>check</mat-icon>
<div mat-line>{{criterion.operandLeft}} {{criterion.operator}} {{criterion.operandRight}}</div>
<div mat-line>{{criterion['edc:operandLeft']}} {{criterion['edc:operator']}} {{criterion['edc:operandRight']}}</div>
</mat-list-item>
<!-- <mat-list-item *ngIf="asset.contentType">
<mat-icon mat-list-icon>content_paste</mat-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export class ContractDefinitionViewerComponent implements OnInit {
this.filteredContractDefinitions$ = this.fetch$
.pipe(
switchMap(() => {
const contractDefinitions$ = this.contractDefinitionService.getAllContractDefinitions();
const contractDefinitions$ = this.contractDefinitionService.queryAllContractDefinitions();
return !!this.searchText ?
contractDefinitions$.pipe(map(contractDefinitions => contractDefinitions.filter(contractDefinition => contractDefinition.id!.toLowerCase().includes(this.searchText))))
contractDefinitions$.pipe(map(contractDefinitions => contractDefinitions.filter(contractDefinition => contractDefinition['@id']!.toLowerCase().includes(this.searchText))))
:
contractDefinitions$;
}));
Expand All @@ -47,13 +47,13 @@ export class ContractDefinitionViewerComponent implements OnInit {
}

onDelete(contractDefinition: ContractDefinitionResponseDto) {
const dialogData = ConfirmDialogModel.forDelete("contract definition", contractDefinition.id!);
const dialogData = ConfirmDialogModel.forDelete("contract definition", contractDefinition['@id']!);

const ref = this.dialog.open(ConfirmationDialogComponent, {maxWidth: '20%', data: dialogData});

ref.afterClosed().subscribe(res => {
if (res) {
this.contractDefinitionService.deleteContractDefinition(contractDefinition.id!).subscribe(() => this.fetch$.next(null));
this.contractDefinitionService.deleteContractDefinition(contractDefinition['@id']!).subscribe(() => this.fetch$.next(null));
}
});

Expand Down
Loading

0 comments on commit b27e97f

Please sign in to comment.