diff --git a/src/main/resources/interface-specification.yml b/src/main/resources/interface-specification.yml index 5d3ff360..459a735e 100644 --- a/src/main/resources/interface-specification.yml +++ b/src/main/resources/interface-specification.yml @@ -3771,6 +3771,108 @@ paths: application/problem+json: schema: $ref: '#/components/schemas/Problem' + /eservices/{eServiceId}/update: + parameters: + - $ref: '#/components/parameters/CorrelationIdHeader' + post: + security: + - bearerAuth: [ ] + tags: + - eservices + summary: Update an e-service description + operationId: updateEServiceDescription + parameters: + - name: eServiceId + in: path + description: the eservice id + required: true + schema: + type: string + format: uuid + requestBody: + description: A payload containing the new description + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/EServiceDescriptionSeed" + responses: + "200": + description: EService description 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 + content: + application/json: + schema: + $ref: "#/components/schemas/CreatedResource" + "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/problem+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/problem+json: + schema: + $ref: "#/components/schemas/Problem" + "400": + description: Bad request + 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/problem+json: + schema: + $ref: "#/components/schemas/Problem" /export/eservices/{eserviceId}/descriptors/{descriptorId}: parameters: - $ref: '#/components/parameters/CorrelationIdHeader' @@ -10666,6 +10768,13 @@ components: type: string description: type: string + EServiceDescriptionSeed: + type: object + properties: + description: + type: string + required: + - description CatalogEServiceDescriptor: type: object required: diff --git a/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/EServicesApiMarshallerImpl.scala b/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/EServicesApiMarshallerImpl.scala index d103c2d5..e7ab60d4 100644 --- a/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/EServicesApiMarshallerImpl.scala +++ b/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/EServicesApiMarshallerImpl.scala @@ -71,4 +71,7 @@ object EServicesApiMarshallerImpl extends EservicesApiMarshaller with SprayJsonS override implicit def toEntityMarshallerPresignedUrl: ToEntityMarshaller[PresignedUrl] = sprayJsonMarshaller[PresignedUrl] + + override implicit def fromEntityUnmarshallerEServiceDescriptionSeed: FromEntityUnmarshaller[EServiceDescriptionSeed] = + sprayJsonUnmarshaller[EServiceDescriptionSeed] } diff --git a/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/EServicesApiServiceImpl.scala b/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/EServicesApiServiceImpl.scala index ad0007e6..9077fe98 100644 --- a/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/EServicesApiServiceImpl.scala +++ b/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/EServicesApiServiceImpl.scala @@ -1289,4 +1289,26 @@ final case class EServicesApiServiceImpl( } } } + + override def updateEServiceDescription(eServiceId: String, eServiceDescriptionSeed: EServiceDescriptionSeed)(implicit + contexts: Seq[(String, String)], + toEntityMarshallerProblem: ToEntityMarshaller[Problem], + toEntityMarshallerCreatedResource: ToEntityMarshaller[CreatedResource] + ): Route = { + val result: Future[CreatedResource] = for { + eServiceUuid <- eServiceId.toFutureUUID + eService <- catalogProcessService.updateEServiceDescription( + eServiceUuid, + CatalogProcess.EServiceDescriptionSeed(eServiceDescriptionSeed.description) + )(contexts) + } yield eService.toApi + + onComplete(result) { + val headers: List[HttpHeader] = headersFromContext() + handleError(s"Error updating description of eservice with Id: $eServiceId", headers) orElse { + case Success(eservice) => + updateEServiceDescription200(headers)(eservice) + } + } + } } diff --git a/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/package.scala b/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/package.scala index 4747fb70..82d51262 100644 --- a/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/package.scala +++ b/src/main/scala/it/pagopa/interop/backendforfrontend/api/impl/package.scala @@ -225,11 +225,14 @@ package object impl extends SprayJsonSupport with DefaultJsonProtocol { implicit val selfcareProductFormat: RootJsonFormat[SelfcareProduct] = jsonFormat2(SelfcareProduct) implicit val selfcareInstitutionFormat: RootJsonFormat[SelfcareInstitution] = jsonFormat4(SelfcareInstitution) - implicit val selfcareUserFormat: RootJsonFormat[CompactUser] = jsonFormat3(CompactUser) - implicit val publicKeyFormat: RootJsonFormat[PublicKey] = + implicit val selfcareUserFormat: RootJsonFormat[CompactUser] = jsonFormat3(CompactUser) + implicit val publicKeyFormat: RootJsonFormat[PublicKey] = jsonFormat5(PublicKey) - implicit val publicKeysFormat: RootJsonFormat[PublicKeys] = + implicit val publicKeysFormat: RootJsonFormat[PublicKeys] = jsonFormat1(PublicKeys) + implicit val EServiceDescriptionSeedFormat: RootJsonFormat[EServiceDescriptionSeed] = jsonFormat1( + EServiceDescriptionSeed + ) implicit def dependencyFormat: RootJsonFormat[Dependency] = jsonFormat2(Dependency) diff --git a/src/main/scala/it/pagopa/interop/backendforfrontend/service/CatalogProcessService.scala b/src/main/scala/it/pagopa/interop/backendforfrontend/service/CatalogProcessService.scala index 6129c9f3..28867d9a 100644 --- a/src/main/scala/it/pagopa/interop/backendforfrontend/service/CatalogProcessService.scala +++ b/src/main/scala/it/pagopa/interop/backendforfrontend/service/CatalogProcessService.scala @@ -108,4 +108,8 @@ trait CatalogProcessService { ): Future[Unit] def deleteRiskAnalysis(eServiceId: UUID, riskAnalysisId: UUID)(implicit contexts: Seq[(String, String)]): Future[Unit] + + def updateEServiceDescription(eServiceId: UUID, eServiceDescriptionSeed: EServiceDescriptionSeed)(implicit + contexts: Seq[(String, String)] + ): Future[EService] } diff --git a/src/main/scala/it/pagopa/interop/backendforfrontend/service/impl/CatalogProcessServiceImpl.scala b/src/main/scala/it/pagopa/interop/backendforfrontend/service/impl/CatalogProcessServiceImpl.scala index f7e7ed8c..145566d7 100644 --- a/src/main/scala/it/pagopa/interop/backendforfrontend/service/impl/CatalogProcessServiceImpl.scala +++ b/src/main/scala/it/pagopa/interop/backendforfrontend/service/impl/CatalogProcessServiceImpl.scala @@ -336,4 +336,17 @@ class CatalogProcessServiceImpl(catalogProcessUrl: String, blockingEc: Execution s"Delete Risk Analysis ${riskAnalysisId.toString} for EService ${eServiceId.toString} from Catalog Process" ) } + + override def updateEServiceDescription(eServiceId: UUID, eServiceDescriptionSeed: EServiceDescriptionSeed)(implicit + contexts: Seq[(String, String)] + ): Future[EService] = + withHeaders { (bearerToken, correlationId) => + val request: ApiRequest[EService] = + api.updateEServiceDescription( + xCorrelationId = correlationId, + eServiceId = eServiceId, + eServiceDescriptionSeed = eServiceDescriptionSeed + )(BearerToken(bearerToken)) + invoker.invoke(request, s"Update E-Service ${eServiceId.toString} description from Catalog Process") + } }