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

zio.aws.verifiedpermissions.model.PolicyItem.scala Maven / Gradle / Ivy

There is a newer version: 7.28.29.5
Show newest version
package zio.aws.verifiedpermissions.model
import java.time.Instant
import zio.prelude.data.Optional
import zio.aws.core.{AwsError, BuilderHelper}
import zio.ZIO
import zio.aws.verifiedpermissions.model.primitives.{
  TimestampFormat,
  PolicyId,
  PolicyStoreId
}
import scala.jdk.CollectionConverters._
final case class PolicyItem(
    policyStoreId: PolicyStoreId,
    policyId: PolicyId,
    policyType: zio.aws.verifiedpermissions.model.PolicyType,
    principal: Optional[zio.aws.verifiedpermissions.model.EntityIdentifier] =
      Optional.Absent,
    resource: Optional[zio.aws.verifiedpermissions.model.EntityIdentifier] =
      Optional.Absent,
    definition: zio.aws.verifiedpermissions.model.PolicyDefinitionItem,
    createdDate: TimestampFormat,
    lastUpdatedDate: TimestampFormat
) {
  def buildAwsValue()
      : software.amazon.awssdk.services.verifiedpermissions.model.PolicyItem = {
    import PolicyItem.zioAwsBuilderHelper.BuilderOps
    software.amazon.awssdk.services.verifiedpermissions.model.PolicyItem
      .builder()
      .policyStoreId(PolicyStoreId.unwrap(policyStoreId): java.lang.String)
      .policyId(PolicyId.unwrap(policyId): java.lang.String)
      .policyType(policyType.unwrap)
      .optionallyWith(principal.map(value => value.buildAwsValue()))(
        _.principal
      )
      .optionallyWith(resource.map(value => value.buildAwsValue()))(_.resource)
      .definition(definition.buildAwsValue())
      .createdDate(TimestampFormat.unwrap(createdDate): Instant)
      .lastUpdatedDate(TimestampFormat.unwrap(lastUpdatedDate): Instant)
      .build()
  }
  def asReadOnly: zio.aws.verifiedpermissions.model.PolicyItem.ReadOnly =
    zio.aws.verifiedpermissions.model.PolicyItem.wrap(buildAwsValue())
}
object PolicyItem {
  private lazy val zioAwsBuilderHelper: BuilderHelper[
    software.amazon.awssdk.services.verifiedpermissions.model.PolicyItem
  ] = BuilderHelper.apply
  trait ReadOnly {
    def asEditable: zio.aws.verifiedpermissions.model.PolicyItem =
      zio.aws.verifiedpermissions.model.PolicyItem(
        policyStoreId,
        policyId,
        policyType,
        principal.map(value => value.asEditable),
        resource.map(value => value.asEditable),
        definition.asEditable,
        createdDate,
        lastUpdatedDate
      )
    def policyStoreId: PolicyStoreId
    def policyId: PolicyId
    def policyType: zio.aws.verifiedpermissions.model.PolicyType
    def principal
        : Optional[zio.aws.verifiedpermissions.model.EntityIdentifier.ReadOnly]
    def resource
        : Optional[zio.aws.verifiedpermissions.model.EntityIdentifier.ReadOnly]
    def definition
        : zio.aws.verifiedpermissions.model.PolicyDefinitionItem.ReadOnly
    def createdDate: TimestampFormat
    def lastUpdatedDate: TimestampFormat
    def getPolicyStoreId: ZIO[Any, Nothing, PolicyStoreId] =
      ZIO.succeed(policyStoreId)
    def getPolicyId: ZIO[Any, Nothing, PolicyId] = ZIO.succeed(policyId)
    def getPolicyType
        : ZIO[Any, Nothing, zio.aws.verifiedpermissions.model.PolicyType] =
      ZIO.succeed(policyType)
    def getPrincipal: ZIO[
      Any,
      AwsError,
      zio.aws.verifiedpermissions.model.EntityIdentifier.ReadOnly
    ] = AwsError.unwrapOptionField("principal", principal)
    def getResource: ZIO[
      Any,
      AwsError,
      zio.aws.verifiedpermissions.model.EntityIdentifier.ReadOnly
    ] = AwsError.unwrapOptionField("resource", resource)
    def getDefinition: ZIO[
      Any,
      Nothing,
      zio.aws.verifiedpermissions.model.PolicyDefinitionItem.ReadOnly
    ] = ZIO.succeed(definition)
    def getCreatedDate: ZIO[Any, Nothing, TimestampFormat] =
      ZIO.succeed(createdDate)
    def getLastUpdatedDate: ZIO[Any, Nothing, TimestampFormat] =
      ZIO.succeed(lastUpdatedDate)
  }
  private final class Wrapper(
      impl: software.amazon.awssdk.services.verifiedpermissions.model.PolicyItem
  ) extends zio.aws.verifiedpermissions.model.PolicyItem.ReadOnly {
    override val policyStoreId: PolicyStoreId =
      zio.aws.verifiedpermissions.model.primitives
        .PolicyStoreId(impl.policyStoreId())
    override val policyId: PolicyId =
      zio.aws.verifiedpermissions.model.primitives.PolicyId(impl.policyId())
    override val policyType: zio.aws.verifiedpermissions.model.PolicyType =
      zio.aws.verifiedpermissions.model.PolicyType.wrap(impl.policyType())
    override val principal: Optional[
      zio.aws.verifiedpermissions.model.EntityIdentifier.ReadOnly
    ] = zio.aws.core.internal
      .optionalFromNullable(impl.principal())
      .map(value =>
        zio.aws.verifiedpermissions.model.EntityIdentifier.wrap(value)
      )
    override val resource: Optional[
      zio.aws.verifiedpermissions.model.EntityIdentifier.ReadOnly
    ] = zio.aws.core.internal
      .optionalFromNullable(impl.resource())
      .map(value =>
        zio.aws.verifiedpermissions.model.EntityIdentifier.wrap(value)
      )
    override val definition
        : zio.aws.verifiedpermissions.model.PolicyDefinitionItem.ReadOnly =
      zio.aws.verifiedpermissions.model.PolicyDefinitionItem
        .wrap(impl.definition())
    override val createdDate: TimestampFormat =
      zio.aws.verifiedpermissions.model.primitives
        .TimestampFormat(impl.createdDate())
    override val lastUpdatedDate: TimestampFormat =
      zio.aws.verifiedpermissions.model.primitives
        .TimestampFormat(impl.lastUpdatedDate())
  }
  def wrap(
      impl: software.amazon.awssdk.services.verifiedpermissions.model.PolicyItem
  ): zio.aws.verifiedpermissions.model.PolicyItem.ReadOnly = new Wrapper(impl)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy