io.github.vigoo.zioaws.rdsdata.package.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zio-aws-rdsdata_3 Show documentation
Show all versions of zio-aws-rdsdata_3 Show documentation
Low-level AWS wrapper for ZIO
package io.github.vigoo.zioaws
import io.github.vigoo.zioaws.rdsdata.model.BatchExecuteStatementResponse.ReadOnly
import software.amazon.awssdk.services.rdsdata.{
RdsDataAsyncClientBuilder,
RdsDataAsyncClient
}
import io.github.vigoo.zioaws.core.{AwsServiceBase, AwsError}
import io.github.vigoo.zioaws.rdsdata.RdsData
import io.github.vigoo.zioaws.core.config.AwsConfig
import zio.{ZManaged, IO, ZIO, ZLayer, URLayer, Has}
import io.github.vigoo.zioaws.core.aspects.{AwsCallAspect, AspectSupport}
import software.amazon.awssdk.services.rdsdata.model.{
ExecuteStatementRequest,
ExecuteStatementResponse,
BeginTransactionRequest,
RollbackTransactionRequest,
CommitTransactionRequest,
BeginTransactionResponse,
CommitTransactionResponse,
BatchExecuteStatementRequest,
BatchExecuteStatementResponse,
RollbackTransactionResponse
}
import zio.test.mock.{Proxy, Mock}
package object rdsdata {
import scala.jdk.CollectionConverters.*
type RdsData = Has[RdsData.Service]
object RdsData {
trait Service extends AspectSupport[Service] {
val api: RdsDataAsyncClient
def commitTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.CommitTransactionRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.CommitTransactionResponse.ReadOnly
]
def rollbackTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.RollbackTransactionRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.RollbackTransactionResponse.ReadOnly
]
def batchExecuteStatement(
request: io.github.vigoo.zioaws.rdsdata.model.BatchExecuteStatementRequest
): IO[AwsError, ReadOnly]
def executeStatement(
request: io.github.vigoo.zioaws.rdsdata.model.ExecuteStatementRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.ExecuteStatementResponse.ReadOnly
]
def beginTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.BeginTransactionRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.BeginTransactionResponse.ReadOnly
]
}
object RdsDataMock extends Mock[RdsData] {
object CommitTransaction
extends Effect[
io.github.vigoo.zioaws.rdsdata.model.CommitTransactionRequest,
AwsError,
io.github.vigoo.zioaws.rdsdata.model.CommitTransactionResponse.ReadOnly
]
object RollbackTransaction
extends Effect[
io.github.vigoo.zioaws.rdsdata.model.RollbackTransactionRequest,
AwsError,
io.github.vigoo.zioaws.rdsdata.model.RollbackTransactionResponse.ReadOnly
]
object BatchExecuteStatement
extends Effect[
io.github.vigoo.zioaws.rdsdata.model.BatchExecuteStatementRequest,
AwsError,
ReadOnly
]
object ExecuteStatement
extends Effect[
io.github.vigoo.zioaws.rdsdata.model.ExecuteStatementRequest,
AwsError,
io.github.vigoo.zioaws.rdsdata.model.ExecuteStatementResponse.ReadOnly
]
object BeginTransaction
extends Effect[
io.github.vigoo.zioaws.rdsdata.model.BeginTransactionRequest,
AwsError,
io.github.vigoo.zioaws.rdsdata.model.BeginTransactionResponse.ReadOnly
]
val compose: URLayer[Has[Proxy], RdsData] = ZLayer.fromServiceM { proxy =>
withRuntime.map { rts =>
new RdsData.Service {
val api: RdsDataAsyncClient = null
def withAspect[R1](
newAspect: AwsCallAspect[R1],
r: R1
): RdsData.Service = this
def commitTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.CommitTransactionRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.CommitTransactionResponse.ReadOnly
] = proxy(CommitTransaction, request)
def rollbackTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.RollbackTransactionRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.RollbackTransactionResponse.ReadOnly
] = proxy(RollbackTransaction, request)
def batchExecuteStatement(
request: io.github.vigoo.zioaws.rdsdata.model.BatchExecuteStatementRequest
): IO[AwsError, ReadOnly] = proxy(BatchExecuteStatement, request)
def executeStatement(
request: io.github.vigoo.zioaws.rdsdata.model.ExecuteStatementRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.ExecuteStatementResponse.ReadOnly
] = proxy(ExecuteStatement, request)
def beginTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.BeginTransactionRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.BeginTransactionResponse.ReadOnly
] = proxy(BeginTransaction, request)
}
}
}
}
}
val live: ZLayer[AwsConfig, java.lang.Throwable, RdsData] = customized(
identity
)
def customized(
customization: RdsDataAsyncClientBuilder => RdsDataAsyncClientBuilder
): ZLayer[AwsConfig, java.lang.Throwable, RdsData] = managed(
customization
).toLayer
def managed(
customization: RdsDataAsyncClientBuilder => RdsDataAsyncClientBuilder
): ZManaged[AwsConfig, java.lang.Throwable, RdsData.Service] = for (
awsConfig <- ZManaged.service[AwsConfig.Service];
executor <- ZIO.executor.toManaged_;
builder = RdsDataAsyncClient
.builder()
.asyncConfiguration(
software.amazon.awssdk.core.client.config.ClientAsyncConfiguration
.builder()
.advancedOption(
software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR,
executor.asJava
)
.build()
);
b0 <- awsConfig
.configure[RdsDataAsyncClient, RdsDataAsyncClientBuilder](builder)
.toManaged_;
b1 <- awsConfig
.configureHttpClient[RdsDataAsyncClient, RdsDataAsyncClientBuilder](
b0,
io.github.vigoo.zioaws.core.httpclient
.ServiceHttpCapabilities(supportsHttp2 = false)
)
.toManaged_; client <- zio.ZIO(customization(b1).build()).toManaged_
) yield new RdsDataImpl(client, AwsCallAspect.identity, ().asInstanceOf[Any])
private class RdsDataImpl[R](
override val api: RdsDataAsyncClient,
override val aspect: AwsCallAspect[R],
r: R
) extends RdsData.Service
with AwsServiceBase[R, RdsDataImpl] {
override val serviceName: String = "RdsData"
override def withAspect[R1](
newAspect: AwsCallAspect[R1],
r: R1
): RdsDataImpl[R1] = new RdsDataImpl(api, newAspect, r)
def commitTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.CommitTransactionRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.CommitTransactionResponse.ReadOnly
] =
asyncRequestResponse[CommitTransactionRequest, CommitTransactionResponse](
"commitTransaction",
api.commitTransaction
)(request.buildAwsValue())
.map(
io.github.vigoo.zioaws.rdsdata.model.CommitTransactionResponse.wrap
)
.provide(r)
def rollbackTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.RollbackTransactionRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.RollbackTransactionResponse.ReadOnly
] = asyncRequestResponse[
RollbackTransactionRequest,
RollbackTransactionResponse
]("rollbackTransaction", api.rollbackTransaction)(request.buildAwsValue())
.map(
io.github.vigoo.zioaws.rdsdata.model.RollbackTransactionResponse.wrap
)
.provide(r)
def batchExecuteStatement(
request: io.github.vigoo.zioaws.rdsdata.model.BatchExecuteStatementRequest
): IO[AwsError, ReadOnly] = asyncRequestResponse[
BatchExecuteStatementRequest,
BatchExecuteStatementResponse
]("batchExecuteStatement", api.batchExecuteStatement)(
request.buildAwsValue()
).map(
io.github.vigoo.zioaws.rdsdata.model.BatchExecuteStatementResponse.wrap
).provide(r)
def executeStatement(
request: io.github.vigoo.zioaws.rdsdata.model.ExecuteStatementRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.ExecuteStatementResponse.ReadOnly
] = asyncRequestResponse[ExecuteStatementRequest, ExecuteStatementResponse](
"executeStatement",
api.executeStatement
)(request.buildAwsValue())
.map(io.github.vigoo.zioaws.rdsdata.model.ExecuteStatementResponse.wrap)
.provide(r)
def beginTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.BeginTransactionRequest
): IO[
AwsError,
io.github.vigoo.zioaws.rdsdata.model.BeginTransactionResponse.ReadOnly
] = asyncRequestResponse[BeginTransactionRequest, BeginTransactionResponse](
"beginTransaction",
api.beginTransaction
)(request.buildAwsValue())
.map(io.github.vigoo.zioaws.rdsdata.model.BeginTransactionResponse.wrap)
.provide(r)
}
def commitTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.CommitTransactionRequest
): ZIO[
RdsData,
AwsError,
io.github.vigoo.zioaws.rdsdata.model.CommitTransactionResponse.ReadOnly
] = ZIO.accessM(_.get.commitTransaction(request))
def rollbackTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.RollbackTransactionRequest
): ZIO[
RdsData,
AwsError,
io.github.vigoo.zioaws.rdsdata.model.RollbackTransactionResponse.ReadOnly
] = ZIO.accessM(_.get.rollbackTransaction(request))
def batchExecuteStatement(
request: io.github.vigoo.zioaws.rdsdata.model.BatchExecuteStatementRequest
): ZIO[RdsData, AwsError, ReadOnly] =
ZIO.accessM(_.get.batchExecuteStatement(request))
def executeStatement(
request: io.github.vigoo.zioaws.rdsdata.model.ExecuteStatementRequest
): ZIO[
RdsData,
AwsError,
io.github.vigoo.zioaws.rdsdata.model.ExecuteStatementResponse.ReadOnly
] = ZIO.accessM(_.get.executeStatement(request))
def beginTransaction(
request: io.github.vigoo.zioaws.rdsdata.model.BeginTransactionRequest
): ZIO[
RdsData,
AwsError,
io.github.vigoo.zioaws.rdsdata.model.BeginTransactionResponse.ReadOnly
] = ZIO.accessM(_.get.beginTransaction(request))
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy