Skip to content

Commit

Permalink
PIN-5891 Feature: add eservice name update (#1372)
Browse files Browse the repository at this point in the history
  • Loading branch information
taglioni-r authored Jan 16, 2025
1 parent 1a90fb7 commit 67fd280
Show file tree
Hide file tree
Showing 23 changed files with 610 additions and 26 deletions.
2 changes: 1 addition & 1 deletion packages/agreement-outbound-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"vitest": "1.6.0"
},
"dependencies": {
"@pagopa/interop-outbound-models": "1.0.13",
"@pagopa/interop-outbound-models": "1.1.0",
"@protobuf-ts/runtime": "2.9.4",
"connection-string": "4.4.0",
"dotenv-flow": "4.1.0",
Expand Down
116 changes: 111 additions & 5 deletions packages/api-clients/open-api/bffApi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3773,7 +3773,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Problem"
/eservices/{eServiceId}/update:
/eservices/{eServiceId}/description/update:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
post:
Expand All @@ -3797,7 +3797,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/EServiceDescriptionSeed"
$ref: "#/components/schemas/EServiceDescriptionUpdateSeed"
responses:
"200":
description: EService description updated
Expand Down Expand Up @@ -3875,6 +3875,104 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Problem"
/eservices/{eServiceId}/name/update:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
post:
security:
- bearerAuth: []
tags:
- eservices
summary: Update an e-service name
operationId: updateEServiceName
parameters:
- name: eServiceId
in: path
description: the eservice id
required: true
schema:
type: string
format: uuid
requestBody:
description: A payload containing the new name
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/EServiceNameUpdateSeed"
responses:
"204":
description: EService name updated
headers:
"X-Rate-Limit-Limit":
schema:
type: integer
description: Max allowed requests within time interval
"X-Rate-Limit-Remaining":
schema:
type: integer
description: Remaining requests within time interval
"X-Rate-Limit-Interval":
schema:
type: integer
description: Time interval in milliseconds. Allowed requests will be constantly replenished during the interval. At the end of the interval the max allowed requests will be available
"403":
description: Forbidden
headers:
"X-Rate-Limit-Limit":
schema:
type: integer
description: Max allowed requests within time interval
"X-Rate-Limit-Remaining":
schema:
type: integer
description: Remaining requests within time interval
"X-Rate-Limit-Interval":
schema:
type: integer
description: Time interval in milliseconds. Allowed requests will be constantly replenished during the interval. At the end of the interval the max allowed requests will be available
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
"404":
description: EService not found
headers:
"X-Rate-Limit-Limit":
schema:
type: integer
description: Max allowed requests within time interval
"X-Rate-Limit-Remaining":
schema:
type: integer
description: Remaining requests within time interval
"X-Rate-Limit-Interval":
schema:
type: integer
description: Time interval in milliseconds. Allowed requests will be constantly replenished during the interval. At the end of the interval the max allowed requests will be available
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
"409":
description: Conflict
headers:
"X-Rate-Limit-Limit":
schema:
type: integer
description: Max allowed requests within time interval
"X-Rate-Limit-Remaining":
schema:
type: integer
description: Remaining requests within time interval
"X-Rate-Limit-Interval":
schema:
type: integer
description: Time interval in milliseconds. Allowed requests will be constantly replenished during the interval. At the end of the interval the max allowed requests will be available
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
/eservices/{eServiceId}/descriptors/{descriptorId}/attributes/update:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
Expand Down Expand Up @@ -9570,7 +9668,7 @@ paths:
minItems: 1
items:
type: string
format: uuid
format: uuid
responses:
"200":
description: Users added
Expand Down Expand Up @@ -11133,7 +11231,7 @@ paths:
minItems: 1
items:
type: string
format: uuid
format: uuid
responses:
"204":
description: Users added
Expand Down Expand Up @@ -12418,14 +12516,22 @@ components:
type: string
description:
type: string
EServiceDescriptionSeed:
EServiceDescriptionUpdateSeed:
type: object
additionalProperties: false
properties:
description:
type: string
required:
- description
EServiceNameUpdateSeed:
type: object
additionalProperties: false
properties:
name:
type: string
required:
- name
CatalogEServiceDescriptor:
type: object
additionalProperties: false
Expand Down
66 changes: 63 additions & 3 deletions packages/api-clients/open-api/catalogApi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Problem"
/eservices/{eServiceId}/update:
/eservices/{eServiceId}/description/update:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
post:
Expand All @@ -1043,7 +1043,7 @@ paths:
content:
application/json:
schema:
$ref: "#/components/schemas/EServiceDescriptionSeed"
$ref: "#/components/schemas/EServiceDescriptionUpdateSeed"
responses:
"200":
description: EService description updated
Expand All @@ -1069,6 +1069,56 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Problem"
/eservices/{eServiceId}/name/update:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
post:
security:
- bearerAuth: []
tags:
- process
summary: Update an e-service name
operationId: updateEServiceName
parameters:
- name: eServiceId
in: path
description: the eservice id
required: true
schema:
type: string
format: uuid
requestBody:
description: A payload containing the new name
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/EServiceNameUpdateSeed"
responses:
"200":
description: EService name updated
content:
application/json:
schema:
$ref: "#/components/schemas/EService"
"403":
description: Forbidden
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
"404":
description: EService not found
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
"409":
description: Conflict
content:
application/json:
schema:
$ref: "#/components/schemas/Problem"
/eservices/{eServiceId}/descriptors/{descriptorId}/attributes/update:
parameters:
- $ref: "#/components/parameters/CorrelationIdHeader"
Expand Down Expand Up @@ -1673,7 +1723,7 @@ components:
type: string
checksum:
type: string
EServiceDescriptionSeed:
EServiceDescriptionUpdateSeed:
type: object
additionalProperties: false
properties:
Expand All @@ -1683,6 +1733,16 @@ components:
maxLength: 250
required:
- description
EServiceNameUpdateSeed:
type: object
additionalProperties: false
properties:
name:
type: string
minLength: 5
maxLength: 60
required:
- name
EServiceDescriptor:
type: object
additionalProperties: false
Expand Down
3 changes: 2 additions & 1 deletion packages/authorization-updater/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ export async function sendCatalogAuthUpdate(
"EServiceRiskAnalysisDeleted",
"EServiceDescriptorQuotasUpdated",
"EServiceDescriptionUpdated",
"EServiceDescriptorAttributesUpdated"
"EServiceDescriptorAttributesUpdated",
"EServiceNameUpdated"
),
},
() => {
Expand Down
22 changes: 21 additions & 1 deletion packages/backend-for-frontend/src/routers/catalogRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ const catalogRouter = (
return res.status(errorRes.status).send(errorRes);
}
})
.post("/eservices/:eServiceId/update", async (req, res) => {
.post("/eservices/:eServiceId/description/update", async (req, res) => {
const ctx = fromBffAppContext(req.ctx, req.headers);
try {
const id = await catalogService.updateEServiceDescription(
Expand All @@ -604,6 +604,26 @@ const catalogRouter = (
return res.status(errorRes.status).send(errorRes);
}
})
.post("/eservices/:eServiceId/name/update", async (req, res) => {
const ctx = fromBffAppContext(req.ctx, req.headers);
try {
await catalogService.updateEServiceName(
ctx,
unsafeBrandId(req.params.eServiceId),
req.body
);
return res.status(204).send();
} catch (error) {
const errorRes = makeApiProblem(
error,
emptyErrorMapper,
ctx.logger,
ctx.correlationId,
`Error updating name of eservice with Id: ${req.params.eServiceId}`
);
return res.status(errorRes.status).send(errorRes);
}
})
.get(
"/eservices/:eServiceId/riskAnalysis/:riskAnalysisId",
async (req, res) => {
Expand Down
15 changes: 14 additions & 1 deletion packages/backend-for-frontend/src/services/catalogService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ export function catalogServiceBuilder(
updateEServiceDescription: async (
{ headers, logger }: WithLogger<BffAppContext>,
eServiceId: EServiceId,
updateSeed: bffApi.EServiceDescriptionSeed
updateSeed: bffApi.EServiceDescriptionUpdateSeed
): Promise<bffApi.CreatedResource> => {
logger.info(
`Updating EService Description for eserviceId = ${eServiceId}`
Expand All @@ -364,6 +364,19 @@ export function catalogServiceBuilder(
id: updatedEservice.id,
};
},
updateEServiceName: async (
{ headers, logger }: WithLogger<BffAppContext>,
eServiceId: EServiceId,
nameUpdateSeed: bffApi.EServiceNameUpdateSeed
): Promise<void> => {
logger.info(`Updating EService name of eservice with id = ${eServiceId}`);
await catalogProcessClient.updateEServiceName(nameUpdateSeed, {
headers,
params: {
eServiceId,
},
});
},
createEService: async (
eServiceSeed: bffApi.EServiceSeed,
{ headers, logger }: WithLogger<BffAppContext>
Expand Down
2 changes: 1 addition & 1 deletion packages/catalog-outbound-writer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"vitest": "1.6.0"
},
"dependencies": {
"@pagopa/interop-outbound-models": "1.0.13",
"@pagopa/interop-outbound-models": "1.1.0",
"@protobuf-ts/runtime": "2.9.4",
"connection-string": "4.4.0",
"dotenv-flow": "4.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function toOutboundEventV2(
{ type: "EServiceAdded" },
{ type: "DraftEServiceUpdated" },
{ type: "EServiceDescriptionUpdated" },
{ type: "EServiceNameUpdated" },
(msg) => ({
event_version: msg.event_version,
type: msg.type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ export async function handleMessageV2(
{ type: "EServiceRiskAnalysisDeleted" },
{ type: "EServiceDescriptionUpdated" },
{ type: "EServiceDescriptorAttributesUpdated" },
{ type: "EServiceNameUpdated" },
() => Promise.resolve()
)
.exhaustive();
Expand Down
17 changes: 17 additions & 0 deletions packages/catalog-process/src/model/domain/toEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,20 @@ export const toCreateEventEServiceDescriptorAttributesUpdated = (
},
correlationId,
});

export const toCreateEventEServiceNameUpdated = (
version: number,
eservice: EService,
correlationId: CorrelationId
): CreateEvent<EServiceEvent> => ({
streamId: eservice.id,
version,
event: {
type: "EServiceNameUpdated",
event_version: 2,
data: {
eservice: toEServiceV2(eservice),
},
},
correlationId,
});
Loading

0 comments on commit 67fd280

Please sign in to comment.