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

org.http4k.connect.amazon.s3.action.CreateBucket.kt Maven / Gradle / Ivy

There is a newer version: 5.41.0.0
Show newest version
package org.http4k.connect.amazon.s3.action

import dev.forkhandles.result4k.Failure
import dev.forkhandles.result4k.Success
import org.http4k.connect.Http4kConnectAction
import org.http4k.connect.amazon.core.model.Region
import org.http4k.connect.amazon.s3.S3Action
import org.http4k.connect.amazon.s3.model.BucketName
import org.http4k.connect.asRemoteFailure
import org.http4k.core.Method.PUT
import org.http4k.core.Request
import org.http4k.core.Response
import org.http4k.core.Uri

@Http4kConnectAction
data class CreateBucket(val bucketName: BucketName, val region: Region) : S3Action {
    private fun uri() = Uri.of("/${bucketName}")

    override fun toRequest() = Request(PUT, uri()).body(
        """

    ${region}
"""
    )

    override fun toResult(response: Response) = with(response) {
        when {
            status.successful -> Success(Unit)
            else -> Failure(asRemoteFailure(this))
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy