Skip to content

Commit

Permalink
adapting openapi spec to the new version without state chains (#246)
Browse files Browse the repository at this point in the history
  • Loading branch information
beetlecrunch authored Jul 25, 2024
1 parent a44e442 commit b9b97e7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 263 deletions.
96 changes: 3 additions & 93 deletions src/main/resources/interface-specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,9 @@ components:
purposes:
type: array
items:
$ref: '#/components/schemas/ClientPurpose'
default: []
type: string
format: uuid
uniqueItems: true
description:
type: string
users:
Expand All @@ -856,14 +857,6 @@ components:
- users
- kind
- createdAt
ClientPurpose:
type: object
description: Models Client purposes
properties:
states:
$ref: '#/components/schemas/ClientStatesChain'
required:
- states
ClientKind:
type: string
description: kind of client
Expand Down Expand Up @@ -1016,8 +1009,6 @@ components:
format: uuid
title:
type: string
states:
$ref: '#/components/schemas/ClientStatesChain'
agreement:
$ref: '#/components/schemas/Agreement'
required:
Expand All @@ -1033,87 +1024,6 @@ components:
format: uuid
required:
- purposeId
ClientStatesChain:
type: object
properties:
id:
type: string
format: uuid
eservice:
$ref: '#/components/schemas/ClientEServiceDetails'
agreement:
$ref: '#/components/schemas/ClientAgreementDetails'
purpose:
$ref: '#/components/schemas/ClientPurposeDetails'
required:
- id
- eservice
- agreement
- purpose
ClientEServiceDetails:
type: object
properties:
eserviceId:
type: string
format: uuid
descriptorId:
type: string
format: uuid
state:
$ref: '#/components/schemas/ClientComponentState'
audience:
type: array
items:
type: string
voucherLifespan:
type: integer
format: int32
required:
- eserviceId
- descriptorId
- state
- audience
- voucherLifespan
ClientAgreementDetails:
type: object
properties:
eserviceId:
type: string
format: uuid
consumerId:
type: string
format: uuid
agreementId:
type: string
format: uuid
state:
$ref: '#/components/schemas/ClientComponentState'
required:
- eserviceId
- consumerId
- agreementId
- state
ClientPurposeDetails:
type: object
properties:
purposeId:
type: string
format: uuid
versionId:
type: string
format: uuid
state:
$ref: '#/components/schemas/ClientComponentState'
required:
- purposeId
- versionId
- state
ClientComponentState:
type: string
description: Represents the State of an object related to the purpose
enum:
- ACTIVE
- INACTIVE
Agreement:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,11 @@ package object impl extends SprayJsonSupport with DefaultJsonProtocol {
implicit val keysFormat: RootJsonFormat[Keys] = jsonFormat1(Keys)
implicit val keySeedFormat: RootJsonFormat[KeySeed] = jsonFormat4(KeySeed)

implicit val eServiceDescriptorFormat: RootJsonFormat[EServiceDescriptor] = jsonFormat2(EServiceDescriptor)
implicit val eServiceFormat: RootJsonFormat[EService] = jsonFormat2(EService)
implicit val agreementFormat: RootJsonFormat[Agreement] = jsonFormat3(Agreement)
implicit val clientAgreementDetailsFormat: RootJsonFormat[ClientAgreementDetails] =
jsonFormat4(ClientAgreementDetails)

implicit val clientEServiceDetailsFormat: RootJsonFormat[ClientEServiceDetails] = jsonFormat5(ClientEServiceDetails)
implicit val clientPurposeDetailsFormat: RootJsonFormat[ClientPurposeDetails] = jsonFormat3(ClientPurposeDetails)
implicit val clientStatesChainFormat: RootJsonFormat[ClientStatesChain] = jsonFormat4(ClientStatesChain)
implicit val clientPurposeFormat: RootJsonFormat[ClientPurpose] = jsonFormat1(ClientPurpose)
implicit val purposeFormat: RootJsonFormat[Purpose] = jsonFormat4(Purpose)
implicit val purposeAddDetailsFormat: RootJsonFormat[PurposeAdditionDetails] = jsonFormat1(PurposeAdditionDetails)
implicit val eServiceDescriptorFormat: RootJsonFormat[EServiceDescriptor] = jsonFormat2(EServiceDescriptor)
implicit val eServiceFormat: RootJsonFormat[EService] = jsonFormat2(EService)
implicit val agreementFormat: RootJsonFormat[Agreement] = jsonFormat3(Agreement)

implicit val purposeAddDetailsFormat: RootJsonFormat[PurposeAdditionDetails] = jsonFormat1(PurposeAdditionDetails)

implicit val clientFormat: RootJsonFormat[Client] = jsonFormat8(Client)
implicit val clientsFormat: RootJsonFormat[Clients] = jsonFormat2(Clients)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@
package it.pagopa.interop.authorizationprocess.common

import cats.syntax.all._
import it.pagopa.interop.authorizationmanagement.client.model.KeyUse
import it.pagopa.interop.authorizationprocess.model._
import it.pagopa.interop.authorizationprocess.model.{KeyUse => ProcessKeyUse}
import it.pagopa.interop.authorizationmanagement.model.client._
import it.pagopa.interop.authorizationmanagement.model.client.PersistentClientComponentState.Active
import it.pagopa.interop.authorizationmanagement.model.client.PersistentClientComponentState.Inactive
import it.pagopa.interop.authorizationmanagement.model.client.{Api, Consumer}
import it.pagopa.interop.authorizationmanagement.model.key.{Enc, Sig}
import it.pagopa.interop.authorizationmanagement.client.{model => AuthorizationManagementDependency}
import it.pagopa.interop.authorizationprocess.common.readmodel.model.ReadModelClientWithKeys
import it.pagopa.interop.authorizationmanagement.model.key.{PersistentKey, PersistentKeyUse}
import it.pagopa.interop.authorizationmanagement.jwk.model.Models._
import it.pagopa.interop.authorizationmanagement.model.client._
import it.pagopa.interop.authorizationmanagement.model.key.{Enc, PersistentKey, PersistentKeyUse, Sig}
import it.pagopa.interop.authorizationprocess.common.readmodel.model.ReadModelClientWithKeys
import it.pagopa.interop.authorizationprocess.error.AuthorizationProcessErrors.MissingUserId
import cats.syntax.all._
import it.pagopa.interop.authorizationprocess.model.{KeyUse => ProcessKeyUse, _}

import java.util.UUID
import java.time.OffsetDateTime
import java.util.UUID

object Adapters {

Expand All @@ -26,7 +21,7 @@ object Adapters {
name = p.name,
description = p.description,
consumerId = p.consumerId,
purposes = p.purposes.map(p => ClientPurpose(states = p.toApi)),
purposes = p.purposes.map(_.id).toSet,
users = if (showUsers) p.users else Set.empty,
kind = p.kind.toApi,
createdAt = p.createdAt
Expand All @@ -44,7 +39,7 @@ object Adapters {
name = rmck.name,
description = rmck.description,
consumerId = rmck.consumerId,
purposes = rmck.purposes.map(p => ClientPurpose(states = p.toApi)),
purposes = rmck.purposes.map(_.id).toSet,
users = if (showUsers) rmck.users else Set.empty,
kind = rmck.kind.toApi,
createdAt = rmck.createdAt
Expand All @@ -71,18 +66,13 @@ object Adapters {
)
}

implicit class ManagementClientPurposeWrapper(private val cp: AuthorizationManagementDependency.Purpose)
extends AnyVal {
def toApi: ClientPurpose = ClientPurpose(states = cp.states.toApi)
}

implicit class ManagementClientWrapper(private val p: AuthorizationManagementDependency.Client) extends AnyVal {
def toApi(showUsers: Boolean): Client = Client(
id = p.id,
name = p.name,
description = p.description,
consumerId = p.consumerId,
purposes = p.purposes.map(_.toApi),
purposes = p.purposes.map(_.states.id).toSet,
users = if (showUsers) p.users else Set.empty,
kind = p.kind.toApi,
createdAt = p.createdAt
Expand Down Expand Up @@ -111,42 +101,6 @@ object Adapters {
}
}

implicit class ClientComponentStateWrapper(private val ck: PersistentClientComponentState) extends AnyVal {
def toApi: ClientComponentState = ck match {
case Active => ClientComponentState.ACTIVE
case Inactive => ClientComponentState.INACTIVE
}
}

implicit class ClientStatesChainWrapper(private val csc: PersistentClientStatesChain) extends AnyVal {
def toApi: ClientStatesChain = ClientStatesChain(
id = csc.id,
eservice = csc.eService.toApi,
agreement = csc.agreement.toApi,
purpose = csc.purpose.toApi
)
}

implicit class ClientEServiceDetailsWrapper(private val pced: PersistentClientEServiceDetails) extends AnyVal {
def toApi: ClientEServiceDetails = ClientEServiceDetails(
descriptorId = pced.descriptorId,
eserviceId = pced.eServiceId,
audience = pced.audience,
voucherLifespan = pced.voucherLifespan,
state = pced.state.toApi
)
}

implicit class ClientAgreementDetailsWrapper(private val pcad: PersistentClientAgreementDetails) extends AnyVal {
def toApi: ClientAgreementDetails =
ClientAgreementDetails(
eserviceId = pcad.eServiceId,
consumerId = pcad.consumerId,
agreementId = pcad.agreementId,
state = pcad.state.toApi
)
}

implicit class KeySeedWrapper(private val keySeed: KeySeed) extends AnyVal {
def toDependency(userId: UUID, createdAt: OffsetDateTime): AuthorizationManagementDependency.KeySeed =
AuthorizationManagementDependency.KeySeed(
Expand Down Expand Up @@ -198,62 +152,6 @@ object Adapters {
def toApi: OtherPrimeInfo = OtherPrimeInfo(r = info.r, d = info.d, t = info.t)
}

implicit class ClientPurposeDetailsWrapper(private val pcpd: PersistentClientPurposeDetails) extends AnyVal {
def toApi: ClientPurposeDetails =
ClientPurposeDetails(purposeId = pcpd.purposeId, versionId = pcpd.versionId, state = pcpd.state.toApi)
}

implicit class ManagementPurposeDetailsWrapper(
private val cpd: AuthorizationManagementDependency.ClientPurposeDetails
) extends AnyVal {
def toApi: ClientPurposeDetails =
ClientPurposeDetails(purposeId = cpd.purposeId, versionId = cpd.versionId, state = cpd.state.toApi)
}

implicit class ManagementClientStatesChainWrapper(
private val csc: AuthorizationManagementDependency.ClientStatesChain
) extends AnyVal {
def toApi: ClientStatesChain = ClientStatesChain(
id = csc.id,
eservice = csc.eservice.toApi,
agreement = csc.agreement.toApi,
purpose = csc.purpose.toApi
)
}

implicit class ManagementClientEServiceDetailsWrapper(
private val ced: AuthorizationManagementDependency.ClientEServiceDetails
) extends AnyVal {
def toApi: ClientEServiceDetails = ClientEServiceDetails(
eserviceId = ced.eserviceId,
descriptorId = ced.descriptorId,
audience = ced.audience,
voucherLifespan = ced.voucherLifespan,
state = ced.state.toApi
)
}

implicit class ManagementClientAgreementDetailsWrapper(
private val cad: AuthorizationManagementDependency.ClientAgreementDetails
) extends AnyVal {
def toApi: ClientAgreementDetails =
ClientAgreementDetails(
eserviceId = cad.eserviceId,
consumerId = cad.consumerId,
agreementId = cad.agreementId,
state = cad.state.toApi
)
}

implicit class ManagementClientComponentStateWrapper(
private val ck: AuthorizationManagementDependency.ClientComponentState
) extends AnyVal {
def toApi: ClientComponentState = ck match {
case AuthorizationManagementDependency.ClientComponentState.ACTIVE => ClientComponentState.ACTIVE
case AuthorizationManagementDependency.ClientComponentState.INACTIVE => ClientComponentState.INACTIVE
}
}

implicit class JwkOtherPrimeInfoWrapper(private val o: JwkOtherPrimeInfo) extends AnyVal {
def toApi: OtherPrimeInfo = OtherPrimeInfo(r = o.r, d = o.d, t = o.t)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ClientOperationSpec extends AnyWordSpecLike with MockFactory with SpecUtil
id = client.id,
consumerId = consumerId,
name = client.name,
purposes = Seq(clientPurposeProcess),
purposes = Set(clientPurpose.states.id),
users = Set.empty,
description = client.description,
kind = ClientKind.CONSUMER,
Expand Down Expand Up @@ -99,7 +99,7 @@ class ClientOperationSpec extends AnyWordSpecLike with MockFactory with SpecUtil
id = persistentClient.id,
consumerId = consumerId,
name = persistentClient.name,
purposes = Seq(clientPurposeProcess),
purposes = Set(clientPurpose.states.id),
description = persistentClient.description,
users = Set.empty,
kind = ClientKind.CONSUMER,
Expand Down Expand Up @@ -127,7 +127,7 @@ class ClientOperationSpec extends AnyWordSpecLike with MockFactory with SpecUtil
id = persistentClient.id,
consumerId = anotherConsumerId,
name = persistentClient.name,
purposes = Seq(clientPurposeProcess),
purposes = Set(clientPurpose.states.id),
description = persistentClient.description,
users = Set.empty,
kind = ClientKind.CONSUMER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class UserOperationSpec extends AnyWordSpecLike with MockFactory with SpecUtilsW
id = persistentClient.id,
consumerId = consumerId,
name = client.name,
purposes = Seq(clientPurposeProcess),
purposes = Set(clientPurpose.states.id),
description = client.description,
users = Set(userId),
kind = ClientKind.CONSUMER,
Expand Down
Loading

0 comments on commit b9b97e7

Please sign in to comment.