Skip to content

Commit

Permalink
W-12689952: add ibmmq channel binding in async21+
Browse files Browse the repository at this point in the history
- add channel binding model, parser and emitter
- add unit validation and cycle tests
- add model to APIEntities and model.md
  • Loading branch information
arielmirra committed Feb 9, 2024
1 parent 72d3644 commit 45d903b
Show file tree
Hide file tree
Showing 15 changed files with 731 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package amf.apicontract.client.platform.model.domain.bindings.ibmmq

import amf.apicontract.client.platform.model.domain.bindings.{BindingVersion, ChannelBinding}
import amf.apicontract.client.scala.model.domain.bindings.ibmmq.{
IBMMQChannelTopic => InternalIBMMQChannelTopic,
IBMMQChannelBinding => InternalIBMMQChannelBinding,
IBMMQChannelQueue => InternalIBMMQChannelQueue
}
import amf.apicontract.internal.convert.ApiClientConverters._
import amf.core.client.platform.model
import amf.core.client.platform.model.domain.{DomainElement, NamedDomainElement}
import amf.core.client.platform.model.{BoolField, IntField, StrField}

import scala.scalajs.js.annotation.{JSExportAll, JSExportTopLevel}

@JSExportAll
case class IBMMQChannelBinding(override private[amf] val _internal: InternalIBMMQChannelBinding)
extends ChannelBinding
with BindingVersion {
@JSExportTopLevel("IBMMQChannelBinding")
def this() = this(InternalIBMMQChannelBinding())

def destinationType: StrField = _internal.destinationType
def queue: IBMMQChannelQueue = _internal.queue
def topic: IBMMQChannelTopic = _internal.topic
def maxMsgLength: IntField = _internal.maxMsgLength

def withDestinationType(destinationType: String): this.type = {
_internal.withDestinationType(destinationType)
this
}

def withQueue(queue: IBMMQChannelQueue): this.type = {
_internal.withQueue(queue)
this
}

def withTopic(topic: IBMMQChannelTopic): this.type = {
_internal.withTopic(topic)
this
}

def withMaxMsgLength(maxMsgLength: Int): this.type = {
_internal.withMaxMsgLength(maxMsgLength)
this
}

override protected def bindingVersion: model.StrField = _internal.bindingVersion

override def withBindingVersion(bindingVersion: String): this.type = {
_internal.withBindingVersion(bindingVersion)
this
}

override def linkCopy(): IBMMQChannelBinding = _internal.linkCopy()
}

@JSExportAll
case class IBMMQChannelQueue(override private[amf] val _internal: InternalIBMMQChannelQueue)
extends DomainElement
with NamedDomainElement {

@JSExportTopLevel("IBMMQChannelQueue")
def this() = this(InternalIBMMQChannelQueue())

def objectName: StrField = _internal.objectName
def isPartitioned: BoolField = _internal.isPartitioned
def exclusive: BoolField = _internal.exclusive

def withObjectName(objectName: Boolean): this.type = {
_internal.withObjectName(objectName)
this
}

def withIsPartitioned(isPartitioned: Boolean): this.type = {
_internal.withIsPartitioned(isPartitioned)
this
}

def withExclusive(exclusive: Boolean): this.type = {
_internal.withExclusive(exclusive)
this
}

override def name: StrField = _internal.name

override def withName(name: String): this.type = {
_internal.withName(name)
this
}
}

@JSExportAll
case class IBMMQChannelTopic(override private[amf] val _internal: InternalIBMMQChannelTopic)
extends DomainElement
with NamedDomainElement {

@JSExportTopLevel("IBMMQChannelTopic")
def this() = this(InternalIBMMQChannelTopic())

def string: BoolField = _internal.string
def objectName: StrField = _internal.objectName
def durablePermitted: BoolField = _internal.durablePermitted
def lastMsgRetained: BoolField = _internal.lastMsgRetained

def withString(string: Boolean): this.type = {
_internal.withString(string)
this
}

def withObjectName(objectName: Boolean): this.type = {
_internal.withObjectName(objectName)
this
}

def withDurablePermitted(durablePermitted: Boolean): this.type = {
_internal.withDurablePermitted(durablePermitted)
this
}

def withLastMsgRetained(lastMsgRetained: Boolean): this.type = {
_internal.withLastMsgRetained(lastMsgRetained)
this
}

override def name: StrField = _internal.name

override def withName(name: String): this.type = {
_internal.withName(name)
this
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package amf.apicontract.client.scala.model.domain.bindings.ibmmq

import amf.apicontract.client.scala.model.domain.bindings.{BindingVersion, ChannelBinding}
import amf.apicontract.internal.metamodel.domain.bindings.{
IBMMQChannelBindingModel,
IBMMQChannelQueueModel,
IBMMQChannelTopicModel
}
import amf.apicontract.internal.metamodel.domain.bindings.IBMMQChannelBindingModel._
import amf.apicontract.internal.spec.async.parser.bindings.Bindings.IBMMQ
import amf.core.client.scala.model.domain.{DomainElement, Linkable, NamedDomainElement}
import amf.core.client.scala.model.{BoolField, IntField, StrField}
import amf.core.internal.metamodel.Field
import amf.core.internal.parser.domain.{Annotations, Fields}
import amf.shapes.client.scala.model.domain.Key

class IBMMQChannelBinding(override val fields: Fields, override val annotations: Annotations)
extends ChannelBinding
with BindingVersion
with Key {

override protected def bindingVersionField: Field = BindingVersion
override def meta: IBMMQChannelBindingModel.type = IBMMQChannelBindingModel

def destinationType: StrField = fields.field(DestinationType)
def queue: IBMMQChannelQueue = fields.field(Queue)
def topic: IBMMQChannelTopic = fields.field(Topic)
def maxMsgLength: IntField = fields.field(MaxMsgLength)

def withDestinationType(destinationType: String): this.type = set(DestinationType, destinationType)
def withQueue(queue: IBMMQChannelQueue): this.type = set(Queue, queue)
def withTopic(topic: IBMMQChannelTopic): this.type = set(Topic, topic)
def withMaxMsgLength(maxMsgLength: Int): this.type = set(MaxMsgLength, maxMsgLength)

override def key: StrField = fields.field(IBMMQChannelBindingModel.key)

override def componentId: String = s"/$IBMMQ-channel"

override def linkCopy(): IBMMQChannelBinding = IBMMQChannelBinding()

override protected def classConstructor: (Fields, Annotations) => Linkable with DomainElement =
IBMMQChannelBinding.apply
}

object IBMMQChannelBinding {

def apply(): IBMMQChannelBinding = apply(Annotations())

def apply(annotations: Annotations): IBMMQChannelBinding = apply(Fields(), annotations)

def apply(fields: Fields, annotations: Annotations): IBMMQChannelBinding =
new IBMMQChannelBinding(fields, annotations)
}

class IBMMQChannelQueue(override val fields: Fields, override val annotations: Annotations)
extends DomainElement
with NamedDomainElement {
override def meta: IBMMQChannelQueueModel.type = IBMMQChannelQueueModel

override def nameField: Field = IBMMQChannelQueueModel.Name

def objectName: StrField = fields.field(IBMMQChannelQueueModel.ObjectName)
def isPartitioned: BoolField = fields.field(IBMMQChannelQueueModel.IsPartitioned)
def exclusive: BoolField = fields.field(IBMMQChannelQueueModel.Exclusive)

def withObjectName(objectName: Boolean): this.type = set(IBMMQChannelQueueModel.ObjectName, objectName)
def withIsPartitioned(isPartitioned: Boolean): this.type = set(IBMMQChannelQueueModel.IsPartitioned, isPartitioned)
def withExclusive(exclusive: Boolean): this.type = set(IBMMQChannelQueueModel.Exclusive, exclusive)

override def componentId: String = s"/$IBMMQ-queue"
}

object IBMMQChannelQueue {

def apply(): IBMMQChannelQueue = apply(Annotations())

def apply(annotations: Annotations): IBMMQChannelQueue = apply(Fields(), annotations)

def apply(fields: Fields, annotations: Annotations): IBMMQChannelQueue = new IBMMQChannelQueue(fields, annotations)
}

class IBMMQChannelTopic(override val fields: Fields, override val annotations: Annotations)
extends DomainElement
with NamedDomainElement {
override def meta: IBMMQChannelTopicModel.type = IBMMQChannelTopicModel

override def nameField: Field = IBMMQChannelTopicModel.Name

def string: BoolField = fields.field(IBMMQChannelTopicModel.String)
def objectName: StrField = fields.field(IBMMQChannelTopicModel.ObjectName)
def durablePermitted: BoolField = fields.field(IBMMQChannelTopicModel.DurablePermitted)
def lastMsgRetained: BoolField = fields.field(IBMMQChannelTopicModel.LastMsgRetained)

def withString(string: Boolean): this.type = set(IBMMQChannelTopicModel.String, string)
def withObjectName(objectName: Boolean): this.type = set(IBMMQChannelTopicModel.ObjectName, objectName)
def withDurablePermitted(durablePermitted: Boolean): this.type =
set(IBMMQChannelTopicModel.DurablePermitted, durablePermitted)
def withLastMsgRetained(lastMsgRetained: Boolean): this.type =
set(IBMMQChannelTopicModel.LastMsgRetained, lastMsgRetained)

override def componentId: String = s"/$IBMMQ-topic"
}

object IBMMQChannelTopic {

def apply(): IBMMQChannelTopic = apply(Annotations())

def apply(annotations: Annotations): IBMMQChannelTopic = apply(Fields(), annotations)

def apply(fields: Fields, annotations: Annotations): IBMMQChannelTopic = new IBMMQChannelTopic(fields, annotations)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ import amf.apicontract.client.scala.model.domain.bindings.amqp.{
Amqp091Queue
}
import amf.apicontract.client.scala.model.domain.bindings.http.{HttpMessageBinding, HttpOperationBinding}
import amf.apicontract.client.scala.model.domain.bindings.ibmmq.{IBMMQMessageBinding, IBMMQServerBinding}
import amf.apicontract.client.scala.model.domain.bindings.ibmmq.{
IBMMQChannelBinding,
IBMMQChannelQueue,
IBMMQChannelTopic,
IBMMQMessageBinding,
IBMMQServerBinding
}
import amf.apicontract.client.scala.model.domain.bindings.kafka.{KafkaMessageBinding, KafkaOperationBinding}
import amf.apicontract.client.scala.model.domain.bindings.mqtt.{
MqttMessageBinding,
Expand Down Expand Up @@ -115,6 +121,9 @@ trait ApiBaseConverter
with Amqp091QueueConverter
with IBBMQMessageBindingConverter
with IBBMQServerBindingConverter
with IBBMQChannelBindingConverter
with IBBMQChannelQueueConverter
with IBBMQChannelTopicConverter
with ChannelBindingConverter
with OperationBindingConverter
with MessageBindingConverter
Expand Down Expand Up @@ -332,6 +341,33 @@ trait IBBMQServerBindingConverter extends PlatformSecrets {
}
}

trait IBBMQChannelBindingConverter extends PlatformSecrets {
implicit object IBBMQChannelBindingMatcher
extends BidirectionalMatcher[IBMMQChannelBinding, domain.bindings.ibmmq.IBMMQChannelBinding] {
override def asClient(from: IBMMQChannelBinding): domain.bindings.ibmmq.IBMMQChannelBinding =
platform.wrap[domain.bindings.ibmmq.IBMMQChannelBinding](from)
override def asInternal(from: domain.bindings.ibmmq.IBMMQChannelBinding): IBMMQChannelBinding = from._internal
}
}

trait IBBMQChannelQueueConverter extends PlatformSecrets {
implicit object IBBMQChannelQueueMatcher
extends BidirectionalMatcher[IBMMQChannelQueue, domain.bindings.ibmmq.IBMMQChannelQueue] {
override def asClient(from: IBMMQChannelQueue): domain.bindings.ibmmq.IBMMQChannelQueue =
platform.wrap[domain.bindings.ibmmq.IBMMQChannelQueue](from)
override def asInternal(from: domain.bindings.ibmmq.IBMMQChannelQueue): IBMMQChannelQueue = from._internal
}
}

trait IBBMQChannelTopicConverter extends PlatformSecrets {
implicit object IBBMQChannelTopicMatcher
extends BidirectionalMatcher[IBMMQChannelTopic, domain.bindings.ibmmq.IBMMQChannelTopic] {
override def asClient(from: IBMMQChannelTopic): domain.bindings.ibmmq.IBMMQChannelTopic =
platform.wrap[domain.bindings.ibmmq.IBMMQChannelTopic](from)
override def asInternal(from: domain.bindings.ibmmq.IBMMQChannelTopic): IBMMQChannelTopic = from._internal
}
}

trait EndPointConverter extends PlatformSecrets {

implicit object EndPointMatcher extends BidirectionalMatcher[EndPoint, domain.EndPoint] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import amf.apicontract.client.platform.model.domain.api.{AsyncApi, WebApi}
import amf.apicontract.client.platform.model.domain.bindings._
import amf.apicontract.client.platform.model.domain.bindings.amqp._
import amf.apicontract.client.platform.model.domain.bindings.http.{HttpMessageBinding, HttpOperationBinding}
import amf.apicontract.client.platform.model.domain.bindings.ibmmq.{IBMMQMessageBinding, IBMMQServerBinding}
import amf.apicontract.client.platform.model.domain.bindings.ibmmq.{
IBMMQChannelBinding,
IBMMQChannelQueue,
IBMMQChannelTopic,
IBMMQMessageBinding,
IBMMQServerBinding
}
import amf.apicontract.client.platform.model.domain.bindings.kafka.{KafkaMessageBinding, KafkaOperationBinding}
import amf.apicontract.client.platform.model.domain.bindings.mqtt.{
MqttMessageBinding,
Expand Down Expand Up @@ -281,6 +287,15 @@ private[amf] object ApiRegister extends UniqueInitializer with PlatformSecrets {
platform.registerWrapper(IBMMQServerBindingModel) {
case s: amf.apicontract.client.scala.model.domain.bindings.ibmmq.IBMMQServerBinding => IBMMQServerBinding(s)
}
platform.registerWrapper(IBMMQChannelBindingModel) {
case s: amf.apicontract.client.scala.model.domain.bindings.ibmmq.IBMMQChannelBinding => IBMMQChannelBinding(s)
}
platform.registerWrapper(IBMMQChannelQueueModel) {
case s: amf.apicontract.client.scala.model.domain.bindings.ibmmq.IBMMQChannelQueue => IBMMQChannelQueue(s)
}
platform.registerWrapper(IBMMQChannelTopicModel) {
case s: amf.apicontract.client.scala.model.domain.bindings.ibmmq.IBMMQChannelTopic => IBMMQChannelTopic(s)
}
platform.registerWrapper(APIContractProcessingDataModel) {
case s: amf.apicontract.client.scala.model.document.APIContractProcessingData => APIContractProcessingData(s)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ private[amf] object APIEntities extends Entities {
ParameterFederationMetadataModel,
EndpointFederationMetadataModel,
IBMMQMessageBindingModel,
IBMMQServerBindingModel
IBMMQServerBindingModel,
IBMMQChannelBindingModel,
IBMMQChannelQueueModel,
IBMMQChannelTopicModel
)
}
Loading

0 comments on commit 45d903b

Please sign in to comment.