From a1ab7a5519fba699e4602a8c32924a058427facb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 6 Jan 2022 10:27:57 +0100 Subject: [PATCH 1/3] Move URIEncoderDecoder to internals --- modules/aws-kernel/src/smithy4s/aws/AwsSignature.scala | 2 +- .../src/smithy4s/{ => http/internals}/URIEncoderDecoder.scala | 4 +++- modules/core/src/smithy4s/package.scala | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) rename modules/core/src/smithy4s/{ => http/internals}/URIEncoderDecoder.scala (98%) diff --git a/modules/aws-kernel/src/smithy4s/aws/AwsSignature.scala b/modules/aws-kernel/src/smithy4s/aws/AwsSignature.scala index 024784670..246bcf916 100644 --- a/modules/aws-kernel/src/smithy4s/aws/AwsSignature.scala +++ b/modules/aws-kernel/src/smithy4s/aws/AwsSignature.scala @@ -16,7 +16,7 @@ package smithy4s.aws.kernel -import smithy4s.URIEncoderDecoder.{encodeOthers => uriEncode} +import smithy4s.http.internals.URIEncoderDecoder.{encodeOthers => uriEncode} import smithy4s.http.CaseInsensitive import smithy4s.http.HttpMethod diff --git a/modules/core/src/smithy4s/URIEncoderDecoder.scala b/modules/core/src/smithy4s/http/internals/URIEncoderDecoder.scala similarity index 98% rename from modules/core/src/smithy4s/URIEncoderDecoder.scala rename to modules/core/src/smithy4s/http/internals/URIEncoderDecoder.scala index 664aa95d2..180cbae19 100644 --- a/modules/core/src/smithy4s/URIEncoderDecoder.scala +++ b/modules/core/src/smithy4s/http/internals/URIEncoderDecoder.scala @@ -15,11 +15,13 @@ */ package smithy4s +package http +package internals import java.io.ByteArrayOutputStream import java.net._ -object URIEncoderDecoder { +private[smithy4s] object URIEncoderDecoder { val digits: String = "0123456789ABCDEF" diff --git a/modules/core/src/smithy4s/package.scala b/modules/core/src/smithy4s/package.scala index c611bb110..77c200b72 100644 --- a/modules/core/src/smithy4s/package.scala +++ b/modules/core/src/smithy4s/package.scala @@ -14,6 +14,8 @@ * limitations under the License. */ +import smithy4s.http.internals.URIEncoderDecoder + package object smithy4s extends TypeAliases { type Hint = Hints.Binding[_] From 13826eccf3aa33a79e3498f1d0dd4fbb5c4f1b09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 6 Jan 2022 10:32:12 +0100 Subject: [PATCH 2/3] Render ShapeId for operations --- modules/codegen/src/smithy4s/codegen/Renderer.scala | 3 +-- modules/core/src/smithy4s/Endpoint.scala | 3 ++- modules/example/src/smithy4s/example/FooService.scala | 3 +-- modules/example/src/smithy4s/example/ObjectService.scala | 6 ++---- modules/example/src/smithy4s/example/StreamedObjects.scala | 6 ++---- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/modules/codegen/src/smithy4s/codegen/Renderer.scala b/modules/codegen/src/smithy4s/codegen/Renderer.scala index e7d828c0e..9a393b0a5 100644 --- a/modules/codegen/src/smithy4s/codegen/Renderer.scala +++ b/modules/codegen/src/smithy4s/codegen/Renderer.scala @@ -280,12 +280,11 @@ private[codegen] class Renderer(compilationUnit: CompilationUnit) { self => ext = s"$Endpoint_[${traitName}, ${op.renderAlgParams}]$httpEndpoint$errorable" )( - s"""def name: String = "${opName}"""", + renderId(op.name, op.originalNamespace), s"val input: $Schema_[${op.input.render}] = ${op.input.schemaRef}.withHints(smithy4s.internals.InputOutput.Input)", s"val output: $Schema_[${op.output.render}] = ${op.output.schemaRef}.withHints(smithy4s.internals.InputOutput.Output)", renderStreamingSchemaVal("streamedInput", op.streamedInput), renderStreamingSchemaVal("streamedOutput", op.streamedOutput), - renderId(op.name, op.originalNamespace), renderHintsValWithId(op.hints), s"def wrap(input: ${op.input.render}) = ${opName}($input)", renderErrorable(op), diff --git a/modules/core/src/smithy4s/Endpoint.scala b/modules/core/src/smithy4s/Endpoint.scala index ea3a3ae0b..6aed87896 100644 --- a/modules/core/src/smithy4s/Endpoint.scala +++ b/modules/core/src/smithy4s/Endpoint.scala @@ -40,7 +40,8 @@ package smithy4s * be encoded a great many ways, using a greatt many libraries) */ trait Endpoint[Op[_, _, _, _, _], I, E, O, SI, SO] { outer => - def name: String + def id: ShapeId + final def name: String = id.name def input: Schema[I] def output: Schema[O] def streamedInput: StreamingSchema[SI] diff --git a/modules/example/src/smithy4s/example/FooService.scala b/modules/example/src/smithy4s/example/FooService.scala index 3724fc82a..1b8774bf5 100644 --- a/modules/example/src/smithy4s/example/FooService.scala +++ b/modules/example/src/smithy4s/example/FooService.scala @@ -49,12 +49,11 @@ object FooServiceGen extends smithy4s.Service[FooServiceGen, FooServiceOperation } case class GetFoo() extends FooServiceOperation[Unit, Nothing, GetFooOutput, Nothing, Nothing] object GetFoo extends smithy4s.Endpoint[FooServiceOperation, Unit, Nothing, GetFooOutput, Nothing, Nothing] with http.HttpEndpoint[Unit] { - def name: String = "GetFoo" + val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "GetFoo") val input: smithy4s.Schema[Unit] = unit.withHints(smithy4s.internals.InputOutput.Input) val output: smithy4s.Schema[GetFooOutput] = GetFooOutput.schema.withHints(smithy4s.internals.InputOutput.Output) val streamedInput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing val streamedOutput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing - val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "GetFoo") val hints : smithy4s.Hints = smithy4s.Hints( id, smithy.api.Http(smithy.api.NonEmptyString("GET"), smithy.api.NonEmptyString("/foo"), Some(200)), diff --git a/modules/example/src/smithy4s/example/ObjectService.scala b/modules/example/src/smithy4s/example/ObjectService.scala index f265df447..dc651beff 100644 --- a/modules/example/src/smithy4s/example/ObjectService.scala +++ b/modules/example/src/smithy4s/example/ObjectService.scala @@ -58,12 +58,11 @@ object ObjectServiceGen extends smithy4s.Service[ObjectServiceGen, ObjectService } case class PutObject(input: PutObjectInput) extends ObjectServiceOperation[PutObjectInput, PutObjectError, Unit, Nothing, Nothing] object PutObject extends smithy4s.Endpoint[ObjectServiceOperation, PutObjectInput, PutObjectError, Unit, Nothing, Nothing] with http.HttpEndpoint[PutObjectInput] with smithy4s.Errorable[PutObjectError] { - def name: String = "PutObject" + val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "PutObject") val input: smithy4s.Schema[PutObjectInput] = PutObjectInput.schema.withHints(smithy4s.internals.InputOutput.Input) val output: smithy4s.Schema[Unit] = unit.withHints(smithy4s.internals.InputOutput.Output) val streamedInput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing val streamedOutput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing - val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "PutObject") val hints : smithy4s.Hints = smithy4s.Hints( id, smithy.api.Idempotent(), @@ -119,12 +118,11 @@ object ObjectServiceGen extends smithy4s.Service[ObjectServiceGen, ObjectService } case class GetObject(input: GetObjectInput) extends ObjectServiceOperation[GetObjectInput, GetObjectError, GetObjectOutput, Nothing, Nothing] object GetObject extends smithy4s.Endpoint[ObjectServiceOperation, GetObjectInput, GetObjectError, GetObjectOutput, Nothing, Nothing] with http.HttpEndpoint[GetObjectInput] with smithy4s.Errorable[GetObjectError] { - def name: String = "GetObject" + val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "GetObject") val input: smithy4s.Schema[GetObjectInput] = GetObjectInput.schema.withHints(smithy4s.internals.InputOutput.Input) val output: smithy4s.Schema[GetObjectOutput] = GetObjectOutput.schema.withHints(smithy4s.internals.InputOutput.Output) val streamedInput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing val streamedOutput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing - val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "GetObject") val hints : smithy4s.Hints = smithy4s.Hints( id, smithy.api.Http(smithy.api.NonEmptyString("GET"), smithy.api.NonEmptyString("/{bucketName}/{key}"), Some(200)), diff --git a/modules/example/src/smithy4s/example/StreamedObjects.scala b/modules/example/src/smithy4s/example/StreamedObjects.scala index 3bb8bcc6b..2f3a07440 100644 --- a/modules/example/src/smithy4s/example/StreamedObjects.scala +++ b/modules/example/src/smithy4s/example/StreamedObjects.scala @@ -54,12 +54,11 @@ object StreamedObjectsGen extends smithy4s.Service[StreamedObjectsGen, StreamedO } case class PutStreamedObject(input: PutStreamedObjectInput) extends StreamedObjectsOperation[PutStreamedObjectInput, Nothing, Unit, StreamedBlob, Nothing] object PutStreamedObject extends smithy4s.Endpoint[StreamedObjectsOperation, PutStreamedObjectInput, Nothing, Unit, StreamedBlob, Nothing] { - def name: String = "PutStreamedObject" + val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "PutStreamedObject") val input: smithy4s.Schema[PutStreamedObjectInput] = PutStreamedObjectInput.schema.withHints(smithy4s.internals.InputOutput.Input) val output: smithy4s.Schema[Unit] = unit.withHints(smithy4s.internals.InputOutput.Output) val streamedInput : smithy4s.StreamingSchema[StreamedBlob] = smithy4s.StreamingSchema("PutStreamedObjectInput", StreamedBlob.schema) val streamedOutput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing - val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "PutStreamedObject") val hints : smithy4s.Hints = smithy4s.Hints( id, ) @@ -67,12 +66,11 @@ object StreamedObjectsGen extends smithy4s.Service[StreamedObjectsGen, StreamedO } case class GetStreamedObject(input: GetStreamedObjectInput) extends StreamedObjectsOperation[GetStreamedObjectInput, Nothing, GetStreamedObjectOutput, Nothing, StreamedBlob] object GetStreamedObject extends smithy4s.Endpoint[StreamedObjectsOperation, GetStreamedObjectInput, Nothing, GetStreamedObjectOutput, Nothing, StreamedBlob] { - def name: String = "GetStreamedObject" + val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "GetStreamedObject") val input: smithy4s.Schema[GetStreamedObjectInput] = GetStreamedObjectInput.schema.withHints(smithy4s.internals.InputOutput.Input) val output: smithy4s.Schema[GetStreamedObjectOutput] = GetStreamedObjectOutput.schema.withHints(smithy4s.internals.InputOutput.Output) val streamedInput : smithy4s.StreamingSchema[Nothing] = smithy4s.StreamingSchema.nothing val streamedOutput : smithy4s.StreamingSchema[StreamedBlob] = smithy4s.StreamingSchema("GetStreamedObjectOutput", StreamedBlob.schema) - val id: smithy4s.ShapeId = smithy4s.ShapeId("smithy4s.example", "GetStreamedObject") val hints : smithy4s.Hints = smithy4s.Hints( id, ) From 03f9de5f12bed53920449c3607c33b310c6ef25d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20M=C3=A9lois?= Date: Thu, 6 Jan 2022 10:37:52 +0100 Subject: [PATCH 3/3] Move UnknownErrorResponse to http package --- modules/core/src/smithy4s/{ => http}/UnknownErrorResponse.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename modules/core/src/smithy4s/{ => http}/UnknownErrorResponse.scala (97%) diff --git a/modules/core/src/smithy4s/UnknownErrorResponse.scala b/modules/core/src/smithy4s/http/UnknownErrorResponse.scala similarity index 97% rename from modules/core/src/smithy4s/UnknownErrorResponse.scala rename to modules/core/src/smithy4s/http/UnknownErrorResponse.scala index 208463650..274bde37f 100644 --- a/modules/core/src/smithy4s/UnknownErrorResponse.scala +++ b/modules/core/src/smithy4s/http/UnknownErrorResponse.scala @@ -14,7 +14,7 @@ * limitations under the License. */ -package smithy4s +package smithy4s.http case class UnknownErrorResponse( code: Int,