zio.aws.verifiedpermissions.model.TemplateLinkedPolicyDefinition.scala Maven / Gradle / Ivy
package zio.aws.verifiedpermissions.model
import zio.aws.verifiedpermissions.model.primitives.PolicyTemplateId
import zio.ZIO
import zio.aws.core.{AwsError, BuilderHelper}
import zio.prelude.data.Optional
import scala.jdk.CollectionConverters._
final case class TemplateLinkedPolicyDefinition(
policyTemplateId: PolicyTemplateId,
principal: Optional[zio.aws.verifiedpermissions.model.EntityIdentifier] =
Optional.Absent,
resource: Optional[zio.aws.verifiedpermissions.model.EntityIdentifier] =
Optional.Absent
) {
def buildAwsValue()
: software.amazon.awssdk.services.verifiedpermissions.model.TemplateLinkedPolicyDefinition = {
import TemplateLinkedPolicyDefinition.zioAwsBuilderHelper.BuilderOps
software.amazon.awssdk.services.verifiedpermissions.model.TemplateLinkedPolicyDefinition
.builder()
.policyTemplateId(
PolicyTemplateId.unwrap(policyTemplateId): java.lang.String
)
.optionallyWith(principal.map(value => value.buildAwsValue()))(
_.principal
)
.optionallyWith(resource.map(value => value.buildAwsValue()))(_.resource)
.build()
}
def asReadOnly
: zio.aws.verifiedpermissions.model.TemplateLinkedPolicyDefinition.ReadOnly =
zio.aws.verifiedpermissions.model.TemplateLinkedPolicyDefinition
.wrap(buildAwsValue())
}
object TemplateLinkedPolicyDefinition {
private lazy val zioAwsBuilderHelper: BuilderHelper[
software.amazon.awssdk.services.verifiedpermissions.model.TemplateLinkedPolicyDefinition
] = BuilderHelper.apply
trait ReadOnly {
def asEditable
: zio.aws.verifiedpermissions.model.TemplateLinkedPolicyDefinition =
zio.aws.verifiedpermissions.model.TemplateLinkedPolicyDefinition(
policyTemplateId,
principal.map(value => value.asEditable),
resource.map(value => value.asEditable)
)
def policyTemplateId: PolicyTemplateId
def principal
: Optional[zio.aws.verifiedpermissions.model.EntityIdentifier.ReadOnly]
def resource
: Optional[zio.aws.verifiedpermissions.model.EntityIdentifier.ReadOnly]
def getPolicyTemplateId: ZIO[Any, Nothing, PolicyTemplateId] =
ZIO.succeed(policyTemplateId)
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)
}
private final class Wrapper(
impl: software.amazon.awssdk.services.verifiedpermissions.model.TemplateLinkedPolicyDefinition
) extends zio.aws.verifiedpermissions.model.TemplateLinkedPolicyDefinition.ReadOnly {
override val policyTemplateId: PolicyTemplateId =
zio.aws.verifiedpermissions.model.primitives
.PolicyTemplateId(impl.policyTemplateId())
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)
)
}
def wrap(
impl: software.amazon.awssdk.services.verifiedpermissions.model.TemplateLinkedPolicyDefinition
): zio.aws.verifiedpermissions.model.TemplateLinkedPolicyDefinition.ReadOnly =
new Wrapper(impl)
}