Skip to content

Commit

Permalink
feat: contract termination API (sovity#987)
Browse files Browse the repository at this point in the history
  • Loading branch information
ununhexium authored Jul 3, 2024
1 parent 6f055a0 commit 7c1f878
Show file tree
Hide file tree
Showing 11 changed files with 261 additions and 12 deletions.
92 changes: 88 additions & 4 deletions docs/api/sovity-edc-api-wrapper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,16 @@ paths:
items:
$ref: '#/components/schemas/UiDataOffer'
/wrapper/ui/pages/contract-agreement-page:
get:
post:
tags:
- UI
description: Collect all data for the Contract Agreement Page
description: Collect filtered data for the Contract Agreement Page
operationId: getContractAgreementPage
requestBody:
content:
'*/*':
schema:
$ref: '#/components/schemas/ContractAgreementPageQuery'
responses:
default:
description: default response
Expand Down Expand Up @@ -407,6 +412,31 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/IdResponseDto'
/wrapper/ui/pages/content-agreement-page/{contractAgreementId}/terminate:
post:
tags:
- UI
description: Terminates a contract agreement designated by its contract agreement
id.
operationId: terminateContractAgreement
parameters:
- name: contractAgreementId
in: path
required: true
schema:
type: string
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/ContractTerminationRequest'
responses:
default:
description: default response
content:
application/json:
schema:
$ref: '#/components/schemas/IdResponseDto'
/wrapper/use-case-api/policy-definition:
post:
tags:
Expand Down Expand Up @@ -494,11 +524,11 @@ components:
DataSourceType:
type: string
description: Supported Data Source Types by UiDataSource
default: CUSTOM
enum:
- HTTP_DATA
- ON_REQUEST
- CUSTOM
default: CUSTOM
SecretValue:
type: object
properties:
Expand Down Expand Up @@ -706,14 +736,14 @@ components:
UiDataSourceHttpDataMethod:
type: string
description: Supported HTTP Methods by UiDataSource
default: GET
enum:
- GET
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
default: GET
UiDataSourceOnRequest:
required:
- contactEmail
Expand Down Expand Up @@ -1261,6 +1291,7 @@ components:
- counterPartyAddress
- counterPartyId
- direction
- terminationStatus
- transferProcesses
type: object
properties:
Expand Down Expand Up @@ -1291,6 +1322,14 @@ components:
description: Contract Agreement's Transfer Processes
items:
$ref: '#/components/schemas/ContractAgreementTransferProcess'
terminationStatus:
type: string
description: Contract Agreement's Termination Status
enum:
- ONGOING
- TERMINATED
terminationInformation:
$ref: '#/components/schemas/ContractAgreementTerminationInfo'
description: Contract Agreement for Contract Agreement Page
ContractAgreementDirection:
type: string
Expand All @@ -1309,6 +1348,26 @@ components:
items:
$ref: '#/components/schemas/ContractAgreementCard'
description: Data as required by the UI's Contract Agreement Page
ContractAgreementTerminationInfo:
required:
- detail
- reason
- terminatedAt
type: object
properties:
terminatedAt:
type: string
description: Termination's date and time
format: date-time
reason:
title: Termination's reason
type: string
description: The termination's nature e.g. User Termination
detail:
type: string
description: Detailed message from the terminating party about why the contract
was terminated.
description: Contract's agreement metadata
ContractAgreementTransferProcess:
required:
- lastUpdatedDate
Expand Down Expand Up @@ -1354,6 +1413,17 @@ components:
simplifiedState:
$ref: '#/components/schemas/TransferProcessSimplifiedState'
description: Transfer Process State interpreted
ContractAgreementPageQuery:
type: object
properties:
status:
type: string
description: Optionally filter the resulting contract agreements by their
termination status.
enum:
- ONGOING
- TERMINATED
description: Filters for querying a Contract Contract Agreement Page
ContractDefinitionEntry:
required:
- accessPolicyId
Expand Down Expand Up @@ -1706,6 +1776,20 @@ components:
description: Additional transfer process properties. These are not passed
to the consumer EDC
description: "For type PARAMS_ONLY: Required data for starting a Transfer Process"
ContractTerminationRequest:
required:
- reason
type: object
properties:
reason:
title: Termination reason
type: string
description: A short reason why this contract was terminated
detail:
title: Termination detail
type: string
description: A user explanation to detail why the contract was terminated.
description: Data for terminating a Contract Agreement
AtomicConstraintDto:
required:
- leftExpression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
import de.sovity.edc.ext.wrapper.api.common.model.UiAssetEditRequest;
import de.sovity.edc.ext.wrapper.api.ui.model.AssetPage;
import de.sovity.edc.ext.wrapper.api.ui.model.ContractAgreementPage;
import de.sovity.edc.ext.wrapper.api.ui.model.ContractAgreementPageQuery;
import de.sovity.edc.ext.wrapper.api.ui.model.ContractDefinitionPage;
import de.sovity.edc.ext.wrapper.api.ui.model.ContractDefinitionRequest;
import de.sovity.edc.ext.wrapper.api.ui.model.ContractNegotiationRequest;
import de.sovity.edc.ext.wrapper.api.ui.model.ContractTerminationRequest;
import de.sovity.edc.ext.wrapper.api.ui.model.DashboardPage;
import de.sovity.edc.ext.wrapper.api.ui.model.IdResponseDto;
import de.sovity.edc.ext.wrapper.api.ui.model.InitiateCustomTransferRequest;
Expand All @@ -43,6 +45,7 @@
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import org.jetbrains.annotations.Nullable;

import java.util.List;

Expand Down Expand Up @@ -139,11 +142,11 @@ interface UiResource {
@Operation(description = "Get Contract Negotiation Information")
UiContractNegotiation getContractNegotiation(@PathParam("contractNegotiationId") String contractNegotiationId);

@GET
@POST
@Path("pages/contract-agreement-page")
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Collect all data for the Contract Agreement Page")
ContractAgreementPage getContractAgreementPage();
@Operation(description = "Collect filtered data for the Contract Agreement Page")
ContractAgreementPage getContractAgreementPage(@Nullable ContractAgreementPageQuery contractAgreementPageQuery);

@POST
@Path("pages/contract-agreement-page/transfers")
Expand All @@ -159,6 +162,15 @@ interface UiResource {
@Operation(description = "Initiate a Transfer Process via a custom Transfer Process JSON-LD. Fields such as connectorId, assetId, providerConnectorId, providerConnectorAddress will be set automatically.")
IdResponseDto initiateCustomTransfer(InitiateCustomTransferRequest initiateCustomTransferRequest);

@POST
@Path("pages/content-agreement-page/{contractAgreementId}/terminate")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Operation(description = "Terminates a contract agreement designated by its contract agreement id.")
IdResponseDto terminateContractAgreement(
@PathParam("contractAgreementId") String contractAgreementId,
ContractTerminationRequest contractTerminationRequest);

@GET
@Path("pages/transfer-history-page")
@Produces(MediaType.APPLICATION_JSON)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,10 @@ public class ContractAgreementCard {

@Schema(description = "Contract Agreement's Transfer Processes", requiredMode = Schema.RequiredMode.REQUIRED)
private List<ContractAgreementTransferProcess> transferProcesses;

@Schema(description = "Contract Agreement's Termination Status", requiredMode = Schema.RequiredMode.REQUIRED)
private ContractTerminationStatus terminationStatus;

@Schema(description = "Contract Agreement's Metadata", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private ContractAgreementTerminationInfo terminationInformation;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*/

package de.sovity.edc.ext.wrapper.api.ui.model;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "Filters for querying a Contract Contract Agreement Page")
public class ContractAgreementPageQuery {
@Schema(
description = "Optionally filter the resulting contract agreements by their termination status.",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
private ContractTerminationStatus terminationStatus;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*/

package de.sovity.edc.ext.wrapper.api.ui.model;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.OffsetDateTime;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Schema(description = "Contract's agreement metadata")
public class ContractAgreementTerminationInfo {

@Schema(description = "Termination's date and time", requiredMode = Schema.RequiredMode.REQUIRED)
private OffsetDateTime terminatedAt;

@Schema(
title = "Termination's reason",
description = "The termination's nature e.g. User Termination",
requiredMode = Schema.RequiredMode.REQUIRED)
private String reason;

@Schema(
description = "Detailed message from the terminating party about why the contract was terminated.",
requiredMode = Schema.RequiredMode.REQUIRED
)
private String detail;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*/

package de.sovity.edc.ext.wrapper.api.ui.model;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@AllArgsConstructor
@RequiredArgsConstructor
@Schema(description = "Data for terminating a Contract Agreement")
public class ContractTerminationRequest {

@Schema(
title = "Termination reason",
description = "A short reason why this contract was terminated",
requiredMode = Schema.RequiredMode.REQUIRED)
String reason;

@Schema(
title = "Termination detail",
description = "A user explanation to detail why the contract was terminated.",
requiredMode = Schema.RequiredMode.NOT_REQUIRED)
String detail;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (c) 2024 sovity GmbH
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* sovity GmbH - initial API and implementation
*/

package de.sovity.edc.ext.wrapper.api.ui.model;

public enum ContractTerminationStatus {
ONGOING,
TERMINATED
}
Loading

0 comments on commit 7c1f878

Please sign in to comment.