diff --git a/app/App.scala b/app/App.scala index 3aedfcd..05116fc 100644 --- a/app/App.scala +++ b/app/App.scala @@ -1,3 +1,14 @@ +//> using scala 3.3.3 +//> using dep com.disneystreaming.smithy4s::smithy4s-aws-http4s::0.18.0-12-da4b23a +//> using dep com.disneystreaming.smithy4s::smithy4s-http4s::0.18.0-12-da4b23a +//> using dep org.http4s::http4s-ember-server::0.23.26 +//> using dep org.http4s::http4s-ember-client::0.23.26 +//> using dep org.http4s::http4s-scalatags::0.25.2 +//> using dep com.outr::scribe-cats::3.13.2 +//> using dep com.outr::scribe-json-circe::3.13.2 +//> using dep com.outr::scribe-slf4j::3.13.2 +//> using dep com.lihaoyi::scalatags::0.12.0 + import cats.effect.* import cats.syntax.all.* import com.amazonaws.comprehend.* diff --git a/app/Dockerfile b/app/Dockerfile index 720657d..c07d01a 100644 --- a/app/Dockerfile +++ b/app/Dockerfile @@ -1,37 +1,32 @@ FROM eclipse-temurin:21 as builder # Wget is needed to bootstrap SBT -RUN apt update && apt install wget +RUN apt update && apt install -y wget make WORKDIR /app # bootstrap SBT -RUN wget https://raw.githubusercontent.com/sbt/sbt/1.10.x/sbt && chmod +x ./sbt -# we only copy the single file that affects which version of SBT gets bootstrapped -# This allows us to cache these steps if you don't change SBT version -COPY project/build.properties project/build.properties -# Start SBT with a dummy command so that it can pre-fetch all the dependencies required -RUN ./sbt --sbt-create version +RUN wget https://raw.githubusercontent.com/VirtusLab/scala-cli/main/scala-cli.sh && mv scala-cli.sh /usr/bin/scala-cli && chmod +x /usr/bin/scala-cli +# Start Scala CLI with a dummy command so that it can pre-fetch all the dependencies required +RUN scala-cli version # build app # We copy all the application sources, so the building step will # run if there are any modifications -COPY build.sbt build.sbt -COPY project/plugins.sbt project/plugins.sbt COPY App.scala App.scala -COPY smithy smithy -RUN ./sbt stage +COPY aws-generated aws-generated +COPY Makefile Makefile +RUN make assembly # this is the start of the runtime container - one we will actually ship to AWS FROM ghcr.io/graalvm/jdk-community:22 RUN mkdir -p /opt # copy just the built app folder into this container - it doesn't need SBT to run, # only JVM -COPY --from=builder /app/target/universal/stage /opt/app +COPY --from=builder /app/assembly /opt/app/assembly ENV SMITHY4S_PORT=80 - EXPOSE 80 # run the app -CMD ["/opt/app/bin/app"] +CMD ["/opt/app/assembly"] diff --git a/app/Makefile b/app/Makefile new file mode 100644 index 0000000..d0b612b --- /dev/null +++ b/app/Makefile @@ -0,0 +1,7 @@ +.PHONY: generate assembly + +generate: + smithy4s generate --dependencies com.disneystreaming.smithy\:aws-comprehend-spec\:2023.09.22 only.smithy --output aws-generated/ + +assembly: + scala-cli --power package --assembly App.scala aws-generated -f -o ./assembly diff --git a/app/aws-generated/com/amazonaws/comprehend/Comprehend.scala b/app/aws-generated/com/amazonaws/comprehend/Comprehend.scala new file mode 100644 index 0000000..342526d --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/Comprehend.scala @@ -0,0 +1,202 @@ +package com.amazonaws.comprehend + +import smithy4s.Endpoint +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.Service +import smithy4s.ShapeId +import smithy4s.Transformation +import smithy4s.kinds.PolyFunction5 +import smithy4s.kinds.toPolyFunction5.const5 +import smithy4s.schema.ErrorSchema +import smithy4s.schema.OperationSchema +import smithy4s.schema.Schema.bijection +import smithy4s.schema.Schema.union + +/**

Amazon Comprehend is an Amazon Web Services service for gaining insight into the content of documents. + * Use these actions to determine the topics contained in your documents, the topics they + * discuss, the predominant sentiment expressed in them, the predominant language used, and + * more.

+ */ +trait ComprehendGen[F[_, _, _, _, _]] { + self => + + /**

Inspects text and returns an inference of the prevailing sentiment + * (POSITIVE, NEUTRAL, MIXED, or NEGATIVE).

+ * @param Text + *

A UTF-8 text string. The maximum string size is 5 KB.

+ * @param LanguageCode + *

The language of the input documents. You can specify any of the primary languages + * supported by Amazon Comprehend. All documents must be in the same language.

+ */ + def detectSentiment(text: CustomerInputString, languageCode: LanguageCode): F[DetectSentimentRequest, ComprehendOperation.DetectSentimentError, DetectSentimentResponse, Nothing, Nothing] + + def transform: Transformation.PartiallyApplied[ComprehendGen[F]] = Transformation.of[ComprehendGen[F]](this) +} + +object ComprehendGen extends Service.Mixin[ComprehendGen, ComprehendOperation] { + + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "Comprehend_20171127") + val version: String = "2017-11-27" + + val hints: Hints = Hints( + aws.auth.Sigv4(name = "comprehend"), + smithy.api.Title("Amazon Comprehend"), + aws.protocols.AwsJson1_1(http = None, eventStreamHttp = None), + smithy.api.Documentation("

Amazon Comprehend is an Amazon Web Services service for gaining insight into the content of documents.\n Use these actions to determine the topics contained in your documents, the topics they\n discuss, the predominant sentiment expressed in them, the predominant language used, and\n more.

"), + aws.api.Service(sdkId = "Comprehend", arnNamespace = Some(aws.api.ArnNamespace("comprehend")), cloudFormationName = Some(aws.api.CloudFormationName("Comprehend")), cloudTrailEventSource = Some("comprehend.amazonaws.com"), endpointPrefix = Some("comprehend")), + ).lazily + + def apply[F[_]](implicit F: Impl[F]): F.type = F + + object ErrorAware { + def apply[F[_, _]](implicit F: ErrorAware[F]): F.type = F + type Default[F[+_, +_]] = Constant[smithy4s.kinds.stubs.Kind2[F]#toKind5] + } + + val endpoints: Vector[smithy4s.Endpoint[ComprehendOperation, _, _, _, _, _]] = Vector( + ComprehendOperation.DetectSentiment, + ) + + def input[I, E, O, SI, SO](op: ComprehendOperation[I, E, O, SI, SO]): I = op.input + def ordinal[I, E, O, SI, SO](op: ComprehendOperation[I, E, O, SI, SO]): Int = op.ordinal + override def endpoint[I, E, O, SI, SO](op: ComprehendOperation[I, E, O, SI, SO]) = op.endpoint + class Constant[P[-_, +_, +_, +_, +_]](value: P[Any, Nothing, Nothing, Nothing, Nothing]) extends ComprehendOperation.Transformed[ComprehendOperation, P](reified, const5(value)) + type Default[F[+_]] = Constant[smithy4s.kinds.stubs.Kind1[F]#toKind5] + def reified: ComprehendGen[ComprehendOperation] = ComprehendOperation.reified + def mapK5[P[_, _, _, _, _], P1[_, _, _, _, _]](alg: ComprehendGen[P], f: PolyFunction5[P, P1]): ComprehendGen[P1] = new ComprehendOperation.Transformed(alg, f) + def fromPolyFunction[P[_, _, _, _, _]](f: PolyFunction5[ComprehendOperation, P]): ComprehendGen[P] = new ComprehendOperation.Transformed(reified, f) + def toPolyFunction[P[_, _, _, _, _]](impl: ComprehendGen[P]): PolyFunction5[ComprehendOperation, P] = ComprehendOperation.toPolyFunction(impl) + + type DetectSentimentError = ComprehendOperation.DetectSentimentError + val DetectSentimentError = ComprehendOperation.DetectSentimentError +} + +sealed trait ComprehendOperation[Input, Err, Output, StreamedInput, StreamedOutput] { + def run[F[_, _, _, _, _]](impl: ComprehendGen[F]): F[Input, Err, Output, StreamedInput, StreamedOutput] + def ordinal: Int + def input: Input + def endpoint: Endpoint[ComprehendOperation, Input, Err, Output, StreamedInput, StreamedOutput] +} + +object ComprehendOperation { + + object reified extends ComprehendGen[ComprehendOperation] { + def detectSentiment(text: CustomerInputString, languageCode: LanguageCode): DetectSentiment = DetectSentiment(DetectSentimentRequest(text, languageCode)) + } + class Transformed[P[_, _, _, _, _], P1[_ ,_ ,_ ,_ ,_]](alg: ComprehendGen[P], f: PolyFunction5[P, P1]) extends ComprehendGen[P1] { + def detectSentiment(text: CustomerInputString, languageCode: LanguageCode): P1[DetectSentimentRequest, ComprehendOperation.DetectSentimentError, DetectSentimentResponse, Nothing, Nothing] = f[DetectSentimentRequest, ComprehendOperation.DetectSentimentError, DetectSentimentResponse, Nothing, Nothing](alg.detectSentiment(text, languageCode)) + } + + def toPolyFunction[P[_, _, _, _, _]](impl: ComprehendGen[P]): PolyFunction5[ComprehendOperation, P] = new PolyFunction5[ComprehendOperation, P] { + def apply[I, E, O, SI, SO](op: ComprehendOperation[I, E, O, SI, SO]): P[I, E, O, SI, SO] = op.run(impl) + } + final case class DetectSentiment(input: DetectSentimentRequest) extends ComprehendOperation[DetectSentimentRequest, ComprehendOperation.DetectSentimentError, DetectSentimentResponse, Nothing, Nothing] { + def run[F[_, _, _, _, _]](impl: ComprehendGen[F]): F[DetectSentimentRequest, ComprehendOperation.DetectSentimentError, DetectSentimentResponse, Nothing, Nothing] = impl.detectSentiment(input.text, input.languageCode) + def ordinal: Int = 0 + def endpoint: smithy4s.Endpoint[ComprehendOperation,DetectSentimentRequest, ComprehendOperation.DetectSentimentError, DetectSentimentResponse, Nothing, Nothing] = DetectSentiment + } + object DetectSentiment extends smithy4s.Endpoint[ComprehendOperation,DetectSentimentRequest, ComprehendOperation.DetectSentimentError, DetectSentimentResponse, Nothing, Nothing] { + val schema: OperationSchema[DetectSentimentRequest, ComprehendOperation.DetectSentimentError, DetectSentimentResponse, Nothing, Nothing] = Schema.operation(ShapeId("com.amazonaws.comprehend", "DetectSentiment")) + .withInput(DetectSentimentRequest.schema) + .withError(DetectSentimentError.errorSchema) + .withOutput(DetectSentimentResponse.schema) + .withHints(smithy.api.Documentation("

Inspects text and returns an inference of the prevailing sentiment\n (POSITIVE, NEUTRAL, MIXED, or NEGATIVE).

")) + def wrap(input: DetectSentimentRequest): DetectSentiment = DetectSentiment(input) + } + sealed trait DetectSentimentError extends scala.Product with scala.Serializable { self => + @inline final def widen: DetectSentimentError = this + def $ordinal: Int + + object project { + def internalServerException: Option[InternalServerException] = DetectSentimentError.InternalServerExceptionCase.alt.project.lift(self).map(_.internalServerException) + def unsupportedLanguageException: Option[UnsupportedLanguageException] = DetectSentimentError.UnsupportedLanguageExceptionCase.alt.project.lift(self).map(_.unsupportedLanguageException) + def textSizeLimitExceededException: Option[TextSizeLimitExceededException] = DetectSentimentError.TextSizeLimitExceededExceptionCase.alt.project.lift(self).map(_.textSizeLimitExceededException) + def invalidRequestException: Option[InvalidRequestException] = DetectSentimentError.InvalidRequestExceptionCase.alt.project.lift(self).map(_.invalidRequestException) + } + + def accept[A](visitor: DetectSentimentError.Visitor[A]): A = this match { + case value: DetectSentimentError.InternalServerExceptionCase => visitor.internalServerException(value.internalServerException) + case value: DetectSentimentError.UnsupportedLanguageExceptionCase => visitor.unsupportedLanguageException(value.unsupportedLanguageException) + case value: DetectSentimentError.TextSizeLimitExceededExceptionCase => visitor.textSizeLimitExceededException(value.textSizeLimitExceededException) + case value: DetectSentimentError.InvalidRequestExceptionCase => visitor.invalidRequestException(value.invalidRequestException) + } + } + object DetectSentimentError extends ErrorSchema.Companion[DetectSentimentError] { + + def internalServerException(internalServerException: InternalServerException): DetectSentimentError = InternalServerExceptionCase(internalServerException) + def unsupportedLanguageException(unsupportedLanguageException: UnsupportedLanguageException): DetectSentimentError = UnsupportedLanguageExceptionCase(unsupportedLanguageException) + def textSizeLimitExceededException(textSizeLimitExceededException: TextSizeLimitExceededException): DetectSentimentError = TextSizeLimitExceededExceptionCase(textSizeLimitExceededException) + def invalidRequestException(invalidRequestException: InvalidRequestException): DetectSentimentError = InvalidRequestExceptionCase(invalidRequestException) + + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "DetectSentimentError") + + val hints: Hints = Hints.empty + + final case class InternalServerExceptionCase(internalServerException: InternalServerException) extends DetectSentimentError { final def $ordinal: Int = 0 } + final case class UnsupportedLanguageExceptionCase(unsupportedLanguageException: UnsupportedLanguageException) extends DetectSentimentError { final def $ordinal: Int = 1 } + final case class TextSizeLimitExceededExceptionCase(textSizeLimitExceededException: TextSizeLimitExceededException) extends DetectSentimentError { final def $ordinal: Int = 2 } + final case class InvalidRequestExceptionCase(invalidRequestException: InvalidRequestException) extends DetectSentimentError { final def $ordinal: Int = 3 } + + object InternalServerExceptionCase { + val hints: Hints = Hints.empty + val schema: Schema[DetectSentimentError.InternalServerExceptionCase] = bijection(InternalServerException.schema.addHints(hints), DetectSentimentError.InternalServerExceptionCase(_), _.internalServerException) + val alt = schema.oneOf[DetectSentimentError]("InternalServerException") + } + object UnsupportedLanguageExceptionCase { + val hints: Hints = Hints.empty + val schema: Schema[DetectSentimentError.UnsupportedLanguageExceptionCase] = bijection(UnsupportedLanguageException.schema.addHints(hints), DetectSentimentError.UnsupportedLanguageExceptionCase(_), _.unsupportedLanguageException) + val alt = schema.oneOf[DetectSentimentError]("UnsupportedLanguageException") + } + object TextSizeLimitExceededExceptionCase { + val hints: Hints = Hints.empty + val schema: Schema[DetectSentimentError.TextSizeLimitExceededExceptionCase] = bijection(TextSizeLimitExceededException.schema.addHints(hints), DetectSentimentError.TextSizeLimitExceededExceptionCase(_), _.textSizeLimitExceededException) + val alt = schema.oneOf[DetectSentimentError]("TextSizeLimitExceededException") + } + object InvalidRequestExceptionCase { + val hints: Hints = Hints.empty + val schema: Schema[DetectSentimentError.InvalidRequestExceptionCase] = bijection(InvalidRequestException.schema.addHints(hints), DetectSentimentError.InvalidRequestExceptionCase(_), _.invalidRequestException) + val alt = schema.oneOf[DetectSentimentError]("InvalidRequestException") + } + + trait Visitor[A] { + def internalServerException(value: InternalServerException): A + def unsupportedLanguageException(value: UnsupportedLanguageException): A + def textSizeLimitExceededException(value: TextSizeLimitExceededException): A + def invalidRequestException(value: InvalidRequestException): A + } + + object Visitor { + trait Default[A] extends Visitor[A] { + def default: A + def internalServerException(value: InternalServerException): A = default + def unsupportedLanguageException(value: UnsupportedLanguageException): A = default + def textSizeLimitExceededException(value: TextSizeLimitExceededException): A = default + def invalidRequestException(value: InvalidRequestException): A = default + } + } + + implicit val schema: Schema[DetectSentimentError] = union( + DetectSentimentError.InternalServerExceptionCase.alt, + DetectSentimentError.UnsupportedLanguageExceptionCase.alt, + DetectSentimentError.TextSizeLimitExceededExceptionCase.alt, + DetectSentimentError.InvalidRequestExceptionCase.alt, + ){ + _.$ordinal + } + def liftError(throwable: Throwable): Option[DetectSentimentError] = throwable match { + case e: InternalServerException => Some(DetectSentimentError.InternalServerExceptionCase(e)) + case e: UnsupportedLanguageException => Some(DetectSentimentError.UnsupportedLanguageExceptionCase(e)) + case e: TextSizeLimitExceededException => Some(DetectSentimentError.TextSizeLimitExceededExceptionCase(e)) + case e: InvalidRequestException => Some(DetectSentimentError.InvalidRequestExceptionCase(e)) + case _ => None + } + def unliftError(e: DetectSentimentError): Throwable = e match { + case DetectSentimentError.InternalServerExceptionCase(e) => e + case DetectSentimentError.UnsupportedLanguageExceptionCase(e) => e + case DetectSentimentError.TextSizeLimitExceededExceptionCase(e) => e + case DetectSentimentError.InvalidRequestExceptionCase(e) => e + } + } +} + diff --git a/app/aws-generated/com/amazonaws/comprehend/CustomerInputString.scala b/app/aws-generated/com/amazonaws/comprehend/CustomerInputString.scala new file mode 100644 index 0000000..02a29a7 --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/CustomerInputString.scala @@ -0,0 +1,17 @@ +package com.amazonaws.comprehend + +import smithy4s.Hints +import smithy4s.Newtype +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.schema.Schema.bijection +import smithy4s.schema.Schema.string + +object CustomerInputString extends Newtype[String] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "CustomerInputString") + val hints: Hints = Hints( + smithy.api.Sensitive(), + ).lazily + val underlyingSchema: Schema[String] = string.withId(id).addHints(hints).validated(smithy.api.Length(min = Some(1L), max = None)) + implicit val schema: Schema[CustomerInputString] = bijection(underlyingSchema, asBijection) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/DetectSentimentRequest.scala b/app/aws-generated/com/amazonaws/comprehend/DetectSentimentRequest.scala new file mode 100644 index 0000000..76b220a --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/DetectSentimentRequest.scala @@ -0,0 +1,31 @@ +package com.amazonaws.comprehend + +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.schema.Schema.struct + +/** @param Text + *

A UTF-8 text string. The maximum string size is 5 KB.

+ * @param LanguageCode + *

The language of the input documents. You can specify any of the primary languages + * supported by Amazon Comprehend. All documents must be in the same language.

+ */ +final case class DetectSentimentRequest(text: CustomerInputString, languageCode: LanguageCode) + +object DetectSentimentRequest extends ShapeTag.Companion[DetectSentimentRequest] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "DetectSentimentRequest") + + val hints: Hints = Hints( + smithy.api.Input(), + ).lazily + + // constructor using the original order from the spec + private def make(text: CustomerInputString, languageCode: LanguageCode): DetectSentimentRequest = DetectSentimentRequest(text, languageCode) + + implicit val schema: Schema[DetectSentimentRequest] = struct( + CustomerInputString.schema.required[DetectSentimentRequest]("Text", _.text).addHints(smithy.api.Documentation("

A UTF-8 text string. The maximum string size is 5 KB.

")), + LanguageCode.schema.required[DetectSentimentRequest]("LanguageCode", _.languageCode).addHints(smithy.api.Documentation("

The language of the input documents. You can specify any of the primary languages\n supported by Amazon Comprehend. All documents must be in the same language.

")), + )(make).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/DetectSentimentResponse.scala b/app/aws-generated/com/amazonaws/comprehend/DetectSentimentResponse.scala new file mode 100644 index 0000000..3da3b25 --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/DetectSentimentResponse.scala @@ -0,0 +1,33 @@ +package com.amazonaws.comprehend + +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.schema.Schema.struct + +/** @param Sentiment + *

The inferred sentiment that Amazon Comprehend has the highest level of confidence + * in.

+ * @param SentimentScore + *

An object that lists the sentiments, and their corresponding confidence + * levels.

+ */ +final case class DetectSentimentResponse(sentiment: Option[SentimentType] = None, sentimentScore: Option[SentimentScore] = None) + +object DetectSentimentResponse extends ShapeTag.Companion[DetectSentimentResponse] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "DetectSentimentResponse") + + val hints: Hints = Hints( + smithy.api.Output(), + smithy.api.Sensitive(), + ).lazily + + // constructor using the original order from the spec + private def make(sentiment: Option[SentimentType], sentimentScore: Option[SentimentScore]): DetectSentimentResponse = DetectSentimentResponse(sentiment, sentimentScore) + + implicit val schema: Schema[DetectSentimentResponse] = struct( + SentimentType.schema.optional[DetectSentimentResponse]("Sentiment", _.sentiment).addHints(smithy.api.Documentation("

The inferred sentiment that Amazon Comprehend has the highest level of confidence\n in.

")), + SentimentScore.schema.optional[DetectSentimentResponse]("SentimentScore", _.sentimentScore).addHints(smithy.api.Documentation("

An object that lists the sentiments, and their corresponding confidence\n levels.

")), + )(make).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/InternalServerException.scala b/app/aws-generated/com/amazonaws/comprehend/InternalServerException.scala new file mode 100644 index 0000000..037cd1a --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/InternalServerException.scala @@ -0,0 +1,31 @@ +package com.amazonaws.comprehend + +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.Smithy4sThrowable +import smithy4s.schema.Schema.string +import smithy4s.schema.Schema.struct + +/**

An internal server error occurred. Retry your request.

*/ +final case class InternalServerException(message: Option[String] = None) extends Smithy4sThrowable { + override def getMessage(): String = message.orNull +} + +object InternalServerException extends ShapeTag.Companion[InternalServerException] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "InternalServerException") + + val hints: Hints = Hints( + smithy.api.Error.SERVER.widen, + smithy.api.Documentation("

An internal server error occurred. Retry your request.

"), + smithy.api.HttpError(500), + ).lazily + + // constructor using the original order from the spec + private def make(message: Option[String]): InternalServerException = InternalServerException(message) + + implicit val schema: Schema[InternalServerException] = struct( + string.optional[InternalServerException]("Message", _.message), + )(make).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/InvalidRequestDetail.scala b/app/aws-generated/com/amazonaws/comprehend/InvalidRequestDetail.scala new file mode 100644 index 0000000..a95b3a0 --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/InvalidRequestDetail.scala @@ -0,0 +1,42 @@ +package com.amazonaws.comprehend + +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.schema.Schema.struct + +/**

Provides additional detail about why the request failed:

+ * + * @param Reason + *

Reason code is INVALID_DOCUMENT.

+ */ +final case class InvalidRequestDetail(reason: Option[InvalidRequestDetailReason] = None) + +object InvalidRequestDetail extends ShapeTag.Companion[InvalidRequestDetail] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "InvalidRequestDetail") + + val hints: Hints = Hints( + smithy.api.Documentation("

Provides additional detail about why the request failed:

\n "), + ).lazily + + // constructor using the original order from the spec + private def make(reason: Option[InvalidRequestDetailReason]): InvalidRequestDetail = InvalidRequestDetail(reason) + + implicit val schema: Schema[InvalidRequestDetail] = struct( + InvalidRequestDetailReason.schema.optional[InvalidRequestDetail]("Reason", _.reason).addHints(smithy.api.Documentation("

Reason code is INVALID_DOCUMENT.

")), + )(make).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/InvalidRequestDetailReason.scala b/app/aws-generated/com/amazonaws/comprehend/InvalidRequestDetailReason.scala new file mode 100644 index 0000000..bf00207 --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/InvalidRequestDetailReason.scala @@ -0,0 +1,43 @@ +package com.amazonaws.comprehend + +import smithy4s.Enumeration +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.schema.EnumTag +import smithy4s.schema.Schema.enumeration + +sealed abstract class InvalidRequestDetailReason(_value: String, _name: String, _intValue: Int, _hints: Hints) extends Enumeration.Value { + override type EnumType = InvalidRequestDetailReason + override val value: String = _value + override val name: String = _name + override val intValue: Int = _intValue + override val hints: Hints = _hints + override def enumeration: Enumeration[EnumType] = InvalidRequestDetailReason + @inline final def widen: InvalidRequestDetailReason = this +} +object InvalidRequestDetailReason extends Enumeration[InvalidRequestDetailReason] with ShapeTag.Companion[InvalidRequestDetailReason] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "InvalidRequestDetailReason") + + val hints: Hints = Hints( + alloy.OpenEnum(), + ).lazily + + case object DOCUMENT_SIZE_EXCEEDED extends InvalidRequestDetailReason("DOCUMENT_SIZE_EXCEEDED", "DOCUMENT_SIZE_EXCEEDED", 0, Hints.empty) + case object UNSUPPORTED_DOC_TYPE extends InvalidRequestDetailReason("UNSUPPORTED_DOC_TYPE", "UNSUPPORTED_DOC_TYPE", 1, Hints.empty) + case object PAGE_LIMIT_EXCEEDED extends InvalidRequestDetailReason("PAGE_LIMIT_EXCEEDED", "PAGE_LIMIT_EXCEEDED", 2, Hints.empty) + case object TEXTRACT_ACCESS_DENIED extends InvalidRequestDetailReason("TEXTRACT_ACCESS_DENIED", "TEXTRACT_ACCESS_DENIED", 3, Hints.empty) + final case class $Unknown(str: String) extends InvalidRequestDetailReason(str, "$Unknown", -1, Hints.empty) + + val $unknown: String => InvalidRequestDetailReason = $Unknown(_) + + val values: List[InvalidRequestDetailReason] = List( + DOCUMENT_SIZE_EXCEEDED, + UNSUPPORTED_DOC_TYPE, + PAGE_LIMIT_EXCEEDED, + TEXTRACT_ACCESS_DENIED, + ) + val tag: EnumTag[InvalidRequestDetailReason] = EnumTag.OpenStringEnum($unknown) + implicit val schema: Schema[InvalidRequestDetailReason] = enumeration(tag, values).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/InvalidRequestException.scala b/app/aws-generated/com/amazonaws/comprehend/InvalidRequestException.scala new file mode 100644 index 0000000..f8024bb --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/InvalidRequestException.scala @@ -0,0 +1,50 @@ +package com.amazonaws.comprehend + +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.Smithy4sThrowable +import smithy4s.schema.Schema.string +import smithy4s.schema.Schema.struct + +/**

The request is invalid.

+ * @param Detail + *

Provides additional detail about why the request failed:

+ * + */ +final case class InvalidRequestException(message: Option[String] = None, reason: Option[InvalidRequestReason] = None, detail: Option[InvalidRequestDetail] = None) extends Smithy4sThrowable { + override def getMessage(): String = message.orNull +} + +object InvalidRequestException extends ShapeTag.Companion[InvalidRequestException] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "InvalidRequestException") + + val hints: Hints = Hints( + smithy.api.Error.CLIENT.widen, + smithy.api.Documentation("

The request is invalid.

"), + smithy.api.HttpError(400), + ).lazily + + // constructor using the original order from the spec + private def make(message: Option[String], reason: Option[InvalidRequestReason], detail: Option[InvalidRequestDetail]): InvalidRequestException = InvalidRequestException(message, reason, detail) + + implicit val schema: Schema[InvalidRequestException] = struct( + string.optional[InvalidRequestException]("Message", _.message), + InvalidRequestReason.schema.optional[InvalidRequestException]("Reason", _.reason), + InvalidRequestDetail.schema.optional[InvalidRequestException]("Detail", _.detail), + )(make).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/InvalidRequestReason.scala b/app/aws-generated/com/amazonaws/comprehend/InvalidRequestReason.scala new file mode 100644 index 0000000..87df80c --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/InvalidRequestReason.scala @@ -0,0 +1,37 @@ +package com.amazonaws.comprehend + +import smithy4s.Enumeration +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.schema.EnumTag +import smithy4s.schema.Schema.enumeration + +sealed abstract class InvalidRequestReason(_value: String, _name: String, _intValue: Int, _hints: Hints) extends Enumeration.Value { + override type EnumType = InvalidRequestReason + override val value: String = _value + override val name: String = _name + override val intValue: Int = _intValue + override val hints: Hints = _hints + override def enumeration: Enumeration[EnumType] = InvalidRequestReason + @inline final def widen: InvalidRequestReason = this +} +object InvalidRequestReason extends Enumeration[InvalidRequestReason] with ShapeTag.Companion[InvalidRequestReason] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "InvalidRequestReason") + + val hints: Hints = Hints( + alloy.OpenEnum(), + ).lazily + + case object INVALID_DOCUMENT extends InvalidRequestReason("INVALID_DOCUMENT", "INVALID_DOCUMENT", 0, Hints.empty) + final case class $Unknown(str: String) extends InvalidRequestReason(str, "$Unknown", -1, Hints.empty) + + val $unknown: String => InvalidRequestReason = $Unknown(_) + + val values: List[InvalidRequestReason] = List( + INVALID_DOCUMENT, + ) + val tag: EnumTag[InvalidRequestReason] = EnumTag.OpenStringEnum($unknown) + implicit val schema: Schema[InvalidRequestReason] = enumeration(tag, values).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/LanguageCode.scala b/app/aws-generated/com/amazonaws/comprehend/LanguageCode.scala new file mode 100644 index 0000000..6998f72 --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/LanguageCode.scala @@ -0,0 +1,59 @@ +package com.amazonaws.comprehend + +import smithy4s.Enumeration +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.schema.EnumTag +import smithy4s.schema.Schema.enumeration + +sealed abstract class LanguageCode(_value: String, _name: String, _intValue: Int, _hints: Hints) extends Enumeration.Value { + override type EnumType = LanguageCode + override val value: String = _value + override val name: String = _name + override val intValue: Int = _intValue + override val hints: Hints = _hints + override def enumeration: Enumeration[EnumType] = LanguageCode + @inline final def widen: LanguageCode = this +} +object LanguageCode extends Enumeration[LanguageCode] with ShapeTag.Companion[LanguageCode] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "LanguageCode") + + val hints: Hints = Hints( + alloy.OpenEnum(), + ).lazily + + case object EN extends LanguageCode("en", "EN", 0, Hints.empty) + case object ES extends LanguageCode("es", "ES", 1, Hints.empty) + case object FR extends LanguageCode("fr", "FR", 2, Hints.empty) + case object DE extends LanguageCode("de", "DE", 3, Hints.empty) + case object IT extends LanguageCode("it", "IT", 4, Hints.empty) + case object PT extends LanguageCode("pt", "PT", 5, Hints.empty) + case object AR extends LanguageCode("ar", "AR", 6, Hints.empty) + case object HI extends LanguageCode("hi", "HI", 7, Hints.empty) + case object JA extends LanguageCode("ja", "JA", 8, Hints.empty) + case object KO extends LanguageCode("ko", "KO", 9, Hints.empty) + case object ZH extends LanguageCode("zh", "ZH", 10, Hints.empty) + case object ZH_TW extends LanguageCode("zh-TW", "ZH_TW", 11, Hints.empty) + final case class $Unknown(str: String) extends LanguageCode(str, "$Unknown", -1, Hints.empty) + + val $unknown: String => LanguageCode = $Unknown(_) + + val values: List[LanguageCode] = List( + EN, + ES, + FR, + DE, + IT, + PT, + AR, + HI, + JA, + KO, + ZH, + ZH_TW, + ) + val tag: EnumTag[LanguageCode] = EnumTag.OpenStringEnum($unknown) + implicit val schema: Schema[LanguageCode] = enumeration(tag, values).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/SentimentScore.scala b/app/aws-generated/com/amazonaws/comprehend/SentimentScore.scala new file mode 100644 index 0000000..642156b --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/SentimentScore.scala @@ -0,0 +1,43 @@ +package com.amazonaws.comprehend + +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.schema.Schema.float +import smithy4s.schema.Schema.struct + +/**

Describes the level of confidence that Amazon Comprehend has in the accuracy of its + * detection of sentiments.

+ * @param Positive + *

The level of confidence that Amazon Comprehend has in the accuracy of its detection of + * the POSITIVE sentiment.

+ * @param Negative + *

The level of confidence that Amazon Comprehend has in the accuracy of its detection of + * the NEGATIVE sentiment.

+ * @param Neutral + *

The level of confidence that Amazon Comprehend has in the accuracy of its detection of + * the NEUTRAL sentiment.

+ * @param Mixed + *

The level of confidence that Amazon Comprehend has in the accuracy of its detection of + * the MIXED sentiment.

+ */ +final case class SentimentScore(positive: Option[Float] = None, negative: Option[Float] = None, neutral: Option[Float] = None, mixed: Option[Float] = None) + +object SentimentScore extends ShapeTag.Companion[SentimentScore] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "SentimentScore") + + val hints: Hints = Hints( + smithy.api.Documentation("

Describes the level of confidence that Amazon Comprehend has in the accuracy of its\n detection of sentiments.

"), + ).lazily + + // constructor using the original order from the spec + private def make(positive: Option[Float], negative: Option[Float], neutral: Option[Float], mixed: Option[Float]): SentimentScore = SentimentScore(positive, negative, neutral, mixed) + + implicit val schema: Schema[SentimentScore] = struct( + float.optional[SentimentScore]("Positive", _.positive).addHints(smithy.api.Documentation("

The level of confidence that Amazon Comprehend has in the accuracy of its detection of\n the POSITIVE sentiment.

")), + float.optional[SentimentScore]("Negative", _.negative).addHints(smithy.api.Documentation("

The level of confidence that Amazon Comprehend has in the accuracy of its detection of\n the NEGATIVE sentiment.

")), + float.optional[SentimentScore]("Neutral", _.neutral).addHints(smithy.api.Documentation("

The level of confidence that Amazon Comprehend has in the accuracy of its detection of\n the NEUTRAL sentiment.

")), + float.optional[SentimentScore]("Mixed", _.mixed).addHints(smithy.api.Documentation("

The level of confidence that Amazon Comprehend has in the accuracy of its detection of\n the MIXED sentiment.

")), + )(make).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/SentimentType.scala b/app/aws-generated/com/amazonaws/comprehend/SentimentType.scala new file mode 100644 index 0000000..144021e --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/SentimentType.scala @@ -0,0 +1,43 @@ +package com.amazonaws.comprehend + +import smithy4s.Enumeration +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.schema.EnumTag +import smithy4s.schema.Schema.enumeration + +sealed abstract class SentimentType(_value: String, _name: String, _intValue: Int, _hints: Hints) extends Enumeration.Value { + override type EnumType = SentimentType + override val value: String = _value + override val name: String = _name + override val intValue: Int = _intValue + override val hints: Hints = _hints + override def enumeration: Enumeration[EnumType] = SentimentType + @inline final def widen: SentimentType = this +} +object SentimentType extends Enumeration[SentimentType] with ShapeTag.Companion[SentimentType] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "SentimentType") + + val hints: Hints = Hints( + alloy.OpenEnum(), + ).lazily + + case object POSITIVE extends SentimentType("POSITIVE", "POSITIVE", 0, Hints.empty) + case object NEGATIVE extends SentimentType("NEGATIVE", "NEGATIVE", 1, Hints.empty) + case object NEUTRAL extends SentimentType("NEUTRAL", "NEUTRAL", 2, Hints.empty) + case object MIXED extends SentimentType("MIXED", "MIXED", 3, Hints.empty) + final case class $Unknown(str: String) extends SentimentType(str, "$Unknown", -1, Hints.empty) + + val $unknown: String => SentimentType = $Unknown(_) + + val values: List[SentimentType] = List( + POSITIVE, + NEGATIVE, + NEUTRAL, + MIXED, + ) + val tag: EnumTag[SentimentType] = EnumTag.OpenStringEnum($unknown) + implicit val schema: Schema[SentimentType] = enumeration(tag, values).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/TextSizeLimitExceededException.scala b/app/aws-generated/com/amazonaws/comprehend/TextSizeLimitExceededException.scala new file mode 100644 index 0000000..940a4f9 --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/TextSizeLimitExceededException.scala @@ -0,0 +1,31 @@ +package com.amazonaws.comprehend + +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.Smithy4sThrowable +import smithy4s.schema.Schema.string +import smithy4s.schema.Schema.struct + +/**

The size of the input text exceeds the limit. Use a smaller document.

*/ +final case class TextSizeLimitExceededException(message: Option[String] = None) extends Smithy4sThrowable { + override def getMessage(): String = message.orNull +} + +object TextSizeLimitExceededException extends ShapeTag.Companion[TextSizeLimitExceededException] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "TextSizeLimitExceededException") + + val hints: Hints = Hints( + smithy.api.Error.CLIENT.widen, + smithy.api.Documentation("

The size of the input text exceeds the limit. Use a smaller document.

"), + smithy.api.HttpError(400), + ).lazily + + // constructor using the original order from the spec + private def make(message: Option[String]): TextSizeLimitExceededException = TextSizeLimitExceededException(message) + + implicit val schema: Schema[TextSizeLimitExceededException] = struct( + string.optional[TextSizeLimitExceededException]("Message", _.message), + )(make).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/UnsupportedLanguageException.scala b/app/aws-generated/com/amazonaws/comprehend/UnsupportedLanguageException.scala new file mode 100644 index 0000000..a83dbda --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/UnsupportedLanguageException.scala @@ -0,0 +1,36 @@ +package com.amazonaws.comprehend + +import smithy4s.Hints +import smithy4s.Schema +import smithy4s.ShapeId +import smithy4s.ShapeTag +import smithy4s.Smithy4sThrowable +import smithy4s.schema.Schema.string +import smithy4s.schema.Schema.struct + +/**

Amazon Comprehend can't process the language of the input text. For custom entity + * recognition APIs, only English, Spanish, French, Italian, German, or Portuguese are accepted. + * For a list of supported languages, + * Supported languages in the Comprehend Developer Guide. + *

+ */ +final case class UnsupportedLanguageException(message: Option[String] = None) extends Smithy4sThrowable { + override def getMessage(): String = message.orNull +} + +object UnsupportedLanguageException extends ShapeTag.Companion[UnsupportedLanguageException] { + val id: ShapeId = ShapeId("com.amazonaws.comprehend", "UnsupportedLanguageException") + + val hints: Hints = Hints( + smithy.api.Error.CLIENT.widen, + smithy.api.Documentation("

Amazon Comprehend can\'t process the language of the input text. For custom entity\n recognition APIs, only English, Spanish, French, Italian, German, or Portuguese are accepted.\n For a list of supported languages,\n Supported languages in the Comprehend Developer Guide.\n

"), + smithy.api.HttpError(400), + ).lazily + + // constructor using the original order from the spec + private def make(message: Option[String]): UnsupportedLanguageException = UnsupportedLanguageException(message) + + implicit val schema: Schema[UnsupportedLanguageException] = struct( + string.optional[UnsupportedLanguageException]("Message", _.message), + )(make).withId(id).addHints(hints) +} diff --git a/app/aws-generated/com/amazonaws/comprehend/package.scala b/app/aws-generated/com/amazonaws/comprehend/package.scala new file mode 100644 index 0000000..f500170 --- /dev/null +++ b/app/aws-generated/com/amazonaws/comprehend/package.scala @@ -0,0 +1,9 @@ +package com.amazonaws + +package object comprehend { + type Comprehend[F[_]] = smithy4s.kinds.FunctorAlgebra[ComprehendGen, F] + val Comprehend = ComprehendGen + + type CustomerInputString = com.amazonaws.comprehend.CustomerInputString.Type + +} \ No newline at end of file diff --git a/app/build.sbt b/app/build.sbt deleted file mode 100644 index 597dcbb..0000000 --- a/app/build.sbt +++ /dev/null @@ -1,39 +0,0 @@ -val V = new { - val scala = "3.3.3" - - val http4s = "0.23.26" - - val http4sScalatags = "0.25.2" - - val scalatags = "0.12.0" - - val scribe = "3.13.2" -} - -scalaVersion := V.scala - -enablePlugins(Smithy4sCodegenPlugin) -enablePlugins(JavaAppPackaging) - -libraryDependencies ++= Seq( - "com.disneystreaming.smithy4s" %% "smithy4s-http4s" % smithy4sVersion.value, - "com.disneystreaming.smithy4s" %% "smithy4s-aws-http4s" % smithy4sVersion.value, - "org.http4s" %% "http4s-ember-server" % V.http4s, - "org.http4s" %% "http4s-ember-client" % V.http4s, - "org.http4s" %% "http4s-scalatags" % V.http4sScalatags, - "com.lihaoyi" %% "scalatags" % V.scalatags, - "com.outr" %% "scribe-slf4j" % V.scribe, - "com.outr" %% "scribe-cats" % V.scribe, - "com.outr" %% "scribe-json-circe" % V.scribe, -) - -Compile / smithy4sInputDirs += (ThisBuild / baseDirectory).value / "smithy" - -// The `AWS` object contains a list of references to artifacts that contain specifications to AWS services. -smithy4sAwsSpecs ++= Seq(AWS.comprehend) - -Compile / doc / sources := Nil - -run / fork := true - -run / envVars += "SMITHY4S_PORT" -> "8080" diff --git a/app/smithy/only.smithy b/app/only.smithy similarity index 100% rename from app/smithy/only.smithy rename to app/only.smithy diff --git a/app/project/build.properties b/app/project/build.properties deleted file mode 100644 index 04267b1..0000000 --- a/app/project/build.properties +++ /dev/null @@ -1 +0,0 @@ -sbt.version=1.9.9 diff --git a/app/project/plugins.sbt b/app/project/plugins.sbt deleted file mode 100644 index abde6ed..0000000 --- a/app/project/plugins.sbt +++ /dev/null @@ -1,5 +0,0 @@ -addSbtPlugin( - "com.disneystreaming.smithy4s" % "smithy4s-sbt-codegen" % "0.18.0-12-da4b23a" -) -addSbtPlugin("io.spray" % "sbt-revolver" % "0.10.0") -addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.9.16")