All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.ngrok.definitions.EndpointLoggingMutate.scala Maven / Gradle / Ivy

There is a newer version: 0.7.0
Show newest version
package com.ngrok.definitions

import io.circe.syntax._

/** A class encapsulating the [[EndpointLoggingMutate]] resource.
  *
  * @constructor create a new EndpointLoggingMutate.
  * @param enabled true if the module will be applied to traffic, false to disable. default true if unspecified
  * @param eventStreamIds list of all EventStreams that will be used to configure and export this endpoint's logs
  */
final case class EndpointLoggingMutate(
  enabled: Option[Boolean] = None,
  eventStreamIds: List[String]
)

object EndpointLoggingMutate {
  implicit val encodeEndpointLoggingMutate: io.circe.Encoder[EndpointLoggingMutate] =
    io.circe.Encoder.encodeJsonObject.contramap(value =>
      List(
        value.enabled.map(_.asJson).map(("enabled", _)),
        Option(("event_stream_ids", value.eventStreamIds.asJson))
      ).flatten.toMap.asJsonObject
    )

  implicit val decodeEndpointLoggingMutate: io.circe.Decoder[EndpointLoggingMutate] = (c: io.circe.HCursor) =>
    for {
      enabled        <- c.downField("enabled").as[Option[Boolean]]
      eventStreamIds <- c.downField("event_stream_ids").as[List[String]]
    } yield EndpointLoggingMutate(
      enabled,
      eventStreamIds
    )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy