com.ngrok.definitions.EndpointIpPolicyMutate.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ngrok-api-scala_2.13 Show documentation
Show all versions of ngrok-api-scala_2.13 Show documentation
ngrok API client for Scala applications
package com.ngrok.definitions
import io.circe.syntax._
/** A class encapsulating the [[EndpointIpPolicyMutate]] resource.
*
* @constructor create a new EndpointIpPolicyMutate.
* @param enabled true
if the module will be applied to traffic, false
to disable. default true
if unspecified
* @param ipPolicyIds list of all IP policies that will be used to check if a source IP is allowed access to the endpoint
*/
final case class EndpointIpPolicyMutate(
enabled: Option[Boolean] = None,
ipPolicyIds: List[String]
)
object EndpointIpPolicyMutate {
implicit val encodeEndpointIpPolicyMutate: io.circe.Encoder[EndpointIpPolicyMutate] =
io.circe.Encoder.encodeJsonObject.contramap(value =>
List(
value.enabled.map(_.asJson).map(("enabled", _)),
Option(("ip_policy_ids", value.ipPolicyIds.asJson))
).flatten.toMap.asJsonObject
)
implicit val decodeEndpointIpPolicyMutate: io.circe.Decoder[EndpointIpPolicyMutate] = (c: io.circe.HCursor) =>
for {
enabled <- c.downField("enabled").as[Option[Boolean]]
ipPolicyIds <- c.downField("ip_policy_ids").as[List[String]]
} yield EndpointIpPolicyMutate(
enabled,
ipPolicyIds
)
}