Skip to content

Commit

Permalink
feat: parameterization of http data sources / data sinks
Browse files Browse the repository at this point in the history
  • Loading branch information
richardtreier committed Jul 4, 2023
1 parent 71153db commit 82ae792
Show file tree
Hide file tree
Showing 45 changed files with 964 additions and 247 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ the detailed section referring to by linking pull requests or issues.

#### Added

- Parameterization of Http Data Sources.

#### Changed

#### Removed
Expand Down
8 changes: 7 additions & 1 deletion fake-backend/json/contractAgreementPage.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,13 @@
"assetId": "urn:artifact:my-test-asset-2",
"createdAt": "2023-04-24T12:32:28.492Z",
"properties": {
"asset:prop:id": "urn:artifact:my-test-asset-2"
"asset:prop:id": "urn:artifact:my-test-asset-2",
"asset:prop:datasource:http:hints:proxyMethod": "true",
"asset:prop:datasource:http:hints:proxyPath": "true",
"asset:prop:datasource:http:hints:proxyQueryParams": "true",
"asset:prop:datasource:http:hints:proxyBody": "true",
"asset:prop:datasource:http:hints:defaultMethod": "GET",
"asset:prop:datasource:http:hints:defaultPath": "/"
}
},
"contractPolicy": {
Expand Down
14 changes: 10 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"@angular/router": "^14.3.0",
"@ng-apimock/core": "^3.6.0",
"@ngxs/store": "^3.8.1",
"@sovity.de/edc-client": "0.20230531.73811-main-e140ef56",
"@sovity.de/broker-server-client": "0.20230703.152001-main-d1ec5276",
"@sovity.de/edc-client": "0.20230629.150330-main-aaa2fa41",
"clean-deep": "^3.4.0",
"date-fns": "^2.29.3",
"dotenv": "^16.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export class AssetDetailDialogComponent implements OnDestroy {
onTransferClick() {
const data: ContractAgreementTransferDialogData = {
contractId: this.data.contractAgreement?.contractAgreementId!!,
asset: this.data.asset,
};
this.matDialog.open(ContractAgreementTransferDialogComponent, {
data,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Injectable} from '@angular/core';
import {MatDialog} from '@angular/material/dialog';
import {DataOfferListEntryContractOffer} from '@sovity.de/edc-client';
import {CatalogContractOffer} from '@sovity.de/broker-server-client';
import {ActiveFeatureSet} from '../../../core/config/active-feature-set';
import {Policy} from '../../../core/services/api/legacy-managent-api-client';
import {AssetProperties} from '../../../core/services/asset-properties';
Expand Down Expand Up @@ -174,7 +174,7 @@ export class AssetPropertyGridGroupBuilder {

buildContractOfferGroup(
asset: Asset,
contractOffer: DataOfferListEntryContractOffer,
contractOffer: CatalogContractOffer,
i: number,
total: number,
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ import {DataAddressTypeSelectMode} from './data-address-type-select-mode';

export const dataAddressTypeSelectItems = (
type: DataAddressTypeSelectMode,
): DataAddressTypeSelectItem[] => [
{
id: 'Http',
label: 'REST-API Endpoint',
},
{
id: 'Custom-Data-Address-Json',
label: `Custom ${type} Config (JSON)`,
},
];
): DataAddressTypeSelectItem[] => {
let items: DataAddressTypeSelectItem[] = [
{
id: 'Http',
label: 'REST-API Endpoint',
},
{
id: 'Custom-Data-Address-Json',
label: `Custom ${type} Config (JSON)`,
},
];

if (type === 'Datasink') {
items.push({
id: 'Custom-Transfer-Process-Request',
label: 'Custom Transfer Process Request (JSON)',
});
}

return items;
};
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export type DataAddressType = 'Custom-Data-Address-Json' | 'Http';
export type DataAddressType =
| 'Custom-Data-Address-Json'
| 'Custom-Transfer-Process-Request'
| 'Http';
65 changes: 65 additions & 0 deletions src/app/core/services/api/broker-server-api.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import {Inject, Injectable} from '@angular/core';
import {Observable, from} from 'rxjs';
import {
BrokerServerClient,
CatalogPageQuery,
CatalogPageResult,
ConnectorDetailPageQuery,
ConnectorDetailPageResult,
ConnectorPageQuery,
ConnectorPageResult,
DataOfferDetailPageQuery,
DataOfferDetailPageResult,
buildBrokerServerClient,
} from '@sovity.de/broker-server-client';
import {APP_CONFIG, AppConfig} from '../../config/app-config';

@Injectable({providedIn: 'root'})
export class BrokerServerApiService {
brokerServerClient: BrokerServerClient;

constructor(@Inject(APP_CONFIG) private config: AppConfig) {
this.brokerServerClient = buildBrokerServerClient({
managementApiUrl: this.config.managementApiUrl,
managementApiKey: this.config.managementApiKey,
});
}

catalogPage(
catalogPageQuery: CatalogPageQuery,
): Observable<CatalogPageResult> {
return from(
this.brokerServerClient.brokerServerApi.catalogPage({catalogPageQuery}),
);
}

dataOfferDetailPage(
dataOfferDetailPageQuery: DataOfferDetailPageQuery,
): Observable<DataOfferDetailPageResult> {
return from(
this.brokerServerClient.brokerServerApi.dataOfferDetailPage({
dataOfferDetailPageQuery,
}),
);
}

connectorPage(
connectorPageQuery: ConnectorPageQuery,
): Observable<ConnectorPageResult> {
return from(
this.brokerServerClient.brokerServerApi.connectorPage({
connectorPageQuery,
}),
);
}

connectorDetailPage(
connectorDetailPageQuery: ConnectorDetailPageQuery,
): Observable<ConnectorDetailPageResult> {
return from(
this.brokerServerClient.brokerServerApi.connectorDetailPage({
connectorDetailPageQuery,
}),
);
}
}
25 changes: 6 additions & 19 deletions src/app/core/services/api/edc-api.service.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import {Inject, Injectable} from '@angular/core';
import {Observable, from} from 'rxjs';
import {
CatalogPageQuery,
CatalogPageResult,
ConnectorPageQuery,
ConnectorPageResult,
ContractAgreementPage,
ContractAgreementTransferRequest,
EdcClient,
KpiResult,
IdResponseDto,
buildEdcClient,
} from '@sovity.de/edc-client';
import {APP_CONFIG, AppConfig} from '../../config/app-config';
Expand All @@ -27,21 +24,11 @@ export class EdcApiService {
return from(this.edcClient.uiApi.contractAgreementEndpoint());
}

getKpis(): Observable<KpiResult> {
return from(this.edcClient.useCaseApi.kpiEndpoint());
}

brokerCatalog(
catalogPageQuery: CatalogPageQuery,
): Observable<CatalogPageResult> {
return from(this.edcClient.brokerServerApi.catalogPage({catalogPageQuery}));
}

brokerConnectors(
connectorPageQuery: ConnectorPageQuery,
): Observable<ConnectorPageResult> {
initiateTranfer(
contractAgreementTransferRequest: ContractAgreementTransferRequest,
): Observable<IdResponseDto> {
return from(
this.edcClient.brokerServerApi.connectorPage({connectorPageQuery}),
this.edcClient.uiApi.initiateTransfer({contractAgreementTransferRequest}),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import {Configuration} from '../configuration';
import {CustomHttpParameterCodec} from '../encoder';
// @ts-ignore
import {ContractAgreementDto} from '../model/contractAgreementDto';
import {DataAddressDto} from '../model/dataAddressDto';
import {TransferId} from '../model/transferId';
// @ts-ignore
import {
API_KEY,
Expand Down Expand Up @@ -341,30 +339,4 @@ export class ContractAgreementService {
},
);
}
initiateTransfer(
id: string,
dataAddressDto: DataAddressDto,
): Observable<TransferId> {
if (id == null) {
throw new Error(
'Required parameter id was null or undefined when calling initiateTransfer.',
);
}

if (dataAddressDto == null) {
throw new Error(
'Required parameter dataAddressDto was null or undefined when calling initiateTransfer.',
);
}

let url = `${
this.configuration.basePath
}/contract-agreements-transfer/contractagreements/${encodeURIComponent(
id,
)}/transfer`;
return this.httpClient.post<TransferId>(url, dataAddressDto, {
withCredentials: this.configuration.withCredentials,
headers: this.defaultHeaders,
});
}
}
25 changes: 6 additions & 19 deletions src/app/core/services/asset-entry-builder.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import {Injectable} from '@angular/core';
import {AssetEditorDialogFormValue} from '../../routes/connector-ui/asset-page/asset-create-dialog/asset-editor-dialog-form-model';
import {AssetEntryDto, DataAddressDto} from './api/legacy-managent-api-client';
import {AssetEntryDto} from './api/legacy-managent-api-client';
import {AssetPropertyMapper} from './asset-property-mapper';
import {HttpRequestParamsMapper} from './http-params-mapper.service';
import {DataAddressMapper} from './data-address-mapper';

@Injectable()
export class AssetEntryBuilder {
constructor(
private assetPropertyMapper: AssetPropertyMapper,
private httpRequestParamsMapper: HttpRequestParamsMapper,
private dataAddressMapper: DataAddressMapper,
) {}

/**
Expand All @@ -19,22 +19,9 @@ export class AssetEntryBuilder {
*/
buildAssetEntry(formValue: AssetEditorDialogFormValue): AssetEntryDto {
let properties = this.assetPropertyMapper.buildProperties(formValue);
const dataAddress = this.buildDataAddressDto(formValue.datasource);
const dataAddress = this.dataAddressMapper.buildDataAddressProperties(
formValue.datasource,
);
return {asset: {properties}, dataAddress};
}

private buildDataAddressDto(
datasource: AssetEditorDialogFormValue['datasource'],
): DataAddressDto {
switch (datasource?.dataAddressType) {
case 'Custom-Data-Address-Json':
return JSON.parse(datasource.dataDestination?.trim() ?? '');
case 'Http':
return this.httpRequestParamsMapper.buildHttpDataAddressDto(datasource);
default:
throw new Error(
`Invalid data address type: ${datasource?.dataAddressType}`,
);
}
}
}
46 changes: 44 additions & 2 deletions src/app/core/services/asset-properties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,52 @@ export const AssetProperties = {
// mds specific asset properties
dataCategory: 'http://w3id.org/mds#dataCategory',
dataSubcategory: 'http://w3id.org/mds#dataSubcategory',
dataModel: 'http://w3id.org/mds#dataModel', // guessed
geoReferenceMethod: 'http://w3id.org/mds#geoReferenceMethod', // guessed
dataModel: 'http://w3id.org/mds#dataModel',
geoReferenceMethod: 'http://w3id.org/mds#geoReferenceMethod',
transportMode: 'http://w3id.org/mds#transportMode',

/**
* Whether this asset supports HTTP Method parameterization
*
* Example values: "true", "false"
*/
httpProxyMethod: 'asset:prop:datasource:http:hints:proxyMethod',

/**
* Whether this asset supports HTTP Path parameterization
*
* Example values: "true", "false"
*/
httpProxyPath: 'asset:prop:datasource:http:hints:proxyPath',

/**
* Whether this asset supports HTTP Query Param parameterization
*
* Example values: "true", "false"
*/
httpProxyQueryParams: 'asset:prop:datasource:http:hints:proxyQueryParams',

/**
* Whether this asset supports HTTP Body parameterization
*
* Example values: "true", "false"
*/
httpProxyBody: 'asset:prop:datasource:http:hints:proxyBody',

/**
* If this asset supports HTTP Method parameterization, this is the default method
*
* Example values: "GET", "POST", "PUT", "DELETE"
*/
httpDefaultMethod: 'asset:prop:datasource:http:hints:defaultMethod',

/**
* If this asset supports HTTP Path parameterization, this is the default path (appended after base path)
*
* Example values: /my-endpoint
*/
httpDefaultPath: 'asset:prop:datasource:http:hints:defaultPath',

/**
* @deprecated use {@link AssetProperties.curatorOrganizationName} instead
*/
Expand Down
Loading

0 comments on commit 82ae792

Please sign in to comment.