Skip to content

Commit 47dc5fb

Browse files
Merge pull request #313 from pagopa/PPANTT-46-add-maintenance-summary-api
[PPANTT-46] feat: Add maintenance summary API
2 parents 363bbd3 + e18961c commit 47dc5fb

File tree

9 files changed

+436
-20
lines changed

9 files changed

+436
-20
lines changed

openapi/openapi.json

Lines changed: 191 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@
12011201
],
12021202
"responses": {
12031203
"200": {
1204-
"description": "Created",
1204+
"description": "OK",
12051205
"headers": {
12061206
"X-Request-Id": {
12071207
"description": "This header identifies the call",
@@ -1451,6 +1451,163 @@
14511451
}
14521452
]
14531453
},
1454+
"/brokers/{brokercode}/station-maintenances/summary": {
1455+
"get": {
1456+
"tags": [
1457+
"Creditor Institutions"
1458+
],
1459+
"summary": "Get the hours' summary of stations' maintenance for the specified broker",
1460+
"operationId": "getBrokerMaintenancesSummary",
1461+
"parameters": [
1462+
{
1463+
"name": "brokercode",
1464+
"in": "path",
1465+
"description": "Broker's tax code",
1466+
"required": true,
1467+
"schema": {
1468+
"type": "string"
1469+
}
1470+
},
1471+
{
1472+
"name": "maintenanceYear",
1473+
"in": "query",
1474+
"description": "Year of maintenance (yyyy)",
1475+
"required": true,
1476+
"schema": {
1477+
"maxLength": 4,
1478+
"minLength": 4,
1479+
"type": "string"
1480+
},
1481+
"example": 2024
1482+
}
1483+
],
1484+
"responses": {
1485+
"200": {
1486+
"description": "OK",
1487+
"headers": {
1488+
"X-Request-Id": {
1489+
"description": "This header identifies the call",
1490+
"schema": {
1491+
"type": "string"
1492+
}
1493+
}
1494+
},
1495+
"content": {
1496+
"application/json": {
1497+
"schema": {
1498+
"$ref": "#/components/schemas/MaintenanceHoursSummaryResource"
1499+
}
1500+
}
1501+
}
1502+
},
1503+
"400": {
1504+
"description": "Bad Request",
1505+
"headers": {
1506+
"X-Request-Id": {
1507+
"description": "This header identifies the call",
1508+
"schema": {
1509+
"type": "string"
1510+
}
1511+
}
1512+
},
1513+
"content": {
1514+
"application/json": {
1515+
"schema": {
1516+
"$ref": "#/components/schemas/ProblemJson"
1517+
}
1518+
}
1519+
}
1520+
},
1521+
"401": {
1522+
"description": "Unauthorized",
1523+
"headers": {
1524+
"X-Request-Id": {
1525+
"description": "This header identifies the call",
1526+
"schema": {
1527+
"type": "string"
1528+
}
1529+
}
1530+
}
1531+
},
1532+
"403": {
1533+
"description": "Forbidden",
1534+
"headers": {
1535+
"X-Request-Id": {
1536+
"description": "This header identifies the call",
1537+
"schema": {
1538+
"type": "string"
1539+
}
1540+
}
1541+
}
1542+
},
1543+
"404": {
1544+
"description": "Not Found",
1545+
"headers": {
1546+
"X-Request-Id": {
1547+
"description": "This header identifies the call",
1548+
"schema": {
1549+
"type": "string"
1550+
}
1551+
}
1552+
},
1553+
"content": {
1554+
"application/json": {
1555+
"schema": {
1556+
"$ref": "#/components/schemas/ProblemJson"
1557+
}
1558+
}
1559+
}
1560+
},
1561+
"429": {
1562+
"description": "Too many requests",
1563+
"headers": {
1564+
"X-Request-Id": {
1565+
"description": "This header identifies the call",
1566+
"schema": {
1567+
"type": "string"
1568+
}
1569+
}
1570+
}
1571+
},
1572+
"500": {
1573+
"description": "Service unavailable",
1574+
"headers": {
1575+
"X-Request-Id": {
1576+
"description": "This header identifies the call",
1577+
"schema": {
1578+
"type": "string"
1579+
}
1580+
}
1581+
},
1582+
"content": {
1583+
"application/json": {
1584+
"schema": {
1585+
"$ref": "#/components/schemas/ProblemJson"
1586+
}
1587+
}
1588+
}
1589+
}
1590+
},
1591+
"security": [
1592+
{
1593+
"ApiKey": []
1594+
},
1595+
{
1596+
"Authorization": []
1597+
}
1598+
]
1599+
},
1600+
"parameters": [
1601+
{
1602+
"name": "X-Request-Id",
1603+
"in": "header",
1604+
"description": "This header identifies the call, if not passed it is self-generated. This ID is returned in the response.",
1605+
"schema": {
1606+
"type": "string"
1607+
}
1608+
}
1609+
]
1610+
},
14541611
"/brokers/{brokercode}/station-maintenances/{maintenanceid}": {
14551612
"put": {
14561613
"tags": [
@@ -1491,7 +1648,7 @@
14911648
},
14921649
"responses": {
14931650
"200": {
1494-
"description": "Created",
1651+
"description": "OK",
14951652
"headers": {
14961653
"X-Request-Id": {
14971654
"description": "This header identifies the call",
@@ -20490,6 +20647,38 @@
2049020647
"$ref": "#/components/schemas/PageInfo"
2049120648
}
2049220649
}
20650+
},
20651+
"MaintenanceHoursSummaryResource": {
20652+
"required": [
20653+
"annual_hours_limit",
20654+
"extra_hours",
20655+
"remaining_hours",
20656+
"scheduled_hours",
20657+
"used_hours"
20658+
],
20659+
"type": "object",
20660+
"properties": {
20661+
"used_hours": {
20662+
"type": "string",
20663+
"description": "Count of used maintenance's hours"
20664+
},
20665+
"scheduled_hours": {
20666+
"type": "string",
20667+
"description": "Count of scheduled maintenance's hours"
20668+
},
20669+
"remaining_hours": {
20670+
"type": "string",
20671+
"description": "Count of remaining maintenance's hours before annual limit"
20672+
},
20673+
"extra_hours": {
20674+
"type": "string",
20675+
"description": "Count of maintenance's hours that exceed annual limit"
20676+
},
20677+
"annual_hours_limit": {
20678+
"type": "string",
20679+
"description": "Annual limit of maintenance hours"
20680+
}
20681+
}
2049320682
}
2049420683
},
2049520684
"securitySchemes": {

src/main/java/it/gov/pagopa/apiconfig/core/controller/StationMaintenanceController.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import io.swagger.v3.oas.annotations.tags.Tag;
1111
import it.gov.pagopa.apiconfig.core.model.ProblemJson;
1212
import it.gov.pagopa.apiconfig.core.model.stationmaintenance.CreateStationMaintenance;
13+
import it.gov.pagopa.apiconfig.core.model.stationmaintenance.MaintenanceHoursSummaryResource;
1314
import it.gov.pagopa.apiconfig.core.model.stationmaintenance.StationMaintenanceListResource;
1415
import it.gov.pagopa.apiconfig.core.model.stationmaintenance.StationMaintenanceResource;
1516
import it.gov.pagopa.apiconfig.core.model.stationmaintenance.UpdateStationMaintenance;
@@ -35,6 +36,7 @@
3536
import javax.validation.constraints.NotNull;
3637
import javax.validation.constraints.Positive;
3738
import javax.validation.constraints.PositiveOrZero;
39+
import javax.validation.constraints.Size;
3840
import java.time.OffsetDateTime;
3941

4042
@RestController
@@ -53,7 +55,7 @@ public StationMaintenanceController(StationMaintenanceService stationMaintenance
5355
@Operation(summary = "Get a paginated list of station's maintenance for the specified broker",
5456
security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")})
5557
@ApiResponses(value = {
56-
@ApiResponse(responseCode = "200", description = "Created",
58+
@ApiResponse(responseCode = "200", description = "OK",
5759
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = StationMaintenanceListResource.class))),
5860
@ApiResponse(responseCode = "400", description = "Bad Request",
5961
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))),
@@ -118,7 +120,7 @@ public ResponseEntity<StationMaintenanceResource> createStationMaintenance(
118120
@Operation(summary = "Update a maintenance for the specified station",
119121
security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")})
120122
@ApiResponses(value = {
121-
@ApiResponse(responseCode = "200", description = "Created",
123+
@ApiResponse(responseCode = "200", description = "OK",
122124
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = StationMaintenanceResource.class))),
123125
@ApiResponse(responseCode = "400", description = "Bad Request",
124126
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))),
@@ -141,4 +143,27 @@ public ResponseEntity<StationMaintenanceResource> updateStationMaintenance(
141143
updateStationMaintenance(brokerCode, maintenanceId, updateStationMaintenance)
142144
);
143145
}
146+
147+
@Operation(summary = "Get the hours' summary of stations' maintenance for the specified broker",
148+
security = {@SecurityRequirement(name = "ApiKey"), @SecurityRequirement(name = "Authorization")})
149+
@ApiResponses(value = {
150+
@ApiResponse(responseCode = "200", description = "OK",
151+
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = MaintenanceHoursSummaryResource.class))),
152+
@ApiResponse(responseCode = "400", description = "Bad Request",
153+
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))),
154+
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(schema = @Schema())),
155+
@ApiResponse(responseCode = "403", description = "Forbidden", content = @Content(schema = @Schema())),
156+
@ApiResponse(responseCode = "404", description = "Not Found",
157+
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class))),
158+
@ApiResponse(responseCode = "429", description = "Too many requests", content = @Content(schema = @Schema())),
159+
@ApiResponse(responseCode = "500", description = "Service unavailable",
160+
content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, schema = @Schema(implementation = ProblemJson.class)))
161+
})
162+
@GetMapping(value = "/{brokercode}/station-maintenances/summary", produces = {MediaType.APPLICATION_JSON_VALUE})
163+
public ResponseEntity<MaintenanceHoursSummaryResource> getBrokerMaintenancesSummary(
164+
@Parameter(description = "Broker's tax code") @PathVariable("brokercode") String brokerCode,
165+
@Parameter(description = "Year of maintenance (yyyy)", example = "2024") @RequestParam @Size(min = 4, max = 4) String maintenanceYear
166+
) {
167+
return ResponseEntity.ok(this.stationMaintenanceService.getBrokerMaintenancesSummary(brokerCode, maintenanceYear));
168+
}
144169
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package it.gov.pagopa.apiconfig.core.model.stationmaintenance;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import io.swagger.v3.oas.annotations.media.Schema;
5+
import lombok.AllArgsConstructor;
6+
import lombok.Builder;
7+
import lombok.Getter;
8+
import lombok.NoArgsConstructor;
9+
import lombok.Setter;
10+
11+
import javax.validation.constraints.NotNull;
12+
13+
/**
14+
* Model class that hold the hours' summary of stations' maintenance for a specific broker
15+
*/
16+
@Getter
17+
@Setter
18+
@Builder
19+
@AllArgsConstructor
20+
@NoArgsConstructor
21+
public class MaintenanceHoursSummaryResource {
22+
23+
@JsonProperty("used_hours")
24+
@Schema(description = "Count of used maintenance's hours", required = true)
25+
@NotNull
26+
private String usedHours;
27+
28+
@JsonProperty("scheduled_hours")
29+
@Schema(description = "Count of scheduled maintenance's hours", required = true)
30+
@NotNull
31+
private String scheduledHours;
32+
33+
@JsonProperty("remaining_hours")
34+
@Schema(description = "Count of remaining maintenance's hours before annual limit", required = true)
35+
@NotNull
36+
private String remainingHours;
37+
38+
@JsonProperty("extra_hours")
39+
@Schema(description = "Count of maintenance's hours that exceed annual limit", required = true)
40+
@NotNull
41+
private String extraHours;
42+
43+
@JsonProperty("annual_hours_limit")
44+
@Schema(description = "Annual limit of maintenance hours", required = true)
45+
@NotNull
46+
private String annualHoursLimit;
47+
}

src/main/java/it/gov/pagopa/apiconfig/core/model/stationmaintenance/StationMaintenanceResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import java.time.OffsetDateTime;
1818

1919
/**
20-
* Model class the response for station's maintenance APIs
20+
* Model class of the response for station's maintenance APIs
2121
*/
2222
@Getter
2323
@Setter

0 commit comments

Comments
 (0)