disneystreaming / smithy4s

https://disneystreaming.github.io/smithy4s/
Other
351 stars 71 forks source link

List bucket support #1560

Closed daddykotex closed 1 month ago

daddykotex commented 5 months ago

This is a subset of https://github.com/disneystreaming/smithy4s/pull/1496 for that should make https://github.com/disneystreaming/smithy4s/issues/1512 work.

I've tried it locally and with the right dependencies (s3 spec) and the right sbt configuration to toggle codegen for it, I can run the following:

package smithy4s.sandbox.aws

import cats.effect._
import org.http4s.ember.client._
import smithy4s.aws.AwsRegion
import smithy4s.aws.AwsClient
import com.amazonaws.{s3 => smithyS3}
import smithy4s.aws.AwsEnvironment

object S3ListFail extends IOApp.Simple {
  import smithyS3._

  val awsEnv =
    for {
      cl <- EmberClientBuilder.default[IO].build
      env <- AwsEnvironment.default(cl, AwsRegion.US_WEST_1)
    } yield env

  def run: IO[Unit] =
    awsEnv
      .flatMap(env => AwsClient(S3, env))
      .use { case s3 =>
        s3.listBuckets()
      }
      .flatMap(IO.println(_))
}
[info] running (fork) smithy4s.sandbox.aws.S3ListFail 
[info] ListBucketsOutput(Some(List(Bucket(Some(readonlyaccess-99238<redacted>),Some(2024-06-10T16:10:29Z)))),Some(Owner(Some(<redacted>),Some(58c87a76c5d2029b0c2c096f57a27e7935b8b3074<redacted>))))

~I quickly tried to list the objects of the first bucket I got as a result but it did not work~

EDIT: it works, I was just targeting the wrong region

PR Checklist (not all items are relevant to all PRs)

Baccata commented 1 month ago

I'm closing this one, and opening an alternative one that does sign the bodies. This PR was used as a source of inspiration though.