d4s.models.table.index.ProvisionedGlobalIndex.scala Maven / Gradle / Ivy
The newest version!
package d4s.models.table.index
import d4s.config.{ProvisionedThroughputConfig, TableProvisionedThroughputConfig}
import d4s.models.table.DynamoKey
import software.amazon.awssdk.services.dynamodb.model.{CreateGlobalSecondaryIndexAction, Projection}
final case class ProvisionedGlobalIndex[-H, -R](
name: String,
key: DynamoKey[H, R],
projection: Projection,
provisionedThroughputConfig: ProvisionedThroughputConfig
) extends TableIndex[H, R] {
def asCreateAction: CreateGlobalSecondaryIndexAction = {
provisionedThroughputConfig.configureThroughput {
CreateGlobalSecondaryIndexAction
.builder()
.indexName(name)
.keySchema(key.toJava)
.projection(projection)
}.build()
}
}
object ProvisionedGlobalIndex {
implicit final class FromGlobalIndex[H, R](index: GlobalIndex[H, R]) {
def toProvisionedIndex(cfg: TableProvisionedThroughputConfig): ProvisionedGlobalIndex[H, R] = {
ProvisionedGlobalIndex(index.name, index.key, index.projection, cfg.getIndexProvisioning(index.name))
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy