From 3f5e5eef73eb2771ccf8a231e9c86d51f36c5c31 Mon Sep 17 00:00:00 2001 From: aaylward Date: Wed, 9 Sep 2026 10:20:51 +0000 Subject: [PATCH 1/2] Rename the runtime namespace from smithy to opal (#201, ADR-0024) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Smithy is the IDL a service is described in, not a property of its JSON codec, its HTTP transport, or its Outcome type. Every `smithy::` scope and `namespace smithy` becomes `opal`: the hand-written runtime, tests, examples, fuzz targets and docs; the 26 codegen emitters that print the namespace into generated code; and the goldens, regenerated from those emitters rather than edited. The generated protocol-conformance suites move with it to `opal::protocoltests::…`, so their headers move to `include/opal/protocoltests/`. What keeps `smithy`: Smithy namespaces in `.smithy` models, the `smithy_cpp_*_library` rules that consume them, the codegen plugin, and the rules-test fixture's `smithy::cpp::ruletest`, which mirrors its own model's Smithy namespace and is the consumer's C++ namespace, not the runtime's. The include root, include guards, `SMITHY_*` macros, the `smithy:` log prefix and the Bazel module are surfaces 2 and 3, each its own PR. Breaking on a pre-1.0 minor per docs/versioning.md; the CHANGELOG carries the migration, which is one substitution over a consumer's tree. The out-of-tree consumer module needed exactly that and nothing else. ADR-0024 records the decision and the sequencing. --- CHANGELOG.md | 24 +- MODULE.bazel | 2 +- README.md | 4 +- bazel/tests/greeter_roundtrip_test.cc | 8 +- benchmarks/beast_benchmark.cc | 36 +- benchmarks/request_benchmark.cc | 28 +- benchmarks/serde_benchmark.cc | 32 +- codegen/BUILD.bazel | 2 +- .../compile-tests/gauntlet_compile_test.cc | 18 +- .../compile-tests/streaming_compile_test.cc | 189 +- codegen/smithy-cpp-codegen/build.gradle.kts | 6 +- .../io/smithycpp/codegen/ClientGenerator.java | 60 +- .../smithycpp/codegen/CppCodegenPlugin.java | 2 +- .../smithycpp/codegen/CppSymbolProvider.java | 22 +- .../smithycpp/codegen/DirectedCppCodegen.java | 2 +- .../smithycpp/codegen/EventStreamCodeGen.java | 70 +- .../smithycpp/codegen/HttpBindingCodeGen.java | 58 +- .../codegen/HttpJsonBindingProtocol.java | 4 +- .../codegen/HttpJsonClientGenerator.java | 36 +- .../codegen/HttpJsonServerGenerator.java | 48 +- .../codegen/IntegrationTestGenerator.java | 32 +- .../smithycpp/codegen/JsonRpc2Protocol.java | 104 +- .../codegen/JsonRpc2StreamCodeGen.java | 91 +- .../io/smithycpp/codegen/MemberDefaults.java | 4 +- .../codegen/NodeLiteralGenerator.java | 34 +- .../smithycpp/codegen/ProtocolGenerator.java | 4 +- .../io/smithycpp/codegen/ProtocolSupport.java | 82 +- .../codegen/ProtocolTestGenerator.java | 52 +- .../codegen/RandomValueGenerator.java | 8 +- .../io/smithycpp/codegen/RecursionIndex.java | 4 +- .../smithycpp/codegen/Rpcv2CborProtocol.java | 38 +- .../io/smithycpp/codegen/SerdeCodeGen.java | 55 +- .../io/smithycpp/codegen/SerdeGenerator.java | 84 +- .../io/smithycpp/codegen/ServerGenerator.java | 43 +- .../smithycpp/codegen/SmokeTestGenerator.java | 10 +- .../io/smithycpp/codegen/TypeGenerators.java | 20 +- .../codegen/ValidationGenerator.java | 40 +- .../ConditionalWiringCoverageTest.java | 2 +- .../codegen/CppCodegenPluginTest.java | 8 +- .../codegen/EventStreamGeneratorTest.java | 81 +- .../codegen/GeneratedCodeShapeTest.java | 46 +- .../codegen/HandlerContextThreadingTest.java | 6 +- .../codegen/HelperNameCoexistenceTest.java | 4 +- .../codegen/HttpJsonBindingProtocolTest.java | 12 +- .../codegen/HttpRedirectCodeGenTest.java | 8 +- .../smithycpp/codegen/RecursionIndexTest.java | 2 +- .../smithycpp/codegen/SerdeGeneratorTest.java | 4 +- .../codegen/ValidationGeneratorTest.java | 6 +- docs/PLAN.md | 8 +- docs/adr/0003-error-handling.md | 8 +- .../adr/0009-fail-fast-contract-violations.md | 2 +- docs/adr/0010-handler-request-context.md | 4 +- docs/adr/0012-forwarded-client-address.md | 2 +- docs/adr/0014-event-stream-framing-first.md | 6 +- docs/adr/0015-websocket-transports.md | 4 +- docs/adr/0016-generated-event-streams.md | 12 +- ...event-stream-session-handles-and-fanout.md | 6 +- .../adr/0018-json-text-event-stream-frames.md | 6 +- .../0019-completion-driven-event-streams.md | 6 +- ...0021-generated-async-streaming-handlers.md | 16 +- docs/adr/0023-jsonrpc2-event-streams.md | 4 +- .../0024-runtime-not-named-after-the-idl.md | 95 + docs/design/codegen-architecture.md | 2 +- docs/design/integration-testing.md | 4 +- docs/generated-types.md | 42 +- docs/production-guide.md | 98 +- docs/quickstart.md | 16 +- docs/runtime.md | 22 +- docs/server-guide.md | 78 +- .../plans/2026-07-08-server-middleware.md | 38 +- .../2026-07-08-server-middleware-design.md | 2 +- docs/versioning.md | 10 +- .../access_log_acceptance_test.cc | 44 +- .../bazel-consumer/async_acceptance_test.cc | 28 +- .../chat_async_reconnect_server_main.cc | 20 +- .../chat_reconnect_client_main.cc | 2 +- .../chat_reconnect_server_main.cc | 24 +- .../eventstream_consumer_test.cc | 14 +- .../exception_safety_acceptance_test.cc | 20 +- examples/bazel-consumer/head_e2e_test.cc | 32 +- .../bazel-consumer/jsonrpc_raw_peer_main.cc | 6 +- .../jsonrpc_stream_client_main.cc | 2 +- .../jsonrpc_stream_server_main.cc | 14 +- .../bazel-consumer/metrics_acceptance_test.cc | 68 +- examples/bazel-consumer/redirect_e2e_test.cc | 54 +- .../streaming_acceptance_test.cc | 32 +- .../todo_beast_acceptance_test.cc | 82 +- .../bazel-consumer/todo_integration_test.cc | 159 +- .../websocket_acceptance_test.cc | 16 +- .../websocket_contract_consumer_test.cc | 34 +- .../generated/include/example/cafe/client.h | 44 +- .../generated/include/example/cafe/serde.h | 54 +- .../generated/include/example/cafe/server.h | 14 +- .../generated/include/example/cafe/types.h | 100 +- examples/cafe/generated/src/client.cc | 72 +- examples/cafe/generated/src/serde.cc | 272 +-- examples/cafe/generated/src/server.cc | 88 +- .../cafe/generated/tests/integration_test.cc | 56 +- examples/cafe/generated/tests/smoke_test.cc | 14 +- examples/cafe/generated_client_test.cc | 39 +- examples/cafe/generated_types_test.cc | 16 +- examples/chat/async_hub_server_main.cc | 34 +- examples/chat/chat_browser_e2e_test.cc | 14 +- examples/chat/chat_e2e_beast_test.cc | 20 +- examples/chat/chat_e2e_test.cc | 98 +- .../generated/include/example/chat/client.h | 36 +- .../generated/include/example/chat/serde.h | 62 +- .../generated/include/example/chat/server.h | 42 +- .../generated/include/example/chat/types.h | 86 +- examples/chat/generated/src/client.cc | 124 +- examples/chat/generated/src/serde.cc | 274 +-- examples/chat/generated/src/server.cc | 156 +- .../chat/generated/tests/integration_test.cc | 34 +- examples/chat/generated/tests/smoke_test.cc | 14 +- examples/chat/hub_client_main.cc | 6 +- examples/chat/hub_e2e_test.cc | 4 +- examples/chat/hub_handler.h | 22 +- examples/chat/hub_server_main.cc | 6 +- examples/chat/room_handler.h | 28 +- examples/chat/stream_test_fixture.h | 15 +- examples/jsonrpc2/accumulate_handler.h | 45 +- .../include/example/calculator/client.h | 48 +- .../include/example/calculator/serde.h | 50 +- .../include/example/calculator/server.h | 34 +- .../include/example/calculator/types.h | 76 +- examples/jsonrpc2/generated/src/client.cc | 150 +- examples/jsonrpc2/generated/src/serde.cc | 256 +-- examples/jsonrpc2/generated/src/server.cc | 186 +- .../generated/tests/integration_test.cc | 52 +- .../jsonrpc2/generated/tests/smoke_test.cc | 18 +- examples/jsonrpc2/interop_wire_test.cc | 77 +- examples/jsonrpc2/stream_e2e_beast_test.cc | 28 +- examples/jsonrpc2/stream_e2e_test.cc | 12 +- examples/jsonrpc2/stream_test_fixture.h | 16 +- .../example/roundtrip/jsonrpc/client.h | 30 +- .../include/example/roundtrip/jsonrpc/serde.h | 46 +- .../example/roundtrip/jsonrpc/server.h | 12 +- .../include/example/roundtrip/jsonrpc/types.h | 144 +- .../roundtrip/jsonrpc/generated/src/client.cc | 78 +- .../roundtrip/jsonrpc/generated/src/serde.cc | 352 ++-- .../roundtrip/jsonrpc/generated/src/server.cc | 100 +- .../generated/tests/integration_test.cc | 42 +- .../jsonrpc/generated/tests/smoke_test.cc | 12 +- examples/roundtrip/rest/api_key_wire_test.cc | 13 +- .../include/example/roundtrip/rest/client.h | 64 +- .../include/example/roundtrip/rest/serde.h | 74 +- .../include/example/roundtrip/rest/server.h | 16 +- .../include/example/roundtrip/rest/types.h | 214 +-- .../roundtrip/rest/generated/src/client.cc | 112 +- .../roundtrip/rest/generated/src/serde.cc | 532 +++--- .../roundtrip/rest/generated/src/server.cc | 158 +- .../rest/generated/tests/integration_test.cc | 82 +- .../rest/generated/tests/smoke_test.cc | 16 +- .../rest/numeric_bounds_wire_test.cc | 50 +- examples/roundtrip/rest/typed_errors_test.cc | 18 +- .../include/example/roundtrip/rpc/client.h | 32 +- .../include/example/roundtrip/rpc/serde.h | 54 +- .../include/example/roundtrip/rpc/server.h | 14 +- .../include/example/roundtrip/rpc/types.h | 144 +- .../roundtrip/rpc/generated/src/client.cc | 64 +- examples/roundtrip/rpc/generated/src/serde.cc | 372 ++-- .../roundtrip/rpc/generated/src/server.cc | 80 +- .../rpc/generated/tests/integration_test.cc | 60 +- .../rpc/generated/tests/smoke_test.cc | 14 +- .../roundtrip/rpc/no_input_body_wire_test.cc | 19 +- .../include/example/bookstore/client.h | 30 +- .../include/example/bookstore/serde.h | 22 +- .../include/example/bookstore/server.h | 14 +- .../include/example/bookstore/types.h | 44 +- .../simplerestjson/generated/src/client.cc | 86 +- .../simplerestjson/generated/src/serde.cc | 142 +- .../simplerestjson/generated/src/server.cc | 112 +- .../generated/tests/integration_test.cc | 48 +- .../generated/tests/smoke_test.cc | 14 +- examples/simplerestjson/serve_main.cc | 14 +- .../include/example/weather/client.h | 72 +- .../generated/include/example/weather/serde.h | 66 +- .../include/example/weather/server.h | 22 +- .../generated/include/example/weather/types.h | 78 +- examples/weather/generated/src/client.cc | 104 +- examples/weather/generated/src/serde.cc | 322 ++-- examples/weather/generated/src/server.cc | 180 +- .../generated/tests/integration_test.cc | 116 +- .../weather/generated/tests/smoke_test.cc | 22 +- examples/weather/generated_client_e2e_test.cc | 24 +- examples/weather/generated_server_e2e_test.cc | 189 +- examples/weather/generated_types_test.cc | 2 +- .../weather/handwritten/weather_client.cc | 46 +- examples/weather/handwritten/weather_client.h | 20 +- .../weather/handwritten/weather_e2e_test.cc | 30 +- .../weather/handwritten/weather_server.cc | 24 +- examples/weather/handwritten/weather_server.h | 12 +- examples/weather/handwritten/weather_types.cc | 14 +- examples/weather/handwritten/weather_types.h | 18 +- fuzz/access_log_fuzz.cc | 6 +- fuzz/cbor_decode_fuzz.cc | 7 +- fuzz/eventstream_frame_fuzz.cc | 6 +- fuzz/eventstream_json_frame_fuzz.cc | 6 +- fuzz/eventstream_jsonrpc_frame_fuzz.cc | 14 +- fuzz/forwarded_fuzz.cc | 18 +- fuzz/gzip_fuzz.cc | 10 +- fuzz/http1_fuzz.cc | 6 +- fuzz/json_decode_fuzz.cc | 4 +- fuzz/regex_fuzz.cc | 2 +- fuzz/server_dispatch_fuzz.cc | 32 +- fuzz/timestamp_fuzz.cc | 13 +- fuzz/uri_fuzz.cc | 10 +- protocol-tests/jsonrpc2/generated/BUILD.bazel | 8 +- .../protocoltests/jsonrpc2/client.h | 72 +- .../opal/protocoltests/jsonrpc2/serde.h | 76 + .../protocoltests/jsonrpc2/server.h | 50 +- .../protocoltests/jsonrpc2/types.h | 210 +-- .../smithy/protocoltests/jsonrpc2/serde.h | 76 - .../jsonrpc2/generated/src/client.cc | 178 +- .../jsonrpc2/generated/src/serde.cc | 394 ++-- .../jsonrpc2/generated/src/server.cc | 240 +-- .../jsonrpc2/generated/tests/request_tests.cc | 46 +- .../generated/tests/response_tests.cc | 12 +- .../generated/tests/server_malformed_tests.cc | 78 +- .../generated/tests/server_request_tests.cc | 46 +- .../generated/tests/server_response_tests.cc | 58 +- .../jsonrpc2/generated/tests/smoke_test.cc | 28 +- .../jsonrpc2/stream_conformance_test.cc | 67 +- .../rpcv2cbor/generated/BUILD.bazel | 8 +- .../protocoltests/rpcv2cbor/client.h | 144 +- .../opal/protocoltests/rpcv2cbor/serde.h | 221 +++ .../opal/protocoltests/rpcv2cbor/server.h | 74 + .../protocoltests/rpcv2cbor/types.h | 790 ++++---- .../smithy/protocoltests/rpcv2cbor/serde.h | 221 --- .../smithy/protocoltests/rpcv2cbor/server.h | 74 - .../rpcv2cbor/generated/src/client.cc | 172 +- .../rpcv2cbor/generated/src/serde.cc | 1620 ++++++++--------- .../rpcv2cbor/generated/src/server.cc | 242 +-- .../generated/tests/request_tests.cc | 196 +- .../generated/tests/response_tests.cc | 116 +- .../generated/tests/server_request_tests.cc | 264 +-- .../generated/tests/server_response_tests.cc | 280 +-- .../rpcv2cbor/generated/tests/smoke_test.cc | 46 +- .../malformed/server_malformed_test.cc | 78 +- .../simplerestjson/generated/BUILD.bazel | 8 +- .../protocoltests/simplerestjson/client.h | 326 ++-- .../opal/protocoltests/simplerestjson/serde.h | 152 ++ .../protocoltests/simplerestjson/server.h | 56 + .../protocoltests/simplerestjson/types.h | 472 ++--- .../protocoltests/simplerestjson/serde.h | 152 -- .../protocoltests/simplerestjson/server.h | 56 - .../simplerestjson/generated/src/client.cc | 242 +-- .../simplerestjson/generated/src/serde.cc | 872 ++++----- .../simplerestjson/generated/src/server.cc | 372 ++-- .../generated/tests/request_tests.cc | 134 +- .../generated/tests/response_tests.cc | 46 +- .../generated/tests/server_request_tests.cc | 134 +- .../generated/tests/server_response_tests.cc | 252 +-- .../generated/tests/smoke_test.cc | 44 +- .../malformed/pattern_violation_test.cc | 26 +- .../malformed/server_malformed_test.cc | 82 +- protocol-tests/unions/union_accessor_test.cc | 2 +- protocol-tests/unions/union_cbor_test.cc | 151 +- .../unions/union_gauntlet_cbor_test.cc | 96 +- .../unions/union_gauntlet_jsonrpc2_test.cc | 112 +- protocol-tests/unions/union_jsonrpc2_test.cc | 160 +- runtime/BUILD.bazel | 6 +- runtime/include/smithy/cbor/cbor.h | 4 +- runtime/include/smithy/client/config.h | 10 +- runtime/include/smithy/client/interceptor.h | 4 +- runtime/include/smithy/client/observability.h | 6 +- runtime/include/smithy/client/pagination.h | 4 +- runtime/include/smithy/client/retry.h | 4 +- runtime/include/smithy/compression/gzip.h | 4 +- .../smithy/compression/gzip_test_peer.h | 4 +- runtime/include/smithy/core/base64.h | 4 +- runtime/include/smithy/core/blob.h | 8 +- runtime/include/smithy/core/boxed.h | 4 +- .../include/smithy/core/container_traits.h | 4 +- runtime/include/smithy/core/document.h | 4 +- runtime/include/smithy/core/document_serde.h | 4 +- runtime/include/smithy/core/error.h | 4 +- runtime/include/smithy/core/exception_guard.h | 4 +- runtime/include/smithy/core/fatal.h | 4 +- runtime/include/smithy/core/hash.h | 4 +- runtime/include/smithy/core/outcome.h | 8 +- runtime/include/smithy/core/overloaded.h | 6 +- runtime/include/smithy/core/print.h | 4 +- runtime/include/smithy/core/regex.h | 4 +- runtime/include/smithy/core/text.h | 4 +- runtime/include/smithy/core/timestamp.h | 8 +- runtime/include/smithy/core/uuid.h | 4 +- runtime/include/smithy/core/version.h | 4 +- .../smithy/eventstream/async_event_stream.h | 8 +- runtime/include/smithy/eventstream/envelope.h | 4 +- .../include/smithy/eventstream/event_stream.h | 6 +- runtime/include/smithy/eventstream/frame.h | 6 +- .../include/smithy/eventstream/json_frame.h | 4 +- .../smithy/eventstream/jsonrpc_frame.h | 4 +- .../eventstream/jsonrpc_stream_socket.h | 4 +- runtime/include/smithy/http/beast_transport.h | 16 +- runtime/include/smithy/http/forwarded.h | 4 +- runtime/include/smithy/http/headers.h | 4 +- runtime/include/smithy/http/http1.h | 4 +- runtime/include/smithy/http/loopback.h | 4 +- runtime/include/smithy/http/message.h | 4 +- runtime/include/smithy/http/server_dispatch.h | 4 +- .../include/smithy/http/socket_transport.h | 4 +- runtime/include/smithy/http/trace_context.h | 4 +- runtime/include/smithy/http/transport.h | 6 +- runtime/include/smithy/http/uri.h | 4 +- runtime/include/smithy/http/websocket.h | 6 +- runtime/include/smithy/http/websocket_pair.h | 4 +- runtime/include/smithy/json/json.h | 4 +- runtime/include/smithy/server/access_log.h | 4 +- runtime/include/smithy/server/metrics.h | 18 +- runtime/include/smithy/server/middleware.h | 6 +- runtime/include/smithy/server/origin_gate.h | 10 +- runtime/include/smithy/server/router.h | 4 +- .../include/smithy/server/session_registry.h | 6 +- .../include/smithy/server/websocket_router.h | 4 +- runtime/src/cbor/cbor.cc | 4 +- runtime/src/client/observability.cc | 4 +- runtime/src/client/retry.cc | 4 +- runtime/src/compression/gzip.cc | 4 +- runtime/src/core/base64.cc | 4 +- runtime/src/core/document_serde.cc | 4 +- runtime/src/core/regex.cc | 4 +- runtime/src/core/text.cc | 4 +- runtime/src/core/timestamp.cc | 4 +- runtime/src/core/uuid.cc | 4 +- runtime/src/core/version.cc | 4 +- runtime/src/eventstream/envelope.cc | 4 +- runtime/src/eventstream/frame.cc | 4 +- runtime/src/eventstream/json_frame.cc | 4 +- runtime/src/eventstream/jsonrpc_frame.cc | 4 +- .../src/eventstream/jsonrpc_stream_socket.cc | 4 +- runtime/src/http/beast_transport.cc | 10 +- runtime/src/http/forwarded.cc | 4 +- runtime/src/http/headers.cc | 4 +- runtime/src/http/http1.cc | 4 +- runtime/src/http/server_dispatch.cc | 8 +- runtime/src/http/socket_transport.cc | 6 +- runtime/src/http/trace_context.cc | 4 +- runtime/src/http/uri.cc | 4 +- runtime/src/http/websocket_pair.cc | 4 +- runtime/src/json/json.cc | 4 +- runtime/src/server/access_log.cc | 18 +- runtime/src/server/metrics.cc | 45 +- runtime/src/server/middleware.cc | 20 +- runtime/src/server/origin_gate.cc | 6 +- runtime/src/server/router.cc | 4 +- runtime/src/server/websocket_router.cc | 4 +- .../testing/connection_event_recorder.h | 4 +- .../include/smithy/testing/protocol_test.h | 50 +- .../smithy/testing/tls_test_identity.h | 4 +- .../smithy/testing/websocket_contract_test.h | 8 +- runtime/tests/cbor/cbor_hostile_test.cc | 4 +- runtime/tests/cbor/cbor_property_test.cc | 10 +- runtime/tests/cbor/cbor_test.cc | 4 +- runtime/tests/client/observability_test.cc | 49 +- runtime/tests/client/pagination_test.cc | 6 +- runtime/tests/client/retry_test.cc | 4 +- runtime/tests/compression/gzip_test.cc | 4 +- runtime/tests/core/boxed_test.cc | 6 +- runtime/tests/core/core_test.cc | 4 +- runtime/tests/core/document_serde_test.cc | 4 +- runtime/tests/core/exception_guard_test.cc | 4 +- runtime/tests/core/hash_test.cc | 4 +- runtime/tests/core/print_test.cc | 4 +- runtime/tests/core/regex_test.cc | 10 +- .../tests/core/timestamp_differential_test.cc | 4 +- runtime/tests/core/timestamp_test.cc | 8 +- runtime/tests/core/uuid_test.cc | 8 +- runtime/tests/core/version_test.cc | 4 +- .../eventstream/async_event_stream_test.cc | 8 +- runtime/tests/eventstream/envelope_test.cc | 4 +- .../tests/eventstream/event_stream_test.cc | 4 +- runtime/tests/eventstream/frame_test.cc | 4 +- runtime/tests/eventstream/json_frame_test.cc | 4 +- .../tests/eventstream/jsonrpc_frame_test.cc | 4 +- .../eventstream/jsonrpc_stream_socket_test.cc | 8 +- runtime/tests/http/beast_client_test.cc | 18 +- runtime/tests/http/beast_transport_test.cc | 82 +- runtime/tests/http/beast_websocket_test.cc | 26 +- runtime/tests/http/forwarded_test.cc | 4 +- runtime/tests/http/http1_hostile_test.cc | 4 +- runtime/tests/http/http_test.cc | 8 +- runtime/tests/http/server_dispatch_test.cc | 4 +- .../http/socket_transport_hostile_test.cc | 4 +- runtime/tests/http/socket_transport_test.cc | 4 +- runtime/tests/http/trace_context_test.cc | 4 +- runtime/tests/http/uri_property_test.cc | 4 +- runtime/tests/http/websocket_pair_test.cc | 4 +- runtime/tests/json/json_conformance_test.cc | 6 +- runtime/tests/json/json_property_test.cc | 12 +- runtime/tests/json/json_test.cc | 4 +- .../tests/json/jsontestsuite/PROVENANCE.md | 2 +- runtime/tests/server/access_log_test.cc | 4 +- runtime/tests/server/metrics_test.cc | 4 +- runtime/tests/server/middleware_test.cc | 8 +- runtime/tests/server/origin_gate_test.cc | 4 +- runtime/tests/server/router_test.cc | 4 +- runtime/tests/server/session_registry_test.cc | 4 +- runtime/tests/server/websocket_router_test.cc | 4 +- .../testing/protocol_test_support_test.cc | 12 +- runtime/tests/testing/random_document.h | 4 +- tools/release.sh | 6 +- 403 files changed, 10904 insertions(+), 10828 deletions(-) create mode 100644 docs/adr/0024-runtime-not-named-after-the-idl.md rename protocol-tests/jsonrpc2/generated/include/{smithy => opal}/protocoltests/jsonrpc2/client.h (75%) create mode 100644 protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/serde.h rename protocol-tests/jsonrpc2/generated/include/{smithy => opal}/protocoltests/jsonrpc2/server.h (69%) rename protocol-tests/jsonrpc2/generated/include/{smithy => opal}/protocoltests/jsonrpc2/types.h (71%) delete mode 100644 protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/serde.h rename protocol-tests/rpcv2cbor/generated/include/{smithy => opal}/protocoltests/rpcv2cbor/client.h (74%) create mode 100644 protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/serde.h create mode 100644 protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/server.h rename protocol-tests/rpcv2cbor/generated/include/{smithy => opal}/protocoltests/rpcv2cbor/types.h (67%) delete mode 100644 protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/serde.h delete mode 100644 protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/server.h rename protocol-tests/simplerestjson/generated/include/{smithy => opal}/protocoltests/simplerestjson/client.h (81%) create mode 100644 protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/serde.h create mode 100644 protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/server.h rename protocol-tests/simplerestjson/generated/include/{smithy => opal}/protocoltests/simplerestjson/types.h (75%) delete mode 100644 protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/serde.h delete mode 100644 protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/server.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bc1fb47..bd1a8117 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,10 +6,28 @@ policy in [docs/versioning.md](docs/versioning.md). ## [Unreleased] +### Breaking + +- **The runtime namespace is `opal`, not `smithy`** (#201, ADR-0024; the + first of three surfaces). Smithy is the IDL a service is described in, not + a property of its JSON codec or its HTTP transport, so `smithy::Outcome`, + `smithy::json::Encode` and `smithy::http::BeastServerTransport` are now + `opal::Outcome`, `opal::json::Encode` and + `opal::http::BeastServerTransport` — every `smithy::` scope in the runtime, + in generated code, and in the generated protocol-conformance suites (now + `opal::protocoltests::…`, whose headers moved to + `include/opal/protocoltests/`). Migration is one substitution over your + tree: `smithy::` → `opal::` and `namespace smithy` → `namespace opal`. + Leave alone anything that names the model rather than the runtime: Smithy + namespaces in `.smithy` files, the `smithy_cpp_*_library` rules, and any + C++ namespace you derived from your own model's Smithy namespace. The + include root (`smithy/http/transport.h`) and the Bazel module + (`@smithy_cpp`) are unchanged here and move in the two PRs that follow. + ### Added - **A dependency-free Prometheus `/metrics` endpoint** (#91, first work - item). `smithy::server::MetricsRegistry` aggregates the existing `Observe` + item). `opal::server::MetricsRegistry` aggregates the existing `Observe` hooks into the five `http_server_*` families labeled by `service_name`, `http_method` and `route`, and `MetricsEndpoint` serves them in the text exposition format, which needs no client library and so costs zero new @@ -87,7 +105,7 @@ policy in [docs/versioning.md](docs/versioning.md). separates a contained crash from a deliberate 500, which report identically otherwise. -- **A structured access-log formatter** (#203). `smithy::server::FormatAccessLog` +- **A structured access-log formatter** (#203). `opal::server::FormatAccessLog` turns a `RequestObservation` into one line of JSON — a pure function with no I/O, no sink, no configuration and no new dependency (`:server` still takes only `:core` and `:http`; the JSON is hand-rolled like the Prometheus @@ -130,7 +148,7 @@ policy in [docs/versioning.md](docs/versioning.md). now shares the same check); a `float` member cast the parsed double unchecked on both the body and text-binding paths, so a finite wire value beyond float range (`1e300`) was undefined behavior per [conv.double] — - the new `smithy::FloatFromDouble` rejects it while NaN/±Infinity still + the new `opal::FloatFromDouble` rejects it while NaN/±Infinity still pass; and the jsonRpc2 client truncated `error.code` to `int` *before* its 100–599 range test, classifying 2^32+404 as HTTP 404 (with 5xx codes wrongly diff --git a/MODULE.bazel b/MODULE.bazel index 9ee90012..21c90881 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -1,7 +1,7 @@ # The bzlmod module version stays 0.0.0 until the module is published to the # Bazel Central Registry (deferred, PLAN Phase 6); consumers override the source # with git_override/local_path_override, which ignores this value. The product -# version consumers actually observe is smithy::Version() / the client +# version consumers actually observe is opal::Version() / the client # User-Agent ("0.2.0"). See docs/versioning.md. module( name = "smithy_cpp", diff --git a/README.md b/README.md index f6c68a89..ca1eef7a 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,9 @@ experience assumed. Day 2 (evolving the model) is Consolidated in one place — if your API depends on any of these, check here before adopting: - **`@streaming` blobs are not modeled yet.** A streaming blob payload generates as an - ordinary `smithy::Blob`, fully buffered in memory. Event streams, by contrast, are real + ordinary `opal::Blob`, fully buffered in memory. Event streams, by contrast, are real ([ADR-0016](docs/adr/0016-generated-event-streams.md)): a `@streaming` union operation - generates a typed `smithy::eventstream::EventStream` session over WebSocket for all + generates a typed `opal::eventstream::EventStream` session over WebSocket for all three protocols — `simpleRestJson` and `rpcv2Cbor` ride the event-stream framing codec ([ADR-0014](docs/adr/0014-event-stream-framing-first.md)) and `jsonRpc2` streams JSON-RPC 2.0 envelopes natively ([ADR-0023](docs/adr/0023-jsonrpc2-event-streams.md)) — diff --git a/bazel/tests/greeter_roundtrip_test.cc b/bazel/tests/greeter_roundtrip_test.cc index aa733a2d..95ca7cb5 100644 --- a/bazel/tests/greeter_roundtrip_test.cc +++ b/bazel/tests/greeter_roundtrip_test.cc @@ -17,18 +17,18 @@ namespace { class Handler final : public GreeterHandler { public: - smithy::Outcome Greet(const GreetInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Greet(const GreetInput& input, + const opal::server::RequestContext&) override { return GreetOutput{.greeting = "hello, " + input.name}; } }; TEST(GreeterMultiModelTest, OverlayBoundServiceRoundTrips) { GreeterServer server(std::make_shared()); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; auto client = GreeterClient::Create(std::move(config)); ASSERT_TRUE(client.ok()) << client.error().message(); diff --git a/benchmarks/beast_benchmark.cc b/benchmarks/beast_benchmark.cc index a97f9e77..5d70ba0f 100644 --- a/benchmarks/beast_benchmark.cc +++ b/benchmarks/beast_benchmark.cc @@ -24,8 +24,8 @@ namespace { -using smithy::testing::kTestCertificatePem; -using smithy::testing::kTestPrivateKeyPem; +using opal::testing::kTestCertificatePem; +using opal::testing::kTestPrivateKeyPem; // The same input request_benchmark sends, so the numbers are comparable. example::roundtrip::rest::PutSinkInput MakeInput() { @@ -43,26 +43,26 @@ example::roundtrip::rest::PutSinkInput MakeInput() { class EchoHandler final : public example::roundtrip::rest::RoundTripRestHandler { public: - smithy::Outcome PutSink( + opal::Outcome PutSink( const example::roundtrip::rest::PutSinkInput& input, - const smithy::server::RequestContext&) override { + const opal::server::RequestContext&) override { return example::roundtrip::rest::PutSinkOutput{.sinkId = input.sinkId, .sink = input.sink}; } - smithy::Outcome UploadAttachment( + opal::Outcome UploadAttachment( const example::roundtrip::rest::UploadAttachmentInput&, - const smithy::server::RequestContext&) override { + const opal::server::RequestContext&) override { return example::roundtrip::rest::UploadAttachmentOutput{}; } - smithy::Outcome DescribeSink( + opal::Outcome DescribeSink( const example::roundtrip::rest::DescribeSinkInput&, - const smithy::server::RequestContext&) override { + const opal::server::RequestContext&) override { return example::roundtrip::rest::DescribeSinkOutput{}; } }; example::roundtrip::rest::RoundTripRestClient MakeClient( - std::string endpoint, std::shared_ptr transport) { - smithy::ClientConfig config; + std::string endpoint, std::shared_ptr transport) { + opal::ClientConfig config; config.retry.max_attempts = 1; config.endpoint = std::move(endpoint); config.http_client = std::move(transport); @@ -84,14 +84,14 @@ void RunLoop(benchmark::State& state, example::roundtrip::rest::RoundTripRestCli // Baseline: the dependency-free socket transport, one connection per request. void BM_SocketRoundTrip(benchmark::State& state) { example::roundtrip::rest::RoundTripRestServer server(std::make_shared()); - smithy::http::SocketHttpServer transport; + opal::http::SocketHttpServer transport; if (!transport.Start(server.Handler()).ok()) { state.SkipWithError("socket server failed to start"); return; } const std::string origin = "http://127.0.0.1:" + std::to_string(transport.port()); auto client = MakeClient( - origin, std::make_shared("127.0.0.1", transport.port())); + origin, std::make_shared("127.0.0.1", transport.port())); RunLoop(state, client); transport.Stop(); } @@ -99,14 +99,14 @@ BENCHMARK(BM_SocketRoundTrip); void BM_BeastRoundTrip(benchmark::State& state) { example::roundtrip::rest::RoundTripRestServer server(std::make_shared()); - smithy::http::BeastServerTransport transport({.port = 0, .threads = 2}); + opal::http::BeastServerTransport transport({.port = 0, .threads = 2}); if (!transport.Start(server.Handler()).ok()) { state.SkipWithError("beast server failed to start"); return; } const std::string origin = "http://127.0.0.1:" + std::to_string(transport.port()); - auto client = MakeClient(origin, std::make_shared( - smithy::http::BeastHttpClient::Options{ + auto client = MakeClient(origin, std::make_shared( + opal::http::BeastHttpClient::Options{ .host = "127.0.0.1", .port = transport.port()})); RunLoop(state, client); transport.Stop(); @@ -115,7 +115,7 @@ BENCHMARK(BM_BeastRoundTrip); void BM_BeastTlsRoundTrip(benchmark::State& state) { example::roundtrip::rest::RoundTripRestServer server(std::make_shared()); - smithy::http::BeastServerTransport transport({.port = 0, + opal::http::BeastServerTransport transport({.port = 0, .threads = 2, .tls_certificate_chain_pem = kTestCertificatePem, .tls_private_key_pem = kTestPrivateKeyPem}); @@ -124,8 +124,8 @@ void BM_BeastTlsRoundTrip(benchmark::State& state) { return; } const std::string origin = "https://127.0.0.1:" + std::to_string(transport.port()); - auto client = MakeClient(origin, std::make_shared( - smithy::http::BeastHttpClient::Options{ + auto client = MakeClient(origin, std::make_shared( + opal::http::BeastHttpClient::Options{ .host = "127.0.0.1", .port = transport.port(), .tls = true, diff --git a/benchmarks/request_benchmark.cc b/benchmarks/request_benchmark.cc index a51c8abb..93b1f504 100644 --- a/benchmarks/request_benchmark.cc +++ b/benchmarks/request_benchmark.cc @@ -43,41 +43,41 @@ Input MakeInput() { class RestHandler final : public example::roundtrip::rest::RoundTripRestHandler { public: - smithy::Outcome PutSink( + opal::Outcome PutSink( const example::roundtrip::rest::PutSinkInput& input, - const smithy::server::RequestContext&) override { + const opal::server::RequestContext&) override { return example::roundtrip::rest::PutSinkOutput{.sinkId = input.sinkId, .sink = input.sink}; } - smithy::Outcome UploadAttachment( + opal::Outcome UploadAttachment( const example::roundtrip::rest::UploadAttachmentInput&, - const smithy::server::RequestContext&) override { + const opal::server::RequestContext&) override { return example::roundtrip::rest::UploadAttachmentOutput{}; } - smithy::Outcome DescribeSink( + opal::Outcome DescribeSink( const example::roundtrip::rest::DescribeSinkInput&, - const smithy::server::RequestContext&) override { + const opal::server::RequestContext&) override { return example::roundtrip::rest::DescribeSinkOutput{}; } }; class RpcHandler final : public example::roundtrip::rpc::RoundTripRpcHandler { public: - smithy::Outcome PutSinkRpc( + opal::Outcome PutSinkRpc( const example::roundtrip::rpc::PutSinkRpcInput& input, - const smithy::server::RequestContext&) override { + const opal::server::RequestContext&) override { return example::roundtrip::rpc::PutSinkRpcOutput{.sinkId = input.sinkId, .sink = input.sink}; } - smithy::Outcome Ping( - const example::roundtrip::rpc::PingInput&, const smithy::server::RequestContext&) override { + opal::Outcome Ping( + const example::roundtrip::rpc::PingInput&, const opal::server::RequestContext&) override { return example::roundtrip::rpc::PingOutput{}; } }; class JsonRpcHandler final : public example::roundtrip::jsonrpc::RoundTripJsonRpcHandler { public: - smithy::Outcome PutSinkRpc( + opal::Outcome PutSinkRpc( const example::roundtrip::jsonrpc::PutSinkRpcInput& input, - const smithy::server::RequestContext&) override { + const opal::server::RequestContext&) override { return example::roundtrip::jsonrpc::PutSinkRpcOutput{.sinkId = input.sinkId, .sink = input.sink}; } @@ -87,9 +87,9 @@ template Client MakeLoopbackClient() { // Handler() owns the router, so the Server object itself may go away. Server server(std::make_shared()); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; config.http_client = std::move(loopback); return *Client::Create(std::move(config)); diff --git a/benchmarks/serde_benchmark.cc b/benchmarks/serde_benchmark.cc index 1ab917f1..0ca4c998 100644 --- a/benchmarks/serde_benchmark.cc +++ b/benchmarks/serde_benchmark.cc @@ -35,12 +35,12 @@ KitchenSink MakeSink() { sink.big = 9876543210LL; sink.ratio = 0.5F; sink.precise = 3.14159265358979; - sink.blob = smithy::Blob::FromString("0123456789abcdef0123456789abcdef"); + sink.blob = opal::Blob::FromString("0123456789abcdef0123456789abcdef"); sink.priority = Priority::Value::kHigh; sink.weight = Weight::kHeavy; - sink.dateTime = smithy::Timestamp::FromEpochMilliseconds(1515531081000LL); - sink.httpDate = smithy::Timestamp::FromEpochMilliseconds(1515531081000LL); - sink.epoch = smithy::Timestamp::FromEpochMilliseconds(1515531081000LL); + sink.dateTime = opal::Timestamp::FromEpochMilliseconds(1515531081000LL); + sink.httpDate = opal::Timestamp::FromEpochMilliseconds(1515531081000LL); + sink.epoch = opal::Timestamp::FromEpochMilliseconds(1515531081000LL); sink.names = std::vector{"alpha", "beta", "gamma", "delta", "epsilon"}; sink.uniqueNames = std::vector{"one", "two", "three"}; sink.sparseNumbers = @@ -61,7 +61,7 @@ void BM_SerializeToDocument(benchmark::State& state) { BENCHMARK(BM_SerializeToDocument); void BM_DeserializeFromDocument(benchmark::State& state) { - const smithy::Document doc = example::roundtrip::rest::SerializeKitchenSink(MakeSink()); + const opal::Document doc = example::roundtrip::rest::SerializeKitchenSink(MakeSink()); for (auto _ : state) { benchmark::DoNotOptimize(example::roundtrip::rest::DeserializeKitchenSink(doc)); } @@ -69,10 +69,10 @@ void BM_DeserializeFromDocument(benchmark::State& state) { BENCHMARK(BM_DeserializeFromDocument); void BM_JsonEncode(benchmark::State& state) { - const smithy::Document doc = example::roundtrip::rest::SerializeKitchenSink(MakeSink()); + const opal::Document doc = example::roundtrip::rest::SerializeKitchenSink(MakeSink()); std::size_t bytes = 0; for (auto _ : state) { - std::string text = smithy::json::Encode(doc); + std::string text = opal::json::Encode(doc); bytes += text.size(); benchmark::DoNotOptimize(text); } @@ -82,10 +82,10 @@ BENCHMARK(BM_JsonEncode); void BM_JsonDecode(benchmark::State& state) { const std::string text = - smithy::json::Encode(example::roundtrip::rest::SerializeKitchenSink(MakeSink())); + opal::json::Encode(example::roundtrip::rest::SerializeKitchenSink(MakeSink())); std::size_t bytes = 0; for (auto _ : state) { - benchmark::DoNotOptimize(smithy::json::Decode(text)); + benchmark::DoNotOptimize(opal::json::Decode(text)); bytes += text.size(); } state.SetBytesProcessed(static_cast(bytes)); @@ -93,10 +93,10 @@ void BM_JsonDecode(benchmark::State& state) { BENCHMARK(BM_JsonDecode); void BM_CborEncode(benchmark::State& state) { - const smithy::Document doc = example::roundtrip::rest::SerializeKitchenSink(MakeSink()); + const opal::Document doc = example::roundtrip::rest::SerializeKitchenSink(MakeSink()); std::size_t bytes = 0; for (auto _ : state) { - smithy::Blob wire = smithy::cbor::Encode(doc); + opal::Blob wire = opal::cbor::Encode(doc); bytes += wire.size(); benchmark::DoNotOptimize(wire); } @@ -105,11 +105,11 @@ void BM_CborEncode(benchmark::State& state) { BENCHMARK(BM_CborEncode); void BM_CborDecode(benchmark::State& state) { - const smithy::Blob wire = - smithy::cbor::Encode(example::roundtrip::rest::SerializeKitchenSink(MakeSink())); + const opal::Blob wire = + opal::cbor::Encode(example::roundtrip::rest::SerializeKitchenSink(MakeSink())); std::size_t bytes = 0; for (auto _ : state) { - benchmark::DoNotOptimize(smithy::cbor::Decode(wire)); + benchmark::DoNotOptimize(opal::cbor::Decode(wire)); bytes += wire.size(); } state.SetBytesProcessed(static_cast(bytes)); @@ -120,8 +120,8 @@ void BM_FullPivotRoundTripJson(benchmark::State& state) { const KitchenSink sink = MakeSink(); for (auto _ : state) { const std::string text = - smithy::json::Encode(example::roundtrip::rest::SerializeKitchenSink(sink)); - auto doc = smithy::json::Decode(text); + opal::json::Encode(example::roundtrip::rest::SerializeKitchenSink(sink)); + auto doc = opal::json::Decode(text); benchmark::DoNotOptimize(example::roundtrip::rest::DeserializeKitchenSink(*doc)); } } diff --git a/codegen/BUILD.bazel b/codegen/BUILD.bazel index 1e833bf3..1896add0 100644 --- a/codegen/BUILD.bazel +++ b/codegen/BUILD.bazel @@ -2,7 +2,7 @@ load("@rules_java//java:defs.bzl", "java_binary", "java_library") package(default_visibility = ["//visibility:public"]) -# Read by //tools:release_test, which pins it to smithy::Version(). +# Read by //tools:release_test, which pins it to opal::Version(). exports_files(["gradle.properties"]) # The generator, compiled from the same sources the Gradle build uses, so the diff --git a/codegen/compile-tests/gauntlet_compile_test.cc b/codegen/compile-tests/gauntlet_compile_test.cc index a8359a65..85e9e3b0 100644 --- a/codegen/compile-tests/gauntlet_compile_test.cc +++ b/codegen/compile-tests/gauntlet_compile_test.cc @@ -110,7 +110,7 @@ TEST(GauntletCompileTest, RecursiveShapesUseValueSemanticBoxes) { root.label = "root"; rest::Node child; child.label = "child"; - root.next = smithy::Boxed(child); + root.next = opal::Boxed(child); root.children = std::vector{child}; const rest::Node copy = root; // deep copy through the box EXPECT_EQ(copy, root); @@ -137,23 +137,23 @@ TEST(GauntletCompileTest, EveryProtocolEmitsTheGauntletShapes) { TEST(GauntletCompileTest, StreamingServersExposeAStreamRouter) { namespace rest_stream = compile::streaming::rest; struct Handler : rest_stream::RelayHandler { - smithy::Outcome Converse( + opal::Outcome Converse( const rest_stream::ConverseInput& input, - smithy::eventstream::EventStream& + opal::eventstream::EventStream& stream, - const smithy::server::RequestContext&) override { + const opal::server::RequestContext&) override { rest_stream::MemberJoined joined; joined.member = input.room; (void)stream.Send(rest_stream::ServerEvents::FromJoined(joined)); - return smithy::Unit{}; + return opal::Unit{}; } - smithy::Outcome Watch( + opal::Outcome Watch( const rest_stream::WatchInput&, - smithy::eventstream::EventStream& + opal::eventstream::EventStream& stream, - const smithy::server::RequestContext&) override { + const opal::server::RequestContext&) override { stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } }; rest_stream::RelayServer server(std::make_shared()); diff --git a/codegen/compile-tests/streaming_compile_test.cc b/codegen/compile-tests/streaming_compile_test.cc index abdad36d..00730b57 100644 --- a/codegen/compile-tests/streaming_compile_test.cc +++ b/codegen/compile-tests/streaming_compile_test.cc @@ -1,6 +1,6 @@ // The streaming halves of the compile harness, behaviorally (ADR-0016). A // separate target from gauntlet_compile_test because generated streaming -// clients fall back to smithy::http::BeastWebSocketClient::Dialer(), so +// clients fall back to opal::http::BeastWebSocketClient::Dialer(), so // linking them pulls in Boost — this test joins the Beast targets behind the // documented local exclusion list (docs/development.md); CI runs it. The // injected in-memory dialer below is the ClientConfig::websocket_dialer seam @@ -49,7 +49,7 @@ namespace wire = compile::streaming::jsonrpc; // first so the thread's blocked Receive drains: an ASSERT's early return // must neither terminate on a joinable thread nor deadlock the join. struct ServeJoin { - std::shared_ptr peer; + std::shared_ptr peer; std::thread thread; ~ServeJoin() { peer->Close(); @@ -59,14 +59,14 @@ struct ServeJoin { // A dialer handing out one end of an in-memory pair, keeping the other for // the test to play the server and the full dial request for assertions. -smithy::ClientConfig InMemoryConfig(std::shared_ptr* server_end, - smithy::http::WebSocketDialRequest* dialed) { - smithy::ClientConfig config; +opal::ClientConfig InMemoryConfig(std::shared_ptr* server_end, + opal::http::WebSocketDialRequest* dialed) { + opal::ClientConfig config; config.endpoint = "http://localhost:8080"; - config.websocket_dialer = [server_end, dialed](const smithy::http::WebSocketDialRequest& request) - -> smithy::Outcome> { + config.websocket_dialer = [server_end, dialed](const opal::http::WebSocketDialRequest& request) + -> opal::Outcome> { *dialed = request; - auto [near, far] = smithy::http::InMemoryWebSocketPair::Create(); + auto [near, far] = opal::http::InMemoryWebSocketPair::Create(); *server_end = std::move(far); return near; }; @@ -74,8 +74,8 @@ smithy::ClientConfig InMemoryConfig(std::shared_ptr* se } TEST(StreamingCompileTest, RestClientOpensAServerPushStream) { - std::shared_ptr server_end; - smithy::http::WebSocketDialRequest dialed; + std::shared_ptr server_end; + opal::http::WebSocketDialRequest dialed; auto client = relay::RelayClient::Create(InMemoryConfig(&server_end, &dialed)); ASSERT_TRUE(client.ok()); @@ -93,9 +93,9 @@ TEST(StreamingCompileTest, TheUpgradeDialCarriesAuthQueryAndHeaderBindings) { // The service's auth traits ride the upgrade dial exactly like a unary // request: @httpBearerAuth attaches the configured token, and the modeled // query/header initial members resolve onto the dial request. - std::shared_ptr server_end; - smithy::http::WebSocketDialRequest dialed; - smithy::ClientConfig config = InMemoryConfig(&server_end, &dialed); + std::shared_ptr server_end; + opal::http::WebSocketDialRequest dialed; + opal::ClientConfig config = InMemoryConfig(&server_end, &dialed); config.bearer_token = [] { return std::string("sesame"); }; auto client = relay::RelayClient::Create(std::move(config)); ASSERT_TRUE(client.ok()); @@ -113,9 +113,9 @@ TEST(StreamingCompileTest, TheUpgradeDialCarriesAuthQueryAndHeaderBindings) { } TEST(StreamingCompileTest, CborClientExchangesOnTheFixedUpgradeUri) { - std::shared_ptr server_end; - smithy::http::WebSocketDialRequest dialed; - smithy::ClientConfig config = InMemoryConfig(&server_end, &dialed); + std::shared_ptr server_end; + opal::http::WebSocketDialRequest dialed; + opal::ClientConfig config = InMemoryConfig(&server_end, &dialed); // @httpApiKeyAuth(in: "header"): the key rides the upgrade request. config.api_key = [] { return std::string("key-123"); }; auto client = pipe::PipeClient::Create(std::move(config)); @@ -136,32 +136,32 @@ TEST(StreamingCompileTest, CborClientExchangesOnTheFixedUpgradeUri) { auto frame = server_end->Receive(); ASSERT_TRUE(frame.ok()); ASSERT_TRUE(frame->has_value()); - auto envelope = smithy::eventstream::ParseEnvelope(**frame); + auto envelope = opal::eventstream::ParseEnvelope(**frame); ASSERT_TRUE(envelope.ok()); - EXPECT_EQ(envelope->kind, smithy::eventstream::EventEnvelope::Kind::kEvent); + EXPECT_EQ(envelope->kind, opal::eventstream::EventEnvelope::Kind::kEvent); EXPECT_EQ(envelope->type, "message"); EXPECT_EQ(envelope->content_type, "application/cbor"); - auto payload = smithy::cbor::Decode(envelope->payload); + auto payload = opal::cbor::Decode(envelope->payload); ASSERT_TRUE(payload.ok()); ASSERT_TRUE(payload->is_map()); - const smithy::Document* text = payload->Find("text"); + const opal::Document* text = payload->Find("text"); ASSERT_NE(text, nullptr); ASSERT_TRUE(text->is_string()); EXPECT_EQ(text->as_string(), "hello"); - const smithy::Document* sender = payload->Find("sender"); + const opal::Document* sender = payload->Find("sender"); ASSERT_NE(sender, nullptr); ASSERT_TRUE(sender->is_string()); EXPECT_EQ(sender->as_string(), "ada"); // The other direction: the test plays the server, minting the same // envelope shape; the generated decoder yields the typed event. - smithy::DocumentMap joined; - joined.emplace("member", smithy::Document("ada")); - ASSERT_TRUE(server_end - ->Send(smithy::eventstream::MakeEventMessage( - "joined", "application/cbor", - smithy::cbor::Encode(smithy::Document(std::move(joined))))) - .ok()); + opal::DocumentMap joined; + joined.emplace("member", opal::Document("ada")); + ASSERT_TRUE( + server_end + ->Send(opal::eventstream::MakeEventMessage( + "joined", "application/cbor", opal::cbor::Encode(opal::Document(std::move(joined))))) + .ok()); auto received = stream->Receive(); ASSERT_TRUE(received.ok()); ASSERT_TRUE(received->has_value()); @@ -175,9 +175,9 @@ TEST(StreamingCompileTest, JsonRpcClientOpensOnTheSharedEndpoint) { // The ADR-0023 face: the dial targets the protocol's shared endpoint on // the raw-text wire, auth rides the upgrade like everywhere else, and // the opening request envelope carries the initial-request members. - std::shared_ptr server_end; - smithy::http::WebSocketDialRequest dialed; - smithy::ClientConfig config = InMemoryConfig(&server_end, &dialed); + std::shared_ptr server_end; + opal::http::WebSocketDialRequest dialed; + opal::ClientConfig config = InMemoryConfig(&server_end, &dialed); config.bearer_token = [] { return std::string("sesame"); }; auto client = wire::WireClient::Create(std::move(config)); ASSERT_TRUE(client.ok()); @@ -201,8 +201,8 @@ TEST(StreamingCompileTest, JsonRpcClientOpensOnTheSharedEndpoint) { TEST(StreamingCompileTest, JsonRpcWatchOpensWithEmptyParams) { // The Unit-input face: no params to serialize, still an (empty) params // member on the opening envelope; the transmit direction is NoEvents. - std::shared_ptr server_end; - smithy::http::WebSocketDialRequest dialed; + std::shared_ptr server_end; + opal::http::WebSocketDialRequest dialed; auto client = wire::WireClient::Create(InMemoryConfig(&server_end, &dialed)); ASSERT_TRUE(client.ok()); @@ -228,22 +228,22 @@ TEST(StreamingCompileTest, JsonRpcWatchOpensWithEmptyParams) { class NeverCalledHandler final : public relay::RelayHandler { public: - smithy::Outcome Converse(const relay::ConverseInput&, relay::ConverseServerStream&, - const smithy::server::RequestContext&) override { + opal::Outcome Converse(const relay::ConverseInput&, relay::ConverseServerStream&, + const opal::server::RequestContext&) override { ADD_FAILURE() << "handler ran despite a validation failure"; - return smithy::Unit{}; + return opal::Unit{}; } - smithy::Outcome Watch(const relay::WatchInput&, relay::WatchServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Watch(const relay::WatchInput&, relay::WatchServerStream& stream, + const opal::server::RequestContext&) override { stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } }; TEST(StreamValidationTest, AnInvalidLabelRefusesWithOneExceptionThenTheClose) { relay::RelayServer server(std::make_shared()); - auto [client_end, server_end] = smithy::http::InMemoryWebSocketPair::Create(); - smithy::http::HttpRequest upgrade; + auto [client_end, server_end] = opal::http::InMemoryWebSocketPair::Create(); + opal::http::HttpRequest upgrade; upgrade.method = "GET"; upgrade.target = "/rooms/waytoolongroom/converse"; // @length(max: 8) violated ServeJoin serve{client_end, std::thread([serve = server.StreamRouter()->Serve(), upgrade, @@ -251,9 +251,9 @@ TEST(StreamValidationTest, AnInvalidLabelRefusesWithOneExceptionThenTheClose) { auto refusal = client_end->Receive(); ASSERT_TRUE(refusal.ok() && refusal->has_value()); - auto envelope = smithy::eventstream::ParseEnvelope(**refusal); + auto envelope = opal::eventstream::ParseEnvelope(**refusal); ASSERT_TRUE(envelope.ok()) << envelope.error().message(); - EXPECT_EQ(envelope->kind, smithy::eventstream::EventEnvelope::Kind::kException); + EXPECT_EQ(envelope->kind, opal::eventstream::EventEnvelope::Kind::kException); EXPECT_EQ(envelope->type, "SerializationException"); auto closed = client_end->Receive(); @@ -265,22 +265,22 @@ TEST(StreamValidationTest, AnInvalidLabelRefusesWithOneExceptionThenTheClose) { // seam's identical refusal — before any coroutine exists. class NeverCalledAsyncHandler final : public relay::RelayAsyncHandler { public: - smithy::eventstream::StreamTask Converse(relay::ConverseInput, - relay::ConverseAsyncServerStream&) override { + opal::eventstream::StreamTask Converse(relay::ConverseInput, + relay::ConverseAsyncServerStream&) override { ADD_FAILURE() << "async handler launched despite a validation failure"; - co_return smithy::Unit{}; + co_return opal::Unit{}; } - smithy::eventstream::StreamTask Watch(relay::WatchInput, - relay::WatchAsyncServerStream& stream) override { + opal::eventstream::StreamTask Watch(relay::WatchInput, + relay::WatchAsyncServerStream& stream) override { (void)co_await stream.Receive(); - co_return smithy::Unit{}; + co_return opal::Unit{}; } }; TEST(StreamValidationTest, TheSessionSeamRefusesAnInvalidLabelIdentically) { relay::RelayServer server(std::make_shared()); - auto [client_end, server_end] = smithy::http::InMemoryWebSocketPair::Create(); - smithy::http::HttpRequest upgrade; + auto [client_end, server_end] = opal::http::InMemoryWebSocketPair::Create(); + opal::http::HttpRequest upgrade; upgrade.method = "GET"; upgrade.target = "/rooms/waytoolongroom/converse"; // @length(max: 8) violated // The launch point refuses inline — no serve thread, no coroutine. @@ -288,9 +288,9 @@ TEST(StreamValidationTest, TheSessionSeamRefusesAnInvalidLabelIdentically) { auto refusal = client_end->Receive(); ASSERT_TRUE(refusal.ok() && refusal->has_value()); - auto envelope = smithy::eventstream::ParseEnvelope(**refusal); + auto envelope = opal::eventstream::ParseEnvelope(**refusal); ASSERT_TRUE(envelope.ok()) << envelope.error().message(); - EXPECT_EQ(envelope->kind, smithy::eventstream::EventEnvelope::Kind::kException); + EXPECT_EQ(envelope->kind, opal::eventstream::EventEnvelope::Kind::kException); EXPECT_EQ(envelope->type, "SerializationException"); auto closed = client_end->Receive(); @@ -304,46 +304,45 @@ TEST(StreamValidationTest, TheSessionSeamRefusesAnInvalidLabelIdentically) { // refusal happens after the first message, not at the upgrade. class NeverCalledWireHandler final : public wire::WireHandler { public: - smithy::Outcome Confer(const wire::ConferInput&, wire::ConferServerStream&, - const smithy::server::RequestContext&) override { + opal::Outcome Confer(const wire::ConferInput&, wire::ConferServerStream&, + const opal::server::RequestContext&) override { ADD_FAILURE() << "handler ran despite a validation failure"; - return smithy::Unit{}; + return opal::Unit{}; } - smithy::Outcome Watch(const wire::WatchInput&, wire::WatchServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Watch(const wire::WatchInput&, wire::WatchServerStream& stream, + const opal::server::RequestContext&) override { stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } }; class NeverCalledAsyncWireHandler final : public wire::WireAsyncHandler { public: - smithy::eventstream::StreamTask Confer(wire::ConferInput, - wire::ConferAsyncServerStream&) override { + opal::eventstream::StreamTask Confer(wire::ConferInput, wire::ConferAsyncServerStream&) override { ADD_FAILURE() << "async handler launched despite a validation failure"; - co_return smithy::Unit{}; + co_return opal::Unit{}; } - smithy::eventstream::StreamTask Watch(wire::WatchInput, - wire::WatchAsyncServerStream& stream) override { + opal::eventstream::StreamTask Watch(wire::WatchInput, + wire::WatchAsyncServerStream& stream) override { (void)co_await stream.Receive(); - co_return smithy::Unit{}; + co_return opal::Unit{}; } }; TEST(StreamValidationTest, TheJsonRpcWireRefusesTheSameConstraintOnBothSeams) { const std::string opening = R"({"jsonrpc":"2.0","method":"Confer","params":{"room":"waytoolongroom"},"id":5})"; - smithy::http::HttpRequest upgrade; + opal::http::HttpRequest upgrade; upgrade.method = "GET"; upgrade.target = "/"; // Session seam: the driver reads the opening inside its Detached frame, // refuses, and closes — inline over the pair. wire::WireServer async_server(std::make_shared()); - auto [async_client_end, async_server_end] = smithy::http::InMemoryWebSocketPair::Create(); + auto [async_client_end, async_server_end] = opal::http::InMemoryWebSocketPair::Create(); async_server.StreamRouter()->ServeSession()(upgrade, async_server_end); - smithy::eventstream::Message open_message; - open_message.payload = smithy::Blob::FromString(opening); + opal::eventstream::Message open_message; + open_message.payload = opal::Blob::FromString(opening); ASSERT_TRUE(async_client_end->Send(open_message).ok()); auto refusal = async_client_end->Receive(); ASSERT_TRUE(refusal.ok() && refusal->has_value()); @@ -357,7 +356,7 @@ TEST(StreamValidationTest, TheJsonRpcWireRefusesTheSameConstraintOnBothSeams) { // Blocking seam: identical bytes through the served thread. wire::WireServer blocking_server(std::make_shared()); - auto [client_end, server_end] = smithy::http::InMemoryWebSocketPair::Create(); + auto [client_end, server_end] = opal::http::InMemoryWebSocketPair::Create(); ServeJoin serve{client_end, std::thread([serve = blocking_server.StreamRouter()->Serve(), upgrade, session = server_end] { serve(upgrade, *session); })}; ASSERT_TRUE(client_end->Send(open_message).ok()); @@ -380,63 +379,62 @@ TEST(StreamValidationTest, TheJsonRpcWireRefusesTheSameConstraintOnBothSeams) { // Echoes messages back prefixed until one says "gone", then fails modeled. class EchoHandler final : public pipe::PipeHandler { public: - smithy::Outcome Exchange(const pipe::ExchangeInput&, - pipe::ExchangeServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Exchange(const pipe::ExchangeInput&, pipe::ExchangeServerStream& stream, + const opal::server::RequestContext&) override { while (true) { auto event = stream.Receive(); - if (!event.ok() || !event->has_value()) return smithy::Unit{}; + if (!event.ok() || !event->has_value()) return opal::Unit{}; if (!(**event).is_message()) continue; const std::string& text = (**event).as_message().text; if (text == "gone") { - smithy::Error gone = smithy::Error::Modeled("RoomGone", "the room left"); + opal::Error gone = opal::Error::Modeled("RoomGone", "the room left"); gone.set_detail(pipe::RoomGone{.message = "the room left"}); return gone; } pipe::ChatMessage echo; echo.text = "echo:" + text; - if (!stream.Send(pipe::ServerEvents::FromMessage(echo)).ok()) return smithy::Unit{}; + if (!stream.Send(pipe::ServerEvents::FromMessage(echo)).ok()) return opal::Unit{}; } } - smithy::Outcome Watch(const pipe::WatchInput&, pipe::WatchServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Watch(const pipe::WatchInput&, pipe::WatchServerStream& stream, + const opal::server::RequestContext&) override { pipe::ChatMessage message; message.text = "pushed"; (void)stream.Send(pipe::ServerEvents::FromMessage(message)); - return smithy::Unit{}; + return opal::Unit{}; } }; // The async EchoHandler (ADR-0021): the same wire behavior, co_awaited. class EchoAsyncHandler final : public pipe::PipeAsyncHandler { public: - smithy::eventstream::StreamTask Exchange(pipe::ExchangeInput, - pipe::ExchangeAsyncServerStream& stream) override { + opal::eventstream::StreamTask Exchange(pipe::ExchangeInput, + pipe::ExchangeAsyncServerStream& stream) override { while (true) { auto event = co_await stream.Receive(); - if (!event.ok() || !event->has_value()) co_return smithy::Unit{}; + if (!event.ok() || !event->has_value()) co_return opal::Unit{}; if (!(**event).is_message()) continue; const std::string& text = (**event).as_message().text; if (text == "gone") { - smithy::Error gone = smithy::Error::Modeled("RoomGone", "the room left"); + opal::Error gone = opal::Error::Modeled("RoomGone", "the room left"); gone.set_detail(pipe::RoomGone{.message = "the room left"}); co_return gone; } pipe::ChatMessage echo; echo.text = "echo:" + text; if (!(co_await stream.Send(pipe::ServerEvents::FromMessage(echo))).ok()) { - co_return smithy::Unit{}; + co_return opal::Unit{}; } } } - smithy::eventstream::StreamTask Watch(pipe::WatchInput, - pipe::WatchAsyncServerStream& stream) override { + opal::eventstream::StreamTask Watch(pipe::WatchInput, + pipe::WatchAsyncServerStream& stream) override { pipe::ChatMessage message; message.text = "pushed"; (void)co_await stream.Send(pipe::ServerEvents::FromMessage(message)); - co_return smithy::Unit{}; + co_return opal::Unit{}; } }; @@ -451,15 +449,14 @@ class CborStreamEndToEndTest : public testing::Test { // earlier sessions stay owned until TearDown. void Start(std::unique_ptr server, bool session_seam) { server_ = std::move(server); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; - config.http_client = std::make_shared(); - config.websocket_dialer = [this, - session_seam](const smithy::http::WebSocketDialRequest& request) - -> smithy::Outcome> { + config.http_client = std::make_shared(); + config.websocket_dialer = [this, session_seam](const opal::http::WebSocketDialRequest& request) + -> opal::Outcome> { dialed_target_ = request.target; - auto [near, far] = smithy::http::InMemoryWebSocketPair::Create(); - smithy::http::HttpRequest upgrade; + auto [near, far] = opal::http::InMemoryWebSocketPair::Create(); + opal::http::HttpRequest upgrade; upgrade.method = "GET"; upgrade.target = request.target; upgrade.headers = request.headers; @@ -485,7 +482,7 @@ class CborStreamEndToEndTest : public testing::Test { std::unique_ptr server_; std::unique_ptr client_; - std::vector> sessions_; + std::vector> sessions_; std::vector threads_; std::string dialed_target_; }; @@ -518,7 +515,7 @@ TEST_F(CborStreamEndToEndTest, RoomGoneRoundTripsAsATypedMidStreamError) { ASSERT_TRUE(stream->Send(pipe::ClientEvents::FromMessage(message)).ok()); auto outcome = stream->Receive(); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "RoomGone"); EXPECT_EQ(outcome.error().message(), "the room left"); const pipe::RoomGone* detail = outcome.error().detail(); diff --git a/codegen/smithy-cpp-codegen/build.gradle.kts b/codegen/smithy-cpp-codegen/build.gradle.kts index 2b65822a..610d3de6 100644 --- a/codegen/smithy-cpp-codegen/build.gradle.kts +++ b/codegen/smithy-cpp-codegen/build.gradle.kts @@ -139,7 +139,7 @@ fun registerProtocolTestTask( val generateSimpleRestJsonProtocolTests = registerProtocolTestTask( "generateSimpleRestJsonProtocolTests", "alloy.test#PizzaAdminService", - "smithy::protocoltests::simplerestjson", + "opal::protocoltests::simplerestjson", "protocol-tests/simplerestjson/generated", omitOperations = listOf( // alloy-protocol-tests 0.3.32+: PrimitiveEncodings.duration targets @@ -153,7 +153,7 @@ val generateSimpleRestJsonProtocolTests = registerProtocolTestTask( val generateRpcv2CborProtocolTests = registerProtocolTestTask( "generateRpcv2CborProtocolTests", "smithy.protocoltests.rpcv2Cbor#RpcV2Protocol", - "smithy::protocoltests::rpcv2cbor", + "opal::protocoltests::rpcv2cbor", "protocol-tests/rpcv2cbor/generated", malformedTests = true, ) @@ -164,7 +164,7 @@ val generateRpcv2CborProtocolTests = registerProtocolTestTask( val generateJsonRpc2ProtocolTests = registerProtocolTestTask( "generateJsonRpc2ProtocolTests", "smithy.cpp.protocoltests.jsonrpc2#JsonRpc2Protocol", - "smithy::protocoltests::jsonrpc2", + "opal::protocoltests::jsonrpc2", "protocol-tests/jsonrpc2/generated", malformedTests = true, modelPath = "protocol-tests/jsonrpc2/model/jsonrpc2.smithy", diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ClientGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ClientGenerator.java index c788fd2e..c2a762d9 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ClientGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ClientGenerator.java @@ -67,14 +67,14 @@ private void writeHeader(CppWriter w) { w, context, service, streamingOperations(), /* serverSide= */ false); } w.write("/// $L client for $L.", protocol.name(), service.getId().toString()); - w.write("/// Modeled service errors surface as smithy::Error with kind kModeled,"); + w.write("/// Modeled service errors surface as opal::Error with kind kModeled,"); w.write("/// code() set to the error shape name, and the deserialized error"); w.write("/// structure attached. Dispatch on them through the per-operation"); w.write("/// Errors listings below rather than comparing code() text."); w.openBlock("class $L {", name); w.write("public:").indent(); w.write("/// Fails when the endpoint cannot be parsed and no transport is injected."); - w.write("static smithy::Outcome<$L> Create(smithy::ClientConfig config);", name); + w.write("static opal::Outcome<$L> Create(opal::ClientConfig config);", name); w.write(""); for (OperationShape operation : operations()) { boolean documented = operation.hasTrait(DocumentationTrait.class); @@ -109,7 +109,7 @@ private void writeHeader(CppWriter w) { w.write("/// surfaces through Receive() as a modeled error, the unary shape."); } w.write( - "smithy::Outcome<$L> $L(const $L& input$L) const;", + "opal::Outcome<$L> $L(const $L& input$L) const;", EventStreamCodeGen.clientStreamAlias(operation), CppReservedWords.escape(operation.getId().getName()), inputType, @@ -117,7 +117,7 @@ private void writeHeader(CppWriter w) { continue; } w.write( - "smithy::Outcome<$L> $L(const $L& input$L) const;", + "opal::Outcome<$L> $L(const $L& input$L) const;", outputType, CppReservedWords.escape(operation.getId().getName()), inputType, @@ -137,15 +137,15 @@ private void writeHeader(CppWriter w) { w.write("").dedent(); w.write("private:").indent(); w.write( - "$L(smithy::ClientConfig config, std::shared_ptr " + "$L(opal::ClientConfig config, std::shared_ptr " + "transport, std::string path_prefix);", name); w.write( - "smithy::Outcome " - + "Send(smithy::http::HttpRequest request) const;"); + "opal::Outcome " + + "Send(opal::http::HttpRequest request) const;"); w.write(""); - w.write("smithy::ClientConfig config_;"); - w.write("std::shared_ptr transport_;"); + w.write("opal::ClientConfig config_;"); + w.write("std::shared_ptr transport_;"); w.write("std::string path_prefix_;").dedent(); w.closeBlock("};"); w.write(""); @@ -161,11 +161,11 @@ private void writeHeader(CppWriter w) { w.write("public:").indent(); w.write("/// The next page, std::nullopt once pagination is complete, or the"); w.write("/// first failed call's error (pagination then stops)."); - w.write("smithy::Outcome> Next();", outputType); + w.write("opal::Outcome> Next();", outputType); w.write(""); w.write("using Page = $L;", outputType); w.write("/// Single-pass range over pages — contract in smithy/client/pagination.h."); - String iterator = "smithy::PageIterator<" + paginatorName(operation) + ">"; + String iterator = "opal::PageIterator<" + paginatorName(operation) + ">"; w.write("$1L begin() { return $1L(this); }", iterator); w.write("$L end() { return {}; }", iterator); w.write("").dedent(); @@ -223,7 +223,7 @@ private void writeErrorListing(CppWriter w, OperationShape operation) { .toList(); String opName = CppReservedWords.escape(operation.getId().getName()); - w.write("/// The modeled errors of $L, matched from a smithy::Error so dispatch is", opName); + w.write("/// The modeled errors of $L, matched from a opal::Error so dispatch is", opName); w.write("/// typed and exhaustive instead of string-compared. FromError() is empty()"); w.write("/// when the error is none of this operation's modeled errors (transport,"); w.write("/// serialization, unknown, or another operation's error)."); @@ -244,9 +244,9 @@ private void writeFromError(CppWriter w, String listingName, List $L::Create(smithy::ClientConfig config) {", name, name); - w.write("std::shared_ptr transport = config.http_client;"); + w.openBlock("opal::Outcome<$L> $L::Create(opal::ClientConfig config) {", name, name); + w.write("std::shared_ptr transport = config.http_client;"); w.write("std::string prefix;"); w.openBlock("if (!config.endpoint.empty()) {"); - w.write("auto endpoint = smithy::http::ParseEndpoint(config.endpoint);"); + w.write("auto endpoint = opal::http::ParseEndpoint(config.endpoint);"); w.write("if (!endpoint) return std::move(endpoint).error();"); w.write("prefix = endpoint->path_prefix;"); w.openBlock("if (transport == nullptr) {"); w.write("// The built-in socket transport is plaintext-only; https needs a"); - w.write("// TLS-capable transport (e.g. smithy::http::BeastHttpClient)."); + w.write("// TLS-capable transport (e.g. opal::http::BeastHttpClient)."); w.openBlock("if (endpoint->tls()) {"); w.write( - "return smithy::Error::Validation($S);", + "return opal::Error::Validation($S);", name + ": https endpoints need a TLS-capable transport" - + " (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + + " (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); w.closeBlock("}"); w.write( - "transport = std::make_shared(endpoint->host, " + "transport = std::make_shared(endpoint->host, " + "endpoint->port, config.request_timeout_ms);"); w.closeBlock("}"); w.closeBlock("}"); w.openBlock("if (transport == nullptr) {"); w.write( - "return smithy::Error::Validation($S);", + "return opal::Error::Validation($S);", name + ": config needs an endpoint or an http_client"); w.closeBlock("}"); w.write("return $L(std::move(config), std::move(transport), std::move(prefix));", name); @@ -390,8 +390,8 @@ private void writeSource(CppWriter w) { w.write(""); w.openBlock( - "$L::$L(smithy::ClientConfig config, " - + "std::shared_ptr transport, std::string path_prefix)", + "$L::$L(opal::ClientConfig config, " + + "std::shared_ptr transport, std::string path_prefix)", name, name); w.write(": config_(std::move(config)),"); @@ -401,8 +401,8 @@ private void writeSource(CppWriter w) { w.write(""); w.openBlock( - "smithy::Outcome $L::Send(" - + "smithy::http::HttpRequest request) const {", + "opal::Outcome $L::Send(" + + "opal::http::HttpRequest request) const {", name); w.write("// Operations with a non-document response payload set their own accept."); w.write( @@ -415,7 +415,7 @@ private void writeSource(CppWriter w) { w.write("request.headers.Set(\"content-length\", std::to_string(request.body.size()));"); w.closeBlock("}"); w.write( - "return smithy::SendWithRetries(*transport_, request, config_.retry, " + "return opal::SendWithRetries(*transport_, request, config_.retry, " + "config_.interceptors);"); w.closeBlock("}"); w.write(""); @@ -432,7 +432,7 @@ private void writeSource(CppWriter w) { .toSymbol(ProtocolSupport.outputShape(context, operation)) .getName(); w.openBlock( - "smithy::Outcome<$L> $L::$L(const $L& input) const {", + "opal::Outcome<$L> $L::$L(const $L& input) const {", outputType, name, CppReservedWords.escape(operation.getId().getName()), @@ -476,7 +476,7 @@ private void writePaginator( // The output token is always optional: Smithy's paginated validator // rejects @required output tokens at assembly (pinned by // ConditionalWiringCoverageTest), so there is no plain-member arm here. - w.openBlock("smithy::Outcome> $L::Next() {", outputType, pager); + w.openBlock("opal::Outcome> $L::Next() {", outputType, pager); w.write("if (done_) return std::optional<$L>();", outputType); w.write("auto page = client_.$L(input_);", opName); w.openBlock("if (!page) {"); diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/CppCodegenPlugin.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/CppCodegenPlugin.java index 6e988a31..7c4e4bbf 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/CppCodegenPlugin.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/CppCodegenPlugin.java @@ -42,7 +42,7 @@ public void execute(PluginContext context) { } /** - * Recursive structure members are supported via smithy::Boxed (and lists via std::vector's + * Recursive structure members are supported via opal::Boxed (and lists via std::vector's * incomplete-element support), but cycles through union members or map values still need * representation work; fail generation with a clear message instead of emitting non-compiling * code. diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/CppSymbolProvider.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/CppSymbolProvider.java index 807a0bba..55d9a94d 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/CppSymbolProvider.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/CppSymbolProvider.java @@ -67,8 +67,8 @@ RecursionIndex recursion() { /** * Whether the shape's C++ type is three-way-comparable, i.e. whether the generators emit a * defaulted operator<=> for it (docs/generated-types.md's ordering caveats): nothing in its - * member closure is a document (smithy::Document has no ordering) or on a recursion cycle - * (smithy::Boxed is deliberately equality-only — an auto-returning deep <=> is a hard error to + * member closure is a document (opal::Document has no ordering) or on a recursion cycle + * (opal::Boxed is deliberately equality-only — an auto-returning deep <=> is a hard error to * deduce around a cycle on clang). Memoized for the run. */ boolean orderable(Shape shape) { @@ -91,8 +91,8 @@ public String toMemberName(MemberShape member) { } /** - * Full member type text: the target type, wrapped in smithy::Boxed for recursive structure - * members and in std::optional unless @required or populated by @default. + * Full member type text: the target type, wrapped in opal::Boxed for recursive structure members + * and in std::optional unless @required or populated by @default. */ Symbol toMemberSymbol(MemberShape member) { Symbol target = toSymbol(model.expectShape(member.getTarget())); @@ -100,7 +100,7 @@ Symbol toMemberSymbol(MemberShape member) { Set headers = new TreeSet<>(headersOf(target)); boolean plain = MemberDefaults.plain(model, member); if (recursion.isBoxed(member)) { - name = "smithy::Boxed<" + name + ">"; + name = "opal::Boxed<" + name + ">"; headers.add("\"smithy/core/boxed.h\""); } else if (plain) { return target; @@ -154,7 +154,7 @@ private static String escapeTypeName(String name) { /** * The spelling generated .cc code uses to reference a shape's C++ type where a file-local helper * could otherwise shadow it (issue #71): declared model types go through the file-level {@code - * types} namespace alias ({@link CppWriter}); builtin mappings (std::string, float, smithy::Blob, + * types} namespace alias ({@link CppWriter}); builtin mappings (std::string, float, opal::Blob, * ...) have no model-controlled name and stay bare. */ String typeRef(Shape shape) { @@ -167,7 +167,7 @@ String typeRef(Shape shape) { /** * Whether the shape declares a C++ type name in the generated module — the filter behind {@link - * #declaredName}. smithy.api#Unit maps to the runtime's smithy::Unit and declares nothing. + * #declaredName}. smithy.api#Unit maps to the runtime's opal::Unit and declares nothing. */ static boolean declaresType(Shape shape) { return (shape.isStructureShape() @@ -247,7 +247,7 @@ protected Symbol getDefault(Shape shape) { @Override public Symbol blobShape(BlobShape shape) { - return builder("smithy::Blob", Set.of("\"smithy/core/blob.h\"")).build(); + return builder("opal::Blob", Set.of("\"smithy/core/blob.h\"")).build(); } @Override @@ -312,12 +312,12 @@ public Symbol intEnumShape(IntEnumShape shape) { @Override public Symbol timestampShape(TimestampShape shape) { - return builder("smithy::Timestamp", Set.of("\"smithy/core/timestamp.h\"")).build(); + return builder("opal::Timestamp", Set.of("\"smithy/core/timestamp.h\"")).build(); } @Override public Symbol documentShape(DocumentShape shape) { - return builder("smithy::Document", Set.of("\"smithy/core/document.h\"")).build(); + return builder("opal::Document", Set.of("\"smithy/core/document.h\"")).build(); } @Override @@ -340,7 +340,7 @@ public Symbol mapShape(MapShape shape) { @Override public Symbol structureShape(StructureShape shape) { if (shape.getId().toString().equals("smithy.api#Unit")) { - return builder("smithy::Unit", Set.of("\"smithy/core/outcome.h\"")).build(); + return builder("opal::Unit", Set.of("\"smithy/core/outcome.h\"")).build(); } return declared(shape); } diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/DirectedCppCodegen.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/DirectedCppCodegen.java index 2f4f0fd0..e0baac2a 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/DirectedCppCodegen.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/DirectedCppCodegen.java @@ -155,7 +155,7 @@ private static ProtocolGenerator resolveProtocol( @Override public void generateStructure(GenerateStructureDirective directive) { if (directive.shape().getId().toString().equals("smithy.api#Unit")) { - return; // Maps to the runtime's smithy::Unit; nothing to declare. + return; // Maps to the runtime's opal::Unit; nothing to declare. } directive .context() diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/EventStreamCodeGen.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/EventStreamCodeGen.java index 7f051b82..9268489b 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/EventStreamCodeGen.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/EventStreamCodeGen.java @@ -222,12 +222,12 @@ private static Map modeledErrors( private static String eventUnionType(CppContext context, Optional info) { return info.map(i -> context.cppSymbols().toSymbol(eventUnion(i)).getName()) - .orElse("smithy::eventstream::NoEvents"); + .orElse("opal::eventstream::NoEvents"); } /** The client's session type: Tx = the input event union, Rx = the output event union. */ static String clientStreamType(CppContext context, OperationShape operation) { - return "smithy::eventstream::EventStream<" + return "opal::eventstream::EventStream<" + eventUnionType(context, inputInfo(context.model(), operation)) + ", " + eventUnionType(context, outputInfo(context.model(), operation)) @@ -236,7 +236,7 @@ static String clientStreamType(CppContext context, OperationShape operation) { /** The handler's session type: the client's with the parameters swapped. */ static String serverStreamType(CppContext context, OperationShape operation) { - return "smithy::eventstream::EventStream<" + return "opal::eventstream::EventStream<" + eventUnionType(context, outputInfo(context.model(), operation)) + ", " + eventUnionType(context, inputInfo(context.model(), operation)) @@ -245,7 +245,7 @@ static String serverStreamType(CppContext context, OperationShape operation) { /** The async handler's session type (ADR-0021): {@link #serverStreamType}'s coroutine sibling. */ static String asyncServerStreamType(CppContext context, OperationShape operation) { - return "smithy::eventstream::AsyncEventStream<" + return "opal::eventstream::AsyncEventStream<" + eventUnionType(context, outputInfo(context.model(), operation)) + ", " + eventUnionType(context, inputInfo(context.model(), operation)) @@ -336,14 +336,14 @@ static void writeTestHandlerStub(CppWriter w, CppContext context, OperationShape w.write("// Streaming operation (ADR-0016): no generated unary-shaped test drives"); w.write("// this; the stub closes the stream so the interface stays implemented."); w.openBlock( - "smithy::Outcome $L(const $L& input, $L& stream, $L) override {", + "opal::Outcome $L(const $L& input, $L& stream, $L) override {", opName(operation), inputType, serverStreamAlias(operation), ProtocolSupport.REQUEST_CONTEXT_PARAM); w.write("(void)input;"); w.write("stream.Close();"); - w.write("return smithy::Unit{};"); + w.write("return opal::Unit{};"); w.closeBlock("}"); } @@ -369,10 +369,10 @@ static void writeClientStreamHelpers( w.write("// configured twice); config.websocket_dialer overrides the Beast dialer the"); w.write("// way http_client overrides the unary transport."); w.openBlock( - "smithy::Outcome> DialStream(" - + "const smithy::ClientConfig& config, smithy::http::WebSocketDialRequest request) {"); + "opal::Outcome> DialStream(" + + "const opal::ClientConfig& config, opal::http::WebSocketDialRequest request) {"); w.openBlock("if (!config.endpoint.empty()) {"); - w.write("auto endpoint = smithy::http::ParseEndpoint(config.endpoint);"); + w.write("auto endpoint = opal::http::ParseEndpoint(config.endpoint);"); w.write("if (!endpoint) return std::move(endpoint).error();"); w.write("request.host = endpoint->host;"); w.write("request.port = endpoint->port;"); @@ -382,10 +382,10 @@ static void writeClientStreamHelpers( w.write("if (config.websocket_dialer) return config.websocket_dialer(request);"); w.openBlock("if (request.host.empty()) {"); w.write( - "return smithy::Error::Validation($S);", + "return opal::Error::Validation($S);", clientName + ": config needs an endpoint or a websocket_dialer"); w.closeBlock("}"); - w.write("return smithy::http::BeastWebSocketClient::Dialer()(request);"); + w.write("return opal::http::BeastWebSocketClient::Dialer()(request);"); w.closeBlock("}"); w.write(""); for (OperationShape operation : streamingOperations) { @@ -489,8 +489,8 @@ static void writeAsyncServeWrapper( w.write("// busy wire can cancel it. Best-effort, like the blocking route: a send"); w.write("// the terminated session refuses is discarded."); w.openBlock( - "smithy::eventstream::Detached Serve$LAsync(std::shared_ptr" - + " handler, $L input, std::shared_ptr socket) {", + "opal::eventstream::Detached Serve$LAsync(std::shared_ptr" + + " handler, $L input, std::shared_ptr socket) {", op, serviceName, inputType); @@ -502,7 +502,7 @@ static void writeAsyncServeWrapper( w.write("auto outcome = co_await handler->$L(std::move(input), stream);", op); w.openBlock("if (!outcome.ok()) {"); w.write( - "(void)co_await smithy::eventstream::SendMessage(socket," + "(void)co_await opal::eventstream::SendMessage(socket," + " helpers::Build$LExceptionMessage(outcome.error()));", op); w.closeBlock("}"); @@ -561,7 +561,7 @@ private static void writeEncodeFunction( w.write("// One event per message (ADR-0016): the engaged member's structure is the"); w.write("// payload, its member name the :event-type."); w.openBlock( - "smithy::Outcome Encode$LEvent(const $L& event) {", + "opal::Outcome Encode$LEvent(const $L& event) {", op, unionType); for (MemberShape member : union.members()) { @@ -569,7 +569,7 @@ private static void writeEncodeFunction( Shape target = context.model().expectShape(member.getTarget()); w.openBlock("if (event.is_$L()) {", name); w.write( - "return smithy::eventstream::MakeEventMessage($S, $S, $L);", + "return opal::eventstream::MakeEventMessage($S, $S, $L);", member.getMemberName(), protocol.contentType(), protocol.eventPayloadEncode( @@ -581,7 +581,7 @@ private static void writeEncodeFunction( w.closeBlock("}"); } w.write( - "return smithy::Error::Validation($S);", + "return opal::Error::Validation($S);", context.cppSymbols().toSymbol(union).getName() + ": no event member engaged"); w.closeBlock("}"); w.write(""); @@ -606,11 +606,11 @@ private static void writeDecodeFunction( w.write("// $L models no events in this direction: any received message is a", op); w.write("// protocol violation and therefore terminal (ADR-0016)."); w.openBlock( - "smithy::Outcome Decode$LEvent(" - + "const smithy::eventstream::Message&) {", + "opal::Outcome Decode$LEvent(" + + "const opal::eventstream::Message&) {", op); w.write( - "return smithy::Error::Serialization($S);", + "return opal::Error::Serialization($S);", op + ": no events are modeled in this direction"); w.closeBlock("}"); w.write(""); @@ -619,18 +619,18 @@ private static void writeDecodeFunction( UnionShape union = eventUnion(rx.get()); String unionType = context.cppSymbols().typeRef(union); w.openBlock( - "smithy::Outcome<$L> Decode$LEvent(const smithy::eventstream::Message& message) {", + "opal::Outcome<$L> Decode$LEvent(const opal::eventstream::Message& message) {", unionType, op); - w.write("auto envelope = smithy::eventstream::ParseEnvelope(message);"); + w.write("auto envelope = opal::eventstream::ParseEnvelope(message);"); w.write("if (!envelope) return std::move(envelope).error();"); - w.openBlock("if (envelope->kind == smithy::eventstream::EventEnvelope::Kind::kException) {"); + w.openBlock("if (envelope->kind == opal::eventstream::EventEnvelope::Kind::kException) {"); if (clientSide) { writeClientExceptionDecode(w, context, service, protocol, operation); } else { w.write("// Clients send events, never exceptions; treat one as a terminal protocol"); w.write("// violation carrying the peer's claimed identity."); - w.write("return smithy::Error::Modeled(envelope->type, \"peer sent an exception message\");"); + w.write("return opal::Error::Modeled(envelope->type, \"peer sent an exception message\");"); } w.closeBlock("}"); for (MemberShape member : union.members()) { @@ -648,7 +648,7 @@ private static void writeDecodeFunction( w.closeBlock("}"); } w.write( - "return smithy::Error::Serialization($S + envelope->type);", op + ": unknown event type: "); + "return opal::Error::Serialization($S + envelope->type);", op + ": unknown event type: "); w.closeBlock("}"); w.write(""); } @@ -671,13 +671,13 @@ private static void writeClientExceptionDecode( w.write("auto exception_doc = $L;", protocol.eventPayloadDecode("envelope->payload")); w.openBlock("if (exception_doc.ok() && exception_doc->is_map()) {"); w.write("parsed.doc = *std::move(exception_doc);"); - w.write("const smithy::Document* text = parsed.doc.Find(\"message\");"); + w.write("const opal::Document* text = parsed.doc.Find(\"message\");"); w.write("if (text != nullptr && text->is_string()) parsed.message = text->as_string();"); w.closeBlock("}"); Map errors = modeledErrors(context, service, operation); if (!errors.isEmpty()) { w.write("// MakeError's header-patch source; exception messages carry none."); - w.write("smithy::http::HttpResponse response;"); + w.write("opal::http::HttpResponse response;"); for (Map.Entry entry : errors.entrySet()) { w.write( "if (parsed.code == $S) return helpers::$L(response, std::move(parsed));", @@ -705,12 +705,12 @@ private static void writeExceptionMessageBuilder( w.write("// A handler failure ends the stream with one exception message before the"); w.write("// close (ADR-0016)."); w.openBlock( - "smithy::eventstream::Message Build$LExceptionMessage(const smithy::Error& error) {", op); + "opal::eventstream::Message Build$LExceptionMessage(const opal::Error& error) {", op); w.write("std::string type = \"InternalFailure\";"); w.write("// Never leak internal detail on unexpected failures."); w.write("std::string message = \"internal failure\";"); - w.write("smithy::DocumentMap body;"); - w.openBlock("if (error.kind() == smithy::ErrorKind::kModeled) {"); + w.write("opal::DocumentMap body;"); + w.openBlock("if (error.kind() == opal::ErrorKind::kModeled) {"); w.write("type = error.code();"); w.write("message = error.message();"); for (Map.Entry entry : errors.entrySet()) { @@ -723,8 +723,8 @@ private static void writeExceptionMessageBuilder( w.closeBlock("}"); } w.closeBlock( - "} else if (error.kind() == smithy::ErrorKind::kValidation || error.kind() ==" - + " smithy::ErrorKind::kSerialization) {"); + "} else if (error.kind() == opal::ErrorKind::kValidation || error.kind() ==" + + " opal::ErrorKind::kSerialization) {"); w.indent(); w.write("type = \"SerializationException\";"); w.write("message = error.message();"); @@ -733,12 +733,12 @@ private static void writeExceptionMessageBuilder( w.write( "const bool has_message = body.count(\"message\") != 0 || body.count(\"Message\") != 0;"); w.openBlock("if (!has_message && !message.empty()) {"); - w.write("body.emplace(\"message\", smithy::Document(std::move(message)));"); + w.write("body.emplace(\"message\", opal::Document(std::move(message)));"); w.closeBlock("}"); w.write( - "return smithy::eventstream::MakeExceptionMessage(type, $S, $L);", + "return opal::eventstream::MakeExceptionMessage(type, $S, $L);", protocol.contentType(), - protocol.eventPayloadEncode("smithy::Document(std::move(body))")); + protocol.eventPayloadEncode("opal::Document(std::move(body))")); w.closeBlock("}"); w.write(""); } diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpBindingCodeGen.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpBindingCodeGen.java index e8ed676f..205ffbc6 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpBindingCodeGen.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpBindingCodeGen.java @@ -216,7 +216,7 @@ static void writePayloadWrite( if (optional && structure) { w.openBlock("if ($L.has_value()) {", field); w.write( - "$L.body = smithy::json::Encode($L);", + "$L.body = opal::json::Encode($L);", messageVar, serde.serializeExpression(member, value)); w.closeBlock("} else {"); @@ -230,7 +230,7 @@ static void writePayloadWrite( case STRING -> { if (jsonText) { // simpleRestJson: plain string payloads are JSON string values. - w.write("$L.body = smithy::json::Encode(smithy::Document($L));", messageVar, value); + w.write("$L.body = opal::json::Encode(opal::Document($L));", messageVar, value); } else { w.write("$L.body = $L;", messageVar, value); } @@ -238,7 +238,7 @@ static void writePayloadWrite( case ENUM -> { if (jsonText) { w.write( - "$L.body = smithy::json::Encode(smithy::Document(std::string($L.ToString())));", + "$L.body = opal::json::Encode(opal::Document(std::string($L.ToString())));", messageVar, value); } else { @@ -247,7 +247,7 @@ static void writePayloadWrite( } default -> w.write( - "$L.body = smithy::json::Encode($L);", + "$L.body = opal::json::Encode($L);", messageVar, serde.serializeExpression(member, value)); } @@ -287,10 +287,10 @@ static void writeDocumentBodyRead( String structType, String opName, SerdeCodeGen.RequiredAbsentEmitter requiredAbsent) { - w.write("auto body_doc = smithy::json::Decode($L.empty() ? \"{}\" : $L);", bodyExpr, bodyExpr); + w.write("auto body_doc = opal::json::Decode($L.empty() ? \"{}\" : $L);", bodyExpr, bodyExpr); w.write("if (!body_doc) return std::move(body_doc).error();"); w.write( - "if (!body_doc->is_map()) return smithy::Error::Serialization($S);", + "if (!body_doc->is_map()) return opal::Error::Serialization($S);", opName + ": expected a JSON object body"); for (HttpBinding binding : body) { serde.writeMemberRead( @@ -323,14 +323,14 @@ static void writePayloadRead( boolean jsonText = jsonTextPayload(context, member); w.openBlock("if (!$L.empty()) {", bodyExpr); switch (target.getType()) { - case BLOB -> w.write("$L = smithy::Blob::FromString($L);", field, bodyExpr); + case BLOB -> w.write("$L = opal::Blob::FromString($L);", field, bodyExpr); case STRING -> { if (jsonText) { // simpleRestJson: plain string payloads are JSON string values. - w.write("auto payload_doc = smithy::json::Decode($L);", bodyExpr); + w.write("auto payload_doc = opal::json::Decode($L);", bodyExpr); w.write("if (!payload_doc) return std::move(payload_doc).error();"); w.write( - "if (!payload_doc->is_string()) return smithy::Error::Serialization(" + "if (!payload_doc->is_string()) return opal::Error::Serialization(" + "\"expected a JSON string payload\");"); w.write("$L = payload_doc->as_string();", field); } else { @@ -340,10 +340,10 @@ static void writePayloadRead( case ENUM -> { String enumType = context.cppSymbols().typeRef(target); if (jsonText) { - w.write("auto payload_doc = smithy::json::Decode($L);", bodyExpr); + w.write("auto payload_doc = opal::json::Decode($L);", bodyExpr); w.write("if (!payload_doc) return std::move(payload_doc).error();"); w.write( - "if (!payload_doc->is_string()) return smithy::Error::Serialization(" + "if (!payload_doc->is_string()) return opal::Error::Serialization(" + "\"expected a JSON string payload\");"); w.write("$L = $L::FromString(payload_doc->as_string());", field, enumType); } else { @@ -351,9 +351,9 @@ static void writePayloadRead( } } default -> { - w.write("auto payload_doc = smithy::json::Decode($L);", bodyExpr); + w.write("auto payload_doc = opal::json::Decode($L);", bodyExpr); w.write("if (!payload_doc) return std::move(payload_doc).error();"); - w.write("const smithy::Document* payload_ptr = &*payload_doc;"); + w.write("const opal::Document* payload_ptr = &*payload_doc;"); boolean structure = target.getType() == ShapeType.STRUCTURE; if (member.isRequired()) { serde.writeDeserializeInto(w, member, "payload_ptr", field, path); @@ -410,7 +410,7 @@ static void writePrefixHeadersRead( String prefix = binding.getLocationName(); boolean optional = !MemberDefaults.plain(context.model(), member); w.openBlock("for (const auto& [header_name, header_value] : $L.entries()) {", headersExpr); - w.write("if (!smithy::http::HeaderNameStartsWith(header_name, $S)) continue;", prefix); + w.write("if (!opal::http::HeaderNameStartsWith(header_name, $S)) continue;", prefix); String container; if (optional) { w.write("if (!$L.has_value()) $L.emplace();", field, field); @@ -426,7 +426,7 @@ static void writePrefixHeadersRead( /** * Reads one @httpHeader binding from {@code headersExpr} into {@code targetPrefix} * (client response headers and server request headers share this shape; failures return - * smithy::Error, so it must run inside an Outcome-returning function). + * opal::Error, so it must run inside an Outcome-returning function). */ static void writeHeaderReadBinding( CppWriter w, @@ -446,13 +446,13 @@ static void writeHeaderReadBinding( var list = target.asListShape().orElseThrow(); MemberShape element = list.getMember(); w.write("$L items;", context.cppSymbols().typeRef(list)); - String tsFormat = serde.timestampFormat(element, "smithy::TimestampFormat::kHttpDate"); + String tsFormat = serde.timestampFormat(element, "opal::TimestampFormat::kHttpDate"); String splitter = context.model().expectShape(element.getTarget()).isTimestampShape() - && tsFormat.equals("smithy::TimestampFormat::kHttpDate") + && tsFormat.equals("opal::TimestampFormat::kHttpDate") ? "SplitHttpDateHeaderValues" : "SplitHeaderListValues"; - w.openBlock("for (const std::string& part : smithy::http::$L(*header_value)) {", splitter); + w.openBlock("for (const std::string& part : opal::http::$L(*header_value)) {", splitter); writeParsedHeaderValue( w, context, element, "part", "items.push_back", /* push= */ true, tsFormat); w.closeBlock("}"); @@ -465,7 +465,7 @@ static void writeHeaderReadBinding( "(*header_value)", field, /* push= */ false, - serde.timestampFormat(member, "smithy::TimestampFormat::kHttpDate")); + serde.timestampFormat(member, "opal::TimestampFormat::kHttpDate")); } w.closeBlock("}"); } @@ -491,14 +491,14 @@ private static void writeParsedHeaderValue( } switch (target.getType()) { case TIMESTAMP -> { - w.write("auto parsed_ts = smithy::Timestamp::Parse($L, $L);", valueExpr, timestampFormat); + w.write("auto parsed_ts = opal::Timestamp::Parse($L, $L);", valueExpr, timestampFormat); w.write("if (!parsed_ts) return std::move(parsed_ts).error();"); w.write("$L*std::move(parsed_ts)$L", open, close); } case STRING -> { if (target.hasTrait(MediaTypeTrait.class)) { // restJson1: string headers with @mediaType are base64 encoded. - w.write("auto decoded = smithy::Base64Decode($L);", valueExpr); + w.write("auto decoded = opal::Base64Decode($L);", valueExpr); w.write("if (!decoded) return std::move(decoded).error();"); w.write("$Ldecoded->ToString()$L", open, close); } else { @@ -536,17 +536,17 @@ static void writeTextValueInto( switch (target.getType()) { case TIMESTAMP -> { String format = serde.timestampFormat(member, timestampDefault); - if (format.equals("smithy::TimestampFormat::kDateTime")) { + if (format.equals("opal::TimestampFormat::kDateTime")) { // Servers reject RFC3339 UTC offsets in text positions (clients must // accept them in responses, so Timestamp::Parse itself stays lenient). w.write( "if ($L.empty() || ($L.back() != 'Z' && $L.back() != 'z')) return " - + "smithy::Error::Serialization(\"expected a Z-terminated date-time\");", + + "opal::Error::Serialization(\"expected a Z-terminated date-time\");", valueExpr, valueExpr, valueExpr); } - w.write("auto parsed_ts = smithy::Timestamp::Parse($L, $L);", valueExpr, format); + w.write("auto parsed_ts = opal::Timestamp::Parse($L, $L);", valueExpr, format); w.write("if (!parsed_ts) return std::move(parsed_ts).error();"); w.write("$L*std::move(parsed_ts)$L", open, close); } @@ -586,7 +586,7 @@ private static boolean writeSimpleTextParse( // UB to cast (UBSan float-cast-overflow), so it fails the parse. w.write("auto parsed_num = helpers::ParseDoubleText($L);", valueExpr); w.write("if (!parsed_num) return std::move(parsed_num).error();"); - w.write("auto narrowed_num = smithy::FloatFromDouble(*parsed_num);"); + w.write("auto narrowed_num = opal::FloatFromDouble(*parsed_num);"); w.write("if (!narrowed_num) return std::move(narrowed_num).error();"); w.write("$L*narrowed_num$L", open, close); } @@ -598,7 +598,7 @@ private static boolean writeSimpleTextParse( case BOOLEAN -> { w.write( "if ($L != \"true\" && $L != \"false\") return " - + "smithy::Error::Serialization(\"expected a boolean, got: \" + $L);", + + "opal::Error::Serialization(\"expected a boolean, got: \" + $L);", valueExpr, valueExpr, valueExpr); @@ -640,7 +640,7 @@ static void writeHeaderWriteBinding( context, element, "item", - serde.timestampFormat(element, "smithy::TimestampFormat::kHttpDate"))); + serde.timestampFormat(element, "opal::TimestampFormat::kHttpDate"))); w.closeBlock("}"); w.write("$L.Set($S, joined);", headersExpr, name); w.closeBlock("}"); @@ -650,10 +650,10 @@ static void writeHeaderWriteBinding( context, member, access, - serde.timestampFormat(member, "smithy::TimestampFormat::kHttpDate")); + serde.timestampFormat(member, "opal::TimestampFormat::kHttpDate")); if (target.isStringShape() && target.hasTrait(MediaTypeTrait.class)) { // restJson1: string headers with @mediaType are base64 encoded. - expr = "smithy::Base64Encode(smithy::Blob::FromString(" + expr + "))"; + expr = "opal::Base64Encode(opal::Blob::FromString(" + expr + "))"; } w.write("$L.Set($S, $L);", headersExpr, name, expr); } diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonBindingProtocol.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonBindingProtocol.java index 1aa28e5d..617ee07e 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonBindingProtocol.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonBindingProtocol.java @@ -128,12 +128,12 @@ public boolean bindsInitialRequestMembers() { @Override public String eventPayloadEncode(String docExpr) { - return "smithy::Blob::FromString(smithy::json::Encode(" + docExpr + "))"; + return "opal::Blob::FromString(opal::json::Encode(" + docExpr + "))"; } @Override public String eventPayloadDecode(String payloadExpr) { - return "smithy::json::Decode(" + payloadExpr + ".ToString())"; + return "opal::json::Decode(" + payloadExpr + ".ToString())"; } @Override diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonClientGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonClientGenerator.java index 403e6a00..2e0a400a 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonClientGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonClientGenerator.java @@ -50,7 +50,7 @@ List includes() { void writeHelpers(CppWriter w) { ProtocolSupport.writeErrorSupport( - w, "auto doc = smithy::json::Decode(response.body);", errorTypeHeaderName); + w, "auto doc = opal::json::Decode(response.body);", errorTypeHeaderName); ProtocolSupport.writeNumericParseHelpers(w); } @@ -84,25 +84,25 @@ void writeErrorDocPatches(CppWriter w, CppContext context, StructureShape error) switch (target.getType()) { case STRING, ENUM -> w.write( - "parsed.doc.as_map().insert_or_assign($S, smithy::Document(*header_value));", + "parsed.doc.as_map().insert_or_assign($S, opal::Document(*header_value));", wireName); // Document patching is best effort: malformed header values are // skipped, never failures. case BYTE, SHORT, INTEGER, LONG, INT_ENUM -> w.write( "if (auto parsed_num = helpers::ParseInt64Text(*header_value, $L)) " - + "parsed.doc.as_map().insert_or_assign($S, smithy::Document(*parsed_num));", + + "parsed.doc.as_map().insert_or_assign($S, opal::Document(*parsed_num));", ProtocolSupport.int64Bounds(target.getType()), wireName); case FLOAT, DOUBLE -> w.write( "if (auto parsed_num = helpers::ParseDoubleText(*header_value)) " - + "parsed.doc.as_map().insert_or_assign($S, smithy::Document(*parsed_num));", + + "parsed.doc.as_map().insert_or_assign($S, opal::Document(*parsed_num));", wireName); case BOOLEAN -> w.write( "parsed.doc.as_map().insert_or_assign($S, " - + "smithy::Document(*header_value == \"true\"));", + + "opal::Document(*header_value == \"true\"));", wireName); default -> throw new CodegenException( @@ -152,7 +152,7 @@ void writeOperationBody( writeTarget(w, context, serde, operation, http, labels, queries, queryParams, in); - w.write("smithy::http::HttpRequest request;"); + w.write("opal::http::HttpRequest request;"); w.write("request.method = $S;", http.getMethod()); w.write("request.target = std::move(target);"); for (HttpBinding binding : headers.values()) { @@ -166,9 +166,9 @@ void writeOperationBody( HttpBindingCodeGen.writePayloadWrite( w, context, serde, operation, payload, in, "request", true); } else if (!body.isEmpty()) { - w.write("smithy::DocumentMap body_map;"); + w.write("opal::DocumentMap body_map;"); HttpBindingCodeGen.writeDocumentBodyMap(w, serde, body, in); - w.write("request.body = smithy::json::Encode(smithy::Document(std::move(body_map)));"); + w.write("request.body = opal::json::Encode(opal::Document(std::move(body_map)));"); w.write("request.headers.Set(\"content-type\", \"application/json\");"); } @@ -208,7 +208,7 @@ void writeOperationBody( if (allOptional) { w.write("if (response->body.empty()) return $L{};", outType); } - w.write("auto body_doc = smithy::json::Decode(response->body);"); + w.write("auto body_doc = opal::json::Decode(response->body);"); w.write("if (!body_doc) return std::move(body_doc).error();"); w.write( "return Deserialize$L(*body_doc);", SerdeCodeGen.serdeFunctionSuffix(context, output)); @@ -228,7 +228,7 @@ void writeOperationBody( if (allOptional) { w.openBlock("if (!response->body.empty()) {"); } - w.write("auto body_doc = smithy::json::Decode(response->body);"); + w.write("auto body_doc = opal::json::Decode(response->body);"); w.write("if (!body_doc) return std::move(body_doc).error();"); w.write( "auto parsed = Deserialize$L(*body_doc);", @@ -250,7 +250,7 @@ void writeOperationBody( (w2, member, deserializeMember) -> { // Clients are strict: a missing required member fails the exchange. w2.write( - "if ($L) return smithy::Error::Serialization($S);", + "if ($L) return opal::Error::Serialization($S);", SerdeCodeGen.MEMBER_ABSENT, "missing required member: " + member.getMemberName()); deserializeMember.run(); @@ -267,7 +267,7 @@ void writeOperationBody( // Clients are strict about required headers, like required body members. w.write( "if (!response->headers.Get($S).has_value()) return " - + "smithy::Error::Serialization($S);", + + "opal::Error::Serialization($S);", binding.getLocationName(), "missing required header: " + binding.getLocationName()); } @@ -325,15 +325,15 @@ private void writeTarget( context, binding.getMember(), in + "." + context.cppSymbols().toMemberName(binding.getMember()), - serde.timestampFormat(binding.getMember(), "smithy::TimestampFormat::kDateTime")); + serde.timestampFormat(binding.getMember(), "opal::TimestampFormat::kDateTime")); String encoder = segment.isGreedyLabel() ? "EncodeGreedyPathSegment" : "EncodePathSegment"; w.write("target += \"/\";"); - w.write("target += smithy::http::$L($L);", encoder, value); + w.write("target += opal::http::$L($L);", encoder, value); } boolean hasQuery = !queries.isEmpty() || queryParams != null || !http.getUri().getQueryLiterals().isEmpty(); if (hasQuery) { - w.write("smithy::http::QueryString query;"); + w.write("opal::http::QueryString query;"); for (Map.Entry literal : new TreeMap<>(http.getUri().getQueryLiterals()).entrySet()) { if (literal.getValue().isEmpty()) { @@ -386,7 +386,7 @@ void writeStreamingOperationBody( w, context, input, context.cppSymbols().toSymbol(input).getName()); writeTarget( w, context, serde, operation, http, req.labels(), req.queries(), req.queryParams(), in); - w.write("smithy::http::WebSocketDialRequest request;"); + w.write("opal::http::WebSocketDialRequest request;"); w.write("request.target = std::move(target);"); for (HttpBinding binding : req.headers().values()) { HttpBindingCodeGen.writeHeaderWriteBinding(w, context, serde, binding, in, "request.headers"); @@ -423,7 +423,7 @@ private void writeQueryBinding( context, element, "item", - serde.timestampFormat(element, "smithy::TimestampFormat::kDateTime"))); + serde.timestampFormat(element, "opal::TimestampFormat::kDateTime"))); w.closeBlock("}"); } else { w.write( @@ -433,7 +433,7 @@ private void writeQueryBinding( context, member, access, - serde.timestampFormat(member, "smithy::TimestampFormat::kDateTime"))); + serde.timestampFormat(member, "opal::TimestampFormat::kDateTime"))); } if (!plain) { w.closeBlock("}"); diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonServerGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonServerGenerator.java index 9474c677..5e7bab0a 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonServerGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/HttpJsonServerGenerator.java @@ -83,7 +83,7 @@ void writeHelpers( w, spec.errorFn(), "application/json", - "smithy::json::Encode(smithy::Document(std::move(body)))"); + "opal::json::Encode(opal::Document(std::move(body)))"); ProtocolSupport.writeServerErrorToResponse(w, context, service, operations, spec); validation = ValidationGenerator.writeWiring( @@ -165,10 +165,10 @@ private void writeParseInputFunction( HttpBinding prefixHeaders = req.prefixHeaders(); w.openBlock( - "smithy::Outcome<$L> $L(const smithy::http::HttpRequest& request, " + "opal::Outcome<$L> $L(const opal::http::HttpRequest& request, " + ProtocolSupport.REQUEST_CONTEXT_PARAM + " context, " - + "std::vector* validation_failures) {", + + "std::vector* validation_failures) {", inputType, parseInputFunction(opName)); w.write("(void)request;"); @@ -188,7 +188,7 @@ private void writeParseInputFunction( member, "label_value", "input." + context.cppSymbols().toMemberName(member), - "smithy::TimestampFormat::kDateTime", + "opal::TimestampFormat::kDateTime", /* push= */ false); w.closeBlock("}"); } @@ -231,7 +231,7 @@ private void writeParseInputFunction( element, "value", container + ".push_back", - "smithy::TimestampFormat::kDateTime", + "opal::TimestampFormat::kDateTime", /* push= */ true); } else { HttpBindingCodeGen.writeTextValueInto( @@ -241,7 +241,7 @@ private void writeParseInputFunction( member, "value", field, - "smithy::TimestampFormat::kDateTime", + "opal::TimestampFormat::kDateTime", /* push= */ false); } w.write("continue;"); @@ -356,11 +356,11 @@ private void writeBuildResponseFunction( HttpBinding responsePrefixHeaders = resp.prefixHeaders(); w.openBlock( - "smithy::http::HttpResponse $L(const $L& output) {", + "opal::http::HttpResponse $L(const $L& output) {", buildResponseFunction(opName), outputType); w.write("(void)output;"); - w.write("smithy::http::HttpResponse response;"); + w.write("opal::http::HttpResponse response;"); w.write("response.status = $L;", http.getCode()); if (responseCode != null) { MemberShape codeMember = responseCode.getMember(); @@ -401,10 +401,10 @@ private void writeBuildResponseFunction( HttpBindingCodeGen.writePayloadWrite( w, context, serde, operation, responsePayload, "output", "response", false); } else { - w.write("smithy::DocumentMap body_map;"); + w.write("opal::DocumentMap body_map;"); HttpBindingCodeGen.writeDocumentBodyMap(w, serde, responseBody, "output"); w.write("response.headers.Set(\"content-type\", \"application/json\");"); - w.write("response.body = smithy::json::Encode(smithy::Document(std::move(body_map)));"); + w.write("response.body = opal::json::Encode(opal::Document(std::move(body_map)));"); } if (responseCode != null) { w.closeBlock("}"); @@ -458,14 +458,14 @@ void writeRoute(CppWriter w, CppContext context, ServiceShape service, Operation boolean hasResponseContent = !resp.body().isEmpty() || resp.payload() != null; boolean compressed = ProtocolSupport.gzipCompressed(operation); w.openBlock( - "(void)router_->Add($S, $S, [handler](const smithy::http::HttpRequest& $L, " + "(void)router_->Add($S, $S, [handler](const opal::http::HttpRequest& $L, " + ProtocolSupport.REQUEST_CONTEXT_PARAM - + " context) -> smithy::http::HttpResponse {", + + " context) -> opal::http::HttpResponse {", http.getMethod(), pattern, compressed ? "raw_request" : "request"); if (compressed) { - w.write("smithy::http::HttpRequest request = raw_request;"); + w.write("opal::http::HttpRequest request = raw_request;"); ProtocolSupport.writeRequestDecompression(w, operation, "JsonError", ""); } boolean noModeledInput = @@ -491,9 +491,9 @@ void writeRoute(CppWriter w, CppContext context, ServiceShape service, Operation // httpRequestTests pin that leniency). String condition = hasRequestPayload - ? "content_type.has_value() ? smithy::http::MediaTypeOf(*content_type) != $S " + ? "content_type.has_value() ? opal::http::MediaTypeOf(*content_type) != $S " + ": !request.body.empty()" - : "content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != $S"; + : "content_type.has_value() && opal::http::MediaTypeOf(*content_type) != $S"; w.openBlock( "if (const auto content_type = request.headers.Get(\"content-type\"); " + condition @@ -512,14 +512,14 @@ void writeRoute(CppWriter w, CppContext context, ServiceShape service, Operation String responseContentType = determined.isEmpty() ? "application/json" : determined; w.openBlock( "if (const auto accept = request.headers.Get(\"accept\"); accept.has_value() && " - + "!smithy::http::AcceptMatches(*accept, $S)) {", + + "!opal::http::AcceptMatches(*accept, $S)) {", responseContentType); w.write("auto error_response = helpers::JsonError(406, \"\", \"not acceptable\", {});"); writeErrorTypeHeader(w, "error_response", "NotAcceptableException"); w.write("return error_response;"); w.closeBlock("}"); } - w.write("std::vector validation_failures;"); + w.write("std::vector validation_failures;"); w.write( "auto input = helpers::$L(request, context, &validation_failures);", parseInputFunction(opName)); @@ -557,12 +557,12 @@ void writeStreamRoute( // whatever method the operation models, and the route must match what // arrives. w.openBlock( - "(void)stream_router_->Add(\"GET\", $S, [handler](const smithy::http::HttpRequest&" + "(void)stream_router_->Add(\"GET\", $S, [handler](const opal::http::HttpRequest&" + " request, " + ProtocolSupport.REQUEST_CONTEXT_PARAM - + " context, smithy::http::WebSocket& socket) {", + + " context, opal::http::WebSocket& socket) {", routePattern(http)); - w.write("std::vector validation_failures;"); + w.write("std::vector validation_failures;"); w.write( "auto input = helpers::$L(request, context, &validation_failures);", parseInputFunction(opName)); @@ -599,12 +599,12 @@ void writeStreamSessionRoute( HttpTrait http = operation.expectTrait(HttpTrait.class); String opName = CppReservedWords.escape(operation.getId().getName()); w.openBlock( - "(void)stream_router_->AddSession(\"GET\", $S, [handler](const smithy::http::HttpRequest&" + "(void)stream_router_->AddSession(\"GET\", $S, [handler](const opal::http::HttpRequest&" + " request, " + ProtocolSupport.REQUEST_CONTEXT_PARAM - + " context, std::shared_ptr socket) {", + + " context, std::shared_ptr socket) {", routePattern(http)); - w.write("std::vector validation_failures;"); + w.write("std::vector validation_failures;"); w.write( "auto input = helpers::$L(request, context, &validation_failures);", parseInputFunction(opName)); @@ -637,7 +637,7 @@ private static void writeStreamValidationRefusal( w.openBlock("if (!validation_failures.empty()) {"); w.write( "(void)$LSend(helpers::Build$LExceptionMessage(" - + "smithy::Error::Validation(validation_failures.front().message)));", + + "opal::Error::Validation(validation_failures.front().message)));", socketAccess, opName); w.write("$LClose();", socketAccess); diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/IntegrationTestGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/IntegrationTestGenerator.java index 88af8fd6..e1d63a2c 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/IntegrationTestGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/IntegrationTestGenerator.java @@ -176,7 +176,7 @@ private void writeScriptedHandler(CppWriter w) { w.closeBlock("}"); w.write("std::optional<$L> last$L;", typeName(input(operation)), op); w.write("$L next$LOutput{};", typeName(output(operation)), op); - w.write("std::optional next$LError;", op); + w.write("std::optional next$LError;", op); } w.dedent(); w.closeBlock("};"); @@ -192,15 +192,15 @@ private void writeFixture(CppWriter w) { w.openBlock("void SetUp() override {"); w.write("handler_ = std::make_shared();"); w.write("server_ = std::make_unique<$LServer>(handler_);", name); - w.write("smithy::ClientConfig config;"); + w.write("opal::ClientConfig config;"); w.write("config.retry.max_attempts = 1; // wire-exact tests: no retries"); w.openBlock("if (GetParam() == TransportKind::kLoopback) {"); - w.write("auto loopback = std::make_shared();"); + w.write("auto loopback = std::make_shared();"); w.write("ASSERT_TRUE(loopback->Start(server_->Handler()).ok());"); w.write("config.http_client = loopback;"); w.closeBlock("} else {"); w.indent(); - w.write("socket_server_ = std::make_unique();"); + w.write("socket_server_ = std::make_unique();"); w.write("ASSERT_TRUE(socket_server_->Start(server_->Handler()).ok());"); w.write("config.endpoint = \"http://127.0.0.1:\" + std::to_string(socket_server_->port());"); w.closeBlock("}"); @@ -213,7 +213,7 @@ private void writeFixture(CppWriter w) { w.write(""); w.write("std::shared_ptr handler_;"); w.write("std::unique_ptr<$LServer> server_;", name); - w.write("std::unique_ptr socket_server_;"); + w.write("std::unique_ptr socket_server_;"); w.write("std::unique_ptr<$LClient> client_;", name); w.dedent(); w.closeBlock("};"); @@ -268,12 +268,12 @@ private void writeErrorTests(CppWriter w, OperationShape operation) { "const $L detail = Random$L(rng);", errorType, SerdeCodeGen.serdeFunctionSuffix(context, error)); - w.write("smithy::Error error = smithy::Error::Modeled($S, \"integration\");", wireName); + w.write("opal::Error error = opal::Error::Modeled($S, \"integration\");", wireName); w.write("error.set_detail(detail);"); w.write("handler_->next$LError = error;", op); writeMinimalCall(w, operation); w.write("ASSERT_FALSE(outcome.ok());"); - w.write("EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled);"); + w.write("EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled);"); w.write("EXPECT_EQ(outcome.error().code(), $S);", wireName); w.write("ASSERT_NE(outcome.error().detail<$L>(), nullptr);", errorType); w.write("EXPECT_EQ(*outcome.error().detail<$L>(), detail);", errorType); @@ -296,27 +296,27 @@ private void writeUnknownFieldTest(CppWriter w, OperationShape operation) { w.openBlock("TEST($LIntegrationUnknownMembers, $LToleratesUnknownResponseMembers) {", name, op); w.write("auto handler = std::make_shared();"); w.write("$LServer server(handler);", name); - w.write("auto loopback = std::make_shared();"); + w.write("auto loopback = std::make_shared();"); w.write("ASSERT_TRUE(loopback->Start(server.Handler()).ok());"); - w.openBlock("auto inject = [](smithy::http::HttpResponse& response) {"); + w.openBlock("auto inject = [](opal::http::HttpResponse& response) {"); if (cbor) { - w.write("auto doc = smithy::cbor::Decode(smithy::Blob::FromString(response.body));"); + w.write("auto doc = opal::cbor::Decode(opal::Blob::FromString(response.body));"); } else { - w.write("auto doc = smithy::json::Decode(response.body);"); + w.write("auto doc = opal::json::Decode(response.body);"); } w.write("if (!doc.ok() || !doc->is_map()) return;"); w.write("auto map = doc->as_map();"); - w.write("map.insert_or_assign(\"smithy_cpp_unknown_member\", smithy::Document(42));"); + w.write("map.insert_or_assign(\"smithy_cpp_unknown_member\", opal::Document(42));"); if (cbor) { - w.write("response.body = smithy::cbor::Encode(smithy::Document(std::move(map))).ToString();"); + w.write("response.body = opal::cbor::Encode(opal::Document(std::move(map))).ToString();"); } else { - w.write("response.body = smithy::json::Encode(smithy::Document(std::move(map)));"); + w.write("response.body = opal::json::Encode(opal::Document(std::move(map)));"); } w.closeBlock("};"); w.write( - "auto transport = std::make_shared(loopback, " + "auto transport = std::make_shared(loopback, " + "inject);"); - w.write("smithy::ClientConfig config;"); + w.write("opal::ClientConfig config;"); w.write("config.retry.max_attempts = 1; // wire-exact tests: no retries"); w.write("config.http_client = transport;"); w.write("auto client = *$LClient::Create(std::move(config));", name); diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/JsonRpc2Protocol.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/JsonRpc2Protocol.java index a109c52b..8b83d2b4 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/JsonRpc2Protocol.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/JsonRpc2Protocol.java @@ -11,7 +11,7 @@ * smithy.cpp.protocols#jsonRpc2: the homegrown vendor-neutral JSON-RPC 2.0 protocol. A single * {@code POST /} endpoint carries {@code {"jsonrpc":"2.0","method":,"params":, * "id":…}}; responses are {@code {"jsonrpc":"2.0","result":,"id":…}} or a JSON-RPC error - * object over the shared {@code smithy::Document} JSON pivot. No HTTP bindings apply. + * object over the shared {@code opal::Document} JSON pivot. No HTTP bindings apply. * *

Wire contract (this class is the normative definition; the authored conformance suite under * {@code protocol-tests/jsonrpc2} pins it): @@ -102,16 +102,16 @@ public void writeClientHelpers(CppWriter w, CppContext context) { w.write("// [[maybe_unused]]: only unary response paths parse wire errors; a"); w.write("// service whose operations all stream never calls this."); w.openBlock( - "[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) {"); + "[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) {"); w.write("ParsedError parsed;"); w.write("parsed.status = response.status;"); w.write("parsed.message = \"HTTP \" + std::to_string(response.status);"); - w.write("auto doc = smithy::json::Decode(response.body);"); + w.write("auto doc = opal::json::Decode(response.body);"); w.write("if (!doc.ok() || !doc->is_map()) return parsed;"); - w.write("const smithy::Document* error = doc->Find(\"error\");"); + w.write("const opal::Document* error = doc->Find(\"error\");"); w.write("if (error == nullptr || !error->is_map()) return parsed;"); w.openBlock( - "if (const smithy::Document* code = error->Find(\"code\"); " + "if (const opal::Document* code = error->Find(\"code\"); " + "code != nullptr && code->is_int()) {"); // Classified on the full int64: narrowing first would alias 2^32+404 // onto 404 and misroute status/retryability (issue #109). @@ -121,13 +121,13 @@ public void writeClientHelpers(CppWriter w, CppContext context) { + ": (rpc_code == -32603 ? 500 : 400);"); w.closeBlock("}"); w.write( - "if (const smithy::Document* message = error->Find(\"message\"); " + "if (const opal::Document* message = error->Find(\"message\"); " + "message != nullptr && message->is_string()) parsed.message = message->as_string();"); w.write( - "if (const smithy::Document* data = error->Find(\"data\"); " + "if (const opal::Document* data = error->Find(\"data\"); " + "data != nullptr) parsed.doc = *data;"); w.openBlock("if (parsed.doc.is_map()) {"); - w.write("const smithy::Document* type = parsed.doc.Find(\"__type\");"); + w.write("const opal::Document* type = parsed.doc.Find(\"__type\");"); w.write( "if (type != nullptr && type->is_string()) " + "parsed.code = helpers::SanitizeErrorCode(type->as_string());"); @@ -147,10 +147,10 @@ public void writeOperationBody( String in = ProtocolSupport.writeRpcRequestPrelude(w, context, input); w.write("request.target = path_prefix_ + \"/\";"); w.write("request.headers.Set(\"content-type\", \"application/json\");"); - w.write("smithy::DocumentMap envelope;"); - w.write("envelope.emplace(\"jsonrpc\", smithy::Document(\"2.0\"));"); - w.write("envelope.emplace(\"method\", smithy::Document($S));", operation.getId().getName()); - w.write("envelope.emplace(\"id\", smithy::Document(1));"); + w.write("opal::DocumentMap envelope;"); + w.write("envelope.emplace(\"jsonrpc\", opal::Document(\"2.0\"));"); + w.write("envelope.emplace(\"method\", opal::Document($S));", operation.getId().getName()); + w.write("envelope.emplace(\"id\", opal::Document(1));"); // Operations with no modeled input (smithy.api#Unit) omit params; empty // input structures still send an (empty) params object. if (!ProtocolSupport.noModeledInput(input)) { @@ -159,10 +159,10 @@ public void writeOperationBody( SerdeCodeGen.serdeFunctionSuffix(context, input), in); } - w.write("request.body = smithy::json::Encode(smithy::Document(std::move(envelope)));"); + w.write("request.body = opal::json::Encode(opal::Document(std::move(envelope)));"); ProtocolSupport.writeRpcSend(w, operation); - w.write("auto envelope_doc = smithy::json::Decode(response->body);"); + w.write("auto envelope_doc = opal::json::Decode(response->body);"); w.write("// Errors are JSON-RPC envelopes on HTTP 200; non-200 means the request"); w.write("// never reached the protocol layer (router 404, proxy) and parses generically."); w.write( @@ -176,13 +176,13 @@ public void writeOperationBody( return; } String outType = context.cppSymbols().toSymbol(output).getName(); - w.write("const smithy::Document* result = envelope_doc->Find(\"result\");"); + w.write("const opal::Document* result = envelope_doc->Find(\"result\");"); boolean allOptional = output.members().stream().noneMatch(MemberShape::isRequired); if (allOptional) { w.write("if (result == nullptr) return $L{};", outType); } else { w.write( - "if (result == nullptr) return smithy::Error::Serialization(" + "if (result == nullptr) return opal::Error::Serialization(" + "\"jsonRpc2: response has no result member\");"); } w.write("return Deserialize$L(*result);", SerdeCodeGen.serdeFunctionSuffix(context, output)); @@ -200,12 +200,12 @@ public boolean streamsRideJsonRpcEnvelopes() { @Override public String eventPayloadEncode(String docExpr) { - return "smithy::Blob::FromString(smithy::json::Encode(" + docExpr + "))"; + return "opal::Blob::FromString(opal::json::Encode(" + docExpr + "))"; } @Override public String eventPayloadDecode(String payloadExpr) { - return "smithy::json::Decode(" + payloadExpr + ".ToString())"; + return "opal::json::Decode(" + payloadExpr + ".ToString())"; } @Override @@ -220,10 +220,10 @@ public void writeStreamServerRoutes( w.write("// One shared-endpoint stream route (ADR-0023): the wire routes on the"); w.write("// opening envelope's method, exactly like the unary POST \"/\" above."); w.openBlock( - "(void)stream_router_->Add(\"GET\", \"/\", [handler](const smithy::http::HttpRequest&" + "(void)stream_router_->Add(\"GET\", \"/\", [handler](const opal::http::HttpRequest&" + " request, " + ProtocolSupport.REQUEST_CONTEXT_PARAM - + " context, smithy::http::WebSocket& socket) {"); + + " context, opal::http::WebSocket& socket) {"); w.write("(void)request;"); w.write("helpers::ServeJsonRpcStream(*handler, context, socket);"); w.closeBlock("}, $S);", service.getId().getName()); @@ -234,9 +234,9 @@ public void writeStreamSessionRoutes( CppWriter w, CppContext context, ServiceShape service, List operations) { w.openBlock( "(void)stream_router_->AddSession(\"GET\", \"/\", [handler](const" - + " smithy::http::HttpRequest& request, " + + " opal::http::HttpRequest& request, " + ProtocolSupport.REQUEST_CONTEXT_PARAM - + " context, std::shared_ptr socket) {"); + + " context, std::shared_ptr socket) {"); w.write("(void)request;"); w.write("(void)context;"); w.write("helpers::ServeJsonRpcSession(handler, std::move(socket));"); @@ -246,7 +246,7 @@ public void writeStreamSessionRoutes( /** jsonRpc2 error identity travels in error.data.__type; every response echoes the id. */ private static final ProtocolSupport.ErrorResponseSpec SPEC = new ProtocolSupport.ErrorResponseSpec( - "JsonRpcError", /* errortypeHeader= */ "", ", const smithy::Document& id", ", id"); + "JsonRpcError", /* errortypeHeader= */ "", ", const opal::Document& id", ", id"); /** Set up by writeServerHelpers (always called before the routes are emitted). */ private ValidationGenerator validation; @@ -265,28 +265,28 @@ public void writeServerHelpers( // errors, reserved -32xxx codes for envelope-level failures); `type` lands // in data.__type; an empty `message` falls back to data's message member. w.openBlock( - "smithy::http::HttpResponse $L(int code, const std::string& type, " - + "const std::string& message, smithy::DocumentMap data, const smithy::Document& id) " + "opal::http::HttpResponse $L(int code, const std::string& type, " + + "const std::string& message, opal::DocumentMap data, const opal::Document& id) " + "{", SPEC.errorFn()); - w.write("if (!type.empty()) data.insert_or_assign(\"__type\", smithy::Document(type));"); + w.write("if (!type.empty()) data.insert_or_assign(\"__type\", opal::Document(type));"); w.write("std::string text = message;"); w.openBlock("if (text.empty()) {"); w.write("const auto it = data.find(\"message\");"); w.write("if (it != data.end() && it->second.is_string()) text = it->second.as_string();"); w.closeBlock("}"); - w.write("smithy::DocumentMap error;"); - w.write("error.emplace(\"code\", smithy::Document(code));"); - w.write("error.emplace(\"message\", smithy::Document(std::move(text)));"); - w.write("if (!data.empty()) error.emplace(\"data\", smithy::Document(std::move(data)));"); - w.write("smithy::DocumentMap envelope;"); - w.write("envelope.emplace(\"jsonrpc\", smithy::Document(\"2.0\"));"); - w.write("envelope.emplace(\"error\", smithy::Document(std::move(error)));"); + w.write("opal::DocumentMap error;"); + w.write("error.emplace(\"code\", opal::Document(code));"); + w.write("error.emplace(\"message\", opal::Document(std::move(text)));"); + w.write("if (!data.empty()) error.emplace(\"data\", opal::Document(std::move(data)));"); + w.write("opal::DocumentMap envelope;"); + w.write("envelope.emplace(\"jsonrpc\", opal::Document(\"2.0\"));"); + w.write("envelope.emplace(\"error\", opal::Document(std::move(error)));"); w.write("envelope.emplace(\"id\", id);"); - w.write("smithy::http::HttpResponse response;"); + w.write("opal::http::HttpResponse response;"); w.write("response.status = 200;"); w.write("response.headers.Set(\"content-type\", \"application/json\");"); - w.write("response.body = smithy::json::Encode(smithy::Document(std::move(envelope)));"); + w.write("response.body = opal::json::Encode(opal::Document(std::move(envelope)));"); w.write("return response;"); w.closeBlock("}"); w.write(""); @@ -325,8 +325,8 @@ private void writeOperationDispatch( w.write("template "); w.openBlock( - "smithy::http::HttpResponse $L(Handler& handler, const smithy::Document& params, " - + "const smithy::Document& id, " + "opal::http::HttpResponse $L(Handler& handler, const opal::Document& params, " + + "const opal::Document& id, " + ProtocolSupport.REQUEST_CONTEXT_PARAM + " context) {", handleFunction(opName)); @@ -340,16 +340,16 @@ private void writeOperationDispatch( ProtocolSupport.writeRpcParsedInput(w, context, input, "params", "-32602", SPEC); } ProtocolSupport.writeRpcDispatch(w, operation, "handler.", SPEC, validation); - w.write("smithy::DocumentMap envelope;"); - w.write("envelope.emplace(\"jsonrpc\", smithy::Document(\"2.0\"));"); + w.write("opal::DocumentMap envelope;"); + w.write("envelope.emplace(\"jsonrpc\", opal::Document(\"2.0\"));"); w.write( "envelope.emplace(\"result\", Serialize$L(*outcome));", SerdeCodeGen.serdeFunctionSuffix(context, output)); w.write("envelope.emplace(\"id\", id);"); - w.write("smithy::http::HttpResponse response;"); + w.write("opal::http::HttpResponse response;"); w.write("response.status = 200;"); w.write("response.headers.Set(\"content-type\", \"application/json\");"); - w.write("response.body = smithy::json::Encode(smithy::Document(std::move(envelope)));"); + w.write("response.body = opal::json::Encode(opal::Document(std::move(envelope)));"); w.write("return response;"); w.closeBlock("}"); w.write(""); @@ -364,17 +364,17 @@ public void writeServerRoutes( // Guidelines F.9) to keep -Wunused-parameter quiet. w.openBlock( "(void)router_->Add(\"POST\", \"/\", " - + "[handler](const smithy::http::HttpRequest& $L, " + + "[handler](const opal::http::HttpRequest& $L, " + ProtocolSupport.REQUEST_CONTEXT_PARAM - + " $L) -> smithy::http::HttpResponse {", + + " $L) -> opal::http::HttpResponse {", anyCompressed ? "raw_request" : "request", operations.isEmpty() ? "/*context*/" : "context"); - w.write("smithy::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5)"); + w.write("opal::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5)"); if (anyCompressed) { // The endpoint is shared, so @requestCompression decodes before dispatch // (the client compresses the whole envelope); the reserved -32700 code // reports an undecodable body, with the envelope id echoed. - w.write("smithy::http::HttpRequest request = raw_request;"); + w.write("opal::http::HttpRequest request = raw_request;"); ProtocolSupport.writeGzipRequestDecode( w, "JsonRpcError", "-32700", "SerializationException", ", id"); } @@ -382,12 +382,12 @@ public void writeServerRoutes( w.openBlock( "if (const auto content_type = request.headers.Get(\"content-type\"); " + "content_type.has_value() && " - + "smithy::http::MediaTypeOf(*content_type) != \"application/json\") {"); + + "opal::http::MediaTypeOf(*content_type) != \"application/json\") {"); w.write( "return helpers::JsonRpcError(-32600, \"UnsupportedMediaTypeException\", " + "\"expected content-type: application/json\", {}, id);"); w.closeBlock("}"); - w.write("auto decoded = smithy::json::Decode(request.body);"); + w.write("auto decoded = opal::json::Decode(request.body);"); w.write("// Envelope failure messages are fixed strings: the conformance suite"); w.write("// compares bodies exactly, so no decoder detail leaks into the wire."); w.write( @@ -397,24 +397,24 @@ public void writeServerRoutes( "if (!decoded->is_map()) return helpers::JsonRpcError(-32600, \"SerializationException\", " + "\"request is not a JSON-RPC 2.0 call\", {}, id);"); w.write( - "if (const smithy::Document* id_doc = decoded->Find(\"id\"); " + "if (const opal::Document* id_doc = decoded->Find(\"id\"); " + "id_doc != nullptr) id = *id_doc;"); - w.write("const smithy::Document* version = decoded->Find(\"jsonrpc\");"); + w.write("const opal::Document* version = decoded->Find(\"jsonrpc\");"); w.openBlock( "if (version == nullptr || !version->is_string() || version->as_string() != \"2.0\") {"); w.write( "return helpers::JsonRpcError(-32600, \"SerializationException\", " + "\"expected jsonrpc: \\\"2.0\\\"\", {}, id);"); w.closeBlock("}"); - w.write("const smithy::Document* method = decoded->Find(\"method\");"); + w.write("const opal::Document* method = decoded->Find(\"method\");"); w.openBlock("if (method == nullptr || !method->is_string()) {"); w.write( "return helpers::JsonRpcError(-32600, \"SerializationException\", " + "\"expected a string method member\", {}, id);"); w.closeBlock("}"); w.write("// Absent/null params deserialize like an empty object."); - w.write("const smithy::Document empty_params{smithy::DocumentMap{}};"); - w.write("const smithy::Document* params = decoded->Find(\"params\");"); + w.write("const opal::Document empty_params{opal::DocumentMap{}};"); + w.write("const opal::Document* params = decoded->Find(\"params\");"); w.write("if (params == nullptr || params->is_null()) params = &empty_params;"); w.write("const std::string& method_name = method->as_string();"); for (OperationShape operation : operations) { diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/JsonRpc2StreamCodeGen.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/JsonRpc2StreamCodeGen.java index b799c438..a3c508e2 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/JsonRpc2StreamCodeGen.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/JsonRpc2StreamCodeGen.java @@ -33,25 +33,25 @@ static void writeSharedServerHelpers(CppWriter w) { w.write("// (ADR-0023): the unary emitters build the envelope, streams reuse their"); w.write("// bodies verbatim — one error identity, one spelling."); w.openBlock( - "smithy::eventstream::Message JsonRpcStreamText(const smithy::http::HttpResponse&" + "opal::eventstream::Message JsonRpcStreamText(const opal::http::HttpResponse&" + " response) {"); - w.write("smithy::eventstream::Message message;"); - w.write("message.payload = smithy::Blob::FromString(response.body);"); + w.write("opal::eventstream::Message message;"); + w.write("message.payload = opal::Blob::FromString(response.body);"); w.write("return message;"); w.closeBlock("}"); w.write(""); w.write("// The terminal result envelope that ends a clean stream: result stays {}"); w.write("// while initial-response members remain deferred (ADR-0016/0023)."); w.openBlock( - "smithy::eventstream::Message BuildJsonRpcTerminalResult(const smithy::Document& id) {"); - w.write("smithy::DocumentMap envelope;"); - w.write("envelope.emplace(\"jsonrpc\", smithy::Document(\"2.0\"));"); - w.write("envelope.emplace(\"result\", smithy::Document(smithy::DocumentMap{}));"); + "opal::eventstream::Message BuildJsonRpcTerminalResult(const opal::Document& id) {"); + w.write("opal::DocumentMap envelope;"); + w.write("envelope.emplace(\"jsonrpc\", opal::Document(\"2.0\"));"); + w.write("envelope.emplace(\"result\", opal::Document(opal::DocumentMap{}));"); w.write("envelope.emplace(\"id\", id);"); - w.write("smithy::eventstream::Message message;"); + w.write("opal::eventstream::Message message;"); w.write( "message.payload =" - + " smithy::Blob::FromString(smithy::json::Encode(smithy::Document(std::move(envelope))));"); + + " opal::Blob::FromString(opal::json::Encode(opal::Document(std::move(envelope))));"); w.write("return message;"); w.closeBlock("}"); w.write(""); @@ -60,21 +60,20 @@ static void writeSharedServerHelpers(CppWriter w) { w.write("// compares bodies, so no decoder detail leaks into the wire."); w.openBlock("struct JsonRpcOpening {"); w.write("bool ok = false;"); - w.write("smithy::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5)"); + w.write("opal::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5)"); w.write("std::string method;"); - w.write("smithy::Document params{smithy::DocumentMap{}};"); - w.write("smithy::eventstream::Message refusal; // when !ok: send, then close"); + w.write("opal::Document params{opal::DocumentMap{}};"); + w.write("opal::eventstream::Message refusal; // when !ok: send, then close"); w.closeBlock("};"); w.write(""); - w.openBlock( - "JsonRpcOpening ParseJsonRpcOpening(const smithy::eventstream::Message& message) {"); + w.openBlock("JsonRpcOpening ParseJsonRpcOpening(const opal::eventstream::Message& message) {"); w.write("JsonRpcOpening opening;"); w.openBlock("if (!message.headers.empty()) {"); w.write("// Only the raw-text wire reaches this route; a framed message means a"); w.write("// peer speaking the wrong wire entirely."); writeOpeningRefusal(w, "-32600", "the opening message must be one JSON-RPC request envelope"); w.closeBlock("}"); - w.write("auto decoded = smithy::json::Decode(message.payload.ToString());"); + w.write("auto decoded = opal::json::Decode(message.payload.ToString());"); w.openBlock("if (!decoded) {"); writeOpeningRefusal(w, "-32700", "request body is not valid JSON"); w.closeBlock("}"); @@ -82,14 +81,14 @@ static void writeSharedServerHelpers(CppWriter w) { writeOpeningRefusal(w, "-32600", "request is not a JSON-RPC 2.0 call"); w.closeBlock("}"); w.write( - "if (const smithy::Document* id_doc = decoded->Find(\"id\"); id_doc != nullptr)" + "if (const opal::Document* id_doc = decoded->Find(\"id\"); id_doc != nullptr)" + " opening.id = *id_doc;"); - w.write("const smithy::Document* version = decoded->Find(\"jsonrpc\");"); + w.write("const opal::Document* version = decoded->Find(\"jsonrpc\");"); w.openBlock( "if (version == nullptr || !version->is_string() || version->as_string() != \"2.0\") {"); writeOpeningRefusal(w, "-32600", "expected jsonrpc: \\\"2.0\\\""); w.closeBlock("}"); - w.write("const smithy::Document* method = decoded->Find(\"method\");"); + w.write("const opal::Document* method = decoded->Find(\"method\");"); w.openBlock("if (method == nullptr || !method->is_string()) {"); writeOpeningRefusal(w, "-32600", "expected a string method member"); w.closeBlock("}"); @@ -99,7 +98,7 @@ static void writeSharedServerHelpers(CppWriter w) { writeOpeningRefusal(w, "-32600", "the opening call must carry an id"); w.closeBlock("}"); w.write("// Absent/null params deserialize like an empty object."); - w.write("const smithy::Document* params = decoded->Find(\"params\");"); + w.write("const opal::Document* params = decoded->Find(\"params\");"); w.write("if (params != nullptr && !params->is_null()) opening.params = *params;"); w.write("opening.method = method->as_string();"); w.write("opening.ok = true;"); @@ -140,14 +139,14 @@ static void writeAsyncServeWrapper( w.write("// frame (and the stream it owns) outlives the write. Best-effort, like"); w.write("// every terminal send: a send the dead session refuses is discarded."); w.openBlock( - "smithy::eventstream::Detached Serve$LAsync(std::shared_ptr handler," - + " $L input, std::shared_ptr socket, smithy::Document id) {", + "opal::eventstream::Detached Serve$LAsync(std::shared_ptr handler," + + " $L input, std::shared_ptr socket, opal::Document id) {", op, serviceName, inputType); w.write( - "auto wrapped = std::make_shared(socket, id," - + " smithy::eventstream::JsonRpcStreamSocket::Role::kServer);"); + "auto wrapped = std::make_shared(socket, id," + + " opal::eventstream::JsonRpcStreamSocket::Role::kServer);"); w.write( "types::$L stream(wrapped, $L, helpers::Decode$LEvent);", EventStreamCodeGen.asyncServerStreamAlias(operation), @@ -158,11 +157,11 @@ static void writeAsyncServeWrapper( w.write("// Built OUTSIDE the co_await expression on purpose: a conditional"); w.write("// operator inside a co_await full expression miscompiles on GCC (the"); w.write("// branch temporaries become frame slots and the wrong branch runs)."); - w.write("smithy::eventstream::Message terminal ="); + w.write("opal::eventstream::Message terminal ="); w.write(" outcome.ok() ? BuildJsonRpcTerminalResult(id)"); w.write( " : helpers::JsonRpcStreamText(helpers::ErrorToResponse(outcome.error(), id));"); - w.write("(void)co_await smithy::eventstream::SendMessage(socket, std::move(terminal));"); + w.write("(void)co_await opal::eventstream::SendMessage(socket, std::move(terminal));"); w.write("stream.Close();"); w.closeBlock("}"); w.write(""); @@ -188,7 +187,7 @@ static void writeServeDrivers( w.openBlock( "void ServeJsonRpcStream(types::$LHandler& handler, " + ProtocolSupport.REQUEST_CONTEXT_PARAM - + " context, smithy::http::WebSocket& socket) {", + + " context, opal::http::WebSocket& socket) {", serviceName); w.write("auto first = socket.Receive();"); w.write("// A wire that failed or closed before the opening call is a non-event."); @@ -208,14 +207,14 @@ static void writeServeDrivers( w.write("// envelope is read inside this Detached frame — a client that upgrades"); w.write("// and never calls costs no parked thread."); w.openBlock( - "smithy::eventstream::Detached ServeJsonRpcSession(std::shared_ptr" - + " handler, std::shared_ptr socket) {", + "opal::eventstream::Detached ServeJsonRpcSession(std::shared_ptr" + + " handler, std::shared_ptr socket) {", serviceName); - w.write("auto first = co_await smithy::eventstream::ReceiveMessage(socket);"); + w.write("auto first = co_await opal::eventstream::ReceiveMessage(socket);"); w.write("if (!first.ok() || !first->has_value()) co_return;"); w.write("const JsonRpcOpening opening = helpers::ParseJsonRpcOpening(**first);"); w.openBlock("if (!opening.ok) {"); - w.write("(void)co_await smithy::eventstream::SendMessage(socket, opening.refusal);"); + w.write("(void)co_await opal::eventstream::SendMessage(socket, opening.refusal);"); w.write("socket->Close();"); w.write("co_return;"); w.closeBlock("}"); @@ -254,7 +253,7 @@ private static void writeOpeningDispatch( w.write("input = *std::move(parsed);"); } if (validation.validates(operation)) { - w.write("std::vector validation_failures;"); + w.write("std::vector validation_failures;"); w.write( "helpers::$L(input, \"\", &validation_failures);", validation.validatorNameFor(operation)); @@ -276,8 +275,8 @@ private static void writeOpeningDispatch( w.write("co_return;"); } else { w.write( - "smithy::eventstream::JsonRpcStreamSocket wrapped(socket, opening.id," - + " smithy::eventstream::JsonRpcStreamSocket::Role::kServer);"); + "opal::eventstream::JsonRpcStreamSocket wrapped(socket, opening.id," + + " opal::eventstream::JsonRpcStreamSocket::Role::kServer);"); w.write( "types::$L stream(wrapped, $L, helpers::Decode$LEvent);", EventStreamCodeGen.serverStreamAlias(operation), @@ -306,7 +305,7 @@ private static void writeOpeningDispatch( /** Send one terminal refusal, close, and leave the driver — seam-appropriate forms. */ private static void writeRefusalTail(CppWriter w, boolean session, String messageExpr) { if (session) { - w.write("(void)co_await smithy::eventstream::SendMessage(socket, $L);", messageExpr); + w.write("(void)co_await opal::eventstream::SendMessage(socket, $L);", messageExpr); w.write("socket->Close();"); w.write("co_return;"); } else { @@ -331,7 +330,7 @@ static void writeStreamingOperationBody( w.addInclude("\"smithy/eventstream/jsonrpc_stream_socket.h\""); StructureShape input = ProtocolSupport.inputShape(context, operation); String op = EventStreamCodeGen.opName(operation); - w.write("smithy::http::WebSocketDialRequest request;"); + w.write("opal::http::WebSocketDialRequest request;"); w.write("// The shared endpoint (ADR-0023): the same target the unary POST uses —"); w.write("// the operation rides the opening envelope, and every frame is text."); w.write("request.target = path_prefix_ + \"/\";"); @@ -343,10 +342,10 @@ static void writeStreamingOperationBody( w.write("// The opening request envelope: selects the operation and carries the"); w.write("// initial-request members (the :initial-request seam, realized)."); if (ProtocolSupport.noModeledInput(input)) { - w.write("smithy::DocumentMap params;"); + w.write("opal::DocumentMap params;"); } else { w.write( - "smithy::DocumentMap params = Serialize$L(input).as_map();", + "opal::DocumentMap params = Serialize$L(input).as_map();", SerdeCodeGen.serdeFunctionSuffix(context, input)); MemberShape streamMember = EventStreamCodeGen.inputStreamMember(context.model(), operation); if (streamMember != null) { @@ -356,21 +355,21 @@ static void writeStreamingOperationBody( HttpBindingCodeGen.wireName(streamMember, protocol.usesJsonName())); } } - w.write("smithy::DocumentMap envelope;"); - w.write("envelope.emplace(\"jsonrpc\", smithy::Document(\"2.0\"));"); - w.write("envelope.emplace(\"method\", smithy::Document($S));", operation.getId().getName()); - w.write("envelope.emplace(\"id\", smithy::Document(1));"); - w.write("envelope.emplace(\"params\", smithy::Document(std::move(params)));"); - w.write("smithy::eventstream::Message opening;"); + w.write("opal::DocumentMap envelope;"); + w.write("envelope.emplace(\"jsonrpc\", opal::Document(\"2.0\"));"); + w.write("envelope.emplace(\"method\", opal::Document($S));", operation.getId().getName()); + w.write("envelope.emplace(\"id\", opal::Document(1));"); + w.write("envelope.emplace(\"params\", opal::Document(std::move(params)));"); + w.write("opal::eventstream::Message opening;"); w.write( "opening.payload =" - + " smithy::Blob::FromString(smithy::json::Encode(smithy::Document(std::move(envelope))));"); + + " opal::Blob::FromString(opal::json::Encode(opal::Document(std::move(envelope))));"); w.write("auto sent = (*socket)->Send(opening);"); w.write("if (!sent) return std::move(sent).error();"); w.write("return $L(", EventStreamCodeGen.clientStreamAlias(operation)); w.write( - " std::make_shared(*std::move(socket)," - + " smithy::Document(1), smithy::eventstream::JsonRpcStreamSocket::Role::kClient),"); + " std::make_shared(*std::move(socket)," + + " opal::Document(1), opal::eventstream::JsonRpcStreamSocket::Role::kClient),"); w.write( " $L, helpers::Decode$LEvent);", EventStreamCodeGen.encoderArgument( diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/MemberDefaults.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/MemberDefaults.java index 533b09cf..534a7556 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/MemberDefaults.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/MemberDefaults.java @@ -92,11 +92,11 @@ static String literal(CppContext context, MemberShape member) { case FLOAT -> "static_cast(" + value.expectNumberNode().getValue().doubleValue() + ")"; case DOUBLE -> String.valueOf(value.expectNumberNode().getValue().doubleValue()); case TIMESTAMP -> - "smithy::Timestamp::FromEpochMilliseconds(" + "opal::Timestamp::FromEpochMilliseconds(" + Math.round(value.expectNumberNode().getValue().doubleValue() * 1000.0) + "LL)"; case BLOB -> - "smithy::Blob::FromString(" + "opal::Blob::FromString(" + CppLiterals.stringLiteral( new String( Base64.getDecoder().decode(value.expectStringNode().getValue()), diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/NodeLiteralGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/NodeLiteralGenerator.java index 7be4d931..d2f87e0e 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/NodeLiteralGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/NodeLiteralGenerator.java @@ -46,7 +46,7 @@ String expression(Shape shape, Node node) { case DOUBLE -> floatingExpression(node, false); case TIMESTAMP -> timestampExpression(node); case BLOB -> - "smithy::Blob::FromString(" + "opal::Blob::FromString(" + CppLiterals.stringLiteral(node.expectStringNode().getValue()) + ")"; case DOCUMENT -> documentExpression(node); @@ -92,13 +92,13 @@ private static String floatingExpression(Node node, boolean isFloat) { private static String timestampExpression(Node node) { NumberNode number = node.expectNumberNode(); long millis = Math.round(number.getValue().doubleValue() * 1000.0); - return "smithy::Timestamp::FromEpochMilliseconds(" + millis + "LL)"; + return "opal::Timestamp::FromEpochMilliseconds(" + millis + "LL)"; } private String structureExpression(StructureShape shape, Node node) { ObjectNode object = node.expectObjectNode(); if (shape.getId().toString().equals("smithy.api#Unit")) { - return "smithy::Unit{}"; + return "opal::Unit{}"; } StringBuilder out = new StringBuilder("[] {\n"); out.append(" ").append(typeName(shape)).append(" v{};\n"); @@ -194,9 +194,9 @@ private String minimalExpression(Shape shape, MemberShape member) { case STRING -> minimalStringExpression(shape, member); case ENUM -> minimalEnumExpression(shape); case INT_ENUM -> minimalIntEnumExpression(shape); - case BLOB -> "smithy::Blob()"; - case TIMESTAMP -> "smithy::Timestamp::FromEpochMilliseconds(0)"; - case DOCUMENT -> "smithy::Document(smithy::DocumentMap{})"; + case BLOB -> "opal::Blob()"; + case TIMESTAMP -> "opal::Timestamp::FromEpochMilliseconds(0)"; + case DOCUMENT -> "opal::Document(opal::DocumentMap{})"; case LIST, MAP -> typeName(shape) + "{}"; case STRUCTURE -> minimalStructureExpression(shape.asStructureShape().orElseThrow()); case UNION -> minimalUnionExpression(shape.asUnionShape().orElseThrow()); @@ -281,7 +281,7 @@ private String minimalIntEnumExpression(Shape shape) { private String minimalStructureExpression(StructureShape shape) { if (shape.getId().toString().equals("smithy.api#Unit")) { - return "smithy::Unit{}"; + return "opal::Unit{}"; } // Default construction is already minimal unless a required member's // default is invalid on the wire or under constraint validation. @@ -356,32 +356,30 @@ private boolean needsExplicitMinimal( private String documentExpression(Node node) { if (node.isNullNode()) { - return "smithy::Document(nullptr)"; + return "opal::Document(nullptr)"; } if (node.isBooleanNode()) { - return "smithy::Document(" + (node.expectBooleanNode().getValue() ? "true" : "false") + ")"; + return "opal::Document(" + (node.expectBooleanNode().getValue() ? "true" : "false") + ")"; } if (node.isNumberNode()) { NumberNode number = node.expectNumberNode(); if (number.isFloatingPointNumber()) { - return "smithy::Document(" - + CppLiterals.doubleLiteral(number.getValue().doubleValue()) - + ")"; + return "opal::Document(" + CppLiterals.doubleLiteral(number.getValue().doubleValue()) + ")"; } - return "smithy::Document(std::int64_t{" + number.getValue().longValue() + "})"; + return "opal::Document(std::int64_t{" + number.getValue().longValue() + "})"; } if (node.isStringNode()) { StringNode string = node.expectStringNode(); - return "smithy::Document(std::string(" + CppLiterals.stringLiteral(string.getValue()) + "))"; + return "opal::Document(std::string(" + CppLiterals.stringLiteral(string.getValue()) + "))"; } if (node.isArrayNode()) { - StringBuilder out = new StringBuilder("[] {\n smithy::DocumentList list;\n"); + StringBuilder out = new StringBuilder("[] {\n opal::DocumentList list;\n"); for (Node element : node.expectArrayNode().getElements()) { out.append(" list.emplace_back(").append(documentExpression(element)).append(");\n"); } - return out.append(" return smithy::Document(std::move(list));\n}()").toString(); + return out.append(" return opal::Document(std::move(list));\n}()").toString(); } - StringBuilder out = new StringBuilder("[] {\n smithy::DocumentMap map;\n"); + StringBuilder out = new StringBuilder("[] {\n opal::DocumentMap map;\n"); for (var entry : node.expectObjectNode().getStringMap().entrySet()) { out.append(" map.emplace(") .append(CppLiterals.stringLiteral(entry.getKey())) @@ -389,6 +387,6 @@ private String documentExpression(Node node) { .append(documentExpression(entry.getValue())) .append(");\n"); } - return out.append(" return smithy::Document(std::move(map));\n}()").toString(); + return out.append(" return opal::Document(std::move(map));\n}()").toString(); } } diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolGenerator.java index 09614883..3563d8e6 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolGenerator.java @@ -94,13 +94,13 @@ default boolean bindsInitialRequestMembers() { return false; } - /** Expression producing an event payload (a smithy::Blob) from a serialized Document. */ + /** Expression producing an event payload (a opal::Blob) from a serialized Document. */ default String eventPayloadEncode(String docExpr) { throw new software.amazon.smithy.codegen.core.CodegenException( "cpp-codegen: " + name() + " does not support event streams"); } - /** Expression producing an Outcome<smithy::Document> from an event payload Blob. */ + /** Expression producing an Outcome<opal::Document> from an event payload Blob. */ default String eventPayloadDecode(String payloadExpr) { throw new software.amazon.smithy.codegen.core.CodegenException( "cpp-codegen: " + name() + " does not support event streams"); diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolSupport.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolSupport.java index 3f70bc8a..abbdbe41 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolSupport.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolSupport.java @@ -17,7 +17,7 @@ final class ProtocolSupport { /** The handler methods' second parameter (ADR-0010), spelled once. */ - static final String REQUEST_CONTEXT_PARAM = "const smithy::server::RequestContext&"; + static final String REQUEST_CONTEXT_PARAM = "const opal::server::RequestContext&"; /** * Opens a generated test-stub handler override — the one signature every test generator's handler @@ -26,7 +26,7 @@ final class ProtocolSupport { static void openTestHandlerOverride( CppWriter w, String outputType, String opName, String inputType) { w.openBlock( - "smithy::Outcome<$L> $L(const $L& input, $L) override {", + "opal::Outcome<$L> $L(const $L& input, $L) override {", outputType, opName, inputType, @@ -78,20 +78,20 @@ static void writeParsedErrorStruct(CppWriter w) { w.write("int status = 0;"); w.write("std::string code = \"UnknownError\";"); w.write("std::string message;"); - w.write("smithy::Document doc;"); + w.write("opal::Document doc;"); w.closeBlock("};"); w.write(""); } - /** Emits GenericError: the fallback smithy::Error for unrecognized wire errors. */ + /** Emits GenericError: the fallback opal::Error for unrecognized wire errors. */ static void writeGenericError(CppWriter w) { - w.openBlock("smithy::Error GenericError(ParsedError parsed) {"); + w.openBlock("opal::Error GenericError(ParsedError parsed) {"); w.write("const bool retryable = parsed.status >= 500;"); w.write( - "if (parsed.code == \"UnknownError\") return smithy::Error(smithy::ErrorKind::kUnknown, " + "if (parsed.code == \"UnknownError\") return opal::Error(opal::ErrorKind::kUnknown, " + "std::move(parsed.code), std::move(parsed.message), retryable);"); w.write( - "return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), " + "return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), " + "retryable);"); w.closeBlock("}"); w.write(""); @@ -109,7 +109,7 @@ static void writeErrorSupport(CppWriter w, String decodeStatement, String errorT w.write("// [[maybe_unused]]: only unary response paths parse wire errors; a"); w.write("// service whose operations all stream never calls this."); w.openBlock( - "[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) {"); + "[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) {"); w.write("ParsedError parsed;"); w.write("parsed.status = response.status;"); w.write("parsed.message = \"HTTP \" + std::to_string(response.status);"); @@ -121,12 +121,12 @@ static void writeErrorSupport(CppWriter w, String decodeStatement, String errorT "if (type_header.has_value()) parsed.code = helpers::SanitizeErrorCode(*type_header);"); } w.openBlock("if (parsed.doc.is_map()) {"); - w.write("const smithy::Document* type = parsed.doc.Find(\"__type\");"); + w.write("const opal::Document* type = parsed.doc.Find(\"__type\");"); w.write("if (type == nullptr) type = parsed.doc.Find(\"code\");"); w.write( "if (parsed.code == \"UnknownError\" && type != nullptr && type->is_string()) " + "parsed.code = helpers::SanitizeErrorCode(type->as_string());"); - w.write("const smithy::Document* text = parsed.doc.Find(\"message\");"); + w.write("const opal::Document* text = parsed.doc.Find(\"message\");"); w.write("if (text != nullptr && text->is_string()) parsed.message = text->as_string();"); w.closeBlock("}"); w.write("return parsed;"); @@ -146,7 +146,7 @@ static void writeNumericParseHelpers(CppWriter w) { w.write("// Trailing text, floats-for-ints, and out-of-range values are rejected"); w.write("// (the malformed-request suites pin this)."); w.openBlock( - "[[maybe_unused]] smithy::Outcome ParseInt64Text(const std::string& text, " + "[[maybe_unused]] opal::Outcome ParseInt64Text(const std::string& text, " + "std::int64_t min_value, std::int64_t max_value) {"); w.write("std::int64_t value = 0;"); w.write("const char* first = text.data();"); @@ -156,7 +156,7 @@ static void writeNumericParseHelpers(CppWriter w) { "if (text.empty() || result.ec != std::errc() || result.ptr != last || " + "value < min_value || value > max_value) {"); w.indent(); - w.write("return smithy::Error::Serialization(\"invalid integer: \" + text);"); + w.write("return opal::Error::Serialization(\"invalid integer: \" + text);"); w.dedent(); w.write("}"); w.write("return value;"); @@ -166,7 +166,7 @@ static void writeNumericParseHelpers(CppWriter w) { // pair a strict character-set check (rejects hex, inf/nan spellings, and // leading '+'/whitespace strtod would accept) with a fully-consuming strtod. w.openBlock( - "[[maybe_unused]] smithy::Outcome ParseDoubleText(const std::string& text) {"); + "[[maybe_unused]] opal::Outcome ParseDoubleText(const std::string& text) {"); w.write("if (text == \"NaN\") return std::numeric_limits::quiet_NaN();"); w.write("if (text == \"Infinity\") return std::numeric_limits::infinity();"); w.write("if (text == \"-Infinity\") return -std::numeric_limits::infinity();"); @@ -178,12 +178,12 @@ static void writeNumericParseHelpers(CppWriter w) { w.openBlock( "if (text.empty() || text.front() == '+' || " + "!std::all_of(text.begin(), text.end(), valid_char)) {"); - w.write("return smithy::Error::Serialization(\"invalid number: \" + text);"); + w.write("return opal::Error::Serialization(\"invalid number: \" + text);"); w.closeBlock("}"); w.write("char* parse_end = nullptr;"); w.write("const double value = std::strtod(text.c_str(), &parse_end);"); w.openBlock("if (parse_end != text.c_str() + text.size() || !std::isfinite(value)) {"); - w.write("return smithy::Error::Serialization(\"invalid number: \" + text);"); + w.write("return opal::Error::Serialization(\"invalid number: \" + text);"); w.closeBlock("}"); w.write("return value;"); w.closeBlock("}"); @@ -253,7 +253,7 @@ static void writeRequestCompression( w.openBlock( "if (request.body.size() >= " + "static_cast(config_.request_min_compression_size_bytes)) {"); - w.write("auto compressed = smithy::GzipCompress(request.body);"); + w.write("auto compressed = opal::GzipCompress(request.body);"); w.write("if (!compressed) return std::move(compressed).error();"); w.write("request.body = *std::move(compressed);"); w.write("const auto existing_encoding = request.headers.Get(\"content-encoding\");"); @@ -287,7 +287,7 @@ static void writeGzipRequestDecode( "if (const auto request_encoding = request.headers.Get(\"content-encoding\"); " + "request_encoding.has_value() && (*request_encoding == \"gzip\" || " + "request_encoding->ends_with(\", gzip\"))) {"); - w.write("auto decompressed = smithy::GzipDecompress(request.body);"); + w.write("auto decompressed = opal::GzipDecompress(request.body);"); w.openBlock("if (!decompressed) {"); w.write( "return helpers::$L($L, $S, \"invalid gzip request body\", {}$L);", @@ -320,12 +320,12 @@ static void writeErrorBodyHelper( String extraHeaderName, String extraHeaderValue) { w.openBlock( - "smithy::http::HttpResponse $L(int status, const std::string& code, " - + "const std::string& message, smithy::DocumentMap body) {", + "opal::http::HttpResponse $L(int status, const std::string& code, " + + "const std::string& message, opal::DocumentMap body) {", name); - w.write("if (!code.empty()) body.insert_or_assign(\"__type\", smithy::Document(code));"); - w.write("if (!message.empty()) body.insert_or_assign(\"message\", smithy::Document(message));"); - w.write("smithy::http::HttpResponse response;"); + w.write("if (!code.empty()) body.insert_or_assign(\"__type\", opal::Document(code));"); + w.write("if (!message.empty()) body.insert_or_assign(\"message\", opal::Document(message));"); + w.write("opal::http::HttpResponse response;"); w.write("response.status = status;"); if (!extraHeaderName.isEmpty()) { w.write("response.headers.Set($S, $S);", extraHeaderName, extraHeaderValue); @@ -345,7 +345,7 @@ static void writeErrorBodyHelper( static String writeRpcRequestPrelude(CppWriter w, CppContext context, StructureShape input) { String in = prepareIdempotencyTokens(w, context, input, context.cppSymbols().toSymbol(input).getName()); - w.write("smithy::http::HttpRequest request;"); + w.write("opal::http::HttpRequest request;"); w.write("request.method = \"POST\";"); return in; } @@ -460,7 +460,7 @@ static void writeServerErrorToResponse( /** * Positional variant behind the {@link ErrorResponseSpec} entry point: {@code extraParams} is - * appended to ErrorToResponse's signature (e.g. ", const smithy::Document& id") and {@code + * appended to ErrorToResponse's signature (e.g. ", const opal::Document& id") and {@code * extraArgs} to every {@code errorBodyFn} call (e.g. ", id"). jsonRpc2 uses this to echo the * request id into error envelopes. */ @@ -486,18 +486,18 @@ private static void writeServerErrorToResponse( w.write("// [[maybe_unused]]: only unary routes map handler errors here; a service"); w.write("// whose operations all stream reports errors on the stream instead."); w.openBlock( - "[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& " + "[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& " + "error$L) {", extraParams); if (!errortypeHeader.isEmpty()) { w.write("std::vector> header_values;"); w.write("(void)header_values;"); } - w.openBlock("if (error.kind() == smithy::ErrorKind::kModeled) {"); + w.openBlock("if (error.kind() == opal::ErrorKind::kModeled) {"); for (StructureShape shape : errorShapes.values()) { String type = context.cppSymbols().toSymbol(shape).getName(); w.openBlock("if (error.code() == $S) {", shape.getId().getName()); - w.write("smithy::DocumentMap body;"); + w.write("opal::DocumentMap body;"); w.openBlock("if (const auto* detail = error.detail()) {", type); w.write( "body = Serialize$L(*detail).as_map();", @@ -508,7 +508,7 @@ private static void writeServerErrorToResponse( "const bool has_message = body.count(\"message\") != 0 || " + "body.count(\"Message\") != 0;"); w.openBlock("if (!has_message && !error.message().empty()) {"); - w.write("body.emplace(\"message\", smithy::Document(error.message()));"); + w.write("body.emplace(\"message\", opal::Document(error.message()));"); w.closeBlock("}"); if (!errortypeHeader.isEmpty()) { // restJson1: @httpHeader-bound error members travel as headers, and the @@ -537,7 +537,7 @@ private static void writeServerErrorToResponse( + "std::to_string(it->second.as_int()));"; case FLOAT, DOUBLE -> "if (it->second.is_double()) header_values.emplace_back($S, " - + "smithy::FormatDouble(it->second.as_double()));"; + + "opal::FormatDouble(it->second.as_double()));"; case BOOLEAN -> "if (it->second.is_bool()) header_values.emplace_back($S, " + "it->second.as_bool() ? \"true\" : \"false\");"; @@ -579,16 +579,16 @@ private static void writeServerErrorToResponse( // restJson1: parse failures answer 400 with the SerializationException // error identity in the header (the malformed-request suite pins this). w.openBlock( - "if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == " - + "smithy::ErrorKind::kSerialization) {"); + "if (error.kind() == opal::ErrorKind::kValidation || error.kind() == " + + "opal::ErrorKind::kSerialization) {"); w.write("auto response = $L(400, \"\", error.message(), {}$L);", errorCall, extraArgs); w.write("response.headers.Set($S, \"SerializationException\");", errortypeHeader); w.write("return response;"); w.closeBlock("}"); } else { w.write( - "if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == " - + "smithy::ErrorKind::kSerialization) return $L(400, \"SerializationException\", " + "if (error.kind() == opal::ErrorKind::kValidation || error.kind() == " + + "opal::ErrorKind::kSerialization) return $L(400, \"SerializationException\", " + "error.message(), {}$L);", errorCall, extraArgs); @@ -636,7 +636,7 @@ static void writeOperationErrorParsers( for (StructureShape shape : errorShapes.values()) { boolean retryable = shape.hasTrait(RetryableTrait.class); w.openBlock( - "smithy::Error $L(const smithy::http::HttpResponse& response, ParsedError parsed) {", + "opal::Error $L(const opal::http::HttpResponse& response, ParsedError parsed) {", makeErrorFunction(context, shape)); w.write("(void)response;"); if (retryable) { @@ -647,12 +647,12 @@ static void writeOperationErrorParsers( // code() carries the wire-level shape name, which can differ from the // C++ type name when a foreign-namespace shape was disambiguated. w.write( - "smithy::Error error = smithy::Error::Modeled($S, std::move(parsed.message), " + "opal::Error error = opal::Error::Modeled($S, std::move(parsed.message), " + "retryable);", shape.getId().getName()); // Errors with header-only payloads (or none at all) may have no body: // deserialize from an empty map so the typed detail still attaches. - w.write("if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{});"); + w.write("if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{});"); // Header-bound members are patched into the document before it // deserializes, so @required header members are satisfied. protocol.writeErrorDocPatches(w, context, shape); @@ -687,7 +687,7 @@ static void writeOperationErrorParsers( // Serialize/Deserialize namespace, and a same-named file-local // helper would hide them (C++ name hiding) for shapes named Error. w.openBlock( - "smithy::Error $L(const smithy::http::HttpResponse& response) {", + "opal::Error $L(const opal::http::HttpResponse& response) {", parseErrorFunction(operation)); w.write("ParsedError parsed = helpers::ParseError(response);"); for (Map.Entry entry : sorted.entrySet()) { @@ -758,9 +758,9 @@ static String prepareIdempotencyTokens( } String field = "prepared." + context.cppSymbols().toMemberName(member); if (member.isRequired()) { - w.write("if ($L.empty()) $L = smithy::GenerateUuidV4();", field, field); + w.write("if ($L.empty()) $L = opal::GenerateUuidV4();", field, field); } else { - w.write("if (!$L.has_value()) $L = smithy::GenerateUuidV4();", field, field); + w.write("if (!$L.has_value()) $L = opal::GenerateUuidV4();", field, field); } } return any ? "prepared" : "input"; @@ -775,8 +775,8 @@ static String toStringExpression( case ENUM -> "std::string(" + valueExpr + ".ToString())"; case BYTE, SHORT, INTEGER, LONG, INT_ENUM -> "std::to_string(static_cast(" + valueExpr + "))"; - case FLOAT -> "smithy::FormatFloat(" + valueExpr + ")"; - case DOUBLE -> "smithy::FormatDouble(" + valueExpr + ")"; + case FLOAT -> "opal::FormatFloat(" + valueExpr + ")"; + case DOUBLE -> "opal::FormatDouble(" + valueExpr + ")"; case BOOLEAN -> "(" + valueExpr + " ? \"true\" : \"false\")"; case TIMESTAMP -> valueExpr + ".Format(" + timestampFormat + ")"; default -> diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolTestGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolTestGenerator.java index 79aebe64..d2f76ce4 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolTestGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ProtocolTestGenerator.java @@ -222,25 +222,25 @@ private String requestTest(OperationShape operation, HttpRequestTestCase testCas t.append(" (void)fixture.client.") .append(CppReservedWords.escape(operation.getId().getName())) .append("(input);\n"); - t.append(" const smithy::http::HttpRequest& request = fixture.transport->last_request;\n"); + t.append(" const opal::http::HttpRequest& request = fixture.transport->last_request;\n"); t.append(" EXPECT_EQ(request.method, ") .append(CppLiterals.stringLiteral(testCase.getMethod())) .append(");\n"); - t.append(" EXPECT_EQ(smithy::testing::UriPath(request.target), ") + t.append(" EXPECT_EQ(opal::testing::UriPath(request.target), ") .append(CppLiterals.stringLiteral(testCase.getUri())) .append(");\n"); if (!testCase.getQueryParams().isEmpty()) { - t.append(" EXPECT_TRUE(smithy::testing::QueryContains(request.target, ") + t.append(" EXPECT_TRUE(opal::testing::QueryContains(request.target, ") .append(stringVector(testCase.getQueryParams())) .append("));\n"); } if (!testCase.getForbidQueryParams().isEmpty()) { - t.append(" EXPECT_TRUE(smithy::testing::QueryForbidsKeys(request.target, ") + t.append(" EXPECT_TRUE(opal::testing::QueryForbidsKeys(request.target, ") .append(stringVector(testCase.getForbidQueryParams())) .append("));\n"); } if (!testCase.getRequireQueryParams().isEmpty()) { - t.append(" EXPECT_TRUE(smithy::testing::QueryRequiresKeys(request.target, ") + t.append(" EXPECT_TRUE(opal::testing::QueryRequiresKeys(request.target, ") .append(stringVector(testCase.getRequireQueryParams())) .append("));\n"); } @@ -276,12 +276,12 @@ private String bodyAssertion(String body, Optional mediaType) { // would spuriously fail (e.g. alloy's RoundTrip response). String type = mediaType.orElse(protocol.contentType()); if (type.equals("application/json") || type.endsWith("+json")) { - return " EXPECT_TRUE(smithy::testing::JsonBodyEquals(" + return " EXPECT_TRUE(opal::testing::JsonBodyEquals(" + CppLiterals.stringLiteral(body) + ", request.body));\n"; } if (type.equals("application/cbor")) { - return " EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64(" + return " EXPECT_TRUE(opal::testing::CborBodyEqualsBase64(" + CppLiterals.stringLiteral(body) + ", request.body));\n"; } @@ -380,7 +380,7 @@ private String responseTest( String body = testCase.getBody().orElse(""); String mediaType = testCase.getBodyMediaType().orElse(""); if (mediaType.equals("application/cbor")) { - t.append(" fixture.transport->next_response.body = smithy::testing::FromBase64(") + t.append(" fixture.transport->next_response.body = opal::testing::FromBase64(") .append(CppLiterals.stringLiteral(body)) .append(");\n"); } else { @@ -456,13 +456,13 @@ private void writeFixture(CppWriter w) { w.write("namespace {"); w.write(""); w.openBlock("struct Fixture {"); - w.write("std::shared_ptr transport;"); + w.write("std::shared_ptr transport;"); w.write("$L client;", client); w.closeBlock("};"); w.write(""); w.openBlock("Fixture MakeFixture(const std::string& endpoint = \"\") {"); - w.write("auto transport = std::make_shared();"); - w.write("smithy::ClientConfig config;"); + w.write("auto transport = std::make_shared();"); + w.write("opal::ClientConfig config;"); w.write("config.retry.max_attempts = 1; // wire-exact tests: no retries"); w.write("config.http_client = transport;"); w.write("config.endpoint = endpoint;"); @@ -560,7 +560,7 @@ private String wireRequest( Optional body, Optional mediaType) { StringBuilder t = new StringBuilder(); - t.append(" smithy::http::HttpRequest request;\n"); + t.append(" opal::http::HttpRequest request;\n"); t.append(" request.method = ").append(CppLiterals.stringLiteral(method)).append(";\n"); StringBuilder target = new StringBuilder(uri); if (!queryParams.isEmpty()) { @@ -578,7 +578,7 @@ private String wireRequest( } if (body.isPresent() && !body.get().isEmpty()) { if (mediaType.orElse(protocol.contentType()).equals("application/cbor")) { - t.append(" request.body = smithy::testing::FromBase64(") + t.append(" request.body = opal::testing::FromBase64(") .append(CppLiterals.stringLiteral(body.get())) .append(");\n"); } else { @@ -646,7 +646,7 @@ private String serverRequestTest(OperationShape operation, HttpRequestTestCase t testCase.getHeaders(), testCase.getBody(), testCase.getBodyMediaType())); - t.append(" const smithy::http::HttpResponse response = server.Handler()(request);\n"); + t.append(" const opal::http::HttpResponse response = server.Handler()(request);\n"); t.append(" ASSERT_TRUE(handler->last") .append(opName) .append(".has_value()) << response.status << \" \" << response.body;\n"); @@ -734,9 +734,9 @@ private void writeServerResponseTests() { /** A routable wire request for the operation, captured from the generated client. */ private void writeMinimalRequestHelper(CppWriter w, OperationShape operation) { String opName = CppReservedWords.escape(operation.getId().getName()); - w.openBlock("smithy::http::HttpRequest MinimalRequestFor$L() {", opName); - w.write("auto transport = std::make_shared();"); - w.write("smithy::ClientConfig config;"); + w.openBlock("opal::http::HttpRequest MinimalRequestFor$L() {", opName); + w.write("auto transport = std::make_shared();"); + w.write("opal::ClientConfig config;"); w.write("config.retry.max_attempts = 1; // wire-exact tests: no retries"); w.write("config.http_client = transport;"); w.write("auto client = *$L::Create(std::move(config));", clientType()); @@ -797,7 +797,7 @@ private String serverResponseTest( .append(") {\n"); t.append(" class Handler final : public RecordingHandler {\n"); t.append(" public:\n"); - t.append(" smithy::Outcome<") + t.append(" opal::Outcome<") .append(outputType) .append("> ") .append(opName) @@ -812,7 +812,7 @@ private String serverResponseTest( .append(literals.expression(outputOf(operation), testCase.getParams())) .append(";\n"); } else { - t.append(" smithy::Error error = smithy::Error::Modeled(") + t.append(" opal::Error error = opal::Error::Modeled(") .append(CppLiterals.stringLiteral(error.getId().getName())) .append(", \"\");\n"); t.append(" error.set_detail(") @@ -823,7 +823,7 @@ private String serverResponseTest( t.append(" }\n"); t.append(" };\n"); t.append(" ").append(serverType()).append(" server(std::make_shared());\n"); - t.append(" const smithy::http::HttpResponse response = server.Handler()(MinimalRequestFor") + t.append(" const opal::http::HttpResponse response = server.Handler()(MinimalRequestFor") .append(opName) .append("());\n"); t.append(" EXPECT_EQ(response.status, ").append(testCase.getCode()).append(");\n"); @@ -838,11 +838,11 @@ private String serverResponseTest( if (body != null && !body.isEmpty()) { String mediaType = testCase.getBodyMediaType().orElse(protocol.contentType()); if (mediaType.equals("application/json") || mediaType.endsWith("+json")) { - t.append(" EXPECT_TRUE(smithy::testing::JsonBodyEquals(") + t.append(" EXPECT_TRUE(opal::testing::JsonBodyEquals(") .append(CppLiterals.stringLiteral(body)) .append(", response.body));\n"); } else if (mediaType.equals("application/cbor")) { - t.append(" EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64(") + t.append(" EXPECT_TRUE(opal::testing::CborBodyEqualsBase64(") .append(CppLiterals.stringLiteral(body)) .append(", response.body));\n"); } else { @@ -913,7 +913,7 @@ private String serverMalformedTest(HttpMalformedRequestTestCase testCase) { request.getHeaders(), request.getBody(), request.getBodyMediaType())); - t.append(" const smithy::http::HttpResponse response = server.Handler()(request);\n"); + t.append(" const opal::http::HttpResponse response = server.Handler()(request);\n"); t.append(" EXPECT_EQ(response.status, ") .append(response.getCode()) .append(") << response.body;\n"); @@ -930,7 +930,7 @@ private String serverMalformedTest(HttpMalformedRequestTestCase testCase) { private String malformedBodyAssertion(HttpMalformedResponseBodyDefinition body) { if (body.getMessageRegex().isPresent()) { - return " EXPECT_TRUE(smithy::testing::BodyMessageMatches(" + return " EXPECT_TRUE(opal::testing::BodyMessageMatches(" + CppLiterals.stringLiteral(body.getMessageRegex().get()) + ", response.body)) << response.body;\n"; } @@ -940,12 +940,12 @@ private String malformedBodyAssertion(HttpMalformedResponseBodyDefinition body) } String mediaType = body.getMediaType(); if (mediaType.equals("application/json") || mediaType.endsWith("+json")) { - return " EXPECT_TRUE(smithy::testing::JsonBodyEquals(" + return " EXPECT_TRUE(opal::testing::JsonBodyEquals(" + CppLiterals.stringLiteral(contents) + ", response.body)) << response.body;\n"; } if (mediaType.equals("application/cbor")) { - return " EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64(" + return " EXPECT_TRUE(opal::testing::CborBodyEqualsBase64(" + CppLiterals.stringLiteral(contents) + ", response.body));\n"; } diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/RandomValueGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/RandomValueGenerator.java index 43b4c766..8901aa21 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/RandomValueGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/RandomValueGenerator.java @@ -231,7 +231,7 @@ private static String patternCandidate(PatternTrait pattern, long minLength) { String expression(MemberShape member) { Shape target = target(member); if (target.getId().toString().equals("smithy.api#Unit")) { - return "smithy::Unit{}"; + return "opal::Unit{}"; } String type = context.cppSymbols().toSymbol(target).getName(); return switch (target.getType()) { @@ -287,13 +287,13 @@ String expression(MemberShape member) { Math.min( constraint(member, LengthTrait.class).flatMap(LengthTrait::getMax).orElse(min + 8), min + 8); - yield "smithy::Blob::FromString(rng.Text(" + min + ", " + Math.max(min, max) + "))"; + yield "opal::Blob::FromString(rng.Text(" + min + ", " + Math.max(min, max) + "))"; } // Whole seconds survive every timestamp format (http-date has second // precision); the range stays http-date friendly (1970..2100). - case TIMESTAMP -> "smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000)"; + case TIMESTAMP -> "opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000)"; case DOCUMENT -> - "smithy::Document(smithy::DocumentMap{{\"key\", smithy::Document(rng.Int(0, 1000))}})"; + "opal::Document(opal::DocumentMap{{\"key\", opal::Document(rng.Int(0, 1000))}})"; case STRUCTURE, UNION, LIST, MAP -> builderName(target) + "(rng)"; default -> throw new CodegenException("cpp-codegen: no random value for " + target.getId()); }; diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/RecursionIndex.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/RecursionIndex.java index 00ceb8ca..28053007 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/RecursionIndex.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/RecursionIndex.java @@ -17,7 +17,7 @@ /** * Strongly connected components over the model's aggregate shapes (structures, unions, lists, * maps), driving boxed-recursion support: a structure member whose target is a structure on the - * same cycle is represented as {@code smithy::Boxed} (heap indirection with value semantics); + * same cycle is represented as {@code opal::Boxed} (heap indirection with value semantics); * cycles through lists need only a forward declaration ({@code std::vector} permits incomplete * element types). Cycles through union members or map values are not supported yet — {@link * #unsupportedCycleMember(MemberShape)} names them so generation fails with a clear message instead @@ -54,7 +54,7 @@ boolean cyclicEdge(MemberShape member) { return sameCycle(member.getContainer(), member.getTarget()); } - /** Structure member targeting a structure on the same cycle: emitted as smithy::Boxed. */ + /** Structure member targeting a structure on the same cycle: emitted as opal::Boxed. */ boolean isBoxed(MemberShape member) { if (!cyclicEdge(member)) { return false; diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/Rpcv2CborProtocol.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/Rpcv2CborProtocol.java index a52bb2ed..1f850985 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/Rpcv2CborProtocol.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/Rpcv2CborProtocol.java @@ -41,7 +41,7 @@ public List clientIncludes() { public void writeClientHelpers(CppWriter w, CppContext context) { ProtocolSupport.writeErrorSupport( w, - "auto doc = smithy::cbor::Decode(smithy::Blob::FromString(response.body));", + "auto doc = opal::cbor::Decode(opal::Blob::FromString(response.body));", /* errorTypeHeader= */ ""); } @@ -64,7 +64,7 @@ public void writeServerHelpers( w, SPEC.errorFn(), "application/cbor", - "smithy::cbor::Encode(smithy::Document(std::move(body))).ToString()", + "opal::cbor::Encode(opal::Document(std::move(body))).ToString()", "smithy-protocol", "rpc-v2-cbor"); ProtocolSupport.writeServerErrorToResponse(w, context, service, operations, SPEC); @@ -89,14 +89,14 @@ public void writeServerRoute( boolean compressed = ProtocolSupport.gzipCompressed(operation); w.openBlock( "(void)router_->Add(\"POST\", \"/service/$L/operation/$L\", " - + "[handler](const smithy::http::HttpRequest& $L, " + + "[handler](const opal::http::HttpRequest& $L, " + ProtocolSupport.REQUEST_CONTEXT_PARAM - + " context) -> smithy::http::HttpResponse {", + + " context) -> opal::http::HttpResponse {", service.getId().getName(), operation.getId().getName(), compressed ? "raw_request" : "request"); if (compressed) { - w.write("smithy::http::HttpRequest request = raw_request;"); + w.write("opal::http::HttpRequest request = raw_request;"); ProtocolSupport.writeRequestDecompression( w, operation, "CborError", "SerializationException"); } @@ -111,7 +111,7 @@ public void writeServerRoute( w.openBlock( "if (const auto content_type = request.headers.Get(\"content-type\"); " + "content_type.has_value() && " - + "smithy::http::MediaTypeOf(*content_type) != \"application/cbor\") {"); + + "opal::http::MediaTypeOf(*content_type) != \"application/cbor\") {"); w.write( "return helpers::CborError(415, \"UnsupportedMediaTypeException\", " + "\"expected content-type: application/cbor\", {});"); @@ -119,9 +119,9 @@ public void writeServerRoute( w.write("$L input{};", inputType); if (!ProtocolSupport.noModeledInput(input)) { w.write("// An absent body deserializes like an empty CBOR map."); - w.write("smithy::Document body_doc{smithy::DocumentMap{}};"); + w.write("opal::Document body_doc{opal::DocumentMap{}};"); w.openBlock("if (!request.body.empty()) {"); - w.write("auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body));"); + w.write("auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body));"); w.write( "if (!decoded) return helpers::CborError(400, \"SerializationException\", " + "decoded.error().message(), {});"); @@ -130,11 +130,11 @@ public void writeServerRoute( ProtocolSupport.writeRpcParsedInput(w, context, input, "body_doc", "400", SPEC); } ProtocolSupport.writeRpcDispatch(w, operation, "handler->", SPEC, validation); - w.write("smithy::http::HttpResponse response;"); + w.write("opal::http::HttpResponse response;"); w.write("response.headers.Set(\"smithy-protocol\", \"rpc-v2-cbor\");"); w.write("response.headers.Set(\"content-type\", \"application/cbor\");"); w.write( - "response.body = smithy::cbor::Encode(Serialize$L(*outcome)).ToString();", + "response.body = opal::cbor::Encode(Serialize$L(*outcome)).ToString();", SerdeCodeGen.serdeFunctionSuffix(context, output)); w.write("return response;"); w.closeBlock("}, $S);", operation.getId().getName()); @@ -147,12 +147,12 @@ public boolean supportsEventStreams() { @Override public String eventPayloadEncode(String docExpr) { - return "smithy::cbor::Encode(" + docExpr + ")"; + return "opal::cbor::Encode(" + docExpr + ")"; } @Override public String eventPayloadDecode(String payloadExpr) { - return "smithy::cbor::Decode(" + payloadExpr + ")"; + return "opal::cbor::Decode(" + payloadExpr + ")"; } @Override @@ -164,7 +164,7 @@ public void writeStreamingOperationBody( // initial members, since the fixed upgrade URI cannot carry them. w.write("(void)input;"); } - w.write("smithy::http::WebSocketDialRequest request;"); + w.write("opal::http::WebSocketDialRequest request;"); w.write( "request.target = path_prefix_ + \"/service/$L/operation/$L\";", service.getId().getName(), @@ -181,9 +181,9 @@ public void writeStreamServerRoute( String inputType = context.cppSymbols().toSymbol(input).getName(); w.openBlock( "(void)stream_router_->Add(\"GET\", \"/service/$L/operation/$L\", " - + "[handler](const smithy::http::HttpRequest& request, " + + "[handler](const opal::http::HttpRequest& request, " + ProtocolSupport.REQUEST_CONTEXT_PARAM - + " context, smithy::http::WebSocket& socket) {", + + " context, opal::http::WebSocket& socket) {", service.getId().getName(), operation.getId().getName()); w.write("(void)request;"); @@ -201,9 +201,9 @@ public void writeStreamSessionRoute( String inputType = context.cppSymbols().toSymbol(input).getName(); w.openBlock( "(void)stream_router_->AddSession(\"GET\", \"/service/$L/operation/$L\", " - + "[handler](const smithy::http::HttpRequest& request, " + + "[handler](const opal::http::HttpRequest& request, " + ProtocolSupport.REQUEST_CONTEXT_PARAM - + " context, std::shared_ptr socket) {", + + " context, std::shared_ptr socket) {", service.getId().getName(), operation.getId().getName()); w.write("(void)request;"); @@ -233,7 +233,7 @@ public void writeOperationBody( if (!ProtocolSupport.noModeledInput(input)) { w.write("request.headers.Set(\"content-type\", \"application/cbor\");"); w.write( - "request.body = smithy::cbor::Encode(Serialize$L($L)).ToString();", + "request.body = opal::cbor::Encode(Serialize$L($L)).ToString();", SerdeCodeGen.serdeFunctionSuffix(context, input), in); } @@ -251,7 +251,7 @@ public void writeOperationBody( if (allOptional) { w.write("if (response->body.empty()) return $L{};", outType); } - w.write("auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body));"); + w.write("auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body));"); w.write("if (!body_doc) return std::move(body_doc).error();"); w.write("return Deserialize$L(*body_doc);", SerdeCodeGen.serdeFunctionSuffix(context, output)); } diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SerdeCodeGen.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SerdeCodeGen.java index e669b9f5..8fc71629 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SerdeCodeGen.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SerdeCodeGen.java @@ -90,7 +90,7 @@ void writeMemberRead( String field = targetPrefix + context.cppSymbols().toMemberName(member); String path = structType + "." + member.getMemberName(); w.openBlock("{"); - w.write("const smithy::Document* member = $LFind($S);", mapAccess, wireName(member)); + w.write("const opal::Document* member = $LFind($S);", mapAccess, wireName(member)); if (MemberDefaults.lenientRequired(context.model(), member)) { // @required + @default (the evolution pattern): absence keeps the // member's default initializer instead of failing. @@ -129,7 +129,7 @@ static String serdeFunctionSuffix(CppContext context, Shape shape) { /** C++ TimestampFormat constant for a member, honoring @timestampFormat. */ String timestampFormat(MemberShape member) { - return timestampFormat(member, "smithy::TimestampFormat::kEpochSeconds"); + return timestampFormat(member, "opal::TimestampFormat::kEpochSeconds"); } String timestampFormat(MemberShape member, String defaultConstant) { @@ -141,31 +141,31 @@ String timestampFormat(MemberShape member, String defaultConstant) { return defaultConstant; } return switch (trait.get().getValue()) { - case "date-time" -> "smithy::TimestampFormat::kDateTime"; - case "http-date" -> "smithy::TimestampFormat::kHttpDate"; - default -> "smithy::TimestampFormat::kEpochSeconds"; + case "date-time" -> "opal::TimestampFormat::kDateTime"; + case "http-date" -> "opal::TimestampFormat::kHttpDate"; + default -> "opal::TimestampFormat::kEpochSeconds"; }; } - /** Expression producing a smithy::Document from {@code valueExpr} of the member's type. */ + /** Expression producing a opal::Document from {@code valueExpr} of the member's type. */ String serializeExpression(MemberShape member, String valueExpr) { Shape shape = target(member); if (shape.getId().toString().equals("smithy.api#Unit")) { - return "smithy::Document(smithy::DocumentMap{})"; + return "opal::Document(opal::DocumentMap{})"; } return switch (shape.getType()) { - case BOOLEAN -> "smithy::Document(" + valueExpr + ")"; + case BOOLEAN -> "opal::Document(" + valueExpr + ")"; case BYTE, SHORT, INTEGER, LONG -> - "smithy::Document(static_cast(" + valueExpr + "))"; - case INT_ENUM -> "smithy::Document(static_cast(" + valueExpr + "))"; - case FLOAT, DOUBLE -> "smithy::Document(static_cast(" + valueExpr + "))"; - case STRING -> "smithy::Document(" + valueExpr + ")"; - case ENUM -> "smithy::Document(std::string(" + valueExpr + ".ToString()))"; - case BLOB -> "smithy::Document(" + valueExpr + ")"; + "opal::Document(static_cast(" + valueExpr + "))"; + case INT_ENUM -> "opal::Document(static_cast(" + valueExpr + "))"; + case FLOAT, DOUBLE -> "opal::Document(static_cast(" + valueExpr + "))"; + case STRING -> "opal::Document(" + valueExpr + ")"; + case ENUM -> "opal::Document(std::string(" + valueExpr + ".ToString()))"; + case BLOB -> "opal::Document(" + valueExpr + ")"; case TIMESTAMP -> - "smithy::Document::FromTimestamp(" + valueExpr + ", " + timestampFormat(member) + ")"; + "opal::Document::FromTimestamp(" + valueExpr + ", " + timestampFormat(member) + ")"; case DOCUMENT -> valueExpr; - // Boxed (recursive) members dereference through the smithy::Boxed. + // Boxed (recursive) members dereference through the opal::Boxed. case STRUCTURE, UNION, LIST, MAP -> context.cppSymbols().recursion().isBoxed(member) ? "Serialize" + serdeFunctionSuffix(context, shape) + "(*(" + valueExpr + "))" @@ -185,9 +185,9 @@ void writeDeserializeInto( CppWriter w, MemberShape member, String docExpr, String outExpr, String path) { Shape shape = target(member); String wrong = - "return smithy::Error::Serialization(\"" + path + ": unexpected type on the wire\");"; + "return opal::Error::Serialization(\"" + path + ": unexpected type on the wire\");"; if (shape.getId().toString().equals("smithy.api#Unit")) { - w.write("$L = smithy::Unit{};", outExpr); + w.write("$L = opal::Unit{};", outExpr); return; } switch (shape.getType()) { @@ -209,7 +209,7 @@ void writeDeserializeInto( default -> "-2147483648LL || " + docExpr + "->as_int() > 2147483647LL"; }; w.write( - "if ($L->as_int() < $L) return smithy::Error::Serialization(\"$L: value out of " + "if ($L->as_int() < $L) return opal::Error::Serialization(\"$L: value out of " + "range\");", docExpr, bounds, @@ -221,22 +221,21 @@ void writeDeserializeInto( // The double→float narrowing is checked: a finite wire value beyond // float range would be UB to cast (UBSan float-cast-overflow). w.openBlock("{"); - w.write("auto parsed = smithy::DoubleFromDocument(*$L);", docExpr); + w.write("auto parsed = opal::DoubleFromDocument(*$L);", docExpr); w.write( - "if (!parsed) return smithy::Error::Serialization($S);", path + ": expected a number"); - w.write("auto narrowed = smithy::FloatFromDouble(*parsed);"); + "if (!parsed) return opal::Error::Serialization($S);", path + ": expected a number"); + w.write("auto narrowed = opal::FloatFromDouble(*parsed);"); w.write( - "if (!narrowed) return smithy::Error::Serialization($S);", - path + ": value out of range"); + "if (!narrowed) return opal::Error::Serialization($S);", path + ": value out of range"); w.write("$L = *narrowed;", outExpr); w.closeBlock("}"); } case DOUBLE -> { String type = context.cppSymbols().typeRef(shape); w.openBlock("{"); - w.write("auto parsed = smithy::DoubleFromDocument(*$L);", docExpr); + w.write("auto parsed = opal::DoubleFromDocument(*$L);", docExpr); w.write( - "if (!parsed) return smithy::Error::Serialization($S);", path + ": expected a number"); + "if (!parsed) return opal::Error::Serialization($S);", path + ": expected a number"); w.write("$L = static_cast<$L>(*parsed);", outExpr, type); w.closeBlock("}"); } @@ -251,7 +250,7 @@ void writeDeserializeInto( } case BLOB -> { w.openBlock("{"); - w.write("auto parsed = smithy::BlobFromDocument(*$L);", docExpr); + w.write("auto parsed = opal::BlobFromDocument(*$L);", docExpr); w.write("if (!parsed) return std::move(parsed).error();"); w.write("$L = std::move(*parsed);", outExpr); w.closeBlock("}"); @@ -259,7 +258,7 @@ void writeDeserializeInto( case TIMESTAMP -> { w.openBlock("{"); w.write( - "auto parsed = smithy::TimestampFromDocument(*$L, $L);", + "auto parsed = opal::TimestampFromDocument(*$L, $L);", docExpr, timestampFormat(member)); w.write("if (!parsed) return std::move(parsed).error();"); diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SerdeGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SerdeGenerator.java index c297b236..53b647d2 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SerdeGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SerdeGenerator.java @@ -103,15 +103,15 @@ private void writeHeader(CppWriter w, List shapes) { w.addInclude("\"smithy/core/outcome.h\""); w.addInclude("\"" + context.settings().includePrefix() + "/types.h\""); w.write("// Document-pivot serde for every aggregate shape in the model closure."); - w.write("// Serializers never fail; deserializers return smithy::Error on wire"); + w.write("// Serializers never fail; deserializers return opal::Error on wire"); w.write("// mismatches and enforce @required members."); w.write(""); for (Shape shape : shapes) { String suffix = SerdeCodeGen.serdeFunctionSuffix(context, shape); String type = valueType(shape); w.addIncludesFor(context.cppSymbols().toSymbol(shape)); - w.write("smithy::Document Serialize$L(const $L& value);", suffix, type); - w.write("smithy::Outcome<$L> Deserialize$L(const smithy::Document& doc);", type, suffix); + w.write("opal::Document Serialize$L(const $L& value);", suffix, type); + w.write("opal::Outcome<$L> Deserialize$L(const opal::Document& doc);", type, suffix); w.write(""); } } @@ -142,18 +142,18 @@ private void writeStructure(CppWriter w, StructureShape shape) { // value; the parameter stays unnamed (Core Guidelines F.9) so the function // is clean under -Wextra's -Wunused-parameter. String valueParam = shape.members().isEmpty() ? "/*value*/" : "value"; - w.openBlock("smithy::Document Serialize$L(const $L& $L) {", suffix, type, valueParam); - w.write("smithy::DocumentMap map;"); + w.openBlock("opal::Document Serialize$L(const $L& $L) {", suffix, type, valueParam); + w.write("opal::DocumentMap map;"); for (MemberShape member : shape.members()) { serde.writeMemberSerialize(w, member, "value", "map"); } - w.write("return smithy::Document(std::move(map));"); + w.write("return opal::Document(std::move(map));"); w.closeBlock("}"); w.write(""); - w.openBlock("smithy::Outcome<$L> Deserialize$L(const smithy::Document& doc) {", type, suffix); + w.openBlock("opal::Outcome<$L> Deserialize$L(const opal::Document& doc) {", type, suffix); w.write( - "if (!doc.is_map()) return smithy::Error::Serialization($S);", + "if (!doc.is_map()) return opal::Error::Serialization($S);", type + ": expected a map on the wire"); w.write("$L out;", type); for (MemberShape member : shape.members()) { @@ -170,7 +170,7 @@ private void writeStructure(CppWriter w, StructureShape shape) { // exchange-level message). w2.openBlock("if ($L) {", SerdeCodeGen.MEMBER_ABSENT); w2.write( - "return smithy::Error::Serialization($S);", + "return opal::Error::Serialization($S);", type + ": missing required member: " + serde.wireName(m)); w2.closeBlock("}"); deserializeMember.run(); @@ -192,8 +192,8 @@ private void writeUnion(CppWriter w, UnionShape shape) { // for unrecognized tags; it has no tag key of its own. Optional unknown = jsonUnknownMember(shape); - w.openBlock("smithy::Document Serialize$L(const $L& value) {", suffix, type); - w.write("smithy::DocumentMap map;"); + w.openBlock("opal::Document Serialize$L(const $L& value) {", suffix, type); + w.write("opal::DocumentMap map;"); for (MemberShape member : shape.members()) { String name = context.cppSymbols().toMemberName(member); if (isJsonUnknown(member)) { @@ -207,13 +207,13 @@ private void writeUnion(CppWriter w, UnionShape shape) { serde.serializeExpression(member, "value.as_" + name + "()")); w.closeBlock("}"); } - w.write("return smithy::Document(std::move(map));"); + w.write("return opal::Document(std::move(map));"); w.closeBlock("}"); w.write(""); - w.openBlock("smithy::Outcome<$L> Deserialize$L(const smithy::Document& doc) {", type, suffix); + w.openBlock("opal::Outcome<$L> Deserialize$L(const opal::Document& doc) {", type, suffix); w.write( - "if (!doc.is_map()) return smithy::Error::Serialization($S);", + "if (!doc.is_map()) return opal::Error::Serialization($S);", type + ": expected a map on the wire"); // Unions are exactly one member on the wire; extra known or unknown // members are malformed (the malformed-request suite pins this), but a @@ -224,7 +224,7 @@ private void writeUnion(CppWriter w, UnionShape shape) { } else { w.write( "if (doc.as_map().size() - (doc.Find(\"__type\") != nullptr ? 1 : 0) != 1) " - + "return smithy::Error::Serialization($S);", + + "return opal::Error::Serialization($S);", type + ": expected exactly one union member"); } for (MemberShape member : shape.members()) { @@ -235,7 +235,7 @@ private void writeUnion(CppWriter w, UnionShape shape) { Symbol targetType = context.cppSymbols().toSymbol(context.model().expectShape(member.getTarget())); w.openBlock( - "if (const smithy::Document* member = doc.Find($S);" + "if (const opal::Document* member = doc.Find($S);" + " member != nullptr && !member->is_null()) {", wireName); w.write("$L parsed_member{};", targetType.getName()); @@ -253,8 +253,7 @@ private void writeUnion(CppWriter w, UnionShape shape) { type, pascal(context.cppSymbols().toMemberName(unknown.get()))); } else { - w.write( - "return smithy::Error::Serialization($S);", type + ": unknown or missing union member"); + w.write("return opal::Error::Serialization($S);", type + ": unknown or missing union member"); } w.closeBlock("}"); w.write(""); @@ -272,7 +271,7 @@ private void writeDiscriminatedUnion(CppWriter w, UnionShape shape) { String discriminator = shape.expectTrait(DiscriminatedUnionTrait.class).getValue(); Optional unknown = jsonUnknownMember(shape); - w.openBlock("smithy::Document Serialize$L(const $L& value) {", suffix, type); + w.openBlock("opal::Document Serialize$L(const $L& value) {", suffix, type); for (MemberShape member : shape.members()) { String name = context.cppSymbols().toMemberName(member); if (isJsonUnknown(member)) { @@ -281,25 +280,25 @@ private void writeDiscriminatedUnion(CppWriter w, UnionShape shape) { } w.openBlock("if (value.is_$L()) {", name); w.write( - "smithy::Document member_doc = $L;", + "opal::Document member_doc = $L;", serde.serializeExpression(member, "value.as_" + name + "()")); w.write( - "member_doc.as_map().insert_or_assign($S, smithy::Document(std::string($S)));", + "member_doc.as_map().insert_or_assign($S, opal::Document(std::string($S)));", discriminator, serde.wireName(member)); w.write("return member_doc;"); w.closeBlock("}"); } - w.write("return smithy::Document(smithy::DocumentMap{});"); + w.write("return opal::Document(opal::DocumentMap{});"); w.closeBlock("}"); w.write(""); - w.openBlock("smithy::Outcome<$L> Deserialize$L(const smithy::Document& doc) {", type, suffix); + w.openBlock("opal::Outcome<$L> Deserialize$L(const opal::Document& doc) {", type, suffix); w.write( - "if (!doc.is_map()) return smithy::Error::Serialization($S);", + "if (!doc.is_map()) return opal::Error::Serialization($S);", type + ": expected a map on the wire"); w.openBlock( - "if (const smithy::Document* discriminator = doc.Find($S);" + "if (const opal::Document* discriminator = doc.Find($S);" + " discriminator != nullptr && discriminator->is_string()) {", discriminator); for (MemberShape member : shape.members()) { @@ -309,7 +308,7 @@ private void writeDiscriminatedUnion(CppWriter w, UnionShape shape) { Symbol targetType = context.cppSymbols().toSymbol(context.model().expectShape(member.getTarget())); w.openBlock("if (discriminator->as_string() == $S) {", serde.wireName(member)); - w.write("const smithy::Document* member = &doc;"); + w.write("const opal::Document* member = &doc;"); w.write("$L parsed_member{};", targetType.getName()); serde.writeDeserializeInto( w, member, "member", "parsed_member", type + "." + serde.wireName(member)); @@ -326,8 +325,7 @@ private void writeDiscriminatedUnion(CppWriter w, UnionShape shape) { type, pascal(context.cppSymbols().toMemberName(unknown.get()))); } else { - w.write( - "return smithy::Error::Serialization($S);", type + ": unknown or missing union member"); + w.write("return opal::Error::Serialization($S);", type + ": unknown or missing union member"); } w.closeBlock("}"); w.write(""); @@ -348,8 +346,8 @@ private void writeList(CppWriter w, ListShape shape) { boolean sparse = shape.hasTrait(SparseTrait.class); Symbol element = context.cppSymbols().toSymbol(context.model().expectShape(member.getTarget())); - w.openBlock("smithy::Document Serialize$L(const $L& value) {", suffix, type); - w.write("smithy::DocumentList list;"); + w.openBlock("opal::Document Serialize$L(const $L& value) {", suffix, type); + w.write("opal::DocumentList list;"); w.write("list.reserve(value.size());"); w.openBlock("for (const auto& item : value) {"); if (sparse) { @@ -362,18 +360,18 @@ private void writeList(CppWriter w, ListShape shape) { w.write("list.push_back($L);", serde.serializeExpression(member, "item")); } w.closeBlock("}"); - w.write("return smithy::Document(std::move(list));"); + w.write("return opal::Document(std::move(list));"); w.closeBlock("}"); w.write(""); - w.openBlock("smithy::Outcome<$L> Deserialize$L(const smithy::Document& doc) {", type, suffix); + w.openBlock("opal::Outcome<$L> Deserialize$L(const opal::Document& doc) {", type, suffix); w.write( - "if (!doc.is_list()) return smithy::Error::Serialization($S);", + "if (!doc.is_list()) return opal::Error::Serialization($S);", type + ": expected a list on the wire"); w.write("$L out;", type); w.write("out.reserve(doc.as_list().size());"); - w.openBlock("for (const smithy::Document& item_doc : doc.as_list()) {"); - w.write("const smithy::Document* item = &item_doc;"); + w.openBlock("for (const opal::Document& item_doc : doc.as_list()) {"); + w.write("const opal::Document* item = &item_doc;"); if (sparse) { w.openBlock("if (item->is_null()) {"); w.write("out.emplace_back(std::nullopt);"); @@ -381,7 +379,7 @@ private void writeList(CppWriter w, ListShape shape) { w.closeBlock("}"); } else { w.write( - "if (item->is_null()) return smithy::Error::Serialization($S);", + "if (item->is_null()) return opal::Error::Serialization($S);", type + ": null element in a dense list"); } w.write("$L parsed_item{};", element.getName()); @@ -400,12 +398,12 @@ private void writeMap(CppWriter w, MapShape shape) { boolean sparse = shape.hasTrait(SparseTrait.class); Symbol element = context.cppSymbols().toSymbol(context.model().expectShape(member.getTarget())); - w.openBlock("smithy::Document Serialize$L(const $L& value) {", suffix, type); - w.write("smithy::DocumentMap map;"); + w.openBlock("opal::Document Serialize$L(const $L& value) {", suffix, type); + w.write("opal::DocumentMap map;"); w.openBlock("for (const auto& [key, item] : value) {"); if (sparse) { w.openBlock("if (!item.has_value()) {"); - w.write("map.emplace(key, smithy::Document(nullptr));"); + w.write("map.emplace(key, opal::Document(nullptr));"); w.write("continue;"); w.closeBlock("}"); w.write("map.emplace(key, $L);", serde.serializeExpression(member, "(*item)")); @@ -413,17 +411,17 @@ private void writeMap(CppWriter w, MapShape shape) { w.write("map.emplace(key, $L);", serde.serializeExpression(member, "item")); } w.closeBlock("}"); - w.write("return smithy::Document(std::move(map));"); + w.write("return opal::Document(std::move(map));"); w.closeBlock("}"); w.write(""); - w.openBlock("smithy::Outcome<$L> Deserialize$L(const smithy::Document& doc) {", type, suffix); + w.openBlock("opal::Outcome<$L> Deserialize$L(const opal::Document& doc) {", type, suffix); w.write( - "if (!doc.is_map()) return smithy::Error::Serialization($S);", + "if (!doc.is_map()) return opal::Error::Serialization($S);", type + ": expected a map on the wire"); w.write("$L out;", type); w.openBlock("for (const auto& [key, item_doc] : doc.as_map()) {"); - w.write("const smithy::Document* item = &item_doc;"); + w.write("const opal::Document* item = &item_doc;"); if (sparse) { w.openBlock("if (item->is_null()) {"); w.write("out.emplace(key, std::nullopt);"); diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ServerGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ServerGenerator.java index dbef1aba..9f738d55 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ServerGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ServerGenerator.java @@ -9,7 +9,7 @@ /** * Emits server.h / src/server.cc: the pure-virtual {@code Handler} interface users * implement and the {@code Server} that binds it to the runtime router. Transport agnostic - * — the resulting {@code smithy::http::RequestHandler} plugs into any {@code HttpServerTransport} + * — the resulting {@code opal::http::RequestHandler} plugs into any {@code HttpServerTransport} * (Loopback, SocketHttpServer, BeastServerTransport). */ final class ServerGenerator { @@ -110,10 +110,10 @@ private void writeHeader(CppWriter w) { w, context, service, streamingOperations(), /* serverSide= */ true); } w.write("/// Implement one method per operation. Return a modeled error as"); - w.write("/// smithy::Error::Modeled(\"\", message), optionally with the"); + w.write("/// opal::Error::Modeled(\"\", message), optionally with the"); w.write("/// typed error structure attached via set_detail() so it serializes fully."); w.write("/// The context carries the raw request and routing captures — see"); - w.write("/// smithy::server::RequestContext; leave the parameter unnamed when unused."); + w.write("/// opal::server::RequestContext; leave the parameter unnamed when unused."); w.write("/// Implementations must be thread-safe: transports may invoke any mix of"); w.write("/// operations concurrently on the one handler instance."); w.openBlock("class $LHandler {", name); @@ -146,7 +146,7 @@ private void writeHeader(CppWriter w) { w.write("/// thread still using it. Blocks the transport's handler thread for"); w.write("/// the session's lifetime."); w.write( - "virtual smithy::Outcome $L(const $L& input, $L& stream, $L context)" + "virtual opal::Outcome $L(const $L& input, $L& stream, $L context)" + " = 0;", CppReservedWords.escape(operation.getId().getName()), context.cppSymbols().toSymbol(input).getName(), @@ -167,7 +167,7 @@ private void writeHeader(CppWriter w) { protocol.name(), service.getId().toString()); w.write("/// response serialization, and modeled-error mapping. Pass Handler() to any"); - w.write("/// smithy::http::HttpServerTransport."); + w.write("/// opal::http::HttpServerTransport."); w.openBlock("class $LServer {", name); w.write("public:").indent(); w.write("explicit $LServer(std::shared_ptr<$LHandler> handler);", name, name); @@ -179,7 +179,7 @@ private void writeHeader(CppWriter w) { w.write("explicit $LServer(std::shared_ptr<$LAsyncHandler> handler);", name, name); } w.write(""); - w.write("smithy::http::RequestHandler Handler() const;"); + w.write("opal::http::RequestHandler Handler() const;"); if (hasStreaming) { w.write(""); w.write("/// The WebSocket router carrying every streaming route (ADR-0016), ready"); @@ -189,13 +189,13 @@ private void writeHeader(CppWriter w) { w.write("/// options.on_websocket = server.StreamRouter()->Serve(); // blocking handler"); w.write("/// options.on_websocket_session ="); w.write("/// server.StreamRouter()->ServeSession(); // async handler (ADR-0021)"); - w.write("std::shared_ptr StreamRouter() const;"); + w.write("std::shared_ptr StreamRouter() const;"); } w.write("").dedent(); w.write("private:").indent(); - w.write("std::shared_ptr router_;"); + w.write("std::shared_ptr router_;"); if (hasStreaming) { - w.write("std::shared_ptr stream_router_;"); + w.write("std::shared_ptr stream_router_;"); } w.dedent(); w.closeBlock("};"); @@ -222,7 +222,7 @@ private boolean writeModelDocs(CppWriter w, OperationShape operation) { */ private void writeUnaryVirtual(CppWriter w, OperationShape operation) { w.write( - "virtual smithy::Outcome<$L> $L(const $L& input, $L context) = 0;", + "virtual opal::Outcome<$L> $L(const $L& input, $L context) = 0;", context.cppSymbols().toSymbol(ProtocolSupport.outputShape(context, operation)).getName(), CppReservedWords.escape(operation.getId().getName()), context.cppSymbols().toSymbol(ProtocolSupport.inputShape(context, operation)).getName(), @@ -261,8 +261,8 @@ private void writeAsyncHandlerClass(CppWriter w, String name) { w.write("/// Async streaming operation (ADR-0021): a coroutine serving the whole"); w.write("/// session — co_await stream.Receive()/Send() until done."); } - w.write("/// co_return smithy::Unit{} for a clean close, or an error — modeled as"); - w.write("/// smithy::Error::Modeled(\"\", message) + set_detail(),"); + w.write("/// co_return opal::Unit{} for a clean close, or an error — modeled as"); + w.write("/// opal::Error::Modeled(\"\", message) + set_detail(),"); w.write("/// like a blocking handler — which ends the stream with one best-effort"); w.write("/// exception message before the close. `input` is the coroutine's own"); w.write("/// copy: the upgrade request (and its RequestContext) is gone by the"); @@ -272,7 +272,7 @@ private void writeAsyncHandlerClass(CppWriter w, String name) { w.write("/// handler thread (brief blocking is fine there); every later resumption"); w.write("/// is a transport completion context — never block those."); w.write( - "virtual smithy::eventstream::StreamTask $L($L input, $L& stream) = 0;", + "virtual opal::eventstream::StreamTask $L($L input, $L& stream) = 0;", CppReservedWords.escape(operation.getId().getName()), context.cppSymbols().toSymbol(input).getName(), EventStreamCodeGen.asyncServerStreamAlias(operation)); @@ -305,10 +305,10 @@ private void writeSource(CppWriter w) { w.openBlock("$LServer::$LServer(std::shared_ptr<$LHandler> handler)", name, name, name); if (hasStreaming) { - w.write(": router_(std::make_shared()),"); - w.write(" stream_router_(std::make_shared()) {"); + w.write(": router_(std::make_shared()),"); + w.write(" stream_router_(std::make_shared()) {"); } else { - w.write(": router_(std::make_shared()) {"); + w.write(": router_(std::make_shared()) {"); } w.dedent(); w.indent(); @@ -328,8 +328,8 @@ private void writeSource(CppWriter w) { if (hasStreaming) { w.openBlock("$LServer::$LServer(std::shared_ptr<$LAsyncHandler> handler)", name, name, name); - w.write(": router_(std::make_shared()),"); - w.write(" stream_router_(std::make_shared()) {"); + w.write(": router_(std::make_shared()),"); + w.write(" stream_router_(std::make_shared()) {"); w.dedent(); w.indent(); w.write("// The same unary table; every streaming route rides the shared-session"); @@ -342,18 +342,17 @@ private void writeSource(CppWriter w) { w.write(""); } - w.openBlock("smithy::http::RequestHandler $LServer::Handler() const {", name); + w.openBlock("opal::http::RequestHandler $LServer::Handler() const {", name); w.write("auto router = router_;"); w.write( - "return [router](const smithy::http::HttpRequest& request) " + "return [router](const opal::http::HttpRequest& request) " + "{ return router->Route(request); };"); w.closeBlock("}"); w.write(""); if (hasStreaming) { w.openBlock( - "std::shared_ptr $LServer::StreamRouter() const {", - name); + "std::shared_ptr $LServer::StreamRouter() const {", name); w.write("return stream_router_;"); w.closeBlock("}"); w.write(""); diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SmokeTestGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SmokeTestGenerator.java index 825e755d..9c4801a2 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SmokeTestGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/SmokeTestGenerator.java @@ -192,9 +192,9 @@ private void writeSource(CppWriter w) { w.write(""); w.openBlock("$LClient MakeClient(std::shared_ptr<$LHandler> handler) {", name, name); w.write("$LServer server(std::move(handler));", name); - w.write("auto loopback = std::make_shared();"); + w.write("auto loopback = std::make_shared();"); w.write("(void)loopback->Start(server.Handler());"); - w.write("smithy::ClientConfig config;"); + w.write("opal::ClientConfig config;"); w.write("config.retry.max_attempts = 1; // wire-exact tests: no retries"); w.write("config.http_client = loopback;"); w.write("// Create cannot fail when a transport is injected."); @@ -250,11 +250,11 @@ private void writeErrorMappingTest(CppWriter w) { ProtocolSupport.openTestHandlerOverride( w, typeName(output(errorOp)), opName, typeName(input(errorOp))); w.write("(void)input;"); - w.write("smithy::Error error = smithy::Error::Modeled($S, \"smoke\");", wireName); + w.write("opal::Error error = opal::Error::Modeled($S, \"smoke\");", wireName); w.writeWithNoFormatting(" auto detail = " + literals.minimalExpression(errorShape) + ";"); // A modeled "message" member would otherwise serialize its minimal value and // shadow the generic error message on the wire. (Case-sensitive: only the - // lowercase wire key feeds smithy::Error::message() on the client side.) + // lowercase wire key feeds opal::Error::message() on the client side.) for (var member : errorShape.members()) { if (!member.getMemberName().equals("message")) { continue; @@ -273,7 +273,7 @@ private void writeErrorMappingTest(CppWriter w) { writeSmokeInput(w, errorOp); w.write("const auto outcome = client.$L(input);", opName); w.write("ASSERT_FALSE(outcome.ok());"); - w.write("EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled);"); + w.write("EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled);"); w.write("EXPECT_EQ(outcome.error().code(), $S);", wireName); w.write("EXPECT_EQ(outcome.error().message(), \"smoke\");"); w.write("EXPECT_NE(outcome.error().detail<$L>(), nullptr);", errorType); diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/TypeGenerators.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/TypeGenerators.java index 790ab537..1311cbd3 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/TypeGenerators.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/TypeGenerators.java @@ -246,7 +246,7 @@ private void writeStructPrinting(StructureShape shape, String name) { if (context.model().expectShape(member.getTarget()).hasTrait(SensitiveTrait.class)) { writer.write("out += \"[REDACTED]\";"); } else { - writer.write("smithy::DebugAppend(out, $Lthis->$L);", optional ? "*" : "", memberName); + writer.write("opal::DebugAppend(out, $Lthis->$L);", optional ? "*" : "", memberName); } if (optional) { writer.closeBlock("}"); @@ -310,7 +310,7 @@ private void writeStructHash(StructureShape shape, String name) { epilogue.write("std::size_t seed = 0;"); for (MemberShape member : shape.members()) { epilogue.write( - "seed = smithy::HashCombine(seed, smithy::HashValue(value.$L));", + "seed = opal::HashCombine(seed, opal::HashValue(value.$L));", symbols().toMemberName(member)); } epilogue.write("return seed;"); @@ -331,8 +331,8 @@ static void writeOrdering(CppWriter writer, String name, boolean orderable) { writer.addInclude(""); writer.write("friend auto operator<=>(const $1L&, const $1L&) = default;", name); } else { - writer.write("// Equality-only: a member type has no ordering (smithy::Document or"); - writer.write("// recursion via smithy::Boxed) — see generated-types.md."); + writer.write("// Equality-only: a member type has no ordering (opal::Document or"); + writer.write("// recursion via opal::Boxed) — see generated-types.md."); } } @@ -430,8 +430,8 @@ private void writeEnumHash(String name) { "std::size_t operator()(const $L::$L& value) const noexcept {", writer.cppNamespace(), name); - epilogue.write("return smithy::HashCombine(static_cast(value.value_),"); - epilogue.write(" smithy::HashValue(value.unknown_));"); + epilogue.write("return opal::HashCombine(static_cast(value.value_),"); + epilogue.write(" opal::HashValue(value.unknown_));"); epilogue.closeBlock("}"); epilogue.closeBlock("};"); epilogue.write(""); @@ -588,7 +588,7 @@ static void emitTaggedVariant( if (member.sensitive()) { writer.write("out += \"[REDACTED]\";"); } else { - writer.write("smithy::DebugAppend(out, std::get<$L>(value_));", i + 1); + writer.write("opal::DebugAppend(out, std::get<$L>(value_));", i + 1); } writer.write("break;"); writer.dedent(); @@ -613,7 +613,7 @@ static void emitTaggedVariant( writer.write("private:").indent(); writer.openBlock("void require_is(std::size_t index, const char* requested) const {"); writer.openBlock("if (value_.index() != index) {"); - writer.write("smithy::internal::FatalWrongUnionAccess($S, requested, case_name());", name); + writer.write("opal::internal::FatalWrongUnionAccess($S, requested, case_name());", name); writer.closeBlock("}"); writer.closeBlock("}"); writer.write(""); @@ -642,8 +642,8 @@ private static void writeTaggedVariantHash(CppWriter writer, String name) { name); epilogue.write("const std::size_t member ="); epilogue.write( - " std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_);"); - epilogue.write("return smithy::HashCombine(value.value_.index(), member);"); + " std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_);"); + epilogue.write("return opal::HashCombine(value.value_.index(), member);"); epilogue.closeBlock("}"); epilogue.closeBlock("};"); epilogue.write(""); diff --git a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ValidationGenerator.java b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ValidationGenerator.java index 3e1ee3c9..7f8dbdcf 100644 --- a/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ValidationGenerator.java +++ b/codegen/smithy-cpp-codegen/src/main/java/io/smithycpp/codegen/ValidationGenerator.java @@ -92,7 +92,7 @@ void writeRouteGuard(CppWriter w, OperationShape operation, String extraArgs) { if (!validates(operation)) { return; } - w.write("std::vector validation_failures;"); + w.write("std::vector validation_failures;"); w.write("helpers::$L(input, \"\", &validation_failures);", validatorNameFor(operation)); w.write( "if (!validation_failures.empty()) " @@ -198,7 +198,7 @@ static void writeFailureHelper(CppWriter w) { w.write("// Constraint validation (smithy.framework#ValidationException): messages"); w.write("// and '/member' paths follow the official validation conformance suite."); w.openBlock( - "void AddValidationFailure(std::vector* failures, " + "void AddValidationFailure(std::vector* failures, " + "std::string path, std::string message) {"); w.write("failures->push_back({std::move(path), std::move(message)});"); w.closeBlock("}"); @@ -226,25 +226,25 @@ private static void writeValidationErrorResponse( w.write("// [[maybe_unused]]: only unary routes reject invalid input over HTTP; a"); w.write("// service whose operations all stream reports validation on the stream."); w.openBlock( - "[[maybe_unused]] smithy::http::HttpResponse ValidationErrorResponse(" - + "const std::vector& failures$L) {", + "[[maybe_unused]] opal::http::HttpResponse ValidationErrorResponse(" + + "const std::vector& failures$L) {", extraParams); w.write( "std::string summary = std::to_string(failures.size()) + \" validation error\" + " + "(failures.size() == 1 ? \"\" : \"s\") + \" detected. \";"); - w.write("smithy::DocumentList field_list;"); + w.write("opal::DocumentList field_list;"); w.openBlock("for (std::size_t i = 0; i < failures.size(); ++i) {"); w.write("if (i > 0) summary += \"; \";"); w.write("summary += failures[i].message;"); - w.write("smithy::DocumentMap field;"); - w.write("field.emplace(\"message\", smithy::Document(failures[i].message));"); - w.write("field.emplace(\"path\", smithy::Document(failures[i].path));"); - w.write("field_list.push_back(smithy::Document(std::move(field)));"); + w.write("opal::DocumentMap field;"); + w.write("field.emplace(\"message\", opal::Document(failures[i].message));"); + w.write("field.emplace(\"path\", opal::Document(failures[i].path));"); + w.write("field_list.push_back(opal::Document(std::move(field)));"); w.closeBlock("}"); - w.write("smithy::DocumentMap body;"); - w.write("body.emplace(\"fieldList\", smithy::Document(std::move(field_list)));"); + w.write("opal::DocumentMap body;"); + w.write("body.emplace(\"fieldList\", opal::Document(std::move(field_list)));"); w.write( - "smithy::http::HttpResponse response = helpers::$L(400, $S, summary, std::move(body)$L);", + "opal::http::HttpResponse response = helpers::$L(400, $S, summary, std::move(body)$L);", errorFn, errorCode, extraArgs); @@ -274,7 +274,7 @@ void writeValidators(CppWriter w) { } w.write( "void $L(const $L& value, const std::string& path, " - + "std::vector* failures);", + + "std::vector* failures);", validatorName(shape), context.cppSymbols().typeRef(shape)); declared = true; @@ -298,7 +298,7 @@ private void writeValidator(CppWriter w, Shape shape) { String type = context.cppSymbols().typeRef(shape); w.openBlock( "void $L(const $L& value, const std::string& path, " - + "std::vector* failures) {", + + "std::vector* failures) {", validatorName(shape), type); if (shape.isStructureShape() || shape.isUnionShape()) { @@ -451,11 +451,11 @@ private void writeLengthCheck( boolean enumAsRawString) { String lengthExpr = switch (target.getType()) { - case STRING -> "smithy::Utf8CodePointCount(" + valueExpr + ")"; + case STRING -> "opal::Utf8CodePointCount(" + valueExpr + ")"; case ENUM -> enumAsRawString - ? "smithy::Utf8CodePointCount(" + valueExpr + ")" - : "smithy::Utf8CodePointCount(" + valueExpr + ".ToString())"; + ? "opal::Utf8CodePointCount(" + valueExpr + ")" + : "opal::Utf8CodePointCount(" + valueExpr + ".ToString())"; default -> valueExpr + ".size()"; }; if (target.getType() == software.amazon.smithy.model.shapes.ShapeType.STRING @@ -547,14 +547,14 @@ private void writePatternCheck( rejectUnsupportedPattern(pattern); String variable = "kPattern" + patternCounter++; w.addInclude("\"smithy/core/regex.h\""); - // smithy::Regex is a linear-time engine, so no pattern/input combination + // opal::Regex is a linear-time engine, so no pattern/input combination // can backtrack catastrophically (ReDoS). The raw string literal keeps // the regex byte-exact; the failure message needs C++ escaping instead. // Compile failure (impossible for generator-accepted patterns) fails // closed: every value is rejected rather than skipping the check. w.write( - "static const smithy::Outcome $L =" - + " smithy::Regex::Compile(R\"__smithy($L)__smithy\");", + "static const opal::Outcome $L =" + + " opal::Regex::Compile(R\"__smithy($L)__smithy\");", variable, pattern.getValue()); w.openBlock("if (!$L.ok() || !$L->Search($L)) {", variable, variable, valueExpr); diff --git a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/ConditionalWiringCoverageTest.java b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/ConditionalWiringCoverageTest.java index fe7539f5..223dcb02 100644 --- a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/ConditionalWiringCoverageTest.java +++ b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/ConditionalWiringCoverageTest.java @@ -90,7 +90,7 @@ void requiredIdempotencyTokensAutofillOnEmptyNotUnset() { PluginTestHarness.generate(model, "test.wiring#Svc", "test::wiring") .expectFileString("/src/client.cc"); assertTrue( - client.contains("if (prepared.token.empty()) prepared.token = smithy::GenerateUuidV4();"), + client.contains("if (prepared.token.empty()) prepared.token = opal::GenerateUuidV4();"), client); } diff --git a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/CppCodegenPluginTest.java b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/CppCodegenPluginTest.java index 7c6b088a..97f38935 100644 --- a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/CppCodegenPluginTest.java +++ b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/CppCodegenPluginTest.java @@ -56,7 +56,7 @@ void generatesTypesHeaderAndBuildFile() { assertTrue(header.contains("struct NoSuchResource {")); assertTrue(header.contains("std::optional nextToken{};")); assertTrue(header.contains("namespace example::weather {")); - assertTrue(header.contains("smithy::Timestamp time{};")); + assertTrue(header.contains("opal::Timestamp time{};")); // Topological order: CityCoordinates is declared before its user GetCityOutput. assertTrue( header.indexOf("struct CityCoordinates {") < header.indexOf("struct GetCityOutput {")); @@ -93,8 +93,8 @@ void generatesTheJsonRpc2ProtocolFromItsTrait() { b -> b.withMember("runtimeTarget", "//runtime:core")); String client = manifest.expectFileString("/src/client.cc"); - assertTrue(client.contains("envelope.emplace(\"jsonrpc\", smithy::Document(\"2.0\"));")); - assertTrue(client.contains("envelope.emplace(\"method\", smithy::Document(\"Add\"));")); + assertTrue(client.contains("envelope.emplace(\"jsonrpc\", opal::Document(\"2.0\"));")); + assertTrue(client.contains("envelope.emplace(\"method\", opal::Document(\"Add\"));")); assertTrue(client.contains("request.target = path_prefix_ + \"/\";")); // One unary route per constructor (the calculator streams, so the async @@ -139,7 +139,7 @@ void generatesRecursiveShapes() { String header = manifest.expectFileString("/include/test/rec/types.h"); // Structure-to-structure cycle edges box; list cycles ride std::vector's // incomplete-element support behind a forward declaration. - assertTrue(header.contains("std::optional> node{};"), header); + assertTrue(header.contains("std::optional> node{};"), header); assertTrue(header.contains("std::optional> children{};"), header); assertTrue(header.contains("struct TreeNode;"), header); } diff --git a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/EventStreamGeneratorTest.java b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/EventStreamGeneratorTest.java index 19009e63..6639f7ff 100644 --- a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/EventStreamGeneratorTest.java +++ b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/EventStreamGeneratorTest.java @@ -124,23 +124,23 @@ void clientSignaturesCarryTheTypedSessionPerDirection() { assertTrue( client.contains( "using ConverseClientStream =" - + " smithy::eventstream::EventStream;"), + + " opal::eventstream::EventStream;"), client); assertTrue( client.contains( - "smithy::Outcome Converse(const ConverseInput& input) const;"), + "opal::Outcome Converse(const ConverseInput& input) const;"), client); // Detection is directional: no input stream parameterizes Tx with the // runtime's NoEvents (and the empty input still defaults). assertTrue( client.contains( "using WatchClientStream =" - + " smithy::eventstream::EventStream;"), client); assertTrue( client.contains( - "smithy::Outcome Watch(const WatchInput& input = {}) const;"), + "opal::Outcome Watch(const WatchInput& input = {}) const;"), client); // The NoEvents direction's doc-comment tells the truth: Send does not // compile there, only Receive is meaningful. @@ -152,7 +152,7 @@ void clientBodyDialsTheUpgradeAndSuppliesTheCodecs() { String client = rest().expectFileString("/src/client.cc"); // The upgrade target resolves labels and query exactly like a unary // request; header bindings ride the upgrade GET. - assertTrue(client.contains("target += smithy::http::EncodePathSegment(input.room);"), client); + assertTrue(client.contains("target += opal::http::EncodePathSegment(input.room);"), client); assertTrue(client.contains("query.Add(\"since\","), client); assertTrue(client.contains("request.headers.Set(\"x-client\", (*input.client));"), client); // config.websocket_dialer wins; the Beast dialer is the fallback. @@ -160,17 +160,17 @@ void clientBodyDialsTheUpgradeAndSuppliesTheCodecs() { client.contains("if (config.websocket_dialer) return config.websocket_dialer(request);"), client); assertTrue( - client.contains("return smithy::http::BeastWebSocketClient::Dialer()(request);"), client); + client.contains("return opal::http::BeastWebSocketClient::Dialer()(request);"), client); // Encode: member-name dispatch -> serde -> protocol bytes -> envelope. assertTrue( client.contains( - "return smithy::eventstream::MakeEventMessage(\"message\", \"application/json\"," - + " smithy::Blob::FromString(smithy::json::Encode(SerializeChatMessage(" + "return opal::eventstream::MakeEventMessage(\"message\", \"application/json\"," + + " opal::Blob::FromString(opal::json::Encode(SerializeChatMessage(" + "event.as_message()))));"), client); // Decode: envelope parse, exception dispatch through the MakeError // machinery (generic fallback), then member-name dispatch into the union. - assertTrue(client.contains("smithy::eventstream::ParseEnvelope(message);"), client); + assertTrue(client.contains("opal::eventstream::ParseEnvelope(message);"), client); assertTrue( client.contains( "if (parsed.code == \"RoomGone\") return helpers::MakeRoomGoneError(response," @@ -199,20 +199,19 @@ void serverGrowsStreamingHandlersAndAStreamRouter() { assertTrue( header.contains( "using ConverseServerStream =" - + " smithy::eventstream::EventStream;"), + + " opal::eventstream::EventStream;"), header); assertTrue( header.contains( - "virtual smithy::Outcome Converse(const ConverseInput& input," + "virtual opal::Outcome Converse(const ConverseInput& input," + " ConverseServerStream& stream," - + " const smithy::server::RequestContext& context) = 0;"), + + " const opal::server::RequestContext& context) = 0;"), header); assertTrue( - header.contains("std::shared_ptr StreamRouter() const;"), + header.contains("std::shared_ptr StreamRouter() const;"), header); assertTrue( - header.contains("std::shared_ptr stream_router_;"), - header); + header.contains("std::shared_ptr stream_router_;"), header); String server = manifest.expectFileString("/src/server.cc"); // Streaming routes register as GET (upgrades are GETs on the wire, @@ -228,7 +227,7 @@ void serverGrowsStreamingHandlersAndAStreamRouter() { "(void)socket.Send(helpers::BuildConverseExceptionMessage(outcome.error()));"), server); assertTrue(server.contains("stream.Close();"), server); - assertTrue(server.contains("return smithy::eventstream::MakeExceptionMessage(type,"), server); + assertTrue(server.contains("return opal::eventstream::MakeExceptionMessage(type,"), server); // Streaming operations answer over the session, never an HTTP response. assertFalse(server.contains("BuildConverseResponse"), server); assertFalse(server.contains("BuildWatchResponse"), server); @@ -257,11 +256,11 @@ void serverGrowsTheAsyncHandlerAndSessionRoutes() { assertTrue( header.contains( "using ConverseAsyncServerStream =" - + " smithy::eventstream::AsyncEventStream;"), + + " opal::eventstream::AsyncEventStream;"), header); assertTrue( header.contains( - "virtual smithy::eventstream::StreamTask Converse(ConverseInput input," + "virtual opal::eventstream::StreamTask Converse(ConverseInput input," + " ConverseAsyncServerStream& stream) = 0;"), header); // Unary operations keep the blocking shape on the async handler — @@ -299,9 +298,9 @@ void serverGrowsTheAsyncHandlerAndSessionRoutes() { server); assertTrue( server.contains( - "smithy::eventstream::Detached ServeConverseAsync(std::shared_ptr" + "opal::eventstream::Detached ServeConverseAsync(std::shared_ptr" + " handler, types::ConverseInput input," - + " std::shared_ptr socket) {"), + + " std::shared_ptr socket) {"), server); assertTrue( server.contains("auto outcome = co_await handler->Converse(std::move(input), stream);"), @@ -312,7 +311,7 @@ void serverGrowsTheAsyncHandlerAndSessionRoutes() { // cancel the in-flight send — and the close follows it. assertTrue( server.contains( - "(void)co_await smithy::eventstream::SendMessage(socket," + "(void)co_await opal::eventstream::SendMessage(socket," + " helpers::BuildConverseExceptionMessage(outcome.error()));"), server); assertFalse(server.contains("socket->SendAsync(BuildConverseExceptionMessage"), server); @@ -335,13 +334,13 @@ void streamRoutesGuardValidationLikeUnaryRoutes() { assertTrue( server.contains( "(void)socket.Send(helpers::BuildConverseExceptionMessage(" - + "smithy::Error::Validation(validation_failures.front().message)));"), + + "opal::Error::Validation(validation_failures.front().message)));"), server); // The session (async) route refuses identically on its owned socket. assertTrue( server.contains( "(void)socket->Send(helpers::BuildConverseExceptionMessage(" - + "smithy::Error::Validation(validation_failures.front().message)));"), + + "opal::Error::Validation(validation_failures.front().message)));"), server); assertFalse(server.contains("ValidateWatchInput"), server); } @@ -355,10 +354,10 @@ void rpcv2CborStreamsOnTheFixedUpgradeUriWithCborPayloads() { client); assertTrue( client.contains( - "return smithy::eventstream::MakeEventMessage(\"message\", \"application/cbor\"," - + " smithy::cbor::Encode(SerializeChatMessage(event.as_message())));"), + "return opal::eventstream::MakeEventMessage(\"message\", \"application/cbor\"," + + " opal::cbor::Encode(SerializeChatMessage(event.as_message())));"), client); - assertTrue(client.contains("smithy::cbor::Decode(envelope->payload)"), client); + assertTrue(client.contains("opal::cbor::Decode(envelope->payload)"), client); String server = manifest.expectFileString("/src/server.cc"); assertTrue( server.contains("(void)stream_router_->Add(\"GET\", \"/service/Svc/operation/Chat\","), @@ -430,25 +429,21 @@ void jsonRpc2ClientOpensTheStreamWithTheRequestEnvelope() { // The opening envelope carries the initial-request members as params, // with the stream union erased — it is the session, not a member. assertTrue( - client.contains("smithy::DocumentMap params = SerializeChatInput(input).as_map();"), - client); + client.contains("opal::DocumentMap params = SerializeChatInput(input).as_map();"), client); assertTrue(client.contains("params.erase(\"events\");"), client); - assertTrue( - client.contains("envelope.emplace(\"method\", smithy::Document(\"Chat\"));"), client); - assertTrue(client.contains("envelope.emplace(\"id\", smithy::Document(1));"), client); + assertTrue(client.contains("envelope.emplace(\"method\", opal::Document(\"Chat\"));"), client); + assertTrue(client.contains("envelope.emplace(\"id\", opal::Document(1));"), client); // The socket is wrapped in the JSON-RPC translation before the typed // stream sees it; the codecs are the shared JSON pair. - assertTrue( - client.contains("std::make_shared"), client); + assertTrue(client.contains("std::make_shared"), client); assertTrue( client.contains( - "return smithy::eventstream::MakeEventMessage(\"message\", \"application/json\"," - + " smithy::Blob::FromString(smithy::json::Encode(SerializeChatMessage(" + "return opal::eventstream::MakeEventMessage(\"message\", \"application/json\"," + + " opal::Blob::FromString(opal::json::Encode(SerializeChatMessage(" + "event.as_message()))));"), client); // A no-input operation still opens with (empty) params. - assertTrue( - client.contains("envelope.emplace(\"method\", smithy::Document(\"Watch\"));"), client); + assertTrue(client.contains("envelope.emplace(\"method\", opal::Document(\"Watch\"));"), client); } @Test @@ -466,7 +461,7 @@ void jsonRpc2ServerDispatchesTheOpeningEnvelopeOnBothSeams() { // frame — never parking a handler thread — and the blocking driver // blocks in Receive, each dispatching on the envelope's method. assertTrue( - server.contains("auto first = co_await smithy::eventstream::ReceiveMessage(socket);"), + server.contains("auto first = co_await opal::eventstream::ReceiveMessage(socket);"), server); assertTrue( server.contains("const JsonRpcOpening opening = helpers::ParseJsonRpcOpening(**first);"), @@ -488,8 +483,8 @@ void jsonRpc2ServerDispatchesTheOpeningEnvelopeOnBothSeams() { // identity otherwise — never an exception message. assertTrue( server.contains( - "smithy::eventstream::JsonRpcStreamSocket wrapped(socket, opening.id," - + " smithy::eventstream::JsonRpcStreamSocket::Role::kServer);"), + "opal::eventstream::JsonRpcStreamSocket wrapped(socket, opening.id," + + " opal::eventstream::JsonRpcStreamSocket::Role::kServer);"), server); assertTrue(server.contains("BuildJsonRpcTerminalResult(opening.id)"), server); assertTrue( @@ -498,9 +493,9 @@ void jsonRpc2ServerDispatchesTheOpeningEnvelopeOnBothSeams() { server); assertTrue( server.contains( - "smithy::eventstream::Detached ServeChatAsync(std::shared_ptr" - + " handler, types::ChatInput input, std::shared_ptr socket," - + " smithy::Document id) {"), + "opal::eventstream::Detached ServeChatAsync(std::shared_ptr" + + " handler, types::ChatInput input, std::shared_ptr socket," + + " opal::Document id) {"), server); assertFalse(server.contains("BuildChatExceptionMessage"), server); assertFalse(server.contains("MakeExceptionMessage"), server); diff --git a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/GeneratedCodeShapeTest.java b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/GeneratedCodeShapeTest.java index 6de53d84..9b0afa25 100644 --- a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/GeneratedCodeShapeTest.java +++ b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/GeneratedCodeShapeTest.java @@ -52,7 +52,7 @@ void unionAccessorsFailWithContextAndOfferSafeAlternatives() { assertTrue(types.contains("require_is(1, \"pending\");"), types); assertTrue( types.contains( - "smithy::internal::FatalWrongUnionAccess(\"Status\", requested," + " case_name());"), + "opal::internal::FatalWrongUnionAccess(\"Status\", requested," + " case_name());"), types); assertTrue( types.contains( @@ -101,10 +101,9 @@ void operationsGrowTypedErrorListings() { PluginTestHarness.generate(ERRORS_MODEL, "test.shape#Svc", "test::shape") .expectFileString("/include/test/shape/client.h"); assertTrue(client.contains("class PingErrors {"), client); + assertTrue(client.contains("static PingErrors FromError(const opal::Error& error) {"), client); assertTrue( - client.contains("static PingErrors FromError(const smithy::Error& error) {"), client); - assertTrue( - client.contains("if (error.kind() != smithy::ErrorKind::kModeled) return result;"), client); + client.contains("if (error.kind() != opal::ErrorKind::kModeled) return result;"), client); assertTrue(client.contains("if (error.code() == \"NotFound\")"), client); assertTrue(client.contains("bool is_not_found() const"), client); assertTrue( @@ -116,7 +115,7 @@ void operationsGrowTypedErrorListings() { "static constexpr const char* kNames[] =" + " {\"(empty)\", \"not_found\", \"quota\"};"), client); - // Error listings are matched from a smithy::Error, never hand-assembled: + // Error listings are matched from a opal::Error, never hand-assembled: // no From factories. assertFalse(client.contains("FromNotFound"), client); } @@ -174,12 +173,11 @@ void generatedTypesHashForUnorderedContainers() { var manifest = PluginTestHarness.generate(ORDERING_MODEL, "test.shape#Svc", "test::shape"); String types = manifest.expectFileString("/include/test/shape/types.h"); assertTrue(types.contains("#include \"smithy/core/hash.h\""), types); - // Structs hash member-wise through smithy::HashValue (containers and + // Structs hash member-wise through opal::HashValue (containers and // optionals have no std::hash of their own). assertTrue(types.contains("struct std::hash {"), types); assertTrue( - types.contains("seed = smithy::HashCombine(seed, smithy::HashValue(value.position));"), - types); + types.contains("seed = opal::HashCombine(seed, opal::HashValue(value.position));"), types); // Member-less structs have nothing to mix — and must not name the unused // parameter (clang's -Wunused-parameter fires in every including TU). assertTrue( @@ -221,7 +219,7 @@ void generatedTypesPrintForLoggingAndTests() { // sink parameter. assertTrue(types.contains("if (this->position.has_value()) {"), types); assertTrue(types.contains("out += \".position = \";"), types); - assertTrue(types.contains("smithy::DebugAppend(out, *this->position);"), types); + assertTrue(types.contains("opal::DebugAppend(out, *this->position);"), types); assertTrue( types.contains( "std::string DebugString() const {" @@ -236,7 +234,7 @@ void generatedTypesPrintForLoggingAndTests() { // Unions print the engaged member by name; the empty state prints none. assertTrue(types.contains("out += \"Status(\";"), types); assertTrue(types.contains("out += \"pending = \";"), types); - assertTrue(types.contains("smithy::DebugAppend(out, std::get<1>(value_));"), types); + assertTrue(types.contains("opal::DebugAppend(out, std::get<1>(value_));"), types); // A @required member prints unconditionally — no presence guard. var required = PluginTestHarness.generate(ERRORS_MODEL, "test.shape#Svc", "test::shape"); String requiredTypes = required.expectFileString("/include/test/shape/types.h"); @@ -280,7 +278,7 @@ void sensitiveShapesRedactInsteadOfPrinting() { assertFalse(types.contains("DebugAppend(out, *this->token)"), types); assertTrue(types.contains("out += \"Vault{[REDACTED]}\";"), types); // The non-sensitive sibling member still prints its value. - assertTrue(types.contains("smithy::DebugAppend(out, *this->user);"), types); + assertTrue(types.contains("opal::DebugAppend(out, *this->user);"), types); } @Test @@ -399,7 +397,7 @@ void typedErrorListingNameCollisionFailsWithContext() { void streamingBlobsStayPlainBufferedBlobs() { // The README's "Current limitations": @streaming BLOBS remain unmodeled — // a streaming blob payload generates as an ordinary, fully buffered - // smithy::Blob with the plain unary operation around it. Event-stream + // opal::Blob with the plain unary operation around it. Event-stream // unions became real in Phase 8 slice 3 (ADR-0016; the flipped pin is // eventStreamOperationsGenerateStreamingSignatures below), which is why // this pin is now blob-specific. @@ -427,10 +425,10 @@ void streamingBlobsStayPlainBufferedBlobs() { """; var manifest = PluginTestHarness.generate(model, "test.shape#Svc", "test::shape"); String types = manifest.expectFileString("/include/test/shape/types.h"); - assertTrue(types.contains("smithy::Blob body{};"), types); + assertTrue(types.contains("opal::Blob body{};"), types); String client = manifest.expectFileString("/include/test/shape/client.h"); assertTrue( - client.contains("smithy::Outcome Upload(const UploadInput& input) const;"), + client.contains("opal::Outcome Upload(const UploadInput& input) const;"), client); assertFalse(client.contains("EventStream"), client); } @@ -468,20 +466,20 @@ void eventStreamOperationsGenerateStreamingSignatures() { var manifest = PluginTestHarness.generate(model, "test.shape#Svc", "test::shape"); String client = manifest.expectFileString("/include/test/shape/client.h"); assertTrue( - client.contains("using ChatClientStream = smithy::eventstream::EventStream;"), + client.contains("using ChatClientStream = opal::eventstream::EventStream;"), client); assertTrue( - client.contains("smithy::Outcome Chat(const ChatInput& input) const;"), + client.contains("opal::Outcome Chat(const ChatInput& input) const;"), client); String server = manifest.expectFileString("/include/test/shape/server.h"); assertTrue( - server.contains("using ChatServerStream = smithy::eventstream::EventStream;"), + server.contains("using ChatServerStream = opal::eventstream::EventStream;"), server); assertTrue( server.contains( - "virtual smithy::Outcome Chat(const ChatInput& input," + "virtual opal::Outcome Chat(const ChatInput& input," + " ChatServerStream& stream," - + " const smithy::server::RequestContext& context) = 0;"), + + " const opal::server::RequestContext& context) = 0;"), server); } @@ -489,7 +487,7 @@ void eventStreamOperationsGenerateStreamingSignatures() { void paginatorsAreRanges() { // Issue #49: @paginated was pull-only — Next()/nullopt with no // begin()/end(), so `for (page : pages)` didn't compile. Paginators now - // expose the single-pass smithy::PageIterator range: iteration yields + // expose the single-pass opal::PageIterator range: iteration yields // Outcome&, and a failed call ends the range after being seen once. String model = """ @@ -517,11 +515,11 @@ void paginatorsAreRanges() { assertTrue(client.contains("using Page = ListThingsOutput;"), client); assertTrue( client.contains( - "smithy::PageIterator begin() { return" - + " smithy::PageIterator(this); }"), + "opal::PageIterator begin() { return" + + " opal::PageIterator(this); }"), client); assertTrue( - client.contains("smithy::PageIterator end() { return {}; }"), client); + client.contains("opal::PageIterator end() { return {}; }"), client); } @Test @@ -536,7 +534,7 @@ void httpsWithoutTransportPointsAtFromConfig() { assertTrue( client.contains( "https endpoints need a TLS-capable transport" - + " (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"), + + " (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"), client); assertFalse(client.contains("FromEndpoint"), client); } diff --git a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HandlerContextThreadingTest.java b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HandlerContextThreadingTest.java index 1de35148..8e452d1b 100644 --- a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HandlerContextThreadingTest.java +++ b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HandlerContextThreadingTest.java @@ -12,7 +12,7 @@ */ class HandlerContextThreadingTest { - private static final String CONTEXT_PARAM = "const smithy::server::RequestContext& context"; + private static final String CONTEXT_PARAM = "const opal::server::RequestContext& context"; private static final String REST_MODEL = """ @@ -66,7 +66,7 @@ void cborRouteLambdaNamesAndForwardsTheContext() { String header = manifest.expectFileString("/include/test/ctx/server.h"); assertTrue(header.contains("Ping(const PingInput& input, " + CONTEXT_PARAM + ") = 0;"), header); String server = manifest.expectFileString("/src/server.cc"); - assertTrue(server.contains(CONTEXT_PARAM + ") -> smithy::http::HttpResponse {"), server); + assertTrue(server.contains(CONTEXT_PARAM + ") -> opal::http::HttpResponse {"), server); assertTrue(server.contains("handler->Ping(input, context)"), server); } @@ -78,7 +78,7 @@ void jsonRpcHandleFunctionsThreadTheContext() { String server = manifest.expectFileString("/src/server.cc"); // The envelope dispatch happens in Handle free functions: the context // enters their signature and rides every dispatch call. - assertTrue(server.contains("const smithy::Document& id, " + CONTEXT_PARAM + ") {"), server); + assertTrue(server.contains("const opal::Document& id, " + CONTEXT_PARAM + ") {"), server); assertTrue(server.contains("handler.Ping(input, context)"), server); assertTrue(server.contains("HandlePing(*handler, *params, id, context)"), server); } diff --git a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HelperNameCoexistenceTest.java b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HelperNameCoexistenceTest.java index 0a4d8e76..aac914f2 100644 --- a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HelperNameCoexistenceTest.java +++ b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HelperNameCoexistenceTest.java @@ -49,7 +49,7 @@ void errorShapeNamedAfterTheOperationCoexistsWithTheErrorHelper() { MockManifest manifest = PluginTestHarness.generate(model, "test.coexist#Svc", "test::coexist"); String client = manifest.expectFileString("/src/client.cc"); assertTrue( - client.contains("smithy::Error ParseGetError(const smithy::http::HttpResponse&"), client); + client.contains("opal::Error ParseGetError(const opal::http::HttpResponse&"), client); assertTrue(client.contains("DeserializeGetError(parsed.doc)"), client); } @@ -79,7 +79,7 @@ void outputMemberTypeNamedAfterTheOperationCoexistsWithTheResponseHelper() { """; MockManifest manifest = PluginTestHarness.generate(model, "test.coexist#Svc", "test::coexist"); String server = manifest.expectFileString("/src/server.cc"); - assertTrue(server.contains("smithy::http::HttpResponse BuildGetResponse("), server); + assertTrue(server.contains("opal::http::HttpResponse BuildGetResponse("), server); // The full call expression, not just the name — a regressed helper // declaration would also contain "SerializeGetResponse(". assertTrue(server.contains("SerializeGetResponse((*output.payload))"), server); diff --git a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HttpJsonBindingProtocolTest.java b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HttpJsonBindingProtocolTest.java index 883f88e9..8247f374 100644 --- a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HttpJsonBindingProtocolTest.java +++ b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HttpJsonBindingProtocolTest.java @@ -102,7 +102,7 @@ void clientEmitsEveryRequestBindingLocation() { String client = generateFiles().expectFileString("/src/client.cc"); assertTrue(client.contains("request.method = \"PUT\";"), client); // @httpLabel: URI-encoded path segment. - assertTrue(client.contains("target += smithy::http::EncodePathSegment("), client); + assertTrue(client.contains("target += opal::http::EncodePathSegment("), client); // @httpQuery, @httpHeader, @httpPrefixHeaders, and the document body. assertTrue(client.contains("query.Add(\"tag\","), client); assertTrue(client.contains("request.headers.Set(\"x-file-kind\","), client); @@ -117,7 +117,7 @@ void clientExtractsEveryResponseBindingLocation() { assertTrue(client.contains("out.code = static_cast<"), client); assertTrue(client.contains("(response->status);"), client); assertTrue( - client.contains("smithy::http::HeaderNameStartsWith(header_name, \"x-out-\")"), client); + client.contains("opal::http::HeaderNameStartsWith(header_name, \"x-out-\")"), client); // Error identity: the neutral x-error-type header discriminates modeled errors. assertTrue(client.contains("x-error-type"), client); } @@ -129,7 +129,7 @@ void serverParsesTheInverseOfTheClientRequest() { assertTrue(server.contains("context.labels.at(\"name\")"), server); assertTrue(server.contains("if (key == \"tag\")"), server); assertTrue( - server.contains("smithy::http::HeaderNameStartsWith(header_name, \"x-meta-\")"), server); + server.contains("opal::http::HeaderNameStartsWith(header_name, \"x-meta-\")"), server); assertTrue(server.contains("body_doc->Find(\"body\")"), server); } @@ -137,7 +137,7 @@ void serverParsesTheInverseOfTheClientRequest() { void floatTextBindingsNarrowThroughTheCheckedHelper() { // No checked-in fixture binds a float to a text position, so the golden // trees can't pin this: a finite query/label/header value beyond float - // range must fail the parse via smithy::FloatFromDouble instead of + // range must fail the parse via opal::FloatFromDouble instead of // hitting the UB static_cast (issue #109). Doubles stay unnarrowed. String server = PluginTestHarness.generate( @@ -165,7 +165,7 @@ void floatTextBindingsNarrowThroughTheCheckedHelper() { "test.rest#Nums", "test::rest") .expectFileString("/src/server.cc"); - assertTrue(server.contains("smithy::FloatFromDouble(*parsed_num)"), server); + assertTrue(server.contains("opal::FloatFromDouble(*parsed_num)"), server); assertTrue( server.contains("if (!narrowed_num) return std::move(narrowed_num).error();"), server); assertEquals(1, count(server, "FloatFromDouble"), server); @@ -282,7 +282,7 @@ void requiredBodyMemberIsStrictOnClientsLenientOnServers() { // Client: strict — the required @httpResponseCode member forces the // member-by-member body parse, and absence is a Serialization error. assertTrue( - client.contains("smithy::Error::Serialization(\"missing required member: name\")"), client); + client.contains("opal::Error::Serialization(\"missing required member: name\")"), client); // Server: lenient — absence is recorded and parsing continues. assertTrue(server.contains("AddValidationFailure(validation_failures, \"/name\""), server); } diff --git a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HttpRedirectCodeGenTest.java b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HttpRedirectCodeGenTest.java index dc987429..e2ee3c2f 100644 --- a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HttpRedirectCodeGenTest.java +++ b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/HttpRedirectCodeGenTest.java @@ -187,7 +187,7 @@ void dynamicResponseCodeGuardsTheBodyOnStatusesThatForbidOne() { // runtime here, so the guard is emitted around the body write rather than // decided at generation time. assertTrue(build.contains("if (helpers::StatusAllowsContent(response.status)) {"), build); - assertTrue(build.contains("response.body = smithy::json::Encode("), build); + assertTrue(build.contains("response.body = opal::json::Encode("), build); } @Test @@ -200,7 +200,7 @@ void modeledNoContentStillSuppressesTheBodyAtGenerationTime() { // the header binding still lands. assertTrue(build.contains("response.status = 204;"), build); assertTrue(build.contains("response.headers.Set(\"x-erased\""), build); - assertFalse(build.contains("response.body = smithy::json::Encode("), build); + assertFalse(build.contains("response.body = opal::json::Encode("), build); assertFalse( build.contains("response.headers.Set(\"content-type\", \"application/json\");"), build); } @@ -229,7 +229,7 @@ void resetContentCarriesNoBody() { String build = function(generate(modeled).expectFileString("/src/server.cc"), "BuildEraseResponse"); assertTrue(build.contains("response.status = 205;"), build); - assertFalse(build.contains("response.body = smithy::json::Encode("), build); + assertFalse(build.contains("response.body = opal::json::Encode("), build); // And the runtime predicate the @httpResponseCode path consults. String server = generate(DYNAMIC_MODEL).expectFileString("/src/server.cc"); @@ -249,7 +249,7 @@ void a2xxStatusStillSendsABody() { function(generate(model).expectFileString("/src/server.cc"), "BuildEraseResponse"); assertTrue(build.contains("response.status = 200;"), build); - assertTrue(build.contains("response.body = smithy::json::Encode("), build); + assertTrue(build.contains("response.body = opal::json::Encode("), build); assertTrue( build.contains("response.headers.Set(\"content-type\", \"application/json\");"), build); } diff --git a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/RecursionIndexTest.java b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/RecursionIndexTest.java index 7d8bac44..7439b9a0 100644 --- a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/RecursionIndexTest.java +++ b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/RecursionIndexTest.java @@ -11,7 +11,7 @@ import software.amazon.smithy.model.shapes.ShapeId; /** - * RecursionIndex decides which generated members get smithy::Boxed indirection and which cycles the + * RecursionIndex decides which generated members get opal::Boxed indirection and which cycles the * generator must refuse — decisions previously pinned only by whole-model goldens. */ class RecursionIndexTest { diff --git a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/SerdeGeneratorTest.java b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/SerdeGeneratorTest.java index 4db17667..5f7d2016 100644 --- a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/SerdeGeneratorTest.java +++ b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/SerdeGeneratorTest.java @@ -109,7 +109,7 @@ void narrowedNumericsRejectOutOfRangeWireValuesInsteadOfTruncating() { assertTrue(intEnumCheck >= 0, serde); assertTrue(intEnumCast >= 0, serde); assertTrue(intEnumCheck < intEnumCast, "range check must precede the narrowing cast"); - assertTrue(serde.contains("smithy::FloatFromDouble"), serde); + assertTrue(serde.contains("opal::FloatFromDouble"), serde); assertTrue(serde.contains("Payload.ratio: value out of range"), serde); assertFalse(serde.contains("Payload.precise: value out of range"), serde); } @@ -117,7 +117,7 @@ void narrowedNumericsRejectOutOfRangeWireValuesInsteadOfTruncating() { @Test void timestampFormatTraitOverridesTheProtocolDefault() { String serde = generateSerde(KITCHEN_MODEL); - assertTrue(serde.contains("smithy::TimestampFormat::kHttpDate"), serde); + assertTrue(serde.contains("opal::TimestampFormat::kHttpDate"), serde); } @Test diff --git a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/ValidationGeneratorTest.java b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/ValidationGeneratorTest.java index cea810f5..eed7fdc5 100644 --- a/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/ValidationGeneratorTest.java +++ b/codegen/smithy-cpp-codegen/src/test/java/io/smithycpp/codegen/ValidationGeneratorTest.java @@ -81,7 +81,7 @@ void rangeMessagesAreSuiteExactAndBoundsCompile() { @Test void patternsCompileOnceIntoTheLinearTimeEngine() { String server = generateServer(CONSTRAINED_MODEL); - assertTrue(server.contains("smithy::Regex::Compile(R\"__smithy(^[a-z]+$)__smithy\")"), server); + assertTrue(server.contains("opal::Regex::Compile(R\"__smithy(^[a-z]+$)__smithy\")"), server); // The message splices the pattern in as a separate escaped literal (the // issue-#43 injection fix), so the text is asserted in its two pieces. assertTrue( @@ -89,7 +89,7 @@ void patternsCompileOnceIntoTheLinearTimeEngine() { "Member must satisfy regular expression pattern: \" + std::string(\"^[a-z]+$\")"), server); // static const: compiled once per process, not per request. - assertTrue(server.contains("static const smithy::Outcome"), server); + assertTrue(server.contains("static const opal::Outcome"), server); } @Test @@ -100,7 +100,7 @@ void lengthCountsCodePointsForStringsAndElementsForCollections() { // upstream suite's exact form ("Member must have length greater than or // equal to N", malformed-length.smithy), not a synthesized // between-1-and-int64max range. - assertTrue(server.contains("smithy::Utf8CodePointCount(value.name)"), server); + assertTrue(server.contains("opal::Utf8CodePointCount(value.name)"), server); assertTrue(server.contains("(*value.tags).size()"), server); assertTrue(server.contains("Member must have length greater than or equal to 1"), server); } diff --git a/docs/PLAN.md b/docs/PLAN.md index dac43fdf..3a57a460 100644 --- a/docs/PLAN.md +++ b/docs/PLAN.md @@ -163,7 +163,7 @@ specs and nothing else: no AWS traits, endpoints, auth, or SDK behaviors (see § ```cpp // Client -smithy::ClientConfig cfg; +opal::ClientConfig cfg; cfg.endpoint = "http://localhost:8080"; WeatherClient client{cfg}; auto outcome = client.GetForecast(GetForecastInput{.city = "Seattle"}); @@ -173,7 +173,7 @@ if (outcome) { use(outcome->chanceOfRain); } else { log(outcome.error().message( struct MyWeatherService final : WeatherServiceHandler { GetForecastOutcome GetForecast(const GetForecastInput& in, const RequestContext& ctx) override; }; -smithy::ServerConfig scfg{.port = 8080}; +opal::ServerConfig scfg{.port = 8080}; WeatherServiceServer server{std::make_shared(), scfg}; server.serve(); // or server.start() / server.stop() for tests ``` @@ -607,7 +607,7 @@ in the error body, (3) client status-code fallback. `@protocolDefinition` trait `smithy.cpp.protocols#jsonRpc2`; single POST endpoint, `{"jsonrpc":"2.0","method":,"params":,"id":…}` request and `{"jsonrpc":"2.0","result":,"id":…}` / `{"error":{code,message,data}}` response over the - `smithy::Document` JSON pivot; JSON-RPC error objects map to modeled errors (`data` carries the + `opal::Document` JSON pivot; JSON-RPC error objects map to modeled errors (`data` carries the shape). We author its protocol-test model (no external suite exists). ✅ Done — `JsonRpc2Protocol` (client + server; the single-endpoint dispatch overrides the new `ProtocolGenerator.writeServerRoutes` hook), authored conformance suite under @@ -636,7 +636,7 @@ client and server — and integration-tested the same way as everything else: ge clients drive generated streaming servers in CI. **Tasks** -- Design doc + ADR first: streaming API shape for C++ (`smithy::EventStream` with an +- Design doc + ADR first: streaming API shape for C++ (`opal::EventStream` with an async sender/receiver pair; backpressure semantics; cancellation; relationship to the `std::future`-based unary API and whether this is the point to introduce a coroutine API). - Runtime: event-stream message framing as mandated by the protocol specs (the diff --git a/docs/adr/0003-error-handling.md b/docs/adr/0003-error-handling.md index 24765433..ea94930e 100644 --- a/docs/adr/0003-error-handling.md +++ b/docs/adr/0003-error-handling.md @@ -9,10 +9,10 @@ exceptions and result types, and many large consumers build with `-fno-exception ## Decision -- Generated client operations and server handler methods return `smithy::Outcome`, an +- Generated client operations and server handler methods return `opal::Outcome`, an `std::expected`-like result type (polyfilled until C++23 is table stakes; the alias switches to `std::expected` when the floor rises). -- Modeled errors derive from `smithy::ModeledError`; transport and deserialization failures use +- Modeled errors derive from `opal::ModeledError`; transport and deserialization failures use distinct error categories, all carried in `Outcome::error()` with code, message, and retryability metadata, plus `ErrorsAs()` accessors for typed access. - Exceptions never cross the generated API boundary. The runtime must be buildable with @@ -20,7 +20,7 @@ exceptions and result types, and many large consumers build with `-fno-exception - **Contract violations fail fast; recoverable bad config returns an error; neither throws.** A composition-time *programming* error — a null callback, a health-check name that would corrupt the failing-list JSON — is not a condition a caller can handle, so it aborts via - `smithy::internal::Fatal` (ADR-0009) rather than throwing `std::invalid_argument`. Bad *config* + `opal::internal::Fatal` (ADR-0009) rather than throwing `std::invalid_argument`. Bad *config* the caller can act on — a malformed proxy-trust CIDR (`TrustedProxies::Parse`), like a bad bind address in `Start` — returns an `Error::Validation` through an `Outcome`. Both replace the old `throw`, so both compile under `-fno-exceptions`; the split is the ADR-0009 line: fail-fast for @@ -28,7 +28,7 @@ exceptions and result types, and many large consumers build with `-fno-exception - **Exceptions are contained at every boundary that must not unwind.** Nothing in the runtime lets an exception cross an `Outcome`-returning entry point or escape a transport io thread. Wire-facing callbacks in the `-fno-exceptions`-clean runtime (request handlers, readiness probes, metrics - sinks) run inside `smithy::internal::Contain` (`smithy/core/exception_guard.h`), which compiles to + sinks) run inside `opal::internal::Contain` (`smithy/core/exception_guard.h`), which compiles to a direct call under `-fno-exceptions`. The Beast transport — which cannot build `-fno-exceptions`, so it always has exceptions — carries its own containment: each background `io_context::run()` is wrapped in a catch-and-re-enter backstop so a stray throw drains remaining work instead of diff --git a/docs/adr/0009-fail-fast-contract-violations.md b/docs/adr/0009-fail-fast-contract-violations.md index df1cca80..0bf18769 100644 --- a/docs/adr/0009-fail-fast-contract-violations.md +++ b/docs/adr/0009-fail-fast-contract-violations.md @@ -17,7 +17,7 @@ Three postures were considered: return a null/sentinel (hides bugs), debug-only ## Decision Contract violations terminate the process with a one-line message carrying the available -context, via `smithy::internal::Fatal` (`smithy/core/fatal.h`): +context, via `opal::internal::Fatal` (`smithy/core/fatal.h`): - `Outcome`: value-access on an error dies with the error's code and message; `value_or_die("context")` adds caller context; `error()` on a value dies naming the misuse. diff --git a/docs/adr/0010-handler-request-context.md b/docs/adr/0010-handler-request-context.md index a757c525..85167486 100644 --- a/docs/adr/0010-handler-request-context.md +++ b/docs/adr/0010-handler-request-context.md @@ -19,7 +19,7 @@ already receive both the raw `HttpRequest` and the router's `RequestContext` Three shapes were considered for the handler surface: 1. **A second parameter on every operation** — `Op(const OpInput&, const - smithy::server::RequestContext&)`, with `RequestContext` gaining the raw request. + opal::server::RequestContext&)`, with `RequestContext` gaining the raw request. 2. **An opt-in overload pair** — keep the 1-arg pure virtual, add a defaulted 2-arg virtual delegating to it. Non-breaking, but a permanent two-method surface per operation and "which do I implement" ambiguity in the primary teaching artifacts. @@ -29,7 +29,7 @@ Three shapes were considered for the handler surface: ## Decision Shape 1. Every generated handler method is -`Op(const OpInput& input, const smithy::server::RequestContext& context)`: +`Op(const OpInput& input, const opal::server::RequestContext& context)`: - `RequestContext` (the type route lambdas already thread) gains `const http::HttpRequest* request`, set by `Router::Route` for the handler call's diff --git a/docs/adr/0012-forwarded-client-address.md b/docs/adr/0012-forwarded-client-address.md index c6232c37..99aef8a0 100644 --- a/docs/adr/0012-forwarded-client-address.md +++ b/docs/adr/0012-forwarded-client-address.md @@ -111,7 +111,7 @@ handlers via `context.request`). adoption (issue #104) showed the extractor-into-admission *wiring* is where silent mutants live (ignoring the trust set, keying on the raw peer: both compile, both pass naturally-written tests, both collapse all - proxied traffic into one bucket). So `smithy::server::PerClientRateLimit` + proxied traffic into one bucket). So `opal::server::PerClientRateLimit` ships that wiring — derive, consult the pluggable `allow(client)` policy, shed with the shaped 429 — while the limiter itself stays an application choice per the middleware contract. Underivable requests diff --git a/docs/adr/0014-event-stream-framing-first.md b/docs/adr/0014-event-stream-framing-first.md index 157d9bc1..19e18e42 100644 --- a/docs/adr/0014-event-stream-framing-first.md +++ b/docs/adr/0014-event-stream-framing-first.md @@ -47,7 +47,7 @@ shippable and tested in the house pattern: dials the upgraded server and drains real frames through the module boundary), the way slice 1 shipped `eventstream_consumer_test` — not just in-repo transport tests. -3. **The streaming API + codegen**: `smithy::EventStream` as a +3. **The streaming API + codegen**: `opal::EventStream` as a blocking sender/receiver pair mirroring the sync unary API (recorded here as *direction*: no coroutine surface before 1.0 — a coroutine adapter can wrap a blocking pair, not vice versa; backpressure by @@ -62,9 +62,9 @@ Codec decisions pinned now: one of the format's ten wire types (bool true/false collapse into one C++ `bool` alternative; timestamps and UUIDs get distinct value types so they cannot be confused with `long`/byte-array — the timestamp is the - runtime's one `smithy::Timestamp`, so slice-3 generated code trades + runtime's one `opal::Timestamp`, so slice-3 generated code trades timestamps with headers without a conversion). The payload is a - `smithy::Blob` — the framing layer carries protocol bytes, it does not + `opal::Blob` — the framing layer carries protocol bytes, it does not interpret them. - **Hand-rolled, dependency-free:** big-endian packing and CRC32 (the IEEE/zlib polynomial) are written out in `frame.cc` like the CBOR diff --git a/docs/adr/0015-websocket-transports.md b/docs/adr/0015-websocket-transports.md index 909f08c8..1774b5b9 100644 --- a/docs/adr/0015-websocket-transports.md +++ b/docs/adr/0015-websocket-transports.md @@ -1,7 +1,7 @@ # ADR-0015: WebSocket transports carry event-stream messages **Status:** Accepted (2026-07-19). Phase 8 slice 2 of ADR-0014's plan. -Implemented: `smithy::http::WebSocket` + `BeastServerTransport` upgrade + +Implemented: `opal::http::WebSocket` + `BeastServerTransport` upgrade + `BeastWebSocketClient` (`//runtime:http_beast`). ## Context @@ -29,7 +29,7 @@ modeled errors — is slice 3's, deliberately not decided here. incremental decode contract stays load-bearing for the future HTTP-body event-stream wire (chunked transfer), which has no message boundaries of its own. -- **One shared session type, `smithy::http::WebSocket`**, for both the +- **One shared session type, `opal::http::WebSocket`**, for both the server-accepted and client-dialed ends: blocking `Outcome> Receive()` (nullopt is the peer's clean close — the stream's natural end, not an error), diff --git a/docs/adr/0016-generated-event-streams.md b/docs/adr/0016-generated-event-streams.md index 6280349b..6ad92b61 100644 --- a/docs/adr/0016-generated-event-streams.md +++ b/docs/adr/0016-generated-event-streams.md @@ -1,8 +1,8 @@ # ADR-0016: Generated event streams — the EventStream API and its wire binding **Status:** Accepted (2026-07-19). Phase 8 slice 3 of ADR-0014's plan. -Implemented: `smithy::eventstream::EventStream` + envelope helpers, -`smithy::server::WebSocketRouter`, `smithy::http::InMemoryWebSocketPair`, +Implemented: `opal::eventstream::EventStream` + envelope helpers, +`opal::server::WebSocketRouter`, `opal::http::InMemoryWebSocketPair`, generated streaming operations (client + server) for `alloy#simpleRestJson` and `smithy.protocols#rpcv2Cbor`. Amended by ADR-0023: the jsonRpc2 generation-time refusal is dead (the protocol streams natively over @@ -65,11 +65,11 @@ normative definition, with an in-repo suite): ## The API -- **`smithy::eventstream::EventStream`** (runtime): blocking +- **`opal::eventstream::EventStream`** (runtime): blocking `Outcome Send(const Tx&)`, `Outcome> Receive()` (nullopt is the peer's clean close — the ADR-0015 convention verbatim), idempotent `Close()`. It - wraps one `smithy::http::WebSocket` plus two codec functions the + wraps one `opal::http::WebSocket` plus two codec functions the generated code supplies; full-duplex threading, backpressure, and cancellation are the session's existing contract. - **Client**: a streaming operation generates @@ -83,14 +83,14 @@ normative definition, with an in-repo suite): `Outcome Op(const OpInput& input, EventStream& stream, const RequestContext& context)` — input first, context last, the ADR-0010 shape. The generated server exposes `StreamRouter()`, a - `smithy::server::WebSocketRouter` with every streaming route + `opal::server::WebSocketRouter` with every streaming route registered; applications mount it in one line each on `websocket_gate` / `on_websocket`. The router reuses the HTTP `Router`'s matching (method, literals > labels > greedy) and populates the same `RequestContext` from the upgrade request, so routing behavior cannot drift between unary and streaming. - **Transport-neutral seams**: `WebSocketRouter` and `EventStream` speak - `smithy::http::WebSocket`, never Beast. `InMemoryWebSocketPair` (the + `opal::http::WebSocket`, never Beast. `InMemoryWebSocketPair` (the loopback analog) lives in dep-light `:http`, so generated integration tests run streams without Boost; the real-wire chat example covers Beast in CI and via the g++ path locally. diff --git a/docs/adr/0017-event-stream-session-handles-and-fanout.md b/docs/adr/0017-event-stream-session-handles-and-fanout.md index d5fdf3a7..f689f17d 100644 --- a/docs/adr/0017-event-stream-session-handles-and-fanout.md +++ b/docs/adr/0017-event-stream-session-handles-and-fanout.md @@ -1,8 +1,8 @@ # ADR-0017: Event-stream session handles and the fan-out registry **Status:** Accepted (2026-07-20). Issue #112. -Implemented: `smithy::eventstream::EventStreamHandle` + -`EventStream::Share()`, `smithy::server::SessionRegistry`, the +Implemented: `opal::eventstream::EventStreamHandle` + +`EventStream::Share()`, `opal::server::SessionRegistry`, the `examples/chat` hub (handler, server and CLI binaries, in-memory and shell-driven e2e suites). @@ -46,7 +46,7 @@ stream's teardown byte-for-byte what it was. `EventStream` becomes move-only: two owners would each claim the teardown, and handles are how a session fans out. -**A fan-out registry over handles.** `smithy::server::SessionRegistry` maps ids to handles with a bounded outbound queue and one writer thread per session (the Go hub's per-client goroutine, typed): `SendTo`/`Broadcast` enqueue and return — never blocking on any wire — and diff --git a/docs/adr/0018-json-text-event-stream-frames.md b/docs/adr/0018-json-text-event-stream-frames.md index fe918c6b..437d1688 100644 --- a/docs/adr/0018-json-text-event-stream-frames.md +++ b/docs/adr/0018-json-text-event-stream-frames.md @@ -1,10 +1,10 @@ # ADR-0018: Negotiated JSON-text event-stream frames — the browser wire **Status:** Accepted (2026-07-20). Phase 8 follow-on; issue #113. -Implemented: `smithy::eventstream::EncodeJsonFrame`/`DecodeJsonFrame` +Implemented: `opal::eventstream::EncodeJsonFrame`/`DecodeJsonFrame` (`//runtime:eventstream_json`), subprotocol negotiation on `BeastServerTransport` + `BeastWebSocketClient`, and -`smithy::server::RequireOrigin`. +`opal::server::RequireOrigin`. ## Context @@ -92,7 +92,7 @@ exactly the purpose the reservation anticipated. generated clients speak binary, and a hand-wired dialer that wants the JSON wire can use `BeastWebSocketClient::Options` directly. - **Origin checking becomes a composable gate.** - `smithy::server::RequireOrigin({"https://example.com", ...})` returns a + `opal::server::RequireOrigin({"https://example.com", ...})` returns a `websocket_gate` that refuses (403) upgrades whose `Origin` is present and not on the allowlist — scheme + host + port exact after normalization (ASCII-lowercased scheme/host, default ports resolved). diff --git a/docs/adr/0019-completion-driven-event-streams.md b/docs/adr/0019-completion-driven-event-streams.md index 7ba67653..ebae2161 100644 --- a/docs/adr/0019-completion-driven-event-streams.md +++ b/docs/adr/0019-completion-driven-event-streams.md @@ -6,7 +6,7 @@ stay blocking — see Non-goals). Implemented: `WebSocket::{ReceiveAsync, SendAsync, SupportsAsync}` (native on the Beast sessions and `InMemoryWebSocketPair`), `BeastServerTransport::Options::on_websocket_session`, -`smithy::eventstream::AsyncEventStream` + `smithy::eventstream::Detached`, +`opal::eventstream::AsyncEventStream` + `opal::eventstream::Detached`, `EventStreamHandle::{SendAsync, SupportsAsync}`, `SessionRegistry Options::async_delivery`, `WebSocketRouter::{AddSession, ServeSession}` (issue #118, the shared-seam @@ -64,7 +64,7 @@ application-authored. The borrowed seam and the generated serve path are byte-for-byte untouched. **A coroutine adapter over the primitives.** -`smithy::eventstream::AsyncEventStream` owns the session +`opal::eventstream::AsyncEventStream` owns the session (`shared_ptr`) plus the two codecs and exposes awaitables: `co_await stream.Receive()` → `Outcome>` (nullopt is the clean end; a decode failure or received exception is terminal and closes, @@ -74,7 +74,7 @@ exactly like `EventStream::Receive`), `co_await stream.Send(event)` → sends from other threads and the registry compose unchanged. Coroutines resume on the completion context: an async handler must not block there; blocking work belongs on the application's own threads, reached through a -handle. `smithy::eventstream::Detached` is the session-loop return type — a +handle. `opal::eventstream::Detached` is the session-loop return type — a fire-and-forget coroutine whose unhandled exceptions are contained to a log line, the transport's containment posture. No general task/executor framework ships: one stream type, two awaitables, one detached launcher is diff --git a/docs/adr/0021-generated-async-streaming-handlers.md b/docs/adr/0021-generated-async-streaming-handlers.md index 71ea7217..0c60e389 100644 --- a/docs/adr/0021-generated-async-streaming-handlers.md +++ b/docs/adr/0021-generated-async-streaming-handlers.md @@ -5,13 +5,13 @@ on a design doc ("generated async surfaces — coroutine handler signatures"), requested as the consumer assessment's named follow-on: a fully-generated handler still pins a thread per stream, and the zero-thread mode has been reachable only by hand-mounting a session loop via `AddSession`. -Implemented: `smithy::eventstream::StreamTask`, the generated +Implemented: `opal::eventstream::StreamTask`, the generated `AsyncHandler` / `AsyncServerStream` surface, the `Server` async constructor wiring `AddSession` routes, the `examples/chat` async hub ported onto it, and an out-of-tree consumer hub with shell-driven tests. Amended by ADR-0023: jsonRpc2 streams ride the same seam through a shared-endpoint session driver -(`ServeJsonRpcSession`) plus `smithy::eventstream::ReceiveMessage`, the +(`ServeJsonRpcSession`) plus `opal::eventstream::ReceiveMessage`, the single-shot receive twin of this ADR's `SendMessageAwaitable`. ## Context @@ -48,7 +48,7 @@ something whose frame outlives the handler must own it. ## Decision -**One new runtime coroutine type, `smithy::eventstream::StreamTask`.** +**One new runtime coroutine type, `opal::eventstream::StreamTask`.** A lazy task whose `co_return` value is `Outcome`: started by `co_await`, resuming its awaiter by symmetric transfer at completion, awaitable exactly once. A handler coroutine that throws completes with @@ -64,12 +64,12 @@ then act on its outcome*. For a service with streaming operations the generator now also emits: - `using AsyncServerStream = - smithy::eventstream::AsyncEventStream;` beside the + opal::eventstream::AsyncEventStream;` beside the blocking alias, same direction convention (Tx = server sends). - `class AsyncHandler` — streaming operations as ```cpp - virtual smithy::eventstream::StreamTask + virtual opal::eventstream::StreamTask Converse(ConverseInput input, ConverseAsyncServerStream& stream) = 0; ``` @@ -92,16 +92,16 @@ For a service with streaming operations the generator now also emits: ```cpp // generated, anonymous namespace - smithy::eventstream::Detached ServeConverseAsync( + opal::eventstream::Detached ServeConverseAsync( std::shared_ptr handler, ConverseInput input, - std::shared_ptr socket) { + std::shared_ptr socket) { ConverseAsyncServerStream stream(socket, EncodeConverseEvent, DecodeConverseEvent); auto outcome = co_await handler->Converse(std::move(input), stream); if (!outcome.ok()) { // Awaited, and best-effort: the wait keeps this frame — and the // stream it owns — alive until the wire has taken the refusal. - (void)co_await smithy::eventstream::SendMessage( + (void)co_await opal::eventstream::SendMessage( socket, BuildConverseExceptionMessage(outcome.error())); } stream.Close(); diff --git a/docs/adr/0023-jsonrpc2-event-streams.md b/docs/adr/0023-jsonrpc2-event-streams.md index 086297a3..7f27a6a9 100644 --- a/docs/adr/0023-jsonrpc2-event-streams.md +++ b/docs/adr/0023-jsonrpc2-event-streams.md @@ -137,7 +137,7 @@ implementation lives. - **The translation is a wrapper socket, not a session flag.** ADR-0018 mounted its translation inside the Beast session, which the in-memory pair never sees. The JSON-RPC translation instead lives in - `smithy::eventstream::JsonRpcStreamSocket`, a delegating + `opal::eventstream::JsonRpcStreamSocket`, a delegating `http::WebSocket` (the `DialedWebSocket` shape) worn by **both ends, on both seams, over both transports**: `Send`/`SendAsync` render an event-envelope `Message` as a notification (headerless raw-text @@ -192,7 +192,7 @@ implementation lives. envelope, validates it, and dispatches on `method` among the service's streaming operations. The blocking seam reads it with `socket.Receive()`; the session seam awaits the new - `smithy::eventstream::ReceiveMessage(socket)` — the single-shot + `opal::eventstream::ReceiveMessage(socket)` — the single-shot receive twin of ADR-0021's `SendMessageAwaitable`, added to the runtime because a Detached launch body has no other way to read one message before constructing the stream. Unknown method, bad diff --git a/docs/adr/0024-runtime-not-named-after-the-idl.md b/docs/adr/0024-runtime-not-named-after-the-idl.md new file mode 100644 index 00000000..6922711a --- /dev/null +++ b/docs/adr/0024-runtime-not-named-after-the-idl.md @@ -0,0 +1,95 @@ +# ADR-0024: The runtime is not named after the IDL + +**Status:** Accepted (2026-09-08). Issue #201. Implemented in three PRs, +one per surface, in this order: the C++ namespace (this ADR lands with +it), the include root, the Bazel module and labels. + +## Context + +Smithy is the IDL a service is *described* in. It is not a property of +the service, of an HTTP request, of a JSON encoder, or of a TLS socket. +Yet every runtime type carried the IDL's name: `smithy::Outcome`, +`smithy::json::Encode`, `smithy::http::BeastServerTransport`. A service +that never opens a model still wrote `smithy::` for its JSON codec and +its HTTP client, and a fleet running services from several toolchains +had one of them announcing its build system in every type name. + +The first symptom to hurt was wire-visible: the built-in metric families +shipped as `smithy_http_requests_total`, which a dashboard has no reason +to know and which the fleet contract (#199) does not spell that way. That +was fixed in place. Issue #201 is the rest of the audit, and it is a +decision rather than a task: a rename this wide is a breaking change +with a real migration cost, and the honest options were to leave the +wart, rename behind a compatibility alias, or rename outright. + +`docs/versioning.md` allows breaking changes on a minor bump pre-1.0 +when they are called out under a "Breaking" heading with a migration +note. There is one out-of-tree consumer in the repository +(`examples/bazel-consumer`) and the known external consumers are +in-house. A compatibility alias would have carried the old spelling +through a deprecation window nobody asked for, doubled every header, and +put off the same diff to a release with more consumers rather than fewer. + +## Decision + +Rename outright, without an alias, on the next minor release. The runtime +is `opal`: + +| Surface | Before | After | +| --- | --- | --- | +| C++ namespace | `smithy::`, `smithy::http::`, … | `opal::`, `opal::http::`, … | +| Include root | `#include "smithy/http/transport.h"` | `#include "opal/http/transport.h"` | +| Bazel module and labels | `bazel_dep(name = "smithy_cpp")`, `@smithy_cpp//runtime:http` | `bazel_dep(name = "opal_cpp")`, `@opal_cpp//runtime:http` | + +The distinction the audit applies: a name that refers to the **model** +keeps `smithy`; a name that refers to a **runtime thing that would exist +identically had the service been hand-written** does not. So these stay: + +- The repository, `smithy-cpp`. It is a Smithy tool. +- The codegen plugin, `codegen/`, `io.smithycpp.codegen`, and the + `software.amazon.smithy` dependency. +- The Bazel rules `smithy_cpp_{types,client,server}_library`. They take a + `.smithy` model as input. +- Smithy namespaces in models (`smithy.cpp.protocols#jsonRpc2`, + `smithy.api#…`) and the C++ namespaces a model's author derives from + them — the rules-test fixture's `smithy::cpp::ruletest` mirrors its + model's `smithy.cpp.ruletest` and is the consumer's, not the runtime's. +- Prose about "the Smithy operation", traits, the model. The `route` + label really is the Smithy operation name. + +And these change, each as its own PR because a mixed one is unreviewable: + +1. **Namespace.** Every `smithy::` scope in hand-written code, in the 26 + codegen emitters that print it into generated code, and in docs. The + generated protocol-conformance suites move with it + (`opal::protocoltests::…`), because they are generated code that + refers to the runtime, not a model. Goldens regenerate from the + emitters; nothing under `generated/` is hand-edited. +2. **Include root.** `runtime/include/smithy/` becomes + `runtime/include/opal/`, with the include guards and the + `SMITHY_*` macro prefix that derive from it, and the `smithy:` prefix + on the runtime's own log lines, which names the library that wrote + them. +3. **Bazel.** The module name, the `@smithy_cpp//…` labels the consumer + module and the docs use, and `SMITHY_COPTS`. + +Sequencing constraint, the same for every surface: the codegen emitters +are the source of truth for generated references, so they change first +and the goldens regenerate from them. + +## Consequences + +- Breaking, on a minor bump, called out in the CHANGELOG with the + one-line migration each surface needs (a `sed` over the consumer's + tree). Consumers migrate once per surface, or once at the release that + carries all three. +- The rename is mechanical and verified by the existing suites: the + goldens must regenerate byte-identically from the emitters (the codegen + job's golden check), and every in-tree consumer — the examples, the + protocol conformance suites, the out-of-tree module — compiles against + the new name with no source change beyond the rename itself. +- Wire-visible strings (metric names, log-line keys, headers) never carry + the IDL's name; the audit that produced this ADR checked them and the + metrics fix in #199 was the only instance. +- `docs/versioning.md`'s compatibility surface #3 reads + `runtime/include/smithy/**` until the include-root PR moves it. diff --git a/docs/design/codegen-architecture.md b/docs/design/codegen-architecture.md index 67e5488d..dc81cbd8 100644 --- a/docs/design/codegen-architecture.md +++ b/docs/design/codegen-architecture.md @@ -14,7 +14,7 @@ smithy-rs's `codegen-core` structure (PLAN §3.2a). | `CppWriter` | `SymbolWriter` per generated file: collects includes while the body is written, renders header comment + `#pragma once` + sorted includes + namespace wrapper. Byte deterministic | | `DirectedCppCodegen` | Implements `DirectedCodegen`; handles structure/error/union/enum/intEnum directives, then (service directive) resolves the protocol and drives serde → client → BUILD generation | | `TypeGenerators` | The actual C++ emission for data shapes | -| `SerdeGenerator` / `SerdeCodeGen` | `serde.h`/`src/serde.cc`: per-shape `Serialize*`/`Deserialize*` functions over the `smithy::Document` pivot, in topological order (`TopologicalIndex`) | +| `SerdeGenerator` / `SerdeCodeGen` | `serde.h`/`src/serde.cc`: per-shape `Serialize*`/`Deserialize*` functions over the `opal::Document` pivot, in topological order (`TopologicalIndex`) | | `ProtocolGenerator` (interface) | Per-protocol request building + response/error handling emission; `resolveProtocol` picks the implementation from the service's protocol traits | | `HttpJsonBindingProtocol` | `alloy#simpleRestJson` (via the `simpleRestJson()` factory): HTTP bindings via `HttpBindingIndex` (labels incl. greedy, query, headers, status), JSON bodies, neutral `X-Error-Type` error identity. A thin `ProtocolGenerator` facade over `HttpJsonClientGenerator` (operation-method bodies), `HttpJsonServerGenerator` (parse/serialize functions, routes, content negotiation), and `HttpBindingCodeGen` (the header/payload/prefix-header read↔write emitters both halves share) | | `Rpcv2CborProtocol` | `smithy.protocols#rpcv2Cbor`: fixed `/service/{S}/operation/{O}` target, `smithy-protocol` header, CBOR bodies | diff --git a/docs/design/integration-testing.md b/docs/design/integration-testing.md index 677ef39d..4ccfa25f 100644 --- a/docs/design/integration-testing.md +++ b/docs/design/integration-testing.md @@ -9,8 +9,8 @@ generated client calls its own generated server through real transports. The generated fixture is parameterized over two transports with identical test bodies: -- **Loopback** — in-memory `smithy::http::Loopback`; fast, deterministic, sanitizer-friendly. -- **Socket** — `smithy::http::SocketHttpServer` bound to an ephemeral port on 127.0.0.1 with the +- **Loopback** — in-memory `opal::http::Loopback`; fast, deterministic, sanitizer-friendly. +- **Socket** — `opal::http::SocketHttpServer` bound to an ephemeral port on 127.0.0.1 with the client pointed at it; catches transport/framing bugs the loopback can't. A generated `ScriptedHandler` records the input each operation received and answers with a diff --git a/docs/generated-types.md b/docs/generated-types.md index 2c95770e..576e66eb 100644 --- a/docs/generated-types.md +++ b/docs/generated-types.md @@ -11,20 +11,20 @@ compatibility contract: changes to it are breaking for consumers of generated co | `byte` / `short` / `integer` / `long` | `std::int8_t` / `std::int16_t` / `std::int32_t` / `std::int64_t` | | | `float` / `double` | `float` / `double` | | | `string` | `std::string` | | -| `blob` | `smithy::Blob` | | -| `timestamp` | `smithy::Timestamp` | | -| `document` | `smithy::Document` | | +| `blob` | `opal::Blob` | | +| `timestamp` | `opal::Timestamp` | | +| `document` | `opal::Document` | | | `list` | `std::vector` | `@sparse` ⇒ `std::vector>` | | `map` | `std::map` | `@sparse` ⇒ optional values; `std::map` keeps output deterministic | | `structure` | `struct` with public members | Aggregate; `operator==` and `operator<=>` defaulted; every member value-initialized with `{}` | | `union` | class over `std::variant` | See below | | `enum` | class with nested `enum class Value` | See below; unknown wire values preserved | | `intEnum` | `enum class X : std::int32_t` | Wire values outside int32 fail the parse; unknown in-range values are preserved (servers additionally validate membership) | -| `smithy.api#Unit` | `smithy::Unit` | Never declared; maps to the runtime type | +| `smithy.api#Unit` | `opal::Unit` | Never declared; maps to the runtime type | | `bigInteger` / `bigDecimal` | — | Rejected with a clear error (planned) | -| `@streaming` blob member | trait ignored | Generates as a fully buffered `smithy::Blob`; see the README's [Current limitations](../README.md#current-limitations) | -| `@streaming` union member | typed event stream (ADR-0016) | The operation generates `smithy::eventstream::EventStream` signatures (client and server) instead of carrying the union in the body; the union itself still generates as a normal union type | -| recursive structures | `smithy::Boxed` member indirection | Deep copy/equality; list cycles ride `std::vector` directly. Cycles through union members or map values are still rejected with a clear error | +| `@streaming` blob member | trait ignored | Generates as a fully buffered `opal::Blob`; see the README's [Current limitations](../README.md#current-limitations) | +| `@streaming` union member | typed event stream (ADR-0016) | The operation generates `opal::eventstream::EventStream` signatures (client and server) instead of carrying the union in the body; the union itself still generates as a normal union type | +| recursive structures | `opal::Boxed` member indirection | Deep copy/equality; list cycles ride `std::vector` directly. Cycles through union members or map values are still rejected with a clear error | ## Conventions @@ -42,8 +42,8 @@ compatibility contract: changes to it are breaking for consumers of generated co `@required` + `@default` reads absence as the default instead of failing. - **Ordering**: generated types default `operator<=>` beside `operator==` whenever every member is three-way-comparable, so structs, unions, and enums key `std::map`/`std::set` and sort - (issue #49). Types that can't order — a `smithy::Document` member, or recursion (via - `smithy::Boxed`, which deliberately has no `<=>`: deducing a deep ordering around the cycle + (issue #49). Types that can't order — a `opal::Document` member, or recursion (via + `opal::Boxed`, which deliberately has no `<=>`: deducing a deep ordering around the cycle it exists to break is a hard error on clang), transitively through members — are equality-only: the generator omits `<=>` and leaves an "Equality-only" comment in the header. `float`/`double` members make the ordering partial. @@ -51,8 +51,8 @@ compatibility contract: changes to it are breaking for consumers of generated co `std::unordered_map`/`std::unordered_set` the same way it keys `std::map` (equality-only types get neither). Structs hash member-wise, enums hash their (value, unknown-text) pair, unions and `Errors` listings hash (engaged index, engaged member); list/map/optional - members hash element-wise via `smithy::HashValue`, and the runtime types (`smithy::Blob`, - `smithy::Timestamp`, `smithy::Unit`) carry `std::hash` in their own headers. The + members hash element-wise via `opal::HashValue`, and the runtime types (`opal::Blob`, + `opal::Timestamp`, `opal::Unit`) carry `std::hash` in their own headers. The specializations sit after the namespace's closing brace in the same generated header. Hash values are **process-local**: they build on `std::hash`, so never persist them or compare them across processes, builds, or library versions. @@ -68,7 +68,7 @@ compatibility contract: changes to it are breaking for consumers of generated co **not gated**: recursion and `Document` members print fine (value semantics keep the data acyclic). The runtime member types render via the same mechanism: `Blob` as size plus a bounded hex prefix (never full contents), `Timestamp` as RFC 3339, `Document` JSON-ish, - `smithy::DebugString(x)`/`DebugAppend` in `smithy/core/print.h` for anything else. Debug + `opal::DebugString(x)`/`DebugAppend` in `smithy/core/print.h` for anything else. Debug output is for **humans and logs only** — it is not a serialization format; never parse it, and never pin exact bytes across library versions. - **Deliberately not generated**: @@ -131,7 +131,7 @@ terminates the process with the union, requested, and engaged member named (e.g. `std::bad_variant_access`. For access that can't die, branch on `is_x()`, use `as_x_or_null()` (`if (const auto* dairy = milk.as_dairy_or_null()) …`), or `visit()` with a visitor that covers every member plus `std::monostate` for the empty state — -`smithy::Overloaded` (`smithy/core/overloaded.h`) builds one from lambdas. +`opal::Overloaded` (`smithy/core/overloaded.h`) builds one from lambdas. ## Serde (Phase 3) @@ -139,15 +139,15 @@ visitor that covers every member plus `std::monostate` for the empty state — operation: ```cpp -smithy::Document SerializeOrderCoffeeInput(const OrderCoffeeInput& value); -smithy::Outcome DeserializeOrderCoffeeInput(const smithy::Document& value); +opal::Document SerializeOrderCoffeeInput(const OrderCoffeeInput& value); +opal::Outcome DeserializeOrderCoffeeInput(const opal::Document& value); ``` -- **Pivot type**: `smithy::Document` — protocol-independent; the client picks the JSON or CBOR +- **Pivot type**: `opal::Document` — protocol-independent; the client picks the JSON or CBOR codec at the wire boundary, so serde is generated once per shape, not once per protocol. - **Tolerant reads**: unknown response members are ignored; unknown enum values are preserved (`Value::kUnknown` + original text). Missing `@required` members produce a - `smithy::ErrorKind::kSerialization` error naming the member. + `opal::ErrorKind::kSerialization` error naming the member. - **Sparse** lists/maps serialize `std::nullopt` as explicit nulls; timestamps honor `@timestampFormat` with the protocol default applied where unspecified. - **alloy unions**: `@discriminated("key")` unions put the engaged member's fields inline with @@ -175,7 +175,7 @@ auto client = WeatherClient::Create(std::move(config)).value_or_die("creating we auto city = client.GetCity(GetCityInput{.cityId = "seattle"}); // Outcome ``` -- **Transport-agnostic**: `smithy::ClientConfig` supplies either an `endpoint` (uses the default +- **Transport-agnostic**: `opal::ClientConfig` supplies either an `endpoint` (uses the default socket transport) or an explicit `http_client` (loopback for tests, Beast, custom). - **Protocol binding** is chosen at generation time from the service's protocol trait: simpleRestJson (HTTP bindings: labels, query, headers, status codes), rpcv2Cbor @@ -183,7 +183,7 @@ auto city = client.GetCity(GetCityInput{.cityId = "seattle"}); // Outcome= 500`) are marked retryable. @@ -197,7 +197,7 @@ auto city = client.GetCity(GetCityInput{.cityId = "seattle"}); // OutcomeorderId); // or exhaustively — the visitor must also cover std::monostate, the // "not one of this operation's modeled errors" state: - typed.visit(smithy::Overloaded{ + typed.visit(opal::Overloaded{ [](const OrderNotFound& e) { /* ... */ }, [](std::monostate) { /* transport/serialization/unknown */ }, }); @@ -214,7 +214,7 @@ auto city = client.GetCity(GetCityInput{.cityId = "seattle"}); // OutcomeHandler` (one `Outcome`-returning method per operation) and a `Server` that binds it to the runtime router; `Handler()` -returns a transport-agnostic `smithy::http::RequestHandler`. Routing, binding deserialization, +returns a transport-agnostic `opal::http::RequestHandler`. Routing, binding deserialization, response serialization, and modeled-error mapping (`@httpError` status, `__type` body, typed detail via `set_detail`) are generated — see [docs/server-guide.md](server-guide.md). Every module also gets `tests/smoke_test.cc`: generated client ↔ generated server over loopback. diff --git a/docs/production-guide.md b/docs/production-guide.md index 28ab25df..ecf182d1 100644 --- a/docs/production-guide.md +++ b/docs/production-guide.md @@ -2,14 +2,14 @@ How to configure generated smithy-cpp clients and servers for production use: timeouts, retries, and request compression. Every knob lives on -`smithy::ClientConfig` (`smithy/client/config.h`), so the guidance below +`opal::ClientConfig` (`smithy/client/config.h`), so the guidance below applies to every generated client the same way. ```cpp #include "myservice/client.h" #include "smithy/client/config.h" -smithy::ClientConfig config; +opal::ClientConfig config; config.endpoint = "http://api.example.com:8080"; config.request_timeout_ms = 5000; config.retry.max_attempts = 5; @@ -33,7 +33,7 @@ caller wait is roughly `max_attempts × timeout` plus backoff sleeps. ## Retries -Every generated client sends through `smithy::SendWithRetries` +Every generated client sends through `opal::SendWithRetries` (`smithy/client/retry.h`). Two failure classes are retried: - **Transport errors flagged retryable** — connection refused/reset, @@ -77,7 +77,7 @@ default; 0 compresses everything). The client appends `gzip` to any existing `Content-Encoding` header value. Nothing is configured per call — model the trait and the generated client and server both handle it: -- **Client:** compresses via `smithy::GzipCompress` (`//runtime:compression`, +- **Client:** compresses via `opal::GzipCompress` (`//runtime:compression`, zlib) after serialization, before send. - **Server:** generated routes for `@requestCompression` operations transparently gunzip requests arriving with `Content-Encoding: gzip` @@ -109,12 +109,12 @@ Server-side, the matching guards ship as middleware (`smithy/server/middleware.h`): ```cpp -transport.Start(smithy::server::Chain( - {smithy::server::RequireBearerAuth([](const std::string& token) { +transport.Start(opal::server::Chain( + {opal::server::RequireBearerAuth([](const std::string& token) { return TokenIsValid(token); // 401 otherwise })}, server.Handler())); -// Or: smithy::server::RequireApiKeyHeader("x-api-key", /*scheme=*/"", validator) +// Or: opal::server::RequireApiKeyHeader("x-api-key", /*scheme=*/"", validator) ``` Vendor-specific signing schemes (e.g. SigV4) are out of scope by design; @@ -125,7 +125,7 @@ implement them as an `Interceptor` (below). Operations modeled with `@paginated` (top-level string tokens) get a generated paginator: `client.PaginateListCities(input)` returns a `ListCitiesPaginator` that is a single-pass range (issue #49) — iteration -yields one `smithy::Outcome&` per page, and a failed call is yielded +yields one `opal::Outcome&` per page, and a failed call is yielded exactly once before the range ends by itself, so the loop needs no manual token or nullopt protocol: @@ -150,13 +150,13 @@ every HTTP attempt a generated client makes — auth headers, tracing ids, request/response logging — without touching generated code: ```cpp -class BearerAuth final : public smithy::Interceptor { +class BearerAuth final : public opal::Interceptor { public: - void ModifyBeforeTransmit(smithy::http::HttpRequest& request, int attempt) override { + void ModifyBeforeTransmit(opal::http::HttpRequest& request, int attempt) override { request.headers.Set("authorization", "Bearer " + LoadToken()); } - void ReadAfterTransmit(const smithy::http::HttpRequest& request, - const smithy::Outcome& outcome, + void ReadAfterTransmit(const opal::http::HttpRequest& request, + const opal::Outcome& outcome, int attempt) override { LogAttempt(request.target, attempt, outcome.ok() ? outcome->status : -1); } @@ -173,7 +173,7 @@ the caller's view. Hooks must not throw. ## Server middleware Generated servers expose their router as a plain -`smithy::http::RequestHandler`, so cross-cutting server behavior — auth +`opal::http::RequestHandler`, so cross-cutting server behavior — auth checks, request logging, metrics — composes as middleware outside the generated code (`smithy/server/middleware.h`), with any transport: @@ -191,16 +191,16 @@ auto db = std::make_shared(/* ... */); // and every request keys as its TCP peer. Parse() rejects a malformed CIDR // with an Error::Validation, so fail startup rather than deploy a boundary // that silently widens or narrows. -auto trusted_result = smithy::http::TrustedProxies::Parse({"10.0.0.0/8"}); +auto trusted_result = opal::http::TrustedProxies::Parse({"10.0.0.0/8"}); if (!trusted_result) { /* report trusted_result.error(); refuse to start */ } -const smithy::http::TrustedProxies trusted = *std::move(trusted_result); +const opal::http::TrustedProxies trusted = *std::move(trusted_result); -transport.Start(smithy::server::Chain( +transport.Start(opal::server::Chain( {// Outermost: shed abusive traffic before it costs anything. The // framework derives the client behind the trust boundary and keys // admission on it — never the raw header, which any client can write // (smithy/http/forwarded.h has the derivation contract). - smithy::server::PerClientRateLimit( + opal::server::PerClientRateLimit( [limiter](const std::string& client) { return limiter->Allow(client); }, trusted, std::chrono::seconds(30)), // Observe everything admitted — health probes included, reporting @@ -209,8 +209,8 @@ transport.Start(smithy::server::Chain( // observation reports the peer while the limiter keyed on the // forwarded client, and the log cannot answer a question about the // limiter's own decision. - smithy::server::Observe( - [](const smithy::server::RequestObservation& o) { + opal::server::Observe( + [](const opal::server::RequestObservation& o) { // One access-log record: o.method, o.target, o.operation, // o.status, o.duration, o.trace_parent, o.request_bytes, // o.response_bytes, o.handler_threw (a contained crash, not a @@ -218,7 +218,7 @@ transport.Start(smithy::server::Chain( // .source provenance, which is the bucket the limiter keyed on. // Also gauge -1; count 1; latency o.duration. }, - [](const smithy::server::RequestStart& s) { + [](const opal::server::RequestStart& s) { // gauge +1 (labeled by s.method/s.target; the operation is not // known until the router runs). }, @@ -226,12 +226,12 @@ transport.Start(smithy::server::Chain( // Liveness: GET or HEAD /livez -> 200 {"status":"healthy"}. A HEAD // gets that body's Content-Length and none of its octets, framed by // the transport; everything else passes through to the router. - smithy::server::HealthEndpoint("/livez"), + opal::server::HealthEndpoint("/livez"), // Readiness: the same endpoint with checks. Every probe runs on every // request (no caching — a cached 200 would hide a dependency outage); // any failure answers 503 {"status":"unhealthy","failing":["db"]}. // A throwing probe counts as failing, never unwinds into the transport. - smithy::server::HealthEndpoint( + opal::server::HealthEndpoint( "/readyz", {{"db", [db] { return db->Alive(); }}})}, server.Handler())); ``` @@ -269,7 +269,7 @@ logged and swallowed. **Watch the trust boundary itself.** A drifted trust set (the proxy's address changed; the CIDR didn't) fails silently: the spoof defense ignores the header on every request and all traffic collapses onto the proxy's one -key. The fingerprint is visible in `smithy::http::DeriveClient` — the +key. The fingerprint is visible in `opal::http::DeriveClient` — the richer form of `ClientAddress` that also reports *how* the address was derived. `Observe` reports it directly — `o.client.source`, derived against the `TrustedProxies` you passed it — so counting it needs no extra @@ -287,10 +287,10 @@ proxied traffic onto one key (the issue-#104 accident, config edition): ```cpp const char* cidrs = std::getenv("TRUSTED_PROXY_CIDRS"); -smithy::http::TrustedProxies trusted = smithy::http::TrustedProxies::None(); +opal::http::TrustedProxies trusted = opal::http::TrustedProxies::None(); if (cidrs != nullptr) { // the comma-list splitter from smithy/http/headers.h - auto parsed = smithy::http::TrustedProxies::Parse(smithy::http::SplitHeaderListValues(cidrs)); + auto parsed = opal::http::TrustedProxies::Parse(opal::http::SplitHeaderListValues(cidrs)); if (!parsed) { /* log parsed.error(); refuse to start */ } trusted = *std::move(parsed); } @@ -315,12 +315,12 @@ int main(int argc, char** argv) { pthread_sigmask(SIG_BLOCK, &shutdown_signals, nullptr); BookstoreServer server(std::make_shared()); - smithy::http::BeastServerTransport transport({ + opal::http::BeastServerTransport transport({ .address = "0.0.0.0", .port = argc > 1 ? std::atoi(argv[1]) : 8080, // 0 binds an ephemeral port .drain_timeout_seconds = 10, }); - smithy::Outcome started = transport.Start(server.Handler()); + opal::Outcome started = transport.Start(server.Handler()); if (!started.ok()) { std::fprintf(stderr, "bookstore: start failed: %s\n", started.error().message().c_str()); return 1; @@ -388,14 +388,14 @@ configuration, no dependency — so the line goes wherever your logs already go, and `Observe` stays the one clock for metrics and the log alike: ```cpp -transport.Start(smithy::server::Chain( - {smithy::server::Observe( - [](const smithy::server::RequestObservation& o) { - std::clog << smithy::server::FormatAccessLog(o, {{"service_name", "todo-service"}}) +transport.Start(opal::server::Chain( + {opal::server::Observe( + [](const opal::server::RequestObservation& o) { + std::clog << opal::server::FormatAccessLog(o, {{"service_name", "todo-service"}}) << '\n'; }, nullptr, nullptr, trusted), - smithy::server::PerClientRateLimit(allow, trusted)}, + opal::server::PerClientRateLimit(allow, trusted)}, server.Handler())); ``` @@ -436,8 +436,8 @@ one more than anyone can reconcile. ```cpp // Metrics/logging: one callback per HTTP attempt (retries visible). -config.interceptors.push_back(smithy::ObserveAttempts( - [](const smithy::AttemptObservation& a) { +config.interceptors.push_back(opal::ObserveAttempts( + [](const opal::AttemptObservation& a) { // a.method, a.target, a.attempt, a.status (-1 = transport error), // a.error_message })); @@ -445,7 +445,7 @@ config.interceptors.push_back(smithy::ObserveAttempts( // Distributed tracing: sets a W3C traceparent header on every attempt that // lacks one. Pass a callback returning your application's active trace // context to join an existing trace; omit it to start fresh roots. -config.interceptors.push_back(smithy::PropagateTraceContext()); +config.interceptors.push_back(opal::PropagateTraceContext()); ``` `smithy/http/trace_context.h` has the underlying helpers — @@ -458,10 +458,10 @@ needs no client library — it is a few lines of text over HTTP, so it costs zero dependencies. Two middleware compose around the generated handler: ```cpp -auto metrics = std::make_shared( - smithy::server::MetricsOptions{.enabled = true, .service_name = "todo-service"}); -transport.Start(smithy::server::Chain({smithy::server::MetricsEndpoint(metrics), - smithy::server::RecordMetrics(metrics)}, +auto metrics = std::make_shared( + opal::server::MetricsOptions{.enabled = true, .service_name = "todo-service"}); +transport.Start(opal::server::Chain({opal::server::MetricsEndpoint(metrics), + opal::server::RecordMetrics(metrics)}, server.Handler())); ``` @@ -571,7 +571,7 @@ auto orders = metrics->NewCounter("orders_processed_total", "Orders processed.") // ladder for a histogram of bytes or queue depth yields meaningless bins. // For a request-shaped duration, the shared ladder is the right one. auto latency = metrics->NewHistogram("order_pipeline_duration_microseconds", "Pipeline time.", - smithy::server::HttpLatencyBuckets()); + opal::server::HttpLatencyBuckets()); auto depth = metrics->NewGauge("queue_depth", "Pending jobs."); orders.Increment({{"region", "us-east"}}); @@ -610,7 +610,7 @@ still reading and before any handler chain exists — so `RecordMetrics` never sees them and an over-limit flood would be invisible in the counters: ```cpp -options.on_rejected = smithy::server::RecordRejections(metrics); +options.on_rejected = opal::server::RecordRejections(metrics); ``` These count as requests (`route="unmatched"`, with `413`/`431` as the @@ -651,10 +651,10 @@ Every knob lives on the one `ClientConfig` (issue #49): pool size come from the config, so nothing is configured twice: ```cpp -smithy::ClientConfig config; +opal::ClientConfig config; config.endpoint = "https://api.example.com"; // identity + path prefix config.tls.ca_pem = corp_ca_pem; // only when not publicly trusted -auto transport = smithy::http::BeastHttpClient::FromConfig(config); +auto transport = opal::http::BeastHttpClient::FromConfig(config); if (!transport) { /* bad URL */ } config.http_client = *transport; // the wire auto client = MyServiceClient::Create(std::move(config)); @@ -711,7 +711,7 @@ and from a broken session (`TransportError`), and it is the only failure that leaves the stream usable — which is what separates it from `Close()`, the other way to end a wait (that one ends the session for good, and reports the peer's own close). The bound is always real: the overload is pure virtual on -`smithy::http::WebSocket`, so every session — the two shipped transports, the +`opal::http::WebSocket`, so every session — the two shipped transports, the delegating wrappers, and any socket you implement yourself — answers the deadline or does not compile. There is no default that quietly blocks forever. The same overload exists one layer down, on `WebSocket` itself, for @@ -749,9 +749,9 @@ streams, and the dial goes out anonymous. Use the modeled auth traits headers to the upgrade request: ```cpp -config.websocket_dialer = [](smithy::http::WebSocketDialRequest request) { +config.websocket_dialer = [](opal::http::WebSocketDialRequest request) { request.headers.Set("authorization", "Bearer " + FetchToken()); - return smithy::http::BeastWebSocketClient::Dialer()(request); + return opal::http::BeastWebSocketClient::Dialer()(request); }; ``` @@ -840,7 +840,7 @@ any other header — a token there is neither modeled, nor validated, nor private. **Browser-facing endpoints need an Origin allowlist.** -`smithy::server::RequireOrigin({"https://muchq.com"})` returns a +`opal::server::RequireOrigin({"https://muchq.com"})` returns a `websocket_gate` that refuses (403) upgrades whose `Origin` is present and not listed — scheme + host + port exact — and admits requests with no Origin header at all (non-browser clients don't send one; the attack this @@ -860,7 +860,7 @@ and the whole loop is made of pieces this guide already taught. Server side, enable grace on the registry and split the handler's exits: ```cpp -smithy::server::SessionRegistry::Options options; +opal::server::SessionRegistry::Options options; options.grace_period = std::chrono::seconds{300}; options.on_expired = [&](const std::string& id) { // The deferred cleanup: collect the game, tell the room. Runs exactly @@ -891,7 +891,7 @@ whole dance is one registry call (ADR-0022) — the blessed admission call every example makes: ```cpp -using Registry = smithy::server::SessionRegistry; +using Registry = opal::server::SessionRegistry; const auto admission = registry.ResumeOrAdd( id, [&stream] { return stream.Share(); }, std::chrono::seconds(1)); diff --git a/docs/quickstart.md b/docs/quickstart.md index a4804d40..ac47710c 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -272,20 +272,20 @@ error — no exceptions): ```cpp class InMemoryHandler final : public TodoHandler { public: - smithy::Outcome AddTask(const AddTaskInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome AddTask(const AddTaskInput& input, + const opal::server::RequestContext&) override { const std::lock_guard lock(mu_); const std::string id = "task-" + std::to_string(next_id_++); titles_[id] = input.title; return AddTaskOutput{.taskId = id, .title = input.title}; } - smithy::Outcome GetTask(const GetTaskInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome GetTask(const GetTaskInput& input, + const opal::server::RequestContext&) override { const std::lock_guard lock(mu_); const auto it = titles_.find(input.taskId); if (it == titles_.end()) { - smithy::Error error = smithy::Error::Modeled("NoSuchTask", "no task: " + input.taskId); + opal::Error error = opal::Error::Modeled("NoSuchTask", "no task: " + input.taskId); error.set_detail(NoSuchTask{.message = "no task: " + input.taskId}); return error; // the server turns this into the modeled 404 } @@ -309,9 +309,9 @@ socket) exactly like ```cpp TodoServer server(std::make_shared()); -auto loopback = std::make_shared(); +auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); -smithy::ClientConfig config; +opal::ClientConfig config; config.http_client = loopback; // Create returns an Outcome; value_or_die unwraps it, and on failure dies // with this context plus the error's code and message. @@ -334,7 +334,7 @@ server does on your behalf. bazel test //... ``` -For production serving, plug `server.Handler()` into `smithy::http::BeastServerTransport` +For production serving, plug `server.Handler()` into `opal::http::BeastServerTransport` (`@smithy_cpp//runtime:http_beast`, ADR-0006) — the [Serving lifecycle](production-guide.md#serving-lifecycle) walkthrough and its compiled example ([`examples/simplerestjson/serve_main.cc`](../examples/simplerestjson/serve_main.cc)) wire diff --git a/docs/runtime.md b/docs/runtime.md index 80129a06..d5ca8051 100644 --- a/docs/runtime.md +++ b/docs/runtime.md @@ -7,17 +7,17 @@ crates (PLAN §3.2a). | Bazel target | Namespace | Contents | |---|---|---| -| `//runtime:core` | `smithy` | `Outcome` + `Error` (ADR-0003), `Blob`, `Timestamp` (epoch-seconds / RFC 3339 date-time / IMF-fixdate http-date), `Document` (dynamic value + serde pivot), base64, `Regex` (linear-time NFA engine behind generated `@pattern` validation — ReDoS-safe) | -| `//runtime:json` | `smithy::json` | `Document` ⇄ JSON text via nlohmann (blobs as base64, timestamps per stored format) | -| `//runtime:cbor` | `smithy::cbor` | `Document` ⇄ deterministic CBOR (RFC 8949; tag-1 timestamps; tolerant decoder) — ADR-0005 | -| `//runtime:eventstream` | `smithy::eventstream` | Event-stream message framing (ADR-0014): CRC-guarded prelude, ten typed header wire types, opaque `Blob` payload; strict fail-closed incremental decoder with symmetric encode/decode bounds. Plus the generated streaming API's substrate (ADR-0016): the envelope helpers (`:message-type`/`:event-type`/`:exception-type` — the one place the header convention lives) and `EventStream`, the typed blocking session generated streaming operations return and handlers receive (its `Receive` carries the socket's deadline overload) | -| `//runtime:eventstream_json` | `smithy::eventstream` | The negotiated JSON-text wire encoding (ADR-0018): `EncodeJsonFrame`/`DecodeJsonFrame` between envelope-bearing `Message`s and the `{"event": ..., "payload": ...}` text frames a browser speaks with `JSON.parse`, plus `kJsonFramesSubprotocol` (`smithy.eventstream.v1+json`). Separate target so `:eventstream` stays a leaf on `:core` | -| `//runtime:eventstream_jsonrpc` | `smithy::eventstream` | The jsonRpc2 stream wire (ADR-0023): the `jsonrpc_frame` codec (notification encode; classify-decode into event / exception / terminal result) and `JsonRpcStreamSocket`, the delegating `WebSocket` generated jsonRpc2 streaming code wears over any socket so every layer above trades ordinary envelope `Message`s. Runs above the transport — unlike ADR-0018's in-session mode, the in-memory pair carries the actual JSON-RPC text | -| `//runtime:http` | `smithy::http` | `Headers` (case-insensitive), URI percent-encoding per the Smithy HTTP binding rules, `HttpRequest`/`HttpResponse`, `HttpClient`/`HttpServerTransport` interfaces, `Loopback` in-memory transport, built-in `SocketHttpClient`/`SocketHttpServer` (test/reference only — ADR-0006), W3C `TraceContext` parse/format/generate, the transport-neutral `WebSocket` interface (blocking calls — `Receive()` and its bounded overload `Receive(timeout)`, both pure virtual, whose `Error::Timeout` is distinct from the clean close and leaves the session usable — plus the ADR-0019 completion-driven `ReceiveAsync`/`SendAsync` twins) + `InMemoryWebSocketPair` (the streaming Loopback analog, async-capable, so generated streaming tests run without Boost — ADR-0016), and the coroutine adapter `AsyncEventStream`/`Detached` (ADR-0019: `co_await` where the blocking facade parks a thread) plus `StreamTask` (ADR-0021: the lazy single-await task a generated async streaming handler returns, its outcome framed by the generated wrapper) | -| `//runtime:http_beast` | `smithy::http` | `BeastServerTransport` (ADR-0006): the production server transport on BCR modular Boost.Beast/asio — concurrent connections on a thread pool, keep-alive, per-connection timeouts, body- and header-size limits, graceful drain on Stop. WebSocket upgrades ride the same transport (ADR-0015): `Options::on_websocket`/`websocket_gate` serve blocking full-duplex `smithy::http::WebSocket` sessions carrying event-stream messages, and `BeastWebSocketClient::Dial` is the client end. `Options::websocket_accept_json_frames` negotiates the ADR-0018 JSON-text wire for clients offering the subprotocol (browsers), transparently to everything above the session; `Options::websocket_raw_text_frames` flips the whole listener to the unnegotiated raw-text wire (ADR-0023: headerless messages as verbatim text frames, one JSON-RPC envelope each — what a generated jsonRpc2 streaming server mounts), with `WebSocketDialRequest::raw_text_frames` as the client end. Separate target so Boost stays out of dep-light builds | -| `//runtime:client` | `smithy` | `ClientConfig` (endpoint, timeout, user-agent, transport injection, `RetryPolicy`, request-compression threshold, `Interceptor` hooks around every attempt, `bearer_token`/`api_key` credential providers), `SendWithRetries` (full-jitter exponential backoff over transport errors and 429/5xx), `ObserveAttempts` + `PropagateTraceContext` interceptors — see docs/production-guide.md | -| `//runtime:compression` | `smithy` | `GzipCompress`/`GzipDecompress` (zlib; decompression-bomb guard, trailing-garbage rejection) backing `@requestCompression` | -| `//runtime:server` | `smithy::server` | `Router` (literal > label > greedy precedence, 404/405/400), `RequestContext`, `MakeErrorResponse`, `ValidationFailure`, user-supplied `Middleware` + `Chain`, the `Observe` logging/metrics hook, `RequireBearerAuth`/`RequireApiKeyHeader` guards, `WebSocketRouter` — the streaming routes' method + URI-pattern dispatch behind generated `StreamRouter()`, sharing `Router`'s matching by construction (ADR-0016), plus the application-facing shared-seam mount `AddSession`/`ServeSession()` for `on_websocket_session` (ADR-0019, issue #118; one router serves one seam) — `RequireOrigin`, the browser-facing Origin-allowlist `websocket_gate` (ADR-0018) — and `SessionRegistry` — the multi-client fan-out helper over owning `EventStream::Share()` handles: bounded per-session outbound queues, non-blocking `SendTo`/`Broadcast` with per-recipient construction, a slow-consumer policy, and `Drain` for graceful shutdown (ADR-0017); `Options::async_delivery` swaps writer threads for `SendAsync` completion chains (ADR-0019); `Detach`/`Resume` + `Options::grace_period` give abrupt disconnects a reconnect window with exactly-once expiry cleanup (ADR-0020); `ResumeOrAdd` is the blessed admission call and `Close(id)` the kick primitive (ADR-0022) | +| `//runtime:core` | `opal` | `Outcome` + `Error` (ADR-0003), `Blob`, `Timestamp` (epoch-seconds / RFC 3339 date-time / IMF-fixdate http-date), `Document` (dynamic value + serde pivot), base64, `Regex` (linear-time NFA engine behind generated `@pattern` validation — ReDoS-safe) | +| `//runtime:json` | `opal::json` | `Document` ⇄ JSON text via nlohmann (blobs as base64, timestamps per stored format) | +| `//runtime:cbor` | `opal::cbor` | `Document` ⇄ deterministic CBOR (RFC 8949; tag-1 timestamps; tolerant decoder) — ADR-0005 | +| `//runtime:eventstream` | `opal::eventstream` | Event-stream message framing (ADR-0014): CRC-guarded prelude, ten typed header wire types, opaque `Blob` payload; strict fail-closed incremental decoder with symmetric encode/decode bounds. Plus the generated streaming API's substrate (ADR-0016): the envelope helpers (`:message-type`/`:event-type`/`:exception-type` — the one place the header convention lives) and `EventStream`, the typed blocking session generated streaming operations return and handlers receive (its `Receive` carries the socket's deadline overload) | +| `//runtime:eventstream_json` | `opal::eventstream` | The negotiated JSON-text wire encoding (ADR-0018): `EncodeJsonFrame`/`DecodeJsonFrame` between envelope-bearing `Message`s and the `{"event": ..., "payload": ...}` text frames a browser speaks with `JSON.parse`, plus `kJsonFramesSubprotocol` (`smithy.eventstream.v1+json`). Separate target so `:eventstream` stays a leaf on `:core` | +| `//runtime:eventstream_jsonrpc` | `opal::eventstream` | The jsonRpc2 stream wire (ADR-0023): the `jsonrpc_frame` codec (notification encode; classify-decode into event / exception / terminal result) and `JsonRpcStreamSocket`, the delegating `WebSocket` generated jsonRpc2 streaming code wears over any socket so every layer above trades ordinary envelope `Message`s. Runs above the transport — unlike ADR-0018's in-session mode, the in-memory pair carries the actual JSON-RPC text | +| `//runtime:http` | `opal::http` | `Headers` (case-insensitive), URI percent-encoding per the Smithy HTTP binding rules, `HttpRequest`/`HttpResponse`, `HttpClient`/`HttpServerTransport` interfaces, `Loopback` in-memory transport, built-in `SocketHttpClient`/`SocketHttpServer` (test/reference only — ADR-0006), W3C `TraceContext` parse/format/generate, the transport-neutral `WebSocket` interface (blocking calls — `Receive()` and its bounded overload `Receive(timeout)`, both pure virtual, whose `Error::Timeout` is distinct from the clean close and leaves the session usable — plus the ADR-0019 completion-driven `ReceiveAsync`/`SendAsync` twins) + `InMemoryWebSocketPair` (the streaming Loopback analog, async-capable, so generated streaming tests run without Boost — ADR-0016), and the coroutine adapter `AsyncEventStream`/`Detached` (ADR-0019: `co_await` where the blocking facade parks a thread) plus `StreamTask` (ADR-0021: the lazy single-await task a generated async streaming handler returns, its outcome framed by the generated wrapper) | +| `//runtime:http_beast` | `opal::http` | `BeastServerTransport` (ADR-0006): the production server transport on BCR modular Boost.Beast/asio — concurrent connections on a thread pool, keep-alive, per-connection timeouts, body- and header-size limits, graceful drain on Stop. WebSocket upgrades ride the same transport (ADR-0015): `Options::on_websocket`/`websocket_gate` serve blocking full-duplex `opal::http::WebSocket` sessions carrying event-stream messages, and `BeastWebSocketClient::Dial` is the client end. `Options::websocket_accept_json_frames` negotiates the ADR-0018 JSON-text wire for clients offering the subprotocol (browsers), transparently to everything above the session; `Options::websocket_raw_text_frames` flips the whole listener to the unnegotiated raw-text wire (ADR-0023: headerless messages as verbatim text frames, one JSON-RPC envelope each — what a generated jsonRpc2 streaming server mounts), with `WebSocketDialRequest::raw_text_frames` as the client end. Separate target so Boost stays out of dep-light builds | +| `//runtime:client` | `opal` | `ClientConfig` (endpoint, timeout, user-agent, transport injection, `RetryPolicy`, request-compression threshold, `Interceptor` hooks around every attempt, `bearer_token`/`api_key` credential providers), `SendWithRetries` (full-jitter exponential backoff over transport errors and 429/5xx), `ObserveAttempts` + `PropagateTraceContext` interceptors — see docs/production-guide.md | +| `//runtime:compression` | `opal` | `GzipCompress`/`GzipDecompress` (zlib; decompression-bomb guard, trailing-garbage rejection) backing `@requestCompression` | +| `//runtime:server` | `opal::server` | `Router` (literal > label > greedy precedence, 404/405/400), `RequestContext`, `MakeErrorResponse`, `ValidationFailure`, user-supplied `Middleware` + `Chain`, the `Observe` logging/metrics hook, `RequireBearerAuth`/`RequireApiKeyHeader` guards, `WebSocketRouter` — the streaming routes' method + URI-pattern dispatch behind generated `StreamRouter()`, sharing `Router`'s matching by construction (ADR-0016), plus the application-facing shared-seam mount `AddSession`/`ServeSession()` for `on_websocket_session` (ADR-0019, issue #118; one router serves one seam) — `RequireOrigin`, the browser-facing Origin-allowlist `websocket_gate` (ADR-0018) — and `SessionRegistry` — the multi-client fan-out helper over owning `EventStream::Share()` handles: bounded per-session outbound queues, non-blocking `SendTo`/`Broadcast` with per-recipient construction, a slow-consumer policy, and `Drain` for graceful shutdown (ADR-0017); `Options::async_delivery` swaps writer threads for `SendAsync` completion chains (ADR-0019); `Detach`/`Resume` + `Options::grace_period` give abrupt disconnects a reconnect window with exactly-once expiry cleanup (ADR-0020); `ResumeOrAdd` is the blessed admission call and `Close(id)` the kick primitive (ADR-0022) | ## Design rules diff --git a/docs/server-guide.md b/docs/server-guide.md index 8655d174..13e0bd2f 100644 --- a/docs/server-guide.md +++ b/docs/server-guide.md @@ -16,10 +16,10 @@ Guard shared state (the quickstart's in-memory handler shows the minimal mutex p class MyHandler final : public example::weather::WeatherHandler { public: - smithy::Outcome GetCity(const GetCityInput& input, - const smithy::server::RequestContext& context) override { + opal::Outcome GetCity(const GetCityInput& input, + const opal::server::RequestContext& context) override { if (/* not found */) { - smithy::Error error = smithy::Error::Modeled("NoSuchResource", "no city: " + input.cityId); + opal::Error error = opal::Error::Modeled("NoSuchResource", "no city: " + input.cityId); error.set_detail(NoSuchResource{.resourceType = "City"}); // serializes the typed body return error; } @@ -31,20 +31,20 @@ class MyHandler final : public example::weather::WeatherHandler { ``` - **Request metadata**: the second parameter carries what the typed input doesn't model - (issue #46). `context.request` is the raw `smithy::http::HttpRequest`: read unmodeled + (issue #46). `context.request` is the raw `opal::http::HttpRequest`: read unmodeled headers (`context.request->headers.Get("x-tenant")`), the transport-stamped client address (`context.request->peer_address`, `"ip:port"`, empty on the in-memory Loopback), or the request's `traceparent` — always present and parseable behind a transport, since the ingress mints a root context when the client sent none (ADR-0011); parse it with - `smithy::http::ParseTraceparent` and `GenerateSpanId` (`smithy/http/trace_context.h`) to + `opal::http::ParseTraceparent` and `GenerateSpanId` (`smithy/http/trace_context.h`) to open child spans. `context.labels` and `context.query_params` hold the decoded routing captures. Handlers that need none of it leave the parameter unnamed. Behind a reverse proxy, derive the real client with - `smithy::http::ClientAddress` over a `TrustedProxies` set (`smithy/http/forwarded.h`, + `opal::http::ClientAddress` over a `TrustedProxies` set (`smithy/http/forwarded.h`, ADR-0012) instead of reading `x-forwarded-for` yourself — the raw header is client-authored. -- **Modeled errors**: return `smithy::Error::Modeled("", message)`. The server +- **Modeled errors**: return `opal::Error::Modeled("", message)`. The server maps the code to the shape's `@httpError` status (else 400/`@error("server")` → 500) and the protocol's error identity — simpleRestJson sets the neutral `X-Error-Type` header and serializes the detail as the body; rpcv2Cbor writes the fully qualified shape id as `__type` in the CBOR @@ -60,26 +60,26 @@ class MyHandler final : public example::weather::WeatherHandler { layer: the exception is converted into a 500 whose `x-correlation-id` header is the request's trace id (ADR-0011), and the same id plus the exception's `what()` is written to `std::clog`. One throwing request fails alone — it never unwinds into the transport's I/O - thread and terminates the process. Prefer returning `smithy::Error` for expected failures; + thread and terminates the process. Prefer returning `opal::Error` for expected failures; the catch-all is a safety net, not a control path. ## Running a server -The server is transport-agnostic: `Handler()` returns a `smithy::http::RequestHandler` that +The server is transport-agnostic: `Handler()` returns a `opal::http::RequestHandler` that plugs into any `HttpServerTransport`: ```cpp example::weather::WeatherServer server(std::make_shared()); -smithy::http::BeastServerTransport transport(options); // production (ADR-0006) +opal::http::BeastServerTransport transport(options); // production (ADR-0006) transport.Start(server.Handler()); -// or smithy::http::Loopback for in-process tests. (SocketHttpServer is test-only: one +// or opal::http::Loopback for in-process tests. (SocketHttpServer is test-only: one // connection at a time, loopback only — its Start() says so on std::clog.) ``` Cross-cutting behavior (auth checks, request logging, metrics) wraps `server.Handler()` as -user-supplied middleware — `smithy::server::Chain` composes it outside the generated router, -and `smithy::server::Observe` is the built-in logging/metrics hook. See +user-supplied middleware — `opal::server::Chain` composes it outside the generated router, +and `opal::server::Observe` is the built-in logging/metrics hook. See [production-guide.md](production-guide.md). Routing (method + URI pattern from `@http`, greedy labels, 404/405 with `Allow`), @@ -108,15 +108,15 @@ session fans out, and all of them share one view of it. A handle sends and close any thread while the session lives; once the handler has returned it fails softly with `Error::Transport` — exactly what a closed stream reports — so nothing dangles and nothing new can go wrong. The generated -server exposes `StreamRouter()`, a `smithy::server::WebSocketRouter` with every streaming +server exposes `StreamRouter()`, a `opal::server::WebSocketRouter` with every streaming route registered; mount it on the transport in two lines — the upgrade path deliberately bypasses the HTTP middleware chain (ADR-0015), so unary dispatch beside it is untouched: ```cpp -smithy::http::BeastServerTransport::Options options; +opal::http::BeastServerTransport::Options options; options.websocket_gate = server.StreamRouter()->Gate(); // 404/405 refusals pre-upgrade options.on_websocket = server.StreamRouter()->Serve(); // blocking per-session dispatch -smithy::http::BeastServerTransport transport(options); +opal::http::BeastServerTransport transport(options); transport.Start(server.Handler()); // unary routes, same port ``` @@ -131,11 +131,11 @@ and comes back. A clean close is still `nullopt` and a broken wire still a while (true) { auto event = stream.Receive(std::chrono::seconds(1)); if (!event.ok()) { - if (event.error().code() != "TimeoutError") return smithy::Unit{}; // wire gone - if (!PublishHeartbeat(stream)) return smithy::Unit{}; + if (event.error().code() != "TimeoutError") return opal::Unit{}; // wire gone + if (!PublishHeartbeat(stream)) return opal::Unit{}; continue; // quiet, not dead } - if (!event->has_value()) return smithy::Unit{}; // clean close + if (!event->has_value()) return opal::Unit{}; // clean close /* handle **event */ } ``` @@ -159,12 +159,12 @@ route parses them — so a validation failure surfaces as a successful dial whos `Receive()` is a terminal `SerializationException`, not as a refused upgrade. Multi-client fan-out — "N connected players, the server pushes state to all of them" — -is `smithy::server::SessionRegistry` (issue #112, ADR-0017), a thread-safe map of +is `opal::server::SessionRegistry` (issue #112, ADR-0017), a thread-safe map of owning handles with a bounded outbound queue and a writer thread per session, so a broadcast never stalls a room behind the slowest client's TCP window: ```cpp -smithy::server::SessionRegistry registry; +opal::server::SessionRegistry registry; registry.Add(player_id, stream.Share()); // handler entry registry.SendTo(player_id, event); // queued, non-blocking registry.Broadcast(ids, [&](const auto& id) { return RedactFor(id); }); // per-recipient @@ -193,14 +193,14 @@ Every session served through `on_websocket` parks one handler-pool thread for it lifetime, so `handler_threads` caps concurrent streams. The completion-driven seam removes that: set `Options::on_websocket_session` instead (exactly one of the two), receive the session as a `std::shared_ptr`, launch a -`smithy::eventstream::Detached` coroutine over -`smithy::eventstream::AsyncEventStream`, and return — the session lives until a +`opal::eventstream::Detached` coroutine over +`opal::eventstream::AsyncEventStream`, and return — the session lives until a `Close`, the idle timeout, or `Stop()`: ```cpp -smithy::eventstream::Detached Serve(Hub& hub, std::string id, - std::shared_ptr socket) { - smithy::eventstream::AsyncEventStream stream(std::move(socket), Encode, Decode); +opal::eventstream::Detached Serve(Hub& hub, std::string id, + std::shared_ptr socket) { + opal::eventstream::AsyncEventStream stream(std::move(socket), Encode, Decode); hub.registry().Add(id, stream.Share()); // the same handle, unchanged while (true) { auto event = co_await stream.Receive(); // parks no thread @@ -210,8 +210,8 @@ smithy::eventstream::Detached Serve(Hub& hub, std::string id, hub.registry().Remove(id); } // stream destroyed here: closes the session and revokes its handles -options.on_websocket_session = [&hub](const smithy::http::HttpRequest& request, - std::shared_ptr socket) { +options.on_websocket_session = [&hub](const opal::http::HttpRequest& request, + std::shared_ptr socket) { Serve(hub, IdFor(request), std::move(socket)); // a Detached coroutine; returns immediately }; ``` @@ -248,17 +248,17 @@ dispatcher). Everything above is the hand-mount shape — yours when the generator does not cover a transport or a wire. For a generated service, the generator now emits the whole thing: implement `AsyncHandler` — each streaming operation is a coroutine returning -`smithy::eventstream::StreamTask` over the operation's `AsyncServerStream&`, unary +`opal::eventstream::StreamTask` over the operation's `AsyncServerStream&`, unary operations keep their blocking signatures — construct `Server` with it, and mount the session seam: ```cpp class MyHandler final : public example::chat::ChatAsyncHandler { - smithy::eventstream::StreamTask Converse(example::chat::ConverseInput input, + opal::eventstream::StreamTask Converse(example::chat::ConverseInput input, example::chat::ConverseAsyncServerStream& stream) override { while (true) { auto event = co_await stream.Receive(); - if (!event.ok() || !event->has_value()) co_return smithy::Unit{}; + if (!event.ok() || !event->has_value()) co_return opal::Unit{}; // ... co_await stream.Send(reply), registry fan-out via stream.Share() ... } } @@ -313,11 +313,11 @@ e2e fixture is ~15 lines: ```cpp auto server = std::make_shared(std::make_shared()); -smithy::ClientConfig config; -config.websocket_dialer = [&](const smithy::http::WebSocketDialRequest& request) - -> smithy::Outcome> { - auto [near, far] = smithy::http::InMemoryWebSocketPair::Create(); - smithy::http::HttpRequest upgrade; // what a transport would deliver +opal::ClientConfig config; +config.websocket_dialer = [&](const opal::http::WebSocketDialRequest& request) + -> opal::Outcome> { + auto [near, far] = opal::http::InMemoryWebSocketPair::Create(); + opal::http::HttpRequest upgrade; // what a transport would deliver upgrade.method = "GET"; upgrade.target = request.target; upgrade.headers = request.headers; @@ -341,10 +341,10 @@ issue #113). Two additions to the mount above make a service browser-ready: ```cpp options.websocket_accept_json_frames = true; // negotiate the JSON wire -options.websocket_gate = [origin = smithy::server::RequireOrigin({"https://muchq.com"}), +options.websocket_gate = [origin = opal::server::RequireOrigin({"https://muchq.com"}), router = server.StreamRouter()->Gate()]( - const smithy::http::HttpRequest& request) - -> std::optional { + const opal::http::HttpRequest& request) + -> std::optional { if (auto refusal = origin(request)) return refusal; // hijacking defense first return router(request); // then 404/405 routing }; diff --git a/docs/superpowers/plans/2026-07-08-server-middleware.md b/docs/superpowers/plans/2026-07-08-server-middleware.md index cd08fa75..e621180c 100644 --- a/docs/superpowers/plans/2026-07-08-server-middleware.md +++ b/docs/superpowers/plans/2026-07-08-server-middleware.md @@ -535,20 +535,20 @@ TEST(TodoMiddlewareTest, GuardObserveAndHealthComposeAroundTheServer) { int started = 0; int completed = 0; bool admit = true; - auto handler = smithy::server::Chain( - {smithy::server::Guard([&admit](const smithy::http::HttpRequest&) { return admit; }, - smithy::server::TooManyRequests(std::chrono::seconds(1))), - smithy::server::Observe( - [&completed](const smithy::server::RequestObservation&) { ++completed; }, - [&started](const smithy::server::RequestStart&) { ++started; }), - smithy::server::HealthEndpoint()}, + auto handler = opal::server::Chain( + {opal::server::Guard([&admit](const opal::http::HttpRequest&) { return admit; }, + opal::server::TooManyRequests(std::chrono::seconds(1))), + opal::server::Observe( + [&completed](const opal::server::RequestObservation&) { ++completed; }, + [&started](const opal::server::RequestStart&) { ++started; }), + opal::server::HealthEndpoint()}, server.Handler()); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(handler).ok()); // Liveness answers without reaching the router, and is observed. - smithy::http::HttpRequest health; + opal::http::HttpRequest health; health.method = "GET"; health.target = "/health"; const auto health_response = loopback->Send(health); @@ -557,7 +557,7 @@ TEST(TodoMiddlewareTest, GuardObserveAndHealthComposeAroundTheServer) { EXPECT_EQ(health_response->body, R"({"status":"healthy"})"); // The generated client works through the chain. - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; auto created = TodoClient::Create(std::move(config)); ASSERT_TRUE(created.ok()) << created.error().message(); @@ -567,7 +567,7 @@ TEST(TodoMiddlewareTest, GuardObserveAndHealthComposeAroundTheServer) { // Once admit flips, Guard sheds load with the shaped 429 before Observe. admit = false; - smithy::http::HttpRequest denied; + opal::http::HttpRequest denied; denied.method = "POST"; denied.target = "/tasks"; const auto denied_response = loopback->Send(denied); @@ -633,28 +633,28 @@ WeatherServer server(handler); // backend); the middleware owns only the composition point. auto limiter = std::make_shared(/* window, budget */); -transport.Start(smithy::server::Chain( +transport.Start(opal::server::Chain( {// Outermost: shed abusive traffic before it costs anything. - smithy::server::Guard( - [limiter](const smithy::http::HttpRequest& request) { + opal::server::Guard( + [limiter](const opal::http::HttpRequest& request) { return limiter->Allow( request.headers.Get("x-forwarded-for").value_or("")); }, - smithy::server::TooManyRequests(std::chrono::seconds(30))), + opal::server::TooManyRequests(std::chrono::seconds(30))), // Observe everything admitted — health probes included. on_start // (optional) enables an in-flight gauge; on_complete carries // method/target/operation/status/duration/trace_parent. - smithy::server::Observe( - [](const smithy::server::RequestObservation& o) { + opal::server::Observe( + [](const opal::server::RequestObservation& o) { // gauge -1; count 1; latency o.duration — feed any backend. }, - [](const smithy::server::RequestStart& s) { + [](const opal::server::RequestStart& s) { // gauge +1 (labeled by s.method/s.target; the operation is not // known until the router runs). }), // Liveness: GET /health -> 200 {"status":"healthy"}; everything else // passes through to the router. - smithy::server::HealthEndpoint()}, + opal::server::HealthEndpoint()}, server.Handler())); ``` diff --git a/docs/superpowers/specs/2026-07-08-server-middleware-design.md b/docs/superpowers/specs/2026-07-08-server-middleware-design.md index a2ee2f06..6c84489c 100644 --- a/docs/superpowers/specs/2026-07-08-server-middleware-design.md +++ b/docs/superpowers/specs/2026-07-08-server-middleware-design.md @@ -102,7 +102,7 @@ Middleware Observe(std::function on_complete, ## Composition order (documented default) ```cpp -transport.Start(smithy::server::Chain( +transport.Start(opal::server::Chain( {Guard(admit, TooManyRequests()), // outermost: shed load first Observe(on_complete, on_start), // observes everything admitted, incl. health HealthEndpoint()}, // liveness, visible in metrics diff --git a/docs/versioning.md b/docs/versioning.md index b4b91945..03c2cc6b 100644 --- a/docs/versioning.md +++ b/docs/versioning.md @@ -2,14 +2,14 @@ smithy-cpp versions the **runtime** and the **generator** together — a release is one git tag (`vX.Y.Z`, signed) covering both, and generated code -from generator X.Y is supported against runtime X.Y. `smithy::Version()` +from generator X.Y is supported against runtime X.Y. `opal::Version()` returns the runtime's version. ## Current state: 0.2.0 released, 0.3.0 in development `v0.2.0` is the current release; `main` develops 0.3.0. The one product version -consumers observe — `smithy::Version()` (`runtime/src/core/version.cc`) and the -client `User-Agent` (`smithy::ClientConfig::user_agent`) — reports +consumers observe — `opal::Version()` (`runtime/src/core/version.cc`) and the +client `User-Agent` (`opal::ClientConfig::user_agent`) — reports **`0.3.0-dev`** on `main` until that tag lands, and the generator's Gradle `version` (`codegen/gradle.properties`) tracks it, since the two ship under one tag. The bzlmod **module** version in `MODULE.bazel` is a separate identifier @@ -39,7 +39,7 @@ Pre-1.0 caveat (per semver): minor releases may break. Concretely: exclusion lists) are the executable definition. 2. **Generated-code shape** — the Smithy → C++ mapping contract in [generated-types.md](generated-types.md): type mappings, optionality - rules, naming, error surfacing (`smithy::Error` + typed details), the + rules, naming, error surfacing (`opal::Error` + typed details), the `Client` / `Handler` / `Server` interfaces. Consumers write code against generated headers; changes that break recompilation of handler implementations or client call sites are @@ -65,7 +65,7 @@ suites are the contract instead). ## Release mechanics -- Update `smithy::Version()` + `CHANGELOG.md` in the release PR; CI must be +- Update `opal::Version()` + `CHANGELOG.md` in the release PR; CI must be fully green (full test matrix, consumer acceptance, all three protocol conformance suites). `//tools:release_test` fails the PR if the version sources disagree or the CHANGELOG's leading section doesn't match the state diff --git a/examples/bazel-consumer/access_log_acceptance_test.cc b/examples/bazel-consumer/access_log_acceptance_test.cc index 83587989..1354c318 100644 --- a/examples/bazel-consumer/access_log_acceptance_test.cc +++ b/examples/bazel-consumer/access_log_acceptance_test.cc @@ -59,15 +59,15 @@ struct LogLine { std::size_t response_bytes = 0; bool handler_threw = false; std::string client; - smithy::http::DerivedClient::Source client_source = smithy::http::DerivedClient::Source::kUnknown; + opal::http::DerivedClient::Source client_source = opal::http::DerivedClient::Source::kUnknown; }; class AccessLog { public: - void Write(const smithy::server::RequestObservation& o) { + void Write(const opal::server::RequestObservation& o) { const std::lock_guard lock(mutex_); lines_.push_back( - LogLine{.json = smithy::server::FormatAccessLog(o, {{"service_name", "todo-service"}}), + LogLine{.json = opal::server::FormatAccessLog(o, {{"service_name", "todo-service"}}), .method = o.method, .operation = o.operation, .status = o.status, @@ -110,16 +110,16 @@ class RecordingLimiter { class ThrowingOnDemandHandler final : public TodoHandler { public: - smithy::Outcome AddTask(const AddTaskInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome AddTask(const AddTaskInput& input, + const opal::server::RequestContext&) override { if (input.title == "boom") { throw std::runtime_error("handler exploded"); } return AddTaskOutput{.taskId = "task-1", .title = input.title}; } - smithy::Outcome GetTask(const GetTaskInput&, - const smithy::server::RequestContext&) override { + opal::Outcome GetTask(const GetTaskInput&, + const opal::server::RequestContext&) override { return GetTaskOutput{.taskId = "task-1", .title = "stored"}; } }; @@ -135,28 +135,28 @@ class AccessLogAcceptanceTest : public ::testing::Test { // The loopback peer is 127.0.0.1, so trusting it makes this connection // look like one arriving through a proxy — the topology the derivation // exists for. - auto trusted = smithy::http::TrustedProxies::Parse({"127.0.0.0/8"}); + auto trusted = opal::http::TrustedProxies::Parse({"127.0.0.0/8"}); ASSERT_TRUE(trusted.ok()) << trusted.error().message(); - const smithy::http::TrustedProxies observe_trust = - observe_trusts_the_proxy ? *trusted : smithy::http::TrustedProxies::None(); + const opal::http::TrustedProxies observe_trust = + observe_trusts_the_proxy ? *trusted : opal::http::TrustedProxies::None(); log_ = std::make_shared(); limiter_ = std::make_shared(kBudget); server_ = std::make_unique(std::make_shared()); - transport_ = std::make_unique( - smithy::http::BeastServerTransport::Options{.threads = 1, .handler_threads = 2}); + transport_ = std::make_unique( + opal::http::BeastServerTransport::Options{.threads = 1, .handler_threads = 2}); auto log = log_; auto limiter = limiter_; ASSERT_TRUE( transport_ - ->Start(smithy::server::Chain( + ->Start(opal::server::Chain( {// Outermost, so a rejected request is still logged with the // client it was rejected for. - smithy::server::Observe( - [log](const smithy::server::RequestObservation& o) { log->Write(o); }, nullptr, + opal::server::Observe( + [log](const opal::server::RequestObservation& o) { log->Write(o); }, nullptr, nullptr, observe_trust), - smithy::server::PerClientRateLimit( + opal::server::PerClientRateLimit( [limiter](const std::string& client) { return limiter->Allow(client); }, *trusted, std::chrono::seconds(1))}, server_->Handler())) @@ -167,9 +167,9 @@ class AccessLogAcceptanceTest : public ::testing::Test { // A request carrying an x-forwarded-for, the way one arrives through a // proxy. The client is the header's entry; the peer is the proxy. - smithy::Outcome SendForwarded(const std::string& body) { - smithy::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); - smithy::http::HttpRequest request; + opal::Outcome SendForwarded(const std::string& body) { + opal::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); + opal::http::HttpRequest request; request.method = "POST"; request.target = "/tasks"; request.headers.Set("content-type", "application/json"); @@ -184,7 +184,7 @@ class AccessLogAcceptanceTest : public ::testing::Test { std::shared_ptr log_; std::shared_ptr limiter_; std::unique_ptr server_; - std::unique_ptr transport_; + std::unique_ptr transport_; }; TEST_F(AccessLogAcceptanceTest, TheLoggedClientIsTheBucketTheLimiterKeyedOn) { @@ -207,7 +207,7 @@ TEST_F(AccessLogAcceptanceTest, TheLoggedClientIsTheBucketTheLimiterKeyedOn) { // Not the peer, which is what the raw header or an unconfigured Observe // would have reported. EXPECT_NE(lines[0].client, "127.0.0.1"); - EXPECT_EQ(lines[0].client_source, smithy::http::DerivedClient::Source::kForwarded); + EXPECT_EQ(lines[0].client_source, opal::http::DerivedClient::Source::kForwarded); } TEST_F(AccessLogAcceptanceTest, ARejectionIsLoggedWithTheClientItWasRejectedFor) { @@ -334,7 +334,7 @@ TEST_F(MisconfiguredAccessLogTest, ObserveWithoutTheTrustBoundaryLogsTheProxy) { // TrustedProxies::None() is the deliberate direct-connect statement, so the // peer IS the client and the header is ignored wholly — correct behavior // for that configuration, and the wrong configuration for this deployment. - EXPECT_EQ(lines[0].client_source, smithy::http::DerivedClient::Source::kUntrustedHeaderIgnored); + EXPECT_EQ(lines[0].client_source, opal::http::DerivedClient::Source::kUntrustedHeaderIgnored); } } // namespace diff --git a/examples/bazel-consumer/async_acceptance_test.cc b/examples/bazel-consumer/async_acceptance_test.cc index 8c7a8e02..111aeb10 100644 --- a/examples/bazel-consumer/async_acceptance_test.cc +++ b/examples/bazel-consumer/async_acceptance_test.cc @@ -24,19 +24,19 @@ namespace { -using smithy::Outcome; -using smithy::Unit; -using smithy::eventstream::AsyncEventStream; -using smithy::eventstream::Detached; -using smithy::eventstream::Message; -using smithy::http::BeastServerTransport; -using smithy::http::BeastWebSocketClient; -using smithy::http::HttpRequest; -using smithy::http::HttpResponse; -using smithy::http::WebSocket; +using opal::Outcome; +using opal::Unit; +using opal::eventstream::AsyncEventStream; +using opal::eventstream::Detached; +using opal::eventstream::Message; +using opal::http::BeastServerTransport; +using opal::http::BeastWebSocketClient; +using opal::http::HttpRequest; +using opal::http::HttpResponse; +using opal::http::WebSocket; Message Event(const std::string& kind, const std::string& body) { - return Message{.headers = {{":event-type", kind}}, .payload = smithy::Blob::FromString(body)}; + return Message{.headers = {{":event-type", kind}}, .payload = opal::Blob::FromString(body)}; } // The identity codec: the adapter's templates instantiate in a consumer @@ -85,7 +85,7 @@ TEST(AsyncAcceptanceTest, TheAsyncPrimitivesRoundTripThroughTheModuleBoundary) { // One session's whole life on completion contexts: registered for fan-out, // echoing until the client closes, then gone from the registry. -Detached Serve(smithy::server::SessionRegistry& registry, std::string id, +Detached Serve(opal::server::SessionRegistry& registry, std::string id, std::shared_ptr socket) { AsyncEventStream stream(std::move(socket), Identity, Identity); if (!registry.Add(id, stream.Share())) { @@ -148,9 +148,9 @@ TEST(AsyncAcceptanceTest, AnAwaitedReceiveDeadlineTicksWithoutEndingTheSession) TEST(AsyncAcceptanceTest, ThreeSessionsShareOneHandlerThreadAndAFanOutRegistry) { // Declared before the transport on purpose: sessions reference the // registry from their coroutines, so it must outlive them. - smithy::server::SessionRegistry::Options fanout; + opal::server::SessionRegistry::Options fanout; fanout.async_delivery = true; // completion chains, no writer threads - smithy::server::SessionRegistry registry(fanout); + opal::server::SessionRegistry registry(fanout); BeastServerTransport::Options options; options.handler_threads = 1; // launches only — the borrowed seam would wedge here diff --git a/examples/bazel-consumer/chat_async_reconnect_server_main.cc b/examples/bazel-consumer/chat_async_reconnect_server_main.cc index 496f8f08..59c4a708 100644 --- a/examples/bazel-consumer/chat_async_reconnect_server_main.cc +++ b/examples/bazel-consumer/chat_async_reconnect_server_main.cc @@ -28,7 +28,7 @@ using acme::chat::ExchangeInput; using acme::chat::Note; using acme::chat::Notes; -using Registry = smithy::server::SessionRegistry; +using Registry = opal::server::SessionRegistry; // The generated async handler with the reconnect exits split the ADR-0020 // way: deliberate leaves Remove, everything else Detaches. Delivery rides @@ -38,8 +38,8 @@ class AsyncReconnectHubHandler final : public acme::chat::ChatAsyncHandler { explicit AsyncReconnectHubHandler(std::chrono::seconds grace) : registry_(RegistryOptions(this, grace)) {} - smithy::eventstream::StreamTask Exchange(ExchangeInput input, - ExchangeAsyncServerStream& stream) override { + opal::eventstream::StreamTask Exchange(ExchangeInput input, + ExchangeAsyncServerStream& stream) override { const std::string id = input.name; // The blessed admission call (ADR-0022): resume-or-fresh-join with the // brief retry the reconnect race needs. It blocks, legally: this runs @@ -48,7 +48,7 @@ class AsyncReconnectHubHandler final : public acme::chat::ChatAsyncHandler { registry_.ResumeOrAdd(id, [&stream] { return stream.Share(); }, std::chrono::seconds(1)); if (admission == Registry::Admission::kRefused) { // The generated wrapper frames this as the typed exception message. - co_return smithy::Error::Validation("name '" + id + "' is already in the session"); + co_return opal::Error::Validation("name '" + id + "' is already in the session"); } if (admission == Registry::Admission::kResumed) { @@ -85,7 +85,7 @@ class AsyncReconnectHubHandler final : public acme::chat::ChatAsyncHandler { registry_.Remove(id); BroadcastText("left:" + id); } - co_return smithy::Unit{}; // the generated wrapper closes the stream + co_return opal::Unit{}; // the generated wrapper closes the stream } bool Drain(std::chrono::milliseconds timeout) { return registry_.Drain(timeout); } @@ -95,9 +95,9 @@ class AsyncReconnectHubHandler final : public acme::chat::ChatAsyncHandler { registry_.Broadcast(Notes::FromNote(Note{.text = text})); } - static smithy::server::SessionRegistry::Options RegistryOptions( + static opal::server::SessionRegistry::Options RegistryOptions( AsyncReconnectHubHandler* handler, std::chrono::seconds grace) { - smithy::server::SessionRegistry::Options options; + opal::server::SessionRegistry::Options options; options.async_delivery = true; // chains on the transport's completions options.grace_period = grace; options.on_expired = [handler](const std::string& id) { @@ -107,7 +107,7 @@ class AsyncReconnectHubHandler final : public acme::chat::ChatAsyncHandler { return options; } - smithy::server::SessionRegistry registry_; + opal::server::SessionRegistry registry_; }; } // namespace @@ -125,13 +125,13 @@ int main(int argc, char** argv) { // shared-session seam; sessions park no handler thread. acme::chat::ChatServer server(handler); - smithy::http::BeastServerTransport::Options options; + opal::http::BeastServerTransport::Options options; options.address = "0.0.0.0"; options.port = argc > 1 ? std::atoi(argv[1]) : 8080; // 0 binds an ephemeral port options.handler_threads = 2; // launches only — sessions hold no thread options.websocket_gate = server.StreamRouter()->Gate(); options.on_websocket_session = server.StreamRouter()->ServeSession(); - smithy::http::BeastServerTransport transport(options); + opal::http::BeastServerTransport transport(options); auto started = transport.Start(server.Handler()); if (!started.ok()) { std::fprintf(stderr, "chat-hub: start failed: %s\n", started.error().message().c_str()); diff --git a/examples/bazel-consumer/chat_reconnect_client_main.cc b/examples/bazel-consumer/chat_reconnect_client_main.cc index f7fa66d4..0f4445d7 100644 --- a/examples/bazel-consumer/chat_reconnect_client_main.cc +++ b/examples/bazel-consumer/chat_reconnect_client_main.cc @@ -36,7 +36,7 @@ int Run(int argc, char** argv) { std::fprintf(stderr, "usage: %s \n", argv[0]); return 2; } - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; config.endpoint = "http://127.0.0.1:" + std::string(argv[1]); auto client = acme::chat::ChatClient::Create(std::move(config)); diff --git a/examples/bazel-consumer/chat_reconnect_server_main.cc b/examples/bazel-consumer/chat_reconnect_server_main.cc index 000a9626..ffd6d374 100644 --- a/examples/bazel-consumer/chat_reconnect_server_main.cc +++ b/examples/bazel-consumer/chat_reconnect_server_main.cc @@ -26,7 +26,7 @@ using acme::chat::ExchangeInput; using acme::chat::Note; using acme::chat::Notes; -using Registry = smithy::server::SessionRegistry; +using Registry = opal::server::SessionRegistry; // The generated blocking handler with the reconnect exits split the // ADR-0020 way: deliberate leaves Remove, everything else Detaches. @@ -35,9 +35,9 @@ class ReconnectHubHandler final : public acme::chat::ChatHandler { explicit ReconnectHubHandler(std::chrono::seconds grace) : registry_(RegistryOptions(this, grace)) {} - smithy::Outcome Exchange(const ExchangeInput& input, - smithy::eventstream::EventStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Exchange(const ExchangeInput& input, + opal::eventstream::EventStream& stream, + const opal::server::RequestContext&) override { const std::string& id = input.name; // The blessed admission call (ADR-0022): resume-or-fresh-join with the // brief retry the reconnect race needs; blocking a blocking handler is @@ -45,7 +45,7 @@ class ReconnectHubHandler final : public acme::chat::ChatHandler { const auto admission = registry_.ResumeOrAdd(id, [&stream] { return stream.Share(); }, std::chrono::seconds(1)); if (admission == Registry::Admission::kRefused) { - return smithy::Error::Validation("name '" + id + "' is already in the session"); + return opal::Error::Validation("name '" + id + "' is already in the session"); } if (admission == Registry::Admission::kResumed) { @@ -82,7 +82,7 @@ class ReconnectHubHandler final : public acme::chat::ChatHandler { registry_.Remove(id); BroadcastText("left:" + id); } - return smithy::Unit{}; + return opal::Unit{}; } bool Drain(std::chrono::milliseconds timeout) { return registry_.Drain(timeout); } @@ -92,9 +92,9 @@ class ReconnectHubHandler final : public acme::chat::ChatHandler { registry_.Broadcast(Notes::FromNote(Note{.text = text})); } - static smithy::server::SessionRegistry::Options RegistryOptions( - ReconnectHubHandler* handler, std::chrono::seconds grace) { - smithy::server::SessionRegistry::Options options; + static opal::server::SessionRegistry::Options RegistryOptions(ReconnectHubHandler* handler, + std::chrono::seconds grace) { + opal::server::SessionRegistry::Options options; options.grace_period = grace; options.on_expired = [handler](const std::string& id) { // Nobody came back: the departure the disconnect deferred. @@ -103,7 +103,7 @@ class ReconnectHubHandler final : public acme::chat::ChatHandler { return options; } - smithy::server::SessionRegistry registry_; + opal::server::SessionRegistry registry_; }; } // namespace @@ -119,12 +119,12 @@ int main(int argc, char** argv) { auto handler = std::make_shared(grace); acme::chat::ChatServer server(handler); - smithy::http::BeastServerTransport::Options options; + opal::http::BeastServerTransport::Options options; options.address = "0.0.0.0"; options.port = argc > 1 ? std::atoi(argv[1]) : 8080; // 0 binds an ephemeral port options.websocket_gate = server.StreamRouter()->Gate(); options.on_websocket = server.StreamRouter()->Serve(); // blocking generated dispatch - smithy::http::BeastServerTransport transport(options); + opal::http::BeastServerTransport transport(options); auto started = transport.Start(server.Handler()); if (!started.ok()) { std::fprintf(stderr, "chat-hub: start failed: %s\n", started.error().message().c_str()); diff --git a/examples/bazel-consumer/eventstream_consumer_test.cc b/examples/bazel-consumer/eventstream_consumer_test.cc index ef1c38e1..f2fecb2b 100644 --- a/examples/bazel-consumer/eventstream_consumer_test.cc +++ b/examples/bazel-consumer/eventstream_consumer_test.cc @@ -19,11 +19,11 @@ namespace { -using smithy::Blob; -using smithy::Timestamp; -using smithy::eventstream::DecodeMessage; -using smithy::eventstream::EncodeMessage; -using smithy::eventstream::Message; +using opal::Blob; +using opal::Timestamp; +using opal::eventstream::DecodeMessage; +using opal::eventstream::EncodeMessage; +using opal::eventstream::Message; TEST(EventStreamConsumerTest, TheDocumentedTransportLoopDrainsAChunkedStream) { // Two frames arriving from a "socket" seven bytes at a time; the inner @@ -64,7 +64,7 @@ TEST(EventStreamConsumerTest, TheDocumentedTransportLoopDrainsAChunkedStream) { EXPECT_EQ(*received[1].FindString(":event-type"), "end"); EXPECT_EQ(received[1].FindString("seq"), nullptr); // absent on the end event - // The timestamp header comes back as the runtime's own smithy::Timestamp. + // The timestamp header comes back as the runtime's own opal::Timestamp. const auto* at = received[0].FindHeader("at"); ASSERT_NE(at, nullptr); EXPECT_EQ(std::get(*at).epoch_milliseconds(), 1721400000000); @@ -79,7 +79,7 @@ TEST(EventStreamConsumerTest, CorruptionSurfacesAsAnErrorAConsumerCanLog) { ASSERT_FALSE(decoded.ok()); EXPECT_NE(decoded.error().message().find("eventstream"), std::string::npos); // And the message itself debug-renders for that log line. - const std::string rendered = smithy::DebugString(Message{.headers = {{":event-type", "chat"}}}); + const std::string rendered = opal::DebugString(Message{.headers = {{":event-type", "chat"}}}); EXPECT_NE(rendered.find(":event-type"), std::string::npos); } diff --git a/examples/bazel-consumer/exception_safety_acceptance_test.cc b/examples/bazel-consumer/exception_safety_acceptance_test.cc index a96b4278..79d29041 100644 --- a/examples/bazel-consumer/exception_safety_acceptance_test.cc +++ b/examples/bazel-consumer/exception_safety_acceptance_test.cc @@ -22,13 +22,13 @@ namespace { -using smithy::eventstream::Message; -using smithy::http::BeastHttpClient; -using smithy::http::BeastServerTransport; -using smithy::http::BeastWebSocketClient; -using smithy::http::HttpRequest; -using smithy::http::HttpResponse; -using smithy::http::WebSocket; +using opal::eventstream::Message; +using opal::http::BeastHttpClient; +using opal::http::BeastServerTransport; +using opal::http::BeastWebSocketClient; +using opal::http::HttpRequest; +using opal::http::HttpResponse; +using opal::http::WebSocket; HttpRequest Get(const std::string& target) { HttpRequest request; @@ -38,7 +38,7 @@ HttpRequest Get(const std::string& target) { } Message Event(const std::string& kind, const std::string& body) { - return Message{.headers = {{":event-type", kind}}, .payload = smithy::Blob::FromString(body)}; + return Message{.headers = {{":event-type", kind}}, .payload = opal::Blob::FromString(body)}; } TEST(ExceptionSafetyAcceptanceTest, AThrowingHandlerBecomesA500AndTheServerKeepsServing) { @@ -60,7 +60,7 @@ TEST(ExceptionSafetyAcceptanceTest, AThrowingHandlerBecomesA500AndTheServerKeeps .ok(); ASSERT_TRUE(started); - smithy::ClientConfig config; + opal::ClientConfig config; config.endpoint = "http://127.0.0.1:" + std::to_string(server.port()); auto client = BeastHttpClient::FromConfig(config); ASSERT_TRUE(client.ok()) << client.error().message(); @@ -108,7 +108,7 @@ TEST(ExceptionSafetyAcceptanceTest, AThrowingAsyncReceiveCallbackSparesTheStream const auto& socket = *dialed; std::promise fired; - socket->ReceiveAsync([&fired](smithy::Outcome> message) { + socket->ReceiveAsync([&fired](opal::Outcome> message) { ASSERT_TRUE(message.ok()) << message.error().message(); fired.set_value(); throw std::runtime_error("consumer receive callback blew up"); diff --git a/examples/bazel-consumer/head_e2e_test.cc b/examples/bazel-consumer/head_e2e_test.cc index db6f5de3..db88d4d6 100644 --- a/examples/bazel-consumer/head_e2e_test.cc +++ b/examples/bazel-consumer/head_e2e_test.cc @@ -59,31 +59,31 @@ std::string ExpectedContentLength() { // false claim about the resource. class ProbeHandler final : public RedirectorHandler { public: - smithy::Outcome Probe(const ProbeInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Probe(const ProbeInput& input, + const opal::server::RequestContext&) override { if (input.slug != "abc") return NotFound(input.slug); - return ProbeOutput{.etag = kEtag, .content = smithy::Blob::FromString(kContent)}; + return ProbeOutput{.etag = kEtag, .content = opal::Blob::FromString(kContent)}; } - smithy::Outcome Fetch(const FetchInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Fetch(const FetchInput& input, + const opal::server::RequestContext&) override { if (input.slug != "abc") return NotFound(input.slug); - return FetchOutput{.status = 200, .etag = kEtag, .content = smithy::Blob::FromString(kContent)}; + return FetchOutput{.status = 200, .etag = kEtag, .content = opal::Blob::FromString(kContent)}; } - smithy::Outcome Resolve(const ResolveInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Resolve(const ResolveInput& input, + const opal::server::RequestContext&) override { return NotFound(input.slug); } - smithy::Outcome ResolveDynamic( - const ResolveDynamicInput& input, const smithy::server::RequestContext&) override { + opal::Outcome ResolveDynamic(const ResolveDynamicInput& input, + const opal::server::RequestContext&) override { return NotFound(input.slug); } private: - static smithy::Error NotFound(const std::string& slug) { - smithy::Error error = smithy::Error::Modeled("NoSuchSlug", "no slug: " + slug); + static opal::Error NotFound(const std::string& slug) { + opal::Error error = opal::Error::Modeled("NoSuchSlug", "no slug: " + slug); error.set_detail(NoSuchSlug{.message = "no slug: " + slug}); return error; } @@ -132,7 +132,7 @@ std::string HeadersOf(const std::string& raw) { TEST(HeadE2ETest, AModeledHeadCarriesTheGetsLengthAndNoBody) { RedirectorServer server(std::make_shared()); - smithy::http::SocketHttpServer transport; + opal::http::SocketHttpServer transport; ASSERT_TRUE(transport.Start(server.Handler()).ok()); const std::string head = @@ -158,13 +158,13 @@ TEST(HeadE2ETest, AModeledHeadCarriesTheGetsLengthAndNoBody) { TEST(HeadE2ETest, TheGeneratedClientReadsTheHeadWithoutBlocking) { RedirectorServer server(std::make_shared()); - smithy::http::SocketHttpServer transport; + opal::http::SocketHttpServer transport; ASSERT_TRUE(transport.Start(server.Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.endpoint = "http://127.0.0.1:" + std::to_string(transport.port()); config.http_client = - std::make_shared("127.0.0.1", transport.port()); + std::make_shared("127.0.0.1", transport.port()); auto created = acme::redirect::RedirectorClient::Create(config); ASSERT_TRUE(created.ok()) << created.error().message(); const auto& client = *created; diff --git a/examples/bazel-consumer/jsonrpc_raw_peer_main.cc b/examples/bazel-consumer/jsonrpc_raw_peer_main.cc index 71355b78..38f054c9 100644 --- a/examples/bazel-consumer/jsonrpc_raw_peer_main.cc +++ b/examples/bazel-consumer/jsonrpc_raw_peer_main.cc @@ -35,7 +35,7 @@ int Run(int argc, char** argv) { std::fprintf(stderr, "usage: %s \n", argv[0]); return 2; } - auto socket = smithy::http::BeastWebSocketClient::Dial( + auto socket = opal::http::BeastWebSocketClient::Dial( {.host = "127.0.0.1", .port = static_cast(std::atoi(argv[1])), .raw_text_frames = true}); @@ -46,8 +46,8 @@ int Run(int argc, char** argv) { std::string line; while (std::getline(std::cin, line)) { - smithy::eventstream::Message frame; - frame.payload = smithy::Blob::FromString(line); + opal::eventstream::Message frame; + frame.payload = opal::Blob::FromString(line); if (!(*socket)->Send(frame).ok()) break; // already closed on us: drain below } diff --git a/examples/bazel-consumer/jsonrpc_stream_client_main.cc b/examples/bazel-consumer/jsonrpc_stream_client_main.cc index 7d5e60d9..9bc783b1 100644 --- a/examples/bazel-consumer/jsonrpc_stream_client_main.cc +++ b/examples/bazel-consumer/jsonrpc_stream_client_main.cc @@ -33,7 +33,7 @@ int Run(int argc, char** argv) { std::fprintf(stderr, "usage: %s ...\n", argv[0]); return 2; } - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; config.endpoint = "http://127.0.0.1:" + std::string(argv[1]); auto client = acme::tally::TallyClient::Create(std::move(config)); diff --git a/examples/bazel-consumer/jsonrpc_stream_server_main.cc b/examples/bazel-consumer/jsonrpc_stream_server_main.cc index b203741a..e95102d0 100644 --- a/examples/bazel-consumer/jsonrpc_stream_server_main.cc +++ b/examples/bazel-consumer/jsonrpc_stream_server_main.cc @@ -26,22 +26,22 @@ using acme::tally::Totals; class TallyHandler final : public acme::tally::TallyAsyncHandler { public: - smithy::eventstream::StreamTask Count(CountInput input, CountAsyncServerStream& stream) override { + opal::eventstream::StreamTask Count(CountInput input, CountAsyncServerStream& stream) override { int total = input.start.value_or(0); while (true) { auto bump = co_await stream.Receive(); - if (!bump.ok() || !bump->has_value()) co_return smithy::Unit{}; + if (!bump.ok() || !bump->has_value()) co_return opal::Unit{}; const int by = (**bump).as_bump().by; - if (by == 0) co_return smithy::Unit{}; // the terminal result, then the close + if (by == 0) co_return opal::Unit{}; // the terminal result, then the close total += by; if (total < 0) { // The terminal error envelope, typed all the way to the client. - smithy::Error busted = smithy::Error::Modeled("Busted", "the tally went negative"); + opal::Error busted = opal::Error::Modeled("Busted", "the tally went negative"); busted.set_detail(Busted{.message = "the tally went negative"}); co_return busted; } auto sent = co_await stream.Send(Totals::FromTotal(Total{.value = total})); - if (!sent.ok()) co_return smithy::Unit{}; + if (!sent.ok()) co_return opal::Unit{}; } } }; @@ -59,14 +59,14 @@ int main(int argc, char** argv) { // registers on the shared-session seam; sessions park no handler thread. acme::tally::TallyServer server(std::make_shared()); - smithy::http::BeastServerTransport::Options options; + opal::http::BeastServerTransport::Options options; options.address = "0.0.0.0"; options.port = argc > 1 ? std::atoi(argv[1]) : 8080; // 0 binds an ephemeral port options.handler_threads = 2; // launches only options.websocket_gate = server.StreamRouter()->Gate(); options.on_websocket_session = server.StreamRouter()->ServeSession(); options.websocket_raw_text_frames = true; // the JSON-RPC text wire (ADR-0023) - smithy::http::BeastServerTransport transport(options); + opal::http::BeastServerTransport transport(options); auto started = transport.Start(server.Handler()); if (!started.ok()) { std::fprintf(stderr, "tally: start failed: %s\n", started.error().message().c_str()); diff --git a/examples/bazel-consumer/metrics_acceptance_test.cc b/examples/bazel-consumer/metrics_acceptance_test.cc index 62c64229..7b9f0ccd 100644 --- a/examples/bazel-consumer/metrics_acceptance_test.cc +++ b/examples/bazel-consumer/metrics_acceptance_test.cc @@ -39,7 +39,7 @@ using acme::todo::TodoServer; // they are cheap to copy and address the same family. class MetricsHandler final : public TodoHandler { public: - explicit MetricsHandler(const std::shared_ptr& metrics) + explicit MetricsHandler(const std::shared_ptr& metrics) : tasks_added_(metrics->NewCounter("todo_tasks_added_total", "Tasks added, by priority.")), title_length_(metrics->NewHistogram("todo_title_length_chars", "Task title length.", {8.0, 32.0, 128.0})), @@ -52,54 +52,54 @@ class MetricsHandler final : public TodoHandler { tasks_stored_.Declare(); } - smithy::Outcome AddTask(const AddTaskInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome AddTask(const AddTaskInput& input, + const opal::server::RequestContext&) override { tasks_added_.Increment({{"priority", input.priority.has_value() ? "set" : "unset"}}); title_length_.Observe(static_cast(input.title.size())); tasks_stored_.Increment(); return AddTaskOutput{.taskId = "task-1", .title = input.title}; } - smithy::Outcome GetTask(const GetTaskInput& input, - const smithy::server::RequestContext&) override { - smithy::Error error = smithy::Error::Modeled("NoSuchTask", "no task: " + input.taskId); + opal::Outcome GetTask(const GetTaskInput& input, + const opal::server::RequestContext&) override { + opal::Error error = opal::Error::Modeled("NoSuchTask", "no task: " + input.taskId); error.set_detail(NoSuchTask{.message = "no task: " + input.taskId}); return error; } private: - smithy::server::Counter tasks_added_; - smithy::server::Histogram title_length_; - smithy::server::Gauge tasks_stored_; + opal::server::Counter tasks_added_; + opal::server::Histogram title_length_; + opal::server::Gauge tasks_stored_; }; class MetricsAcceptanceTest : public ::testing::Test { protected: void SetUp() override { - Start(smithy::server::MetricsOptions{.enabled = true, .service_name = "todo-service"}); + Start(opal::server::MetricsOptions{.enabled = true, .service_name = "todo-service"}); } // Stands the service up under `options`, so a subclass can exercise a // different dialect — or none at all — over the same real socket. - void Start(smithy::server::MetricsOptions options) { - metrics_ = std::make_shared(std::move(options)); + void Start(opal::server::MetricsOptions options) { + metrics_ = std::make_shared(std::move(options)); server_ = std::make_unique(std::make_shared(metrics_)); - transport_ = std::make_unique( - smithy::http::BeastServerTransport::Options{.threads = 1, .handler_threads = 4}); + transport_ = std::make_unique( + opal::http::BeastServerTransport::Options{.threads = 1, .handler_threads = 4}); // The composition the production guide documents, assembled here in // consumer code against the published targets alone. // The liveness probe sits INSIDE the recorder, so probe traffic is // counted — the arrangement that makes its operation label matter. ASSERT_TRUE(transport_ - ->Start(smithy::server::Chain({smithy::server::MetricsEndpoint(metrics_), - smithy::server::RecordMetrics(metrics_), - smithy::server::HealthEndpoint("/livez")}, - server_->Handler())) + ->Start(opal::server::Chain({opal::server::MetricsEndpoint(metrics_), + opal::server::RecordMetrics(metrics_), + opal::server::HealthEndpoint("/livez")}, + server_->Handler())) .ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.endpoint = "http://127.0.0.1:" + std::to_string(transport_->port()); - auto http_client = smithy::http::BeastHttpClient::FromConfig(config); + auto http_client = opal::http::BeastHttpClient::FromConfig(config); ASSERT_TRUE(http_client.ok()) << http_client.error().message(); config.http_client = *http_client; auto client = TodoClient::Create(std::move(config)); @@ -111,17 +111,17 @@ class MetricsAcceptanceTest : public ::testing::Test { // Scrapes /metrics the way Prometheus does: a plain GET, no generated code // in the loop. - smithy::Outcome Scrape() { - smithy::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); - smithy::http::HttpRequest request; + opal::Outcome Scrape() { + opal::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); + opal::http::HttpRequest request; request.method = "GET"; request.target = "/metrics"; return raw.Send(request); } std::unique_ptr server_; - std::shared_ptr metrics_; - std::unique_ptr transport_; + std::shared_ptr metrics_; + std::unique_ptr transport_; std::unique_ptr client_; }; @@ -183,8 +183,8 @@ TEST_F(MetricsAcceptanceTest, ScrapesDoNotCountThemselvesAndLeaveNothingInFlight TEST_F(MetricsAcceptanceTest, AnUnroutedRequestCountsWithAnEmptyOperation) { // A 404 never reaches an operation, and its target — which is what varies // without bound — must not become a label. - smithy::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); - smithy::http::HttpRequest request; + opal::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); + opal::http::HttpRequest request; request.method = "GET"; request.target = "/no/such/route/8f3a2b"; const auto missed = raw.Send(request); @@ -209,15 +209,15 @@ TEST_F(MetricsAcceptanceTest, AHealthProbeIsItsOwnSeriesNotAnAnonymous404) { // miss the generated router, and before HealthEndpoint stamped its path // both reported `operation=""` — so a service polled every few seconds had // its 404 rate buried under probe volume and no query could separate them. - smithy::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); - smithy::http::HttpRequest probe; + opal::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); + opal::http::HttpRequest probe; probe.method = "GET"; probe.target = "/livez"; const auto probed = raw.Send(probe); ASSERT_TRUE(probed.ok()) << probed.error().message(); EXPECT_EQ(probed->status, 200); - smithy::http::HttpRequest unrouted; + opal::http::HttpRequest unrouted; unrouted.method = "GET"; unrouted.target = "/livez-typo"; ASSERT_TRUE(raw.Send(unrouted).ok()); @@ -326,13 +326,13 @@ TEST_F(MetricsAcceptanceTest, TheProbeRouteThePanelsSubtractIsReported) { // what this pins is that the probe gets a route of its own rather than // joining unmatched traffic, which is what makes the subtraction possible // at all. - smithy::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); - smithy::http::HttpRequest probe; + opal::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); + opal::http::HttpRequest probe; probe.method = "GET"; probe.target = "/livez"; ASSERT_TRUE(raw.Send(probe).ok()); - smithy::http::HttpRequest unrouted; + opal::http::HttpRequest unrouted; unrouted.method = "GET"; unrouted.target = "/nope"; ASSERT_TRUE(raw.Send(unrouted).ok()); @@ -358,7 +358,7 @@ TEST_F(MetricsAcceptanceTest, TheProbeRouteThePanelsSubtractIsReported) { // stack without asking for it. class DisabledMetricsAcceptanceTest : public MetricsAcceptanceTest { // NOLINT protected: - void SetUp() override { Start(smithy::server::MetricsOptions{}); } + void SetUp() override { Start(opal::server::MetricsOptions{}); } }; TEST_F(DisabledMetricsAcceptanceTest, TheScrapePathIsNotServedAndTheServiceStillWorks) { diff --git a/examples/bazel-consumer/redirect_e2e_test.cc b/examples/bazel-consumer/redirect_e2e_test.cc index 13bb7c3f..4446a7bc 100644 --- a/examples/bazel-consumer/redirect_e2e_test.cc +++ b/examples/bazel-consumer/redirect_e2e_test.cc @@ -61,15 +61,15 @@ class SlugHandler final : public RedirectorHandler { targets_["cached"] = "https://example.com/cached"; } - smithy::Outcome Resolve(const ResolveInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Resolve(const ResolveInput& input, + const opal::server::RequestContext&) override { auto target = Lookup(input.slug); if (!target) return std::move(target).error(); return ResolveOutput{.location = *target}; } - smithy::Outcome ResolveDynamic( - const ResolveDynamicInput& input, const smithy::server::RequestContext&) override { + opal::Outcome ResolveDynamic(const ResolveDynamicInput& input, + const opal::server::RequestContext&) override { auto target = Lookup(input.slug); if (!target) return std::move(target).error(); int status = kFound; @@ -85,32 +85,32 @@ class SlugHandler final : public RedirectorHandler { // is the ordinary way to write this. Whether that content reaches the wire // is the framework's job, not the handler's: RFC 9110 compliance must not // depend on every handler author remembering to clear the payload. - smithy::Outcome Fetch(const FetchInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Fetch(const FetchInput& input, + const opal::server::RequestContext&) override { auto target = Lookup(input.slug); if (!target) return std::move(target).error(); const bool fresh = input.ifNoneMatch.has_value() && *input.ifNoneMatch == kEtag; return FetchOutput{.status = fresh ? kNotModified : kOk, .etag = kEtag, - .content = smithy::Blob::FromString(kContent)}; + .content = opal::Blob::FromString(kContent)}; } // Not exercised here — HEAD framing is head_e2e_test.cc's subject. Answers // the same resource Fetch does, so the two files cannot drift on what /c // serves. - smithy::Outcome Probe(const ProbeInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Probe(const ProbeInput& input, + const opal::server::RequestContext&) override { auto target = Lookup(input.slug); if (!target) return std::move(target).error(); - return ProbeOutput{.etag = kEtag, .content = smithy::Blob::FromString(kContent)}; + return ProbeOutput{.etag = kEtag, .content = opal::Blob::FromString(kContent)}; } private: - smithy::Outcome Lookup(const std::string& slug) { + opal::Outcome Lookup(const std::string& slug) { const std::lock_guard lock(mu_); const auto it = targets_.find(slug); if (it == targets_.end()) { - smithy::Error error = smithy::Error::Modeled("NoSuchSlug", "no slug: " + slug); + opal::Error error = opal::Error::Modeled("NoSuchSlug", "no slug: " + slug); error.set_detail(NoSuchSlug{.message = "no slug: " + slug}); return error; } @@ -127,13 +127,13 @@ class RedirectE2ETest : public ::testing::TestWithParam { protected: void SetUp() override { server_ = std::make_unique(std::make_shared()); - smithy::ClientConfig config; + opal::ClientConfig config; if (GetParam() == Transport::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); config.http_client = loopback; } else { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(server_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } @@ -147,7 +147,7 @@ class RedirectE2ETest : public ::testing::TestWithParam { } std::unique_ptr server_; - std::unique_ptr socket_server_; + std::unique_ptr socket_server_; std::unique_ptr client_; }; @@ -217,11 +217,11 @@ INSTANTIATE_TEST_SUITE_P(Transports, RedirectE2ETest, // generated server about a renamed header and prove nothing. TEST(RedirectWireTest, TheBytesABrowserSeesCarryStatusAndLocation) { RedirectorServer server(std::make_shared()); - smithy::http::SocketHttpServer transport; + opal::http::SocketHttpServer transport; ASSERT_TRUE(transport.Start(server.Handler()).ok()); - smithy::http::SocketHttpClient client("127.0.0.1", transport.port()); + opal::http::SocketHttpClient client("127.0.0.1", transport.port()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/r/abc"; const auto response = client.Send(request); @@ -246,11 +246,11 @@ TEST(RedirectWireTest, TheBytesABrowserSeesCarryStatusAndLocation) { // fix — and it has to be raw, because the generated client never looks. TEST(RedirectWireTest, NotModifiedCarriesNoBodyAndNoContentType) { RedirectorServer server(std::make_shared()); - smithy::http::SocketHttpServer transport; + opal::http::SocketHttpServer transport; ASSERT_TRUE(transport.Start(server.Handler()).ok()); - smithy::http::SocketHttpClient client("127.0.0.1", transport.port()); + opal::http::SocketHttpClient client("127.0.0.1", transport.port()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/d/cached"; const auto response = client.Send(request); @@ -264,7 +264,7 @@ TEST(RedirectWireTest, NotModifiedCarriesNoBodyAndNoContentType) { // The positive twin, sharing the fixture: the same operation on a status // that *does* allow a body still sends one. Without this, a server that had // simply stopped emitting bodies would pass the assertions above. - smithy::http::HttpRequest live; + opal::http::HttpRequest live; live.method = "GET"; live.target = "/d/abc"; const auto live_response = client.Send(live); @@ -287,13 +287,13 @@ TEST(RedirectWireTest, NotModifiedCarriesNoBodyAndNoContentType) { // without the guard, because there would be nothing to suppress. TEST(RedirectWireTest, ANotModifiedFromAPayloadOperationSendsNoPayload) { RedirectorServer server(std::make_shared()); - smithy::http::SocketHttpServer transport; + opal::http::SocketHttpServer transport; ASSERT_TRUE(transport.Start(server.Handler()).ok()); - smithy::http::SocketHttpClient client("127.0.0.1", transport.port()); + opal::http::SocketHttpClient client("127.0.0.1", transport.port()); // Unconditional: 200 with the payload, which is the control — it proves the // fixture serves content at all, so the empty 304 below means something. - smithy::http::HttpRequest cold; + opal::http::HttpRequest cold; cold.method = "GET"; cold.target = "/c/abc"; const auto cold_response = client.Send(cold); @@ -303,7 +303,7 @@ TEST(RedirectWireTest, ANotModifiedFromAPayloadOperationSendsNoPayload) { EXPECT_EQ(cold_response->headers.Get("ETag").value_or(""), kEtag); // Conditional on the ETag the server just sent: 304, and not one byte of it. - smithy::http::HttpRequest conditional; + opal::http::HttpRequest conditional; conditional.method = "GET"; conditional.target = "/c/abc"; conditional.headers.Set("If-None-Match", kEtag); diff --git a/examples/bazel-consumer/streaming_acceptance_test.cc b/examples/bazel-consumer/streaming_acceptance_test.cc index 675a680d..271a28f9 100644 --- a/examples/bazel-consumer/streaming_acceptance_test.cc +++ b/examples/bazel-consumer/streaming_acceptance_test.cc @@ -27,16 +27,16 @@ namespace { // Echoes every note back with an "echo:" prefix until the client closes. class EchoHandler final : public acme::chat::ChatHandler { public: - smithy::Outcome Exchange( + opal::Outcome Exchange( const acme::chat::ExchangeInput&, - smithy::eventstream::EventStream& stream, - const smithy::server::RequestContext&) override { + opal::eventstream::EventStream& stream, + const opal::server::RequestContext&) override { while (true) { auto event = stream.Receive(); - if (!event.ok() || !event->has_value()) return smithy::Unit{}; + if (!event.ok() || !event->has_value()) return opal::Unit{}; acme::chat::Note reply; reply.text = "echo:" + (**event).as_note().text; - if (!stream.Send(acme::chat::Notes::FromNote(reply)).ok()) return smithy::Unit{}; + if (!stream.Send(acme::chat::Notes::FromNote(reply)).ok()) return opal::Unit{}; } } }; @@ -51,17 +51,17 @@ class StreamingAcceptanceTest : public testing::Test { } acme::chat::ChatServer server_{std::make_shared()}; - std::shared_ptr server_session_; + std::shared_ptr server_session_; std::thread serve_thread_; }; TEST_F(StreamingAcceptanceTest, ABidiRoundTripCrossesTheModuleBoundary) { - smithy::ClientConfig config; + opal::ClientConfig config; config.endpoint = "http://localhost:8080"; - config.websocket_dialer = [this](const smithy::http::WebSocketDialRequest& request) - -> smithy::Outcome> { - auto [near, far] = smithy::http::InMemoryWebSocketPair::Create(); - smithy::http::HttpRequest upgrade; + config.websocket_dialer = [this](const opal::http::WebSocketDialRequest& request) + -> opal::Outcome> { + auto [near, far] = opal::http::InMemoryWebSocketPair::Create(); + opal::http::HttpRequest upgrade; upgrade.method = "GET"; upgrade.target = request.target; upgrade.headers = request.headers; @@ -97,12 +97,12 @@ TEST_F(StreamingAcceptanceTest, ABoundedReceiveFailsInsteadOfHangingOnAMissingEv // answers what it is sent, so a suite expecting an unprompted event would // park in Receive() until the job's timeout killed it — no assertion, no // clue which expectation was wrong. Bounded, the same wait is a red test. - smithy::ClientConfig config; + opal::ClientConfig config; config.endpoint = "http://localhost:8080"; - config.websocket_dialer = [this](const smithy::http::WebSocketDialRequest& request) - -> smithy::Outcome> { - auto [near, far] = smithy::http::InMemoryWebSocketPair::Create(); - smithy::http::HttpRequest upgrade; + config.websocket_dialer = [this](const opal::http::WebSocketDialRequest& request) + -> opal::Outcome> { + auto [near, far] = opal::http::InMemoryWebSocketPair::Create(); + opal::http::HttpRequest upgrade; upgrade.method = "GET"; upgrade.target = request.target; upgrade.headers = request.headers; diff --git a/examples/bazel-consumer/todo_beast_acceptance_test.cc b/examples/bazel-consumer/todo_beast_acceptance_test.cc index 64f20a95..e5ce85f6 100644 --- a/examples/bazel-consumer/todo_beast_acceptance_test.cc +++ b/examples/bazel-consumer/todo_beast_acceptance_test.cc @@ -34,18 +34,18 @@ using acme::todo::NoSuchTask; using acme::todo::TodoClient; using acme::todo::TodoHandler; using acme::todo::TodoServer; -using smithy::testing::kTestCertificatePem; -using smithy::testing::kTestPrivateKeyPem; +using opal::testing::kTestCertificatePem; +using opal::testing::kTestPrivateKeyPem; // The blessed endpoint→FromConfig→Create wiring from the production guide, // shared by every test here: plain http by default, https when a trust // anchor is supplied. -smithy::Outcome MakeTodoClient(int port, const std::string& ca_pem = "") { - smithy::ClientConfig config; +opal::Outcome MakeTodoClient(int port, const std::string& ca_pem = "") { + opal::ClientConfig config; config.endpoint = std::string(ca_pem.empty() ? "http" : "https") + "://127.0.0.1:" + std::to_string(port); config.tls.ca_pem = ca_pem; - auto http_client = smithy::http::BeastHttpClient::FromConfig(config); + auto http_client = opal::http::BeastHttpClient::FromConfig(config); if (!http_client) return std::move(http_client).error(); config.http_client = *http_client; return TodoClient::Create(std::move(config)); @@ -55,17 +55,17 @@ smithy::Outcome MakeTodoClient(int port, const std::string& ca_pem = // "boom" title throws (the bug the framework must contain). class AcceptanceHandler final : public TodoHandler { public: - smithy::Outcome AddTask(const AddTaskInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome AddTask(const AddTaskInput& input, + const opal::server::RequestContext&) override { if (input.title == "boom") { throw std::runtime_error("consumer handler bug"); } return AddTaskOutput{.taskId = "task-1", .title = input.title}; } - smithy::Outcome GetTask(const GetTaskInput& input, - const smithy::server::RequestContext&) override { - smithy::Error error = smithy::Error::Modeled("NoSuchTask", "no task: " + input.taskId); + opal::Outcome GetTask(const GetTaskInput& input, + const opal::server::RequestContext&) override { + opal::Error error = opal::Error::Modeled("NoSuchTask", "no task: " + input.taskId); error.set_detail(NoSuchTask{.message = "no task: " + input.taskId}); return error; } @@ -79,8 +79,8 @@ class TodoBeastAcceptanceTest : public ::testing::Test { protected: void SetUp() override { server_ = std::make_unique(std::make_shared()); - transport_ = std::make_unique( - smithy::http::BeastServerTransport::Options{ + transport_ = std::make_unique( + opal::http::BeastServerTransport::Options{ .threads = 1, .handler_threads = 8, .drain_timeout_seconds = 5}); ASSERT_TRUE(transport_->Start(server_->Handler()).ok()); @@ -92,7 +92,7 @@ class TodoBeastAcceptanceTest : public ::testing::Test { void TearDown() override { transport_->Stop(); } std::unique_ptr server_; - std::unique_ptr transport_; + std::unique_ptr transport_; std::unique_ptr client_; }; @@ -112,9 +112,9 @@ TEST_F(TodoBeastAcceptanceTest, RoundTripsAndModeledErrorsWork) { // the generated server before the handler runs, and the generated client // serializes valid ones — the same generator output consumers ship. TEST_F(TodoBeastAcceptanceTest, NumericBoundsAreEnforcedOverTheRealSocket) { - smithy::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); + opal::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport_->port()}); const auto post = [&raw](const std::string& body) { - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/tasks"; request.headers.Set("content-type", "application/json"); @@ -163,8 +163,8 @@ TEST_F(TodoBeastAcceptanceTest, LifecycleStopsAndRestartsAcrossTransportGenerati transport_->Stop(); EXPECT_LT(std::chrono::steady_clock::now() - begin, std::chrono::seconds(10)); - smithy::http::BeastServerTransport second_generation( - smithy::http::BeastServerTransport::Options{.threads = 1, .handler_threads = 8}); + opal::http::BeastServerTransport second_generation( + opal::http::BeastServerTransport::Options{.threads = 1, .handler_threads = 8}); ASSERT_TRUE(second_generation.Start(server_->Handler()).ok()); auto client = MakeTodoClient(second_generation.port()); ASSERT_TRUE(client.ok()) << client.error().message(); @@ -191,19 +191,19 @@ TEST(TodoBeastMetadataTest, ContextArrivesOverTheProductionTransport) { // and loopback flavors are pinned in todo_integration_test.cc). class PeerProbe final : public TodoHandler { public: - smithy::Outcome AddTask(const AddTaskInput&, - const smithy::server::RequestContext& context) override { + opal::Outcome AddTask(const AddTaskInput&, + const opal::server::RequestContext& context) override { return AddTaskOutput{.taskId = "task-1", .title = context.request->peer_address}; } - smithy::Outcome GetTask(const GetTaskInput& input, - const smithy::server::RequestContext&) override { - return smithy::Error::Modeled("NoSuchTask", "no task: " + input.taskId); + opal::Outcome GetTask(const GetTaskInput& input, + const opal::server::RequestContext&) override { + return opal::Error::Modeled("NoSuchTask", "no task: " + input.taskId); } }; TodoServer server(std::make_shared()); - smithy::http::BeastServerTransport transport( - smithy::http::BeastServerTransport::Options{.threads = 1}); + opal::http::BeastServerTransport transport( + opal::http::BeastServerTransport::Options{.threads = 1}); ASSERT_TRUE(transport.Start(server.Handler()).ok()); auto client = MakeTodoClient(transport.port()); ASSERT_TRUE(client.ok()) << client.error().message(); @@ -218,19 +218,19 @@ TEST(TodoBeastMetadataTest, TransportRejectionsAreObservableFromAConsumerBuild) // convention): an over-limit rejection that Observe middleware can never // see reaches the consumer's own hook. std::mutex mutex; - std::vector rejected; + std::vector rejected; TodoServer server(std::make_shared()); - smithy::http::BeastServerTransport transport(smithy::http::BeastServerTransport::Options{ + opal::http::BeastServerTransport transport(opal::http::BeastServerTransport::Options{ .threads = 1, .max_body_bytes = 1024, - .on_rejected = [&](const smithy::http::BeastServerTransport::RejectedRequest& r) { + .on_rejected = [&](const opal::http::BeastServerTransport::RejectedRequest& r) { const std::lock_guard lock(mutex); rejected.push_back(r); }}); ASSERT_TRUE(transport.Start(server.Handler()).ok()); - smithy::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport.port()}); - smithy::http::HttpRequest request; + opal::http::BeastHttpClient raw({.host = "127.0.0.1", .port = transport.port()}); + opal::http::HttpRequest request; request.method = "POST"; request.target = "/tasks"; request.headers.Set("content-type", "application/json"); @@ -251,17 +251,17 @@ TEST(TodoBeastMetadataTest, ConnectionEventsAreObservableFromAConsumerBuild) { // The on_connection_event knob at the module boundary (ADR-0013): a TLS // client speaking to a plain-http server never produces a request, so // only the transport can see it — as framing garbage (the ClientHello). - smithy::testing::ConnectionEventRecorder recorder; + opal::testing::ConnectionEventRecorder recorder; TodoServer server(std::make_shared()); - smithy::http::BeastServerTransport transport(smithy::http::BeastServerTransport::Options{ + opal::http::BeastServerTransport transport(opal::http::BeastServerTransport::Options{ .threads = 1, .on_connection_event = recorder.Hook()}); ASSERT_TRUE(transport.Start(server.Handler()).ok()); - smithy::http::BeastHttpClient wrong_scheme({.host = "127.0.0.1", - .port = transport.port(), - .tls = true, - .tls_options = {.ca_pem = kTestCertificatePem}}); - smithy::http::HttpRequest request; + opal::http::BeastHttpClient wrong_scheme({.host = "127.0.0.1", + .port = transport.port(), + .tls = true, + .tls_options = {.ca_pem = kTestCertificatePem}}); + opal::http::HttpRequest request; request.method = "POST"; request.target = "/tasks"; const auto response = wrong_scheme.Send(request); @@ -272,7 +272,7 @@ TEST(TodoBeastMetadataTest, ConnectionEventsAreObservableFromAConsumerBuild) { const std::lock_guard lock(recorder.mutex); ASSERT_EQ(recorder.events.size(), 1u); EXPECT_EQ(recorder.events[0].kind, - smithy::http::BeastServerTransport::ConnectionEvent::Kind::kFramingError); + opal::http::BeastServerTransport::ConnectionEvent::Kind::kFramingError); EXPECT_EQ(recorder.events[0].peer_address.rfind("127.0.0.1:", 0), 0u) << recorder.events[0].peer_address; } @@ -286,10 +286,10 @@ TEST(TodoBeastTlsAcceptanceTest, TlsTerminationServesTheGeneratedClient) { // pinned in the runtime suite) composes with the blessed FromConfig client // from a consumer build. TodoServer server(std::make_shared()); - smithy::http::BeastServerTransport transport( - smithy::http::BeastServerTransport::Options{.threads = 1, - .tls_certificate_chain_pem = kTestCertificatePem, - .tls_private_key_pem = kTestPrivateKeyPem}); + opal::http::BeastServerTransport transport( + opal::http::BeastServerTransport::Options{.threads = 1, + .tls_certificate_chain_pem = kTestCertificatePem, + .tls_private_key_pem = kTestPrivateKeyPem}); ASSERT_TRUE(transport.Start(server.Handler()).ok()); auto client = MakeTodoClient(transport.port(), kTestCertificatePem); diff --git a/examples/bazel-consumer/todo_integration_test.cc b/examples/bazel-consumer/todo_integration_test.cc index 49395fe7..e1429d8f 100644 --- a/examples/bazel-consumer/todo_integration_test.cc +++ b/examples/bazel-consumer/todo_integration_test.cc @@ -40,20 +40,20 @@ using acme::todo::TodoServer; // teaches; QuickstartMirrorTest fails if the two ever diverge. class InMemoryHandler final : public TodoHandler { public: - smithy::Outcome AddTask(const AddTaskInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome AddTask(const AddTaskInput& input, + const opal::server::RequestContext&) override { const std::lock_guard lock(mu_); const std::string id = "task-" + std::to_string(next_id_++); titles_[id] = input.title; return AddTaskOutput{.taskId = id, .title = input.title}; } - smithy::Outcome GetTask(const GetTaskInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome GetTask(const GetTaskInput& input, + const opal::server::RequestContext&) override { const std::lock_guard lock(mu_); const auto it = titles_.find(input.taskId); if (it == titles_.end()) { - smithy::Error error = smithy::Error::Modeled("NoSuchTask", "no task: " + input.taskId); + opal::Error error = opal::Error::Modeled("NoSuchTask", "no task: " + input.taskId); error.set_detail(NoSuchTask{.message = "no task: " + input.taskId}); return error; // the server turns this into the modeled 404 } @@ -73,13 +73,13 @@ class TodoIntegrationTest : public ::testing::TestWithParam { protected: void SetUp() override { server_ = std::make_unique(std::make_shared()); - smithy::ClientConfig config; + opal::ClientConfig config; if (GetParam() == Transport::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); config.http_client = loopback; } else { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(server_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } @@ -93,7 +93,7 @@ class TodoIntegrationTest : public ::testing::TestWithParam { } std::unique_ptr server_; - std::unique_ptr socket_server_; + std::unique_ptr socket_server_; std::unique_ptr client_; }; @@ -133,24 +133,22 @@ INSTANTIATE_TEST_SUITE_P(Transports, TodoIntegrationTest, TEST(TodoCborTest, SameModelServesRpcv2Cbor) { class CborHandler final : public acme::todo::cbor::TodoHandler { public: - smithy::Outcome AddTask( - const acme::todo::cbor::AddTaskInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome AddTask( + const acme::todo::cbor::AddTaskInput& input, const opal::server::RequestContext&) override { return acme::todo::cbor::AddTaskOutput{.taskId = "task-1", .title = input.title}; } - smithy::Outcome GetTask( - const acme::todo::cbor::GetTaskInput& input, - const smithy::server::RequestContext&) override { - smithy::Error error = smithy::Error::Modeled("NoSuchTask", "no task: " + input.taskId); + opal::Outcome GetTask( + const acme::todo::cbor::GetTaskInput& input, const opal::server::RequestContext&) override { + opal::Error error = opal::Error::Modeled("NoSuchTask", "no task: " + input.taskId); error.set_detail(acme::todo::cbor::NoSuchTask{.message = "no task: " + input.taskId}); return error; } }; acme::todo::cbor::TodoServer server(std::make_shared()); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; auto client = acme::todo::cbor::TodoClient::Create(std::move(config)); ASSERT_TRUE(client.ok()) << client.error().message(); @@ -171,24 +169,24 @@ TEST(TodoCborTest, SameModelServesRpcv2Cbor) { TEST(TodoJsonRpcTest, SameModelServesJsonRpc2) { class JsonRpcHandler final : public acme::todo::jsonrpc::TodoHandler { public: - smithy::Outcome AddTask( + opal::Outcome AddTask( const acme::todo::jsonrpc::AddTaskInput& input, - const smithy::server::RequestContext&) override { + const opal::server::RequestContext&) override { return acme::todo::jsonrpc::AddTaskOutput{.taskId = "task-1", .title = input.title}; } - smithy::Outcome GetTask( + opal::Outcome GetTask( const acme::todo::jsonrpc::GetTaskInput& input, - const smithy::server::RequestContext&) override { - smithy::Error error = smithy::Error::Modeled("NoSuchTask", "no task: " + input.taskId); + const opal::server::RequestContext&) override { + opal::Error error = opal::Error::Modeled("NoSuchTask", "no task: " + input.taskId); error.set_detail(acme::todo::jsonrpc::NoSuchTask{.message = "no task: " + input.taskId}); return error; } }; acme::todo::jsonrpc::TodoServer server(std::make_shared()); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; auto client = acme::todo::jsonrpc::TodoClient::Create(std::move(config)); ASSERT_TRUE(client.ok()) << client.error().message(); @@ -209,10 +207,10 @@ TEST(TodoJsonRpcTest, SameModelServesJsonRpc2) { // answers — 405 with a deterministic, deduplicated Allow list, and 404. TEST(TodoRoutingTest, WrongMethodGets405WithAllowAndUnknownPathGets404) { TodoServer server(std::make_shared()); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - smithy::http::HttpRequest wrong_method; + opal::http::HttpRequest wrong_method; wrong_method.method = "DELETE"; wrong_method.target = "/tasks"; const auto not_allowed = loopback->Send(wrong_method); @@ -220,7 +218,7 @@ TEST(TodoRoutingTest, WrongMethodGets405WithAllowAndUnknownPathGets404) { EXPECT_EQ(not_allowed->status, 405); EXPECT_EQ(not_allowed->headers.Get("allow").value_or(""), "POST"); - smithy::http::HttpRequest unknown; + opal::http::HttpRequest unknown; unknown.method = "GET"; unknown.target = "/no/such/route"; const auto not_found = loopback->Send(unknown); @@ -234,29 +232,29 @@ TEST(TodoRoutingTest, WrongMethodGets405WithAllowAndUnknownPathGets404) { TEST(TodoMetadataTest, RestHandlerSeesHeadersPeerAndTraceOverARealSocket) { class MetadataHandler final : public TodoHandler { public: - smithy::Outcome AddTask(const AddTaskInput& input, - const smithy::server::RequestContext& context) override { + opal::Outcome AddTask(const AddTaskInput& input, + const opal::server::RequestContext& context) override { const auto trace = - smithy::http::ParseTraceparent(context.request->headers.Get("traceparent").value_or("")); + opal::http::ParseTraceparent(context.request->headers.Get("traceparent").value_or("")); return AddTaskOutput{.taskId = context.request->peer_address, .title = input.title + "|" + context.request->headers.Get("x-tenant").value_or("missing") + "|" + (trace.has_value() ? trace->trace_id : "no-trace")}; } - smithy::Outcome GetTask(const GetTaskInput& input, - const smithy::server::RequestContext&) override { - return smithy::Error::Modeled("NoSuchTask", "no task: " + input.taskId); + opal::Outcome GetTask(const GetTaskInput& input, + const opal::server::RequestContext&) override { + return opal::Error::Modeled("NoSuchTask", "no task: " + input.taskId); } }; TodoServer server(std::make_shared()); - smithy::http::SocketHttpServer transport; + opal::http::SocketHttpServer transport; ASSERT_TRUE(transport.Start(server.Handler()).ok()); // A raw request so unmodeled headers ride along (generated clients only // send what the model binds). - smithy::http::SocketHttpClient raw("127.0.0.1", transport.port()); - smithy::http::HttpRequest request; + opal::http::SocketHttpClient raw("127.0.0.1", transport.port()); + opal::http::HttpRequest request; request.method = "POST"; request.target = "/tasks"; request.headers.Set("content-type", "application/json"); @@ -273,7 +271,7 @@ TEST(TodoMetadataTest, RestHandlerSeesHeadersPeerAndTraceOverARealSocket) { // And with no inbound traceparent at all, the ingress mints one // (ADR-0011): the handler still sees a parseable identity, never // "no-trace". - smithy::http::HttpRequest bare; + opal::http::HttpRequest bare; bare.method = "POST"; bare.target = "/tasks"; bare.headers.Set("content-type", "application/json"); @@ -292,22 +290,22 @@ TEST(TodoMetadataTest, RestHandlerSeesHeadersPeerAndTraceOverARealSocket) { TEST(TodoMetadataTest, ReturnedServerErrorsCarryTheTraceCorrelationId) { class FailingHandler final : public TodoHandler { public: - smithy::Outcome AddTask(const AddTaskInput&, - const smithy::server::RequestContext&) override { - return smithy::Error::Transport("db down"); + opal::Outcome AddTask(const AddTaskInput&, + const opal::server::RequestContext&) override { + return opal::Error::Transport("db down"); } - smithy::Outcome GetTask(const GetTaskInput& input, - const smithy::server::RequestContext&) override { - return smithy::Error::Modeled("NoSuchTask", "no task: " + input.taskId); + opal::Outcome GetTask(const GetTaskInput& input, + const opal::server::RequestContext&) override { + return opal::Error::Modeled("NoSuchTask", "no task: " + input.taskId); } }; TodoServer server(std::make_shared()); - smithy::http::SocketHttpServer transport; + opal::http::SocketHttpServer transport; ASSERT_TRUE(transport.Start(server.Handler()).ok()); - smithy::http::SocketHttpClient raw("127.0.0.1", transport.port()); + opal::http::SocketHttpClient raw("127.0.0.1", transport.port()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/tasks"; request.headers.Set("content-type", "application/json"); @@ -319,7 +317,7 @@ TEST(TodoMetadataTest, ReturnedServerErrorsCarryTheTraceCorrelationId) { EXPECT_EQ(failed->headers.Get("x-correlation-id").value_or(""), "0af7651916cd43dd8448eb211c80319c"); - smithy::http::HttpRequest missing; + opal::http::HttpRequest missing; missing.method = "GET"; missing.target = "/tasks/nope"; const auto modeled = raw.Send(missing); @@ -338,22 +336,21 @@ TEST(TodoMiddlewareTest, GuardObserveAndHealthComposeAroundTheServer) { int completed = 0; bool admit = true; bool ready = true; - auto handler = smithy::server::Chain( - {smithy::server::Guard([&admit](const smithy::http::HttpRequest&) { return admit; }, - smithy::server::TooManyRequests(std::chrono::seconds(1))), + auto handler = opal::server::Chain( + {opal::server::Guard([&admit](const opal::http::HttpRequest&) { return admit; }, + opal::server::TooManyRequests(std::chrono::seconds(1))), // Observe takes on_complete first, then the optional on_start. - smithy::server::Observe( - [&completed](const smithy::server::RequestObservation&) { ++completed; }, - [&started](const smithy::server::RequestStart&) { ++started; }), - smithy::server::HealthEndpoint(), - smithy::server::HealthEndpoint("/readyz", {{"db", [&ready] { return ready; }}})}, + opal::server::Observe([&completed](const opal::server::RequestObservation&) { ++completed; }, + [&started](const opal::server::RequestStart&) { ++started; }), + opal::server::HealthEndpoint(), + opal::server::HealthEndpoint("/readyz", {{"db", [&ready] { return ready; }}})}, server.Handler()); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(handler).ok()); // Liveness answers without reaching the router, and is observed. - smithy::http::HttpRequest health; + opal::http::HttpRequest health; health.method = "GET"; health.target = "/health"; const auto health_response = loopback->Send(health); @@ -363,7 +360,7 @@ TEST(TodoMiddlewareTest, GuardObserveAndHealthComposeAroundTheServer) { // Readiness re-probes on every request: 200 while the dependency serves, // 503 naming it once it stops. - smithy::http::HttpRequest readyz; + opal::http::HttpRequest readyz; readyz.method = "GET"; readyz.target = "/readyz"; const auto ready_response = loopback->Send(readyz); @@ -376,7 +373,7 @@ TEST(TodoMiddlewareTest, GuardObserveAndHealthComposeAroundTheServer) { EXPECT_EQ(unready_response->body, R"({"status":"unhealthy","failing":["db"]})"); // The generated client works through the chain. - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; auto created = TodoClient::Create(std::move(config)); ASSERT_TRUE(created.ok()) << created.error().message(); @@ -387,7 +384,7 @@ TEST(TodoMiddlewareTest, GuardObserveAndHealthComposeAroundTheServer) { // Once admit flips, Guard sheds load with the shaped 429 before Observe. admit = false; - smithy::http::HttpRequest denied; + opal::http::HttpRequest denied; denied.method = "POST"; denied.target = "/tasks"; const auto denied_response = loopback->Send(denied); @@ -409,8 +406,8 @@ TEST(TodoMiddlewareTest, GuardObserveAndHealthComposeAroundTheServer) { // through the derivation, which the status alone cannot prove. TEST(TodoMiddlewareTest, PerClientRateLimitKeysOnTheDerivedClientAddressNotTheSpoofableHeader) { std::string seen; - const auto deny_banned = [&seen](const smithy::http::TrustedProxies& trusted) { - return smithy::server::PerClientRateLimit( + const auto deny_banned = [&seen](const opal::http::TrustedProxies& trusted) { + return opal::server::PerClientRateLimit( [&seen](const std::string& client) { seen = client; return client != "203.0.113.9"; @@ -419,7 +416,7 @@ TEST(TodoMiddlewareTest, PerClientRateLimitKeysOnTheDerivedClientAddressNotTheSp }; TodoServer server(std::make_shared()); - smithy::http::HttpRequest add; + opal::http::HttpRequest add; add.method = "POST"; add.target = "/tasks"; add.headers.Set("content-type", "application/json"); @@ -430,20 +427,20 @@ TEST(TodoMiddlewareTest, PerClientRateLimitKeysOnTheDerivedClientAddressNotTheSp // trusted-tier path and keys as the stamped peer itself; the banned // client is seen through the appended entry — the walk never reaches // the spoofed prefix — and shed as the shaped 429. - smithy::http::SocketHttpServer transport; + opal::http::SocketHttpServer transport; ASSERT_TRUE(transport - .Start(smithy::server::Chain( - {deny_banned(*smithy::http::TrustedProxies::Parse({"127.0.0.0/8"}))}, + .Start(opal::server::Chain( + {deny_banned(*opal::http::TrustedProxies::Parse({"127.0.0.0/8"}))}, server.Handler())) .ok()); - smithy::http::SocketHttpClient raw("127.0.0.1", transport.port()); + opal::http::SocketHttpClient raw("127.0.0.1", transport.port()); const auto direct = raw.Send(add); ASSERT_TRUE(direct.ok()) << direct.error().message(); EXPECT_EQ(direct->status, 200); EXPECT_EQ(seen, "127.0.0.1"); - smithy::http::HttpRequest banned = add; + opal::http::HttpRequest banned = add; banned.headers.Set("x-forwarded-for", "198.51.100.7, 203.0.113.9"); const auto denied = raw.Send(banned); ASSERT_TRUE(denied.ok()) << denied.error().message(); @@ -454,14 +451,14 @@ TEST(TodoMiddlewareTest, PerClientRateLimitKeysOnTheDerivedClientAddressNotTheSp { // The direct-connect deployment (no trust configured): the same header // is ignored wholly, the peer stays the key, the request is admitted. - smithy::http::SocketHttpServer transport; + opal::http::SocketHttpServer transport; ASSERT_TRUE(transport - .Start(smithy::server::Chain( - {deny_banned(smithy::http::TrustedProxies::None())}, server.Handler())) + .Start(opal::server::Chain({deny_banned(opal::http::TrustedProxies::None())}, + server.Handler())) .ok()); - smithy::http::SocketHttpClient raw("127.0.0.1", transport.port()); + opal::http::SocketHttpClient raw("127.0.0.1", transport.port()); - smithy::http::HttpRequest spoofed = add; + opal::http::HttpRequest spoofed = add; spoofed.headers.Set("x-forwarded-for", "203.0.113.9"); const auto admitted = raw.Send(spoofed); ASSERT_TRUE(admitted.ok()) << admitted.error().message(); @@ -478,31 +475,31 @@ TEST(TodoMiddlewareTest, PerClientRateLimitKeysOnTheDerivedClientAddressNotTheSp // through the module boundary, with a live server proving nothing is sent. TEST(TodoRequestLineInjectionTest, ARawClientRefusesCrlfInTargetOrMethodAndServesCleanOnes) { TodoServer server(std::make_shared()); - smithy::http::SocketHttpServer transport; + opal::http::SocketHttpServer transport; ASSERT_TRUE(transport.Start(server.Handler()).ok()); - smithy::http::SocketHttpClient client("127.0.0.1", transport.port()); + opal::http::SocketHttpClient client("127.0.0.1", transport.port()); // A smuggled second request line hidden in the target: refused, not sent. - smithy::http::HttpRequest injected_target; + opal::http::HttpRequest injected_target; injected_target.method = "POST"; injected_target.target = "/tasks HTTP/1.1\r\nX-Smuggled: 1\r\n\r\nGET /tasks"; injected_target.headers.Set("content-type", "application/json"); injected_target.body = R"({"title":"x"})"; const auto target_outcome = client.Send(injected_target); ASSERT_FALSE(target_outcome.ok()); - EXPECT_EQ(target_outcome.error().kind(), smithy::ErrorKind::kValidation); + EXPECT_EQ(target_outcome.error().kind(), opal::ErrorKind::kValidation); // Same in the method. - smithy::http::HttpRequest injected_method; + opal::http::HttpRequest injected_method; injected_method.method = "POST /evil HTTP/1.1\r\nX-Smuggled: 1\r\n\r\nGET"; injected_method.target = "/tasks"; const auto method_outcome = client.Send(injected_method); ASSERT_FALSE(method_outcome.ok()); - EXPECT_EQ(method_outcome.error().kind(), smithy::ErrorKind::kValidation); + EXPECT_EQ(method_outcome.error().kind(), opal::ErrorKind::kValidation); // A legitimate request on the same client still works — the guard is not // a false positive. - smithy::http::HttpRequest clean; + opal::http::HttpRequest clean; clean.method = "POST"; clean.target = "/tasks"; clean.headers.Set("content-type", "application/json"); diff --git a/examples/bazel-consumer/websocket_acceptance_test.cc b/examples/bazel-consumer/websocket_acceptance_test.cc index 2ab406d6..572e66d5 100644 --- a/examples/bazel-consumer/websocket_acceptance_test.cc +++ b/examples/bazel-consumer/websocket_acceptance_test.cc @@ -18,15 +18,15 @@ namespace { -using smithy::eventstream::Message; -using smithy::http::BeastServerTransport; -using smithy::http::BeastWebSocketClient; -using smithy::http::HttpRequest; -using smithy::http::HttpResponse; -using smithy::http::WebSocket; +using opal::eventstream::Message; +using opal::http::BeastServerTransport; +using opal::http::BeastWebSocketClient; +using opal::http::HttpRequest; +using opal::http::HttpResponse; +using opal::http::WebSocket; Message Event(const std::string& kind, const std::string& body) { - return Message{.headers = {{":event-type", kind}}, .payload = smithy::Blob::FromString(body)}; + return Message{.headers = {{":event-type", kind}}, .payload = opal::Blob::FromString(body)}; } TEST(WebSocketAcceptanceTest, AConsumerServesAndDrainsAStreamThroughTheModuleBoundary) { @@ -68,7 +68,7 @@ TEST(WebSocketAcceptanceTest, AConsumerServesAndDrainsAStreamThroughTheModuleBou // An unauthenticated dial is refused before any upgrade exists. EXPECT_FALSE(BeastWebSocketClient::Dial({.host = "127.0.0.1", .port = server.port()}).ok()); - smithy::http::Headers credentials; + opal::http::Headers credentials; credentials.Add("authorization", "Bearer consumer-token"); auto dialed = BeastWebSocketClient::Dial( {.host = "127.0.0.1", .port = server.port(), .target = "/events", .headers = credentials}); diff --git a/examples/bazel-consumer/websocket_contract_consumer_test.cc b/examples/bazel-consumer/websocket_contract_consumer_test.cc index 5a123f12..f298f86f 100644 --- a/examples/bazel-consumer/websocket_contract_consumer_test.cc +++ b/examples/bazel-consumer/websocket_contract_consumer_test.cc @@ -30,10 +30,10 @@ namespace { -using smithy::Outcome; -using smithy::Unit; -using smithy::eventstream::Message; -using smithy::http::WebSocket; +using opal::Outcome; +using opal::Unit; +using opal::eventstream::Message; +using opal::http::WebSocket; // A third-party session: a bounded outbound wire nobody drains, one parked // receive, one parked send. Deliberately minimal — the point is not the @@ -55,7 +55,7 @@ class ConsumerSocket final : public WebSocket, public std::enable_shared_from_th Outcome> Receive(std::chrono::milliseconds timeout) override { std::unique_lock lock(mutex_); if (!changed_.wait_for(lock, timeout, [this] { return closed_; })) { - return smithy::Error::Timeout("consumer socket: no message within the deadline"); + return opal::Error::Timeout("consumer socket: no message within the deadline"); } return std::optional(); } @@ -63,7 +63,7 @@ class ConsumerSocket final : public WebSocket, public std::enable_shared_from_th Outcome Send(const Message& message) override { std::unique_lock lock(mutex_); changed_.wait(lock, [this] { return queued_ < kDepth || closed_; }); - if (closed_) return smithy::Error::Transport("consumer socket: session is closed"); + if (closed_) return opal::Error::Transport("consumer socket: session is closed"); ++queued_; (void)message; return Unit{}; @@ -87,7 +87,7 @@ class ConsumerSocket final : public WebSocket, public std::enable_shared_from_th pending_receive_ = std::exchange(deliver, nullptr); ++receive_park_generation_; // a stale deadline must not fire this park } else if (!closed_) { - immediate = smithy::Error::Validation("consumer socket: a receive is already outstanding"); + immediate = opal::Error::Validation("consumer socket: a receive is already outstanding"); } } if (!deliver) return; // parked: EndSession completes it @@ -113,11 +113,11 @@ class ConsumerSocket final : public WebSocket, public std::enable_shared_from_th pending_receive_ = std::exchange(deliver, nullptr); parked_generation = ++receive_park_generation_; } else if (!closed_ && pending_receive_) { - immediate = smithy::Error::Validation("consumer socket: a receive is already outstanding"); + immediate = opal::Error::Validation("consumer socket: a receive is already outstanding"); } else if (!closed_) { // The non-positive poll — this peer never sends, so nothing is // ever already in hand. - immediate = smithy::Error::Timeout("consumer socket: no message within the deadline"); + immediate = opal::Error::Timeout("consumer socket: no message within the deadline"); } } if (!deliver) { @@ -133,9 +133,9 @@ class ConsumerSocket final : public WebSocket, public std::enable_shared_from_th { const std::lock_guard lock(mutex_); if (closed_) { - immediate = smithy::Error::Transport("consumer socket: session is closed"); + immediate = opal::Error::Transport("consumer socket: session is closed"); } else if (pending_send_) { - immediate = smithy::Error::Validation("consumer socket: a send is already in flight"); + immediate = opal::Error::Validation("consumer socket: a send is already in flight"); } else if (queued_ >= kDepth) { pending_send_ = std::move(callback); // parked on the full wire return; @@ -161,7 +161,7 @@ class ConsumerSocket final : public WebSocket, public std::enable_shared_from_th changed_.notify_all(); } std::move(waiters).Fire( - smithy::Error::Transport("consumer socket: session is closed"), std::optional(), + opal::Error::Transport("consumer socket: session is closed"), std::optional(), [](const char*, const auto& callback, auto outcome) { callback(std::move(outcome)); }); } @@ -191,7 +191,7 @@ class ConsumerSocket final : public WebSocket, public std::enable_shared_from_th expired = std::exchange(self->pending_receive_, nullptr); self->changed_.notify_all(); } - expired(smithy::Error::Timeout("consumer socket: no message within the deadline")); + expired(opal::Error::Timeout("consumer socket: no message within the deadline")); }; ReceiveCallback refused; try { @@ -205,7 +205,7 @@ class ConsumerSocket final : public WebSocket, public std::enable_shared_from_th } } if (refused) { - refused(smithy::Error::Transport("consumer socket: cannot arm the receive deadline")); + refused(opal::Error::Transport("consumer socket: cannot arm the receive deadline")); } } @@ -225,7 +225,7 @@ struct ConsumerContractDriver { Message BulkMessage(int n) { return Message{.headers = {{":event-type", "bulk"}}, - .payload = smithy::Blob::FromString(std::to_string(n))}; + .payload = opal::Blob::FromString(std::to_string(n))}; } void EndSessionFromPeer() { socket_->EndSession(); } @@ -237,6 +237,6 @@ struct ConsumerContractDriver { // gtest builds the registration symbols from the bare suite name, so the // instantiation lives in the namespace the suite was registered in. -namespace smithy::testing { +namespace opal::testing { INSTANTIATE_TYPED_TEST_SUITE_P(ConsumerSocket, WebSocketContractTest, ConsumerContractDriver); -} // namespace smithy::testing +} // namespace opal::testing diff --git a/examples/cafe/generated/include/example/cafe/client.h b/examples/cafe/generated/include/example/cafe/client.h index 659cb4c0..f9d43bc5 100644 --- a/examples/cafe/generated/include/example/cafe/client.h +++ b/examples/cafe/generated/include/example/cafe/client.h @@ -23,28 +23,28 @@ namespace example::cafe { /// rpcv2Cbor client for example.cafe#Cafe. -/// Modeled service errors surface as smithy::Error with kind kModeled, +/// Modeled service errors surface as opal::Error with kind kModeled, /// code() set to the error shape name, and the deserialized error /// structure attached. Dispatch on them through the per-operation /// Errors listings below rather than comparing code() text. class CafeClient { public: /// Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); + static opal::Outcome Create(opal::ClientConfig config); - smithy::Outcome GetOrder(const GetOrderInput& input) const; - smithy::Outcome OrderCoffee(const OrderCoffeeInput& input) const; + opal::Outcome GetOrder(const GetOrderInput& input) const; + opal::Outcome OrderCoffee(const OrderCoffeeInput& input) const; private: - CafeClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix); - smithy::Outcome Send(smithy::http::HttpRequest request) const; + CafeClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix); + opal::Outcome Send(opal::http::HttpRequest request) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; -/// The modeled errors of GetOrder, matched from a smithy::Error so dispatch is +/// The modeled errors of GetOrder, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -55,9 +55,9 @@ class GetOrderErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static GetOrderErrors FromError(const smithy::Error& error) { + static GetOrderErrors FromError(const opal::Error& error) { GetOrderErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "OrderNotFound") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : OrderNotFound{}); @@ -96,7 +96,7 @@ class GetOrderErrors { switch (value_.index()) { case 1: out += "order_not_found = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -115,14 +115,14 @@ class GetOrderErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("GetOrderErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("GetOrderErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of OrderCoffee, matched from a smithy::Error so dispatch is +/// The modeled errors of OrderCoffee, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -133,9 +133,9 @@ class OrderCoffeeErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static OrderCoffeeErrors FromError(const smithy::Error& error) { + static OrderCoffeeErrors FromError(const opal::Error& error) { OrderCoffeeErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "OutOfBeans") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : OutOfBeans{}); @@ -174,7 +174,7 @@ class OrderCoffeeErrors { switch (value_.index()) { case 1: out += "out_of_beans = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -193,7 +193,7 @@ class OrderCoffeeErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("OrderCoffeeErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("OrderCoffeeErrors", requested, case_name()); } } @@ -210,8 +210,8 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::GetOrderErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -219,8 +219,8 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::OrderCoffeeErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; diff --git a/examples/cafe/generated/include/example/cafe/serde.h b/examples/cafe/generated/include/example/cafe/serde.h index 06f7ed17..059336e5 100644 --- a/examples/cafe/generated/include/example/cafe/serde.h +++ b/examples/cafe/generated/include/example/cafe/serde.h @@ -10,47 +10,47 @@ namespace example::cafe { // Document-pivot serde for every aggregate shape in the model closure. -// Serializers never fail; deserializers return smithy::Error on wire +// Serializers never fail; deserializers return opal::Error on wire // mismatches and enforce @required members. -smithy::Document SerializeAlternativeMilk(const AlternativeMilk& value); -smithy::Outcome DeserializeAlternativeMilk(const smithy::Document& doc); +opal::Document SerializeAlternativeMilk(const AlternativeMilk& value); +opal::Outcome DeserializeAlternativeMilk(const opal::Document& doc); -smithy::Document SerializeGetOrderInput(const GetOrderInput& value); -smithy::Outcome DeserializeGetOrderInput(const smithy::Document& doc); +opal::Document SerializeGetOrderInput(const GetOrderInput& value); +opal::Outcome DeserializeGetOrderInput(const opal::Document& doc); -smithy::Document SerializeCancelledStatus(const CancelledStatus& value); -smithy::Outcome DeserializeCancelledStatus(const smithy::Document& doc); +opal::Document SerializeCancelledStatus(const CancelledStatus& value); +opal::Outcome DeserializeCancelledStatus(const opal::Document& doc); -smithy::Document SerializePendingStatus(const PendingStatus& value); -smithy::Outcome DeserializePendingStatus(const smithy::Document& doc); +opal::Document SerializePendingStatus(const PendingStatus& value); +opal::Outcome DeserializePendingStatus(const opal::Document& doc); -smithy::Document SerializeReadyStatus(const ReadyStatus& value); -smithy::Outcome DeserializeReadyStatus(const smithy::Document& doc); +opal::Document SerializeReadyStatus(const ReadyStatus& value); +opal::Outcome DeserializeReadyStatus(const opal::Document& doc); -smithy::Document SerializeOrderStatus(const OrderStatus& value); -smithy::Outcome DeserializeOrderStatus(const smithy::Document& doc); +opal::Document SerializeOrderStatus(const OrderStatus& value); +opal::Outcome DeserializeOrderStatus(const opal::Document& doc); -smithy::Document SerializeGetOrderOutput(const GetOrderOutput& value); -smithy::Outcome DeserializeGetOrderOutput(const smithy::Document& doc); +opal::Document SerializeGetOrderOutput(const GetOrderOutput& value); +opal::Outcome DeserializeGetOrderOutput(const opal::Document& doc); -smithy::Document SerializeOrderNotFound(const OrderNotFound& value); -smithy::Outcome DeserializeOrderNotFound(const smithy::Document& doc); +opal::Document SerializeOrderNotFound(const OrderNotFound& value); +opal::Outcome DeserializeOrderNotFound(const opal::Document& doc); -smithy::Document SerializeDairyMilk(const DairyMilk& value); -smithy::Outcome DeserializeDairyMilk(const smithy::Document& doc); +opal::Document SerializeDairyMilk(const DairyMilk& value); +opal::Outcome DeserializeDairyMilk(const opal::Document& doc); -smithy::Document SerializeMilkOption(const MilkOption& value); -smithy::Outcome DeserializeMilkOption(const smithy::Document& doc); +opal::Document SerializeMilkOption(const MilkOption& value); +opal::Outcome DeserializeMilkOption(const opal::Document& doc); -smithy::Document SerializeOrderCoffeeInput(const OrderCoffeeInput& value); -smithy::Outcome DeserializeOrderCoffeeInput(const smithy::Document& doc); +opal::Document SerializeOrderCoffeeInput(const OrderCoffeeInput& value); +opal::Outcome DeserializeOrderCoffeeInput(const opal::Document& doc); -smithy::Document SerializeOrderCoffeeOutput(const OrderCoffeeOutput& value); -smithy::Outcome DeserializeOrderCoffeeOutput(const smithy::Document& doc); +opal::Document SerializeOrderCoffeeOutput(const OrderCoffeeOutput& value); +opal::Outcome DeserializeOrderCoffeeOutput(const opal::Document& doc); -smithy::Document SerializeOutOfBeans(const OutOfBeans& value); -smithy::Outcome DeserializeOutOfBeans(const smithy::Document& doc); +opal::Document SerializeOutOfBeans(const OutOfBeans& value); +opal::Outcome DeserializeOutOfBeans(const opal::Document& doc); } // namespace example::cafe diff --git a/examples/cafe/generated/include/example/cafe/server.h b/examples/cafe/generated/include/example/cafe/server.h index 0eeb7bd3..a4fda319 100644 --- a/examples/cafe/generated/include/example/cafe/server.h +++ b/examples/cafe/generated/include/example/cafe/server.h @@ -13,31 +13,31 @@ namespace example::cafe { /// Implement one method per operation. Return a modeled error as -/// smithy::Error::Modeled("", message), optionally with the +/// opal::Error::Modeled("", message), optionally with the /// typed error structure attached via set_detail() so it serializes fully. /// The context carries the raw request and routing captures — see -/// smithy::server::RequestContext; leave the parameter unnamed when unused. +/// opal::server::RequestContext; leave the parameter unnamed when unused. /// Implementations must be thread-safe: transports may invoke any mix of /// operations concurrently on the one handler instance. class CafeHandler { public: virtual ~CafeHandler() = default; - virtual smithy::Outcome GetOrder(const GetOrderInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome OrderCoffee(const OrderCoffeeInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome GetOrder(const GetOrderInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome OrderCoffee(const OrderCoffeeInput& input, const opal::server::RequestContext& context) = 0; }; /// rpcv2Cbor server for example.cafe#Cafe: routing, deserialization, handler dispatch, /// response serialization, and modeled-error mapping. Pass Handler() to any -/// smithy::http::HttpServerTransport. +/// opal::http::HttpServerTransport. class CafeServer { public: explicit CafeServer(std::shared_ptr handler); - smithy::http::RequestHandler Handler() const; + opal::http::RequestHandler Handler() const; private: - std::shared_ptr router_; + std::shared_ptr router_; }; } // namespace example::cafe diff --git a/examples/cafe/generated/include/example/cafe/types.h b/examples/cafe/generated/include/example/cafe/types.h index ede09959..ec974574 100644 --- a/examples/cafe/generated/include/example/cafe/types.h +++ b/examples/cafe/generated/include/example/cafe/types.h @@ -32,7 +32,7 @@ struct AlternativeMilk { out += sep; sep = ", "; out += ".kind = "; - smithy::DebugAppend(out, this->kind); + opal::DebugAppend(out, this->kind); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -55,7 +55,7 @@ struct GetOrderInput { out += sep; sep = ", "; out += ".orderId = "; - smithy::DebugAppend(out, this->orderId); + opal::DebugAppend(out, this->orderId); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -143,7 +143,7 @@ struct CancelledStatus { out += sep; sep = ", "; out += ".reason = "; - smithy::DebugAppend(out, *this->reason); + opal::DebugAppend(out, *this->reason); } out += '}'; } @@ -167,7 +167,7 @@ struct PendingStatus { out += sep; sep = ", "; out += ".position = "; - smithy::DebugAppend(out, this->position); + opal::DebugAppend(out, this->position); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -181,7 +181,7 @@ struct PendingStatus { struct ReadyStatus { - smithy::Timestamp readyAt{}; + opal::Timestamp readyAt{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -190,7 +190,7 @@ struct ReadyStatus { out += sep; sep = ", "; out += ".readyAt = "; - smithy::DebugAppend(out, this->readyAt); + opal::DebugAppend(out, this->readyAt); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -268,15 +268,15 @@ class OrderStatus { switch (value_.index()) { case 1: out += "pending = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "ready = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "cancelled = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; default: break; @@ -295,7 +295,7 @@ class OrderStatus { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("OrderStatus", requested, case_name()); + opal::internal::FatalWrongUnionAccess("OrderStatus", requested, case_name()); } } @@ -315,15 +315,15 @@ struct GetOrderOutput { out += sep; sep = ", "; out += ".orderId = "; - smithy::DebugAppend(out, this->orderId); + opal::DebugAppend(out, this->orderId); out += sep; sep = ", "; out += ".coffeeType = "; - smithy::DebugAppend(out, this->coffeeType); + opal::DebugAppend(out, this->coffeeType); out += sep; sep = ", "; out += ".status = "; - smithy::DebugAppend(out, this->status); + opal::DebugAppend(out, this->status); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -347,7 +347,7 @@ struct OrderNotFound { out += sep; sep = ", "; out += ".orderId = "; - smithy::DebugAppend(out, this->orderId); + opal::DebugAppend(out, this->orderId); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -370,7 +370,7 @@ struct DairyMilk { out += sep; sep = ", "; out += ".percentFat = "; - smithy::DebugAppend(out, this->percentFat); + opal::DebugAppend(out, this->percentFat); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -388,18 +388,18 @@ class MilkOption { public: MilkOption() = default; - static MilkOption FromNone(smithy::Unit value) { + static MilkOption FromNone(opal::Unit value) { MilkOption result; result.value_.emplace<1>(std::move(value)); return result; } bool is_none() const { return value_.index() == 1; } - const smithy::Unit& as_none() const { + const opal::Unit& as_none() const { require_is(1, "none"); return std::get<1>(value_); } /// The engaged member, or nullptr when another member (or none) is set. - const smithy::Unit* as_none_or_null() const { return std::get_if<1>(&value_); } + const opal::Unit* as_none_or_null() const { return std::get_if<1>(&value_); } static MilkOption FromDairy(DairyMilk value) { MilkOption result; @@ -449,15 +449,15 @@ class MilkOption { switch (value_.index()) { case 1: out += "none = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "dairy = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "alternative = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; default: break; @@ -476,11 +476,11 @@ class MilkOption { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("MilkOption", requested, case_name()); + opal::internal::FatalWrongUnionAccess("MilkOption", requested, case_name()); } } - std::variant value_; + std::variant value_; }; @@ -496,12 +496,12 @@ struct OrderCoffeeInput { out += sep; sep = ", "; out += ".coffeeType = "; - smithy::DebugAppend(out, this->coffeeType); + opal::DebugAppend(out, this->coffeeType); if (this->milk.has_value()) { out += sep; sep = ", "; out += ".milk = "; - smithy::DebugAppend(out, *this->milk); + opal::DebugAppend(out, *this->milk); } if (this->clientToken.has_value()) { out += sep; @@ -532,11 +532,11 @@ struct OrderCoffeeOutput { out += sep; sep = ", "; out += ".orderId = "; - smithy::DebugAppend(out, this->orderId); + opal::DebugAppend(out, this->orderId); out += sep; sep = ", "; out += ".status = "; - smithy::DebugAppend(out, this->status); + opal::DebugAppend(out, this->status); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -561,7 +561,7 @@ struct OutOfBeans { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, *this->message); + opal::DebugAppend(out, *this->message); } out += '}'; } @@ -584,7 +584,7 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::AlternativeMilk& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.kind)); + seed = opal::HashCombine(seed, opal::HashValue(value.kind)); return seed; } }; @@ -593,7 +593,7 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::GetOrderInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.orderId)); + seed = opal::HashCombine(seed, opal::HashValue(value.orderId)); return seed; } }; @@ -601,8 +601,8 @@ struct std::hash { template <> struct std::hash { std::size_t operator()(const example::cafe::CoffeeType& value) const noexcept { - return smithy::HashCombine(static_cast(value.value_), - smithy::HashValue(value.unknown_)); + return opal::HashCombine(static_cast(value.value_), + opal::HashValue(value.unknown_)); } }; @@ -610,7 +610,7 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::CancelledStatus& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.reason)); + seed = opal::HashCombine(seed, opal::HashValue(value.reason)); return seed; } }; @@ -619,7 +619,7 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::PendingStatus& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.position)); + seed = opal::HashCombine(seed, opal::HashValue(value.position)); return seed; } }; @@ -628,7 +628,7 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::ReadyStatus& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.readyAt)); + seed = opal::HashCombine(seed, opal::HashValue(value.readyAt)); return seed; } }; @@ -637,8 +637,8 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::OrderStatus& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -646,9 +646,9 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::GetOrderOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.orderId)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.coffeeType)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.status)); + seed = opal::HashCombine(seed, opal::HashValue(value.orderId)); + seed = opal::HashCombine(seed, opal::HashValue(value.coffeeType)); + seed = opal::HashCombine(seed, opal::HashValue(value.status)); return seed; } }; @@ -657,7 +657,7 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::OrderNotFound& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.orderId)); + seed = opal::HashCombine(seed, opal::HashValue(value.orderId)); return seed; } }; @@ -666,7 +666,7 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::DairyMilk& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.percentFat)); + seed = opal::HashCombine(seed, opal::HashValue(value.percentFat)); return seed; } }; @@ -675,8 +675,8 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::MilkOption& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -684,9 +684,9 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::OrderCoffeeInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.coffeeType)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.milk)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.clientToken)); + seed = opal::HashCombine(seed, opal::HashValue(value.coffeeType)); + seed = opal::HashCombine(seed, opal::HashValue(value.milk)); + seed = opal::HashCombine(seed, opal::HashValue(value.clientToken)); return seed; } }; @@ -695,8 +695,8 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::OrderCoffeeOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.orderId)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.status)); + seed = opal::HashCombine(seed, opal::HashValue(value.orderId)); + seed = opal::HashCombine(seed, opal::HashValue(value.status)); return seed; } }; @@ -705,7 +705,7 @@ template <> struct std::hash { std::size_t operator()(const example::cafe::OutOfBeans& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); return seed; } }; diff --git a/examples/cafe/generated/src/client.cc b/examples/cafe/generated/src/client.cc index b07d4bf1..8ea06e23 100644 --- a/examples/cafe/generated/src/client.cc +++ b/examples/cafe/generated/src/client.cc @@ -32,38 +32,38 @@ struct ParsedError { int status = 0; std::string code = "UnknownError"; std::string message; - smithy::Document doc; + opal::Document doc; }; // [[maybe_unused]]: only unary response paths parse wire errors; a // service whose operations all stream never calls this. -[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) { +[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) { ParsedError parsed; parsed.status = response.status; parsed.message = "HTTP " + std::to_string(response.status); - auto doc = smithy::cbor::Decode(smithy::Blob::FromString(response.body)); + auto doc = opal::cbor::Decode(opal::Blob::FromString(response.body)); if (doc.ok()) parsed.doc = *std::move(doc); if (parsed.doc.is_map()) { - const smithy::Document* type = parsed.doc.Find("__type"); + const opal::Document* type = parsed.doc.Find("__type"); if (type == nullptr) type = parsed.doc.Find("code"); if (parsed.code == "UnknownError" && type != nullptr && type->is_string()) parsed.code = helpers::SanitizeErrorCode(type->as_string()); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } return parsed; } -smithy::Error GenericError(ParsedError parsed) { +opal::Error GenericError(ParsedError parsed) { const bool retryable = parsed.status >= 500; - if (parsed.code == "UnknownError") return smithy::Error(smithy::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); - return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); + if (parsed.code == "UnknownError") return opal::Error(opal::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); + return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); } -smithy::Error MakeOrderNotFoundError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeOrderNotFoundError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("OrderNotFound", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("OrderNotFound", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeOrderNotFound(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -71,11 +71,11 @@ smithy::Error MakeOrderNotFoundError(const smithy::http::HttpResponse& response, return error; } -smithy::Error MakeOutOfBeansError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeOutOfBeansError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = true; // @retryable - smithy::Error error = smithy::Error::Modeled("OutOfBeans", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("OutOfBeans", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeOutOfBeans(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -83,13 +83,13 @@ smithy::Error MakeOutOfBeansError(const smithy::http::HttpResponse& response, Pa return error; } -smithy::Error ParseGetOrderError(const smithy::http::HttpResponse& response) { +opal::Error ParseGetOrderError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "OrderNotFound") return helpers::MakeOrderNotFoundError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseOrderCoffeeError(const smithy::http::HttpResponse& response) { +opal::Error ParseOrderCoffeeError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "OutOfBeans") return helpers::MakeOutOfBeansError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); @@ -98,34 +98,34 @@ smithy::Error ParseOrderCoffeeError(const smithy::http::HttpResponse& response) } // namespace helpers } // namespace -smithy::Outcome CafeClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome CafeClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { // The built-in socket transport is plaintext-only; https needs a - // TLS-capable transport (e.g. smithy::http::BeastHttpClient). + // TLS-capable transport (e.g. opal::http::BeastHttpClient). if (endpoint->tls()) { - return smithy::Error::Validation("CafeClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + return opal::Error::Validation("CafeClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); } - transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); } } if (transport == nullptr) { - return smithy::Error::Validation("CafeClient: config needs an endpoint or an http_client"); + return opal::Error::Validation("CafeClient: config needs an endpoint or an http_client"); } return CafeClient(std::move(config), std::move(transport), std::move(prefix)); } -CafeClient::CafeClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix) +CafeClient::CafeClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} -smithy::Outcome CafeClient::Send(smithy::http::HttpRequest request) const { +opal::Outcome CafeClient::Send(opal::http::HttpRequest request) const { // Operations with a non-document response payload set their own accept. if (!request.headers.Get("accept").has_value()) request.headers.Set("accept", "application/cbor"); request.headers.Set("user-agent", config_.user_agent); @@ -136,36 +136,36 @@ smithy::Outcome CafeClient::Send(smithy::http::HttpR if (!request.body.empty()) { request.headers.Set("content-length", std::to_string(request.body.size())); } - return smithy::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); + return opal::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); } -smithy::Outcome CafeClient::GetOrder(const GetOrderInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome CafeClient::GetOrder(const GetOrderInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/Cafe/operation/GetOrder"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeGetOrderInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializeGetOrderInput(input)).ToString(); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseGetOrderError(*response); - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeGetOrderOutput(*body_doc); } -smithy::Outcome CafeClient::OrderCoffee(const OrderCoffeeInput& input) const { +opal::Outcome CafeClient::OrderCoffee(const OrderCoffeeInput& input) const { OrderCoffeeInput prepared = input; - if (!prepared.clientToken.has_value()) prepared.clientToken = smithy::GenerateUuidV4(); - smithy::http::HttpRequest request; + if (!prepared.clientToken.has_value()) prepared.clientToken = opal::GenerateUuidV4(); + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/Cafe/operation/OrderCoffee"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeOrderCoffeeInput(prepared)).ToString(); + request.body = opal::cbor::Encode(SerializeOrderCoffeeInput(prepared)).ToString(); // @requestCompression(gzip): applied last, appended to Content-Encoding. if (request.body.size() >= static_cast(config_.request_min_compression_size_bytes)) { - auto compressed = smithy::GzipCompress(request.body); + auto compressed = opal::GzipCompress(request.body); if (!compressed) return std::move(compressed).error(); request.body = *std::move(compressed); const auto existing_encoding = request.headers.Get("content-encoding"); @@ -174,7 +174,7 @@ smithy::Outcome CafeClient::OrderCoffee(const OrderCoffeeInpu auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseOrderCoffeeError(*response); - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeOrderCoffeeOutput(*body_doc); } diff --git a/examples/cafe/generated/src/serde.cc b/examples/cafe/generated/src/serde.cc index 74dfef5b..7ac9bdf5 100644 --- a/examples/cafe/generated/src/serde.cc +++ b/examples/cafe/generated/src/serde.cc @@ -10,62 +10,62 @@ namespace example::cafe { namespace types = ::example::cafe; -smithy::Document SerializeAlternativeMilk(const AlternativeMilk& value) { - smithy::DocumentMap map; - map.emplace("kind", smithy::Document(value.kind)); - return smithy::Document(std::move(map)); +opal::Document SerializeAlternativeMilk(const AlternativeMilk& value) { + opal::DocumentMap map; + map.emplace("kind", opal::Document(value.kind)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeAlternativeMilk(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("AlternativeMilk: expected a map on the wire"); +opal::Outcome DeserializeAlternativeMilk(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("AlternativeMilk: expected a map on the wire"); AlternativeMilk out; { - const smithy::Document* member = doc.Find("kind"); + const opal::Document* member = doc.Find("kind"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AlternativeMilk: missing required member: kind"); + return opal::Error::Serialization("AlternativeMilk: missing required member: kind"); } - if (!member->is_string()) return smithy::Error::Serialization("AlternativeMilk.kind: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("AlternativeMilk.kind: unexpected type on the wire"); out.kind = member->as_string(); } return out; } -smithy::Document SerializeGetOrderInput(const GetOrderInput& value) { - smithy::DocumentMap map; - map.emplace("orderId", smithy::Document(value.orderId)); - return smithy::Document(std::move(map)); +opal::Document SerializeGetOrderInput(const GetOrderInput& value) { + opal::DocumentMap map; + map.emplace("orderId", opal::Document(value.orderId)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetOrderInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetOrderInput: expected a map on the wire"); +opal::Outcome DeserializeGetOrderInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetOrderInput: expected a map on the wire"); GetOrderInput out; { - const smithy::Document* member = doc.Find("orderId"); + const opal::Document* member = doc.Find("orderId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetOrderInput: missing required member: orderId"); + return opal::Error::Serialization("GetOrderInput: missing required member: orderId"); } - if (!member->is_string()) return smithy::Error::Serialization("GetOrderInput.orderId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetOrderInput.orderId: unexpected type on the wire"); out.orderId = member->as_string(); } return out; } -smithy::Document SerializeCancelledStatus(const CancelledStatus& value) { - smithy::DocumentMap map; +opal::Document SerializeCancelledStatus(const CancelledStatus& value) { + opal::DocumentMap map; if (value.reason.has_value()) { - map.emplace("reason", smithy::Document((*value.reason))); + map.emplace("reason", opal::Document((*value.reason))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeCancelledStatus(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("CancelledStatus: expected a map on the wire"); +opal::Outcome DeserializeCancelledStatus(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("CancelledStatus: expected a map on the wire"); CancelledStatus out; { - const smithy::Document* member = doc.Find("reason"); + const opal::Document* member = doc.Find("reason"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("CancelledStatus.reason: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("CancelledStatus.reason: unexpected type on the wire"); parsed_member = member->as_string(); out.reason = std::move(parsed_member); } @@ -73,43 +73,43 @@ smithy::Outcome DeserializeCancelledStatus(const smithy::Docume return out; } -smithy::Document SerializePendingStatus(const PendingStatus& value) { - smithy::DocumentMap map; - map.emplace("position", smithy::Document(static_cast(value.position))); - return smithy::Document(std::move(map)); +opal::Document SerializePendingStatus(const PendingStatus& value) { + opal::DocumentMap map; + map.emplace("position", opal::Document(static_cast(value.position))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePendingStatus(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PendingStatus: expected a map on the wire"); +opal::Outcome DeserializePendingStatus(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PendingStatus: expected a map on the wire"); PendingStatus out; { - const smithy::Document* member = doc.Find("position"); + const opal::Document* member = doc.Find("position"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PendingStatus: missing required member: position"); + return opal::Error::Serialization("PendingStatus: missing required member: position"); } - if (!member->is_int()) return smithy::Error::Serialization("PendingStatus.position: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("PendingStatus.position: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("PendingStatus.position: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("PendingStatus.position: value out of range"); out.position = static_cast(member->as_int()); } return out; } -smithy::Document SerializeReadyStatus(const ReadyStatus& value) { - smithy::DocumentMap map; - map.emplace("readyAt", smithy::Document::FromTimestamp(value.readyAt, smithy::TimestampFormat::kEpochSeconds)); - return smithy::Document(std::move(map)); +opal::Document SerializeReadyStatus(const ReadyStatus& value) { + opal::DocumentMap map; + map.emplace("readyAt", opal::Document::FromTimestamp(value.readyAt, opal::TimestampFormat::kEpochSeconds)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeReadyStatus(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ReadyStatus: expected a map on the wire"); +opal::Outcome DeserializeReadyStatus(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ReadyStatus: expected a map on the wire"); ReadyStatus out; { - const smithy::Document* member = doc.Find("readyAt"); + const opal::Document* member = doc.Find("readyAt"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("ReadyStatus: missing required member: readyAt"); + return opal::Error::Serialization("ReadyStatus: missing required member: readyAt"); } { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kEpochSeconds); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kEpochSeconds); if (!parsed) return std::move(parsed).error(); out.readyAt = *parsed; } @@ -117,8 +117,8 @@ smithy::Outcome DeserializeReadyStatus(const smithy::Document& doc) return out; } -smithy::Document SerializeOrderStatus(const OrderStatus& value) { - smithy::DocumentMap map; +opal::Document SerializeOrderStatus(const OrderStatus& value) { + opal::DocumentMap map; if (value.is_pending()) { map.emplace("pending", SerializePendingStatus(value.as_pending())); } @@ -128,13 +128,13 @@ smithy::Document SerializeOrderStatus(const OrderStatus& value) { if (value.is_cancelled()) { map.emplace("cancelled", SerializeCancelledStatus(value.as_cancelled())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOrderStatus(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OrderStatus: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("OrderStatus: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("pending"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeOrderStatus(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OrderStatus: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("OrderStatus: expected exactly one union member"); + if (const opal::Document* member = doc.Find("pending"); member != nullptr && !member->is_null()) { PendingStatus parsed_member{}; { auto parsed = DeserializePendingStatus(*member); @@ -143,7 +143,7 @@ smithy::Outcome DeserializeOrderStatus(const smithy::Document& doc) } return OrderStatus::FromPending(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("ready"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("ready"); member != nullptr && !member->is_null()) { ReadyStatus parsed_member{}; { auto parsed = DeserializeReadyStatus(*member); @@ -152,7 +152,7 @@ smithy::Outcome DeserializeOrderStatus(const smithy::Document& doc) } return OrderStatus::FromReady(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("cancelled"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("cancelled"); member != nullptr && !member->is_null()) { CancelledStatus parsed_member{}; { auto parsed = DeserializeCancelledStatus(*member); @@ -161,40 +161,40 @@ smithy::Outcome DeserializeOrderStatus(const smithy::Document& doc) } return OrderStatus::FromCancelled(std::move(parsed_member)); } - return smithy::Error::Serialization("OrderStatus: unknown or missing union member"); + return opal::Error::Serialization("OrderStatus: unknown or missing union member"); } -smithy::Document SerializeGetOrderOutput(const GetOrderOutput& value) { - smithy::DocumentMap map; - map.emplace("orderId", smithy::Document(value.orderId)); - map.emplace("coffeeType", smithy::Document(std::string(value.coffeeType.ToString()))); +opal::Document SerializeGetOrderOutput(const GetOrderOutput& value) { + opal::DocumentMap map; + map.emplace("orderId", opal::Document(value.orderId)); + map.emplace("coffeeType", opal::Document(std::string(value.coffeeType.ToString()))); map.emplace("status", SerializeOrderStatus(value.status)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetOrderOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetOrderOutput: expected a map on the wire"); +opal::Outcome DeserializeGetOrderOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetOrderOutput: expected a map on the wire"); GetOrderOutput out; { - const smithy::Document* member = doc.Find("orderId"); + const opal::Document* member = doc.Find("orderId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetOrderOutput: missing required member: orderId"); + return opal::Error::Serialization("GetOrderOutput: missing required member: orderId"); } - if (!member->is_string()) return smithy::Error::Serialization("GetOrderOutput.orderId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetOrderOutput.orderId: unexpected type on the wire"); out.orderId = member->as_string(); } { - const smithy::Document* member = doc.Find("coffeeType"); + const opal::Document* member = doc.Find("coffeeType"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetOrderOutput: missing required member: coffeeType"); + return opal::Error::Serialization("GetOrderOutput: missing required member: coffeeType"); } - if (!member->is_string()) return smithy::Error::Serialization("GetOrderOutput.coffeeType: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetOrderOutput.coffeeType: unexpected type on the wire"); out.coffeeType = types::CoffeeType::FromString(member->as_string()); } { - const smithy::Document* member = doc.Find("status"); + const opal::Document* member = doc.Find("status"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetOrderOutput: missing required member: status"); + return opal::Error::Serialization("GetOrderOutput: missing required member: status"); } { auto parsed = DeserializeOrderStatus(*member); @@ -205,55 +205,55 @@ smithy::Outcome DeserializeGetOrderOutput(const smithy::Document return out; } -smithy::Document SerializeOrderNotFound(const OrderNotFound& value) { - smithy::DocumentMap map; - map.emplace("orderId", smithy::Document(value.orderId)); - return smithy::Document(std::move(map)); +opal::Document SerializeOrderNotFound(const OrderNotFound& value) { + opal::DocumentMap map; + map.emplace("orderId", opal::Document(value.orderId)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOrderNotFound(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OrderNotFound: expected a map on the wire"); +opal::Outcome DeserializeOrderNotFound(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OrderNotFound: expected a map on the wire"); OrderNotFound out; { - const smithy::Document* member = doc.Find("orderId"); + const opal::Document* member = doc.Find("orderId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("OrderNotFound: missing required member: orderId"); + return opal::Error::Serialization("OrderNotFound: missing required member: orderId"); } - if (!member->is_string()) return smithy::Error::Serialization("OrderNotFound.orderId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OrderNotFound.orderId: unexpected type on the wire"); out.orderId = member->as_string(); } return out; } -smithy::Document SerializeDairyMilk(const DairyMilk& value) { - smithy::DocumentMap map; - map.emplace("percentFat", smithy::Document(static_cast(value.percentFat))); - return smithy::Document(std::move(map)); +opal::Document SerializeDairyMilk(const DairyMilk& value) { + opal::DocumentMap map; + map.emplace("percentFat", opal::Document(static_cast(value.percentFat))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeDairyMilk(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("DairyMilk: expected a map on the wire"); +opal::Outcome DeserializeDairyMilk(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("DairyMilk: expected a map on the wire"); DairyMilk out; { - const smithy::Document* member = doc.Find("percentFat"); + const opal::Document* member = doc.Find("percentFat"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("DairyMilk: missing required member: percentFat"); + return opal::Error::Serialization("DairyMilk: missing required member: percentFat"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("DairyMilk.percentFat: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("DairyMilk.percentFat: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("DairyMilk.percentFat: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("DairyMilk.percentFat: value out of range"); out.percentFat = *narrowed; } } return out; } -smithy::Document SerializeMilkOption(const MilkOption& value) { - smithy::DocumentMap map; +opal::Document SerializeMilkOption(const MilkOption& value) { + opal::DocumentMap map; if (value.is_none()) { - map.emplace("none", smithy::Document(smithy::DocumentMap{})); + map.emplace("none", opal::Document(opal::DocumentMap{})); } if (value.is_dairy()) { map.emplace("dairy", SerializeDairyMilk(value.as_dairy())); @@ -261,18 +261,18 @@ smithy::Document SerializeMilkOption(const MilkOption& value) { if (value.is_alternative()) { map.emplace("alternative", SerializeAlternativeMilk(value.as_alternative())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeMilkOption(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("MilkOption: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("MilkOption: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("none"); member != nullptr && !member->is_null()) { - smithy::Unit parsed_member{}; - parsed_member = smithy::Unit{}; +opal::Outcome DeserializeMilkOption(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("MilkOption: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("MilkOption: expected exactly one union member"); + if (const opal::Document* member = doc.Find("none"); member != nullptr && !member->is_null()) { + opal::Unit parsed_member{}; + parsed_member = opal::Unit{}; return MilkOption::FromNone(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("dairy"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("dairy"); member != nullptr && !member->is_null()) { DairyMilk parsed_member{}; { auto parsed = DeserializeDairyMilk(*member); @@ -281,7 +281,7 @@ smithy::Outcome DeserializeMilkOption(const smithy::Document& doc) { } return MilkOption::FromDairy(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("alternative"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("alternative"); member != nullptr && !member->is_null()) { AlternativeMilk parsed_member{}; { auto parsed = DeserializeAlternativeMilk(*member); @@ -290,34 +290,34 @@ smithy::Outcome DeserializeMilkOption(const smithy::Document& doc) { } return MilkOption::FromAlternative(std::move(parsed_member)); } - return smithy::Error::Serialization("MilkOption: unknown or missing union member"); + return opal::Error::Serialization("MilkOption: unknown or missing union member"); } -smithy::Document SerializeOrderCoffeeInput(const OrderCoffeeInput& value) { - smithy::DocumentMap map; - map.emplace("coffeeType", smithy::Document(std::string(value.coffeeType.ToString()))); +opal::Document SerializeOrderCoffeeInput(const OrderCoffeeInput& value) { + opal::DocumentMap map; + map.emplace("coffeeType", opal::Document(std::string(value.coffeeType.ToString()))); if (value.milk.has_value()) { map.emplace("milk", SerializeMilkOption((*value.milk))); } if (value.clientToken.has_value()) { - map.emplace("clientToken", smithy::Document((*value.clientToken))); + map.emplace("clientToken", opal::Document((*value.clientToken))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOrderCoffeeInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OrderCoffeeInput: expected a map on the wire"); +opal::Outcome DeserializeOrderCoffeeInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OrderCoffeeInput: expected a map on the wire"); OrderCoffeeInput out; { - const smithy::Document* member = doc.Find("coffeeType"); + const opal::Document* member = doc.Find("coffeeType"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("OrderCoffeeInput: missing required member: coffeeType"); + return opal::Error::Serialization("OrderCoffeeInput: missing required member: coffeeType"); } - if (!member->is_string()) return smithy::Error::Serialization("OrderCoffeeInput.coffeeType: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OrderCoffeeInput.coffeeType: unexpected type on the wire"); out.coffeeType = types::CoffeeType::FromString(member->as_string()); } { - const smithy::Document* member = doc.Find("milk"); + const opal::Document* member = doc.Find("milk"); if (member != nullptr && !member->is_null()) { types::MilkOption parsed_member{}; { @@ -329,10 +329,10 @@ smithy::Outcome DeserializeOrderCoffeeInput(const smithy::Docu } } { - const smithy::Document* member = doc.Find("clientToken"); + const opal::Document* member = doc.Find("clientToken"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("OrderCoffeeInput.clientToken: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OrderCoffeeInput.clientToken: unexpected type on the wire"); parsed_member = member->as_string(); out.clientToken = std::move(parsed_member); } @@ -340,28 +340,28 @@ smithy::Outcome DeserializeOrderCoffeeInput(const smithy::Docu return out; } -smithy::Document SerializeOrderCoffeeOutput(const OrderCoffeeOutput& value) { - smithy::DocumentMap map; - map.emplace("orderId", smithy::Document(value.orderId)); +opal::Document SerializeOrderCoffeeOutput(const OrderCoffeeOutput& value) { + opal::DocumentMap map; + map.emplace("orderId", opal::Document(value.orderId)); map.emplace("status", SerializeOrderStatus(value.status)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOrderCoffeeOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OrderCoffeeOutput: expected a map on the wire"); +opal::Outcome DeserializeOrderCoffeeOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OrderCoffeeOutput: expected a map on the wire"); OrderCoffeeOutput out; { - const smithy::Document* member = doc.Find("orderId"); + const opal::Document* member = doc.Find("orderId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("OrderCoffeeOutput: missing required member: orderId"); + return opal::Error::Serialization("OrderCoffeeOutput: missing required member: orderId"); } - if (!member->is_string()) return smithy::Error::Serialization("OrderCoffeeOutput.orderId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OrderCoffeeOutput.orderId: unexpected type on the wire"); out.orderId = member->as_string(); } { - const smithy::Document* member = doc.Find("status"); + const opal::Document* member = doc.Find("status"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("OrderCoffeeOutput: missing required member: status"); + return opal::Error::Serialization("OrderCoffeeOutput: missing required member: status"); } { auto parsed = DeserializeOrderStatus(*member); @@ -372,22 +372,22 @@ smithy::Outcome DeserializeOrderCoffeeOutput(const smithy::Do return out; } -smithy::Document SerializeOutOfBeans(const OutOfBeans& value) { - smithy::DocumentMap map; +opal::Document SerializeOutOfBeans(const OutOfBeans& value) { + opal::DocumentMap map; if (value.message.has_value()) { - map.emplace("message", smithy::Document((*value.message))); + map.emplace("message", opal::Document((*value.message))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOutOfBeans(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OutOfBeans: expected a map on the wire"); +opal::Outcome DeserializeOutOfBeans(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OutOfBeans: expected a map on the wire"); OutOfBeans out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("OutOfBeans.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OutOfBeans.message: unexpected type on the wire"); parsed_member = member->as_string(); out.message = std::move(parsed_member); } diff --git a/examples/cafe/generated/src/server.cc b/examples/cafe/generated/src/server.cc index 807be384..79dcb966 100644 --- a/examples/cafe/generated/src/server.cc +++ b/examples/cafe/generated/src/server.cc @@ -23,63 +23,63 @@ namespace types = ::example::cafe; namespace { namespace helpers { -smithy::http::HttpResponse CborError(int status, const std::string& code, const std::string& message, smithy::DocumentMap body) { - if (!code.empty()) body.insert_or_assign("__type", smithy::Document(code)); - if (!message.empty()) body.insert_or_assign("message", smithy::Document(message)); - smithy::http::HttpResponse response; +opal::http::HttpResponse CborError(int status, const std::string& code, const std::string& message, opal::DocumentMap body) { + if (!code.empty()) body.insert_or_assign("__type", opal::Document(code)); + if (!message.empty()) body.insert_or_assign("message", opal::Document(message)); + opal::http::HttpResponse response; response.status = status; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(smithy::Document(std::move(body))).ToString(); + response.body = opal::cbor::Encode(opal::Document(std::move(body))).ToString(); return response; } // [[maybe_unused]]: only unary routes map handler errors here; a service // whose operations all stream reports errors on the stream instead. -[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& error) { - if (error.kind() == smithy::ErrorKind::kModeled) { +[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& error) { + if (error.kind() == opal::ErrorKind::kModeled) { if (error.code() == "OrderNotFound") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeOrderNotFound(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::CborError(400, "example.cafe#OrderNotFound", "", std::move(body)); } if (error.code() == "OutOfBeans") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeOutOfBeans(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::CborError(500, "example.cafe#OutOfBeans", "", std::move(body)); } return helpers::CborError(400, error.code(), error.message(), {}); } - if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) return helpers::CborError(400, "SerializationException", error.message(), {}); + if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) return helpers::CborError(400, "SerializationException", error.message(), {}); // Never leak internal detail on unexpected failures. return helpers::CborError(500, "InternalFailure", "internal failure", {}); } // Constraint validation (smithy.framework#ValidationException): messages // and '/member' paths follow the official validation conformance suite. -void AddValidationFailure(std::vector* failures, std::string path, std::string message) { +void AddValidationFailure(std::vector* failures, std::string path, std::string message) { failures->push_back({std::move(path), std::move(message)}); } -void ValidateGetOrderInput(const types::GetOrderInput& value, const std::string& path, std::vector* failures) { +void ValidateGetOrderInput(const types::GetOrderInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/orderId"; { - const std::size_t member_length = smithy::Utf8CodePointCount(value.orderId); + const std::size_t member_length = opal::Utf8CodePointCount(value.orderId); if (member_length < 1ULL || member_length > 128ULL) { helpers::AddValidationFailure(failures, member_path, "Value with length " + std::to_string(member_length) + " at '" + member_path + "' failed to satisfy constraint: Member must have length between 1 and 128, inclusive"); } @@ -87,7 +87,7 @@ void ValidateGetOrderInput(const types::GetOrderInput& value, const std::string& } } -void ValidateOrderCoffeeInput(const types::OrderCoffeeInput& value, const std::string& path, std::vector* failures) { +void ValidateOrderCoffeeInput(const types::OrderCoffeeInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/coffeeType"; if (value.coffeeType.value() == CoffeeType::Value::kUnknown) { @@ -98,20 +98,20 @@ void ValidateOrderCoffeeInput(const types::OrderCoffeeInput& value, const std::s // [[maybe_unused]]: only unary routes reject invalid input over HTTP; a // service whose operations all stream reports validation on the stream. -[[maybe_unused]] smithy::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { +[[maybe_unused]] opal::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { std::string summary = std::to_string(failures.size()) + " validation error" + (failures.size() == 1 ? "" : "s") + " detected. "; - smithy::DocumentList field_list; + opal::DocumentList field_list; for (std::size_t i = 0; i < failures.size(); ++i) { if (i > 0) summary += "; "; summary += failures[i].message; - smithy::DocumentMap field; - field.emplace("message", smithy::Document(failures[i].message)); - field.emplace("path", smithy::Document(failures[i].path)); - field_list.push_back(smithy::Document(std::move(field))); + opal::DocumentMap field; + field.emplace("message", opal::Document(failures[i].message)); + field.emplace("path", opal::Document(failures[i].path)); + field_list.push_back(opal::Document(std::move(field))); } - smithy::DocumentMap body; - body.emplace("fieldList", smithy::Document(std::move(field_list))); - smithy::http::HttpResponse response = helpers::CborError(400, "smithy.framework#ValidationException", summary, std::move(body)); + opal::DocumentMap body; + body.emplace("fieldList", opal::Document(std::move(field_list))); + opal::http::HttpResponse response = helpers::CborError(400, "smithy.framework#ValidationException", summary, std::move(body)); return response; } @@ -119,46 +119,46 @@ void ValidateOrderCoffeeInput(const types::OrderCoffeeInput& value, const std::s } // namespace CafeServer::CafeServer(std::shared_ptr handler) - : router_(std::make_shared()) { + : router_(std::make_shared()) { // The route table is derived from the model's @http traits; conflicts are // a modeling error surfaced by Router::Add (checked at generation time in a // later phase), so registration results are intentionally discarded. - (void)router_->Add("POST", "/service/Cafe/operation/GetOrder", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/Cafe/operation/GetOrder", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } GetOrderInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } auto parsed = DeserializeGetOrderInput(body_doc); if (!parsed) return helpers::CborError(400, "SerializationException", parsed.error().message(), {}); input = *std::move(parsed); - std::vector validation_failures; + std::vector validation_failures; helpers::ValidateGetOrderInput(input, "", &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); auto outcome = handler->GetOrder(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeGetOrderOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeGetOrderOutput(*outcome)).ToString(); return response; }, "GetOrder"); - (void)router_->Add("POST", "/service/Cafe/operation/OrderCoffee", [handler](const smithy::http::HttpRequest& raw_request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { - smithy::http::HttpRequest request = raw_request; + (void)router_->Add("POST", "/service/Cafe/operation/OrderCoffee", [handler](const opal::http::HttpRequest& raw_request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { + opal::http::HttpRequest request = raw_request; // @requestCompression(gzip): decode before parsing. if (const auto request_encoding = request.headers.Get("content-encoding"); request_encoding.has_value() && (*request_encoding == "gzip" || request_encoding->ends_with(", gzip"))) { - auto decompressed = smithy::GzipDecompress(request.body); + auto decompressed = opal::GzipDecompress(request.body); if (!decompressed) { return helpers::CborError(400, "SerializationException", "invalid gzip request body", {}); } @@ -169,36 +169,36 @@ CafeServer::CafeServer(std::shared_ptr handler) } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } OrderCoffeeInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } auto parsed = DeserializeOrderCoffeeInput(body_doc); if (!parsed) return helpers::CborError(400, "SerializationException", parsed.error().message(), {}); input = *std::move(parsed); - std::vector validation_failures; + std::vector validation_failures; helpers::ValidateOrderCoffeeInput(input, "", &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); auto outcome = handler->OrderCoffee(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeOrderCoffeeOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeOrderCoffeeOutput(*outcome)).ToString(); return response; }, "OrderCoffee"); } -smithy::http::RequestHandler CafeServer::Handler() const { +opal::http::RequestHandler CafeServer::Handler() const { auto router = router_; - return [router](const smithy::http::HttpRequest& request) { return router->Route(request); }; + return [router](const opal::http::HttpRequest& request) { return router->Route(request); }; } } // namespace example::cafe diff --git a/examples/cafe/generated/tests/integration_test.cc b/examples/cafe/generated/tests/integration_test.cc index 93be6fd3..c737e7d9 100644 --- a/examples/cafe/generated/tests/integration_test.cc +++ b/examples/cafe/generated/tests/integration_test.cc @@ -87,7 +87,7 @@ struct Rng { [[maybe_unused]] ReadyStatus RandomReadyStatus([[maybe_unused]] Rng& rng) { ReadyStatus v{}; - v.readyAt = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + v.readyAt = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); return v; } @@ -125,7 +125,7 @@ struct Rng { [[maybe_unused]] MilkOption RandomMilkOption([[maybe_unused]] Rng& rng) { switch (rng.engine() % 3) { case 0: - return MilkOption::FromNone(smithy::Unit{}); + return MilkOption::FromNone(opal::Unit{}); case 1: return MilkOption::FromDairy(RandomDairyMilk(rng)); default: @@ -156,22 +156,22 @@ struct Rng { class ScriptedHandler final : public CafeHandler { public: - smithy::Outcome GetOrder(const GetOrderInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetOrder(const GetOrderInput& input, const opal::server::RequestContext&) override { lastGetOrder = input; if (nextGetOrderError.has_value()) return *nextGetOrderError; return nextGetOrderOutput; } std::optional lastGetOrder; GetOrderOutput nextGetOrderOutput{}; - std::optional nextGetOrderError; - smithy::Outcome OrderCoffee(const OrderCoffeeInput& input, const smithy::server::RequestContext&) override { + std::optional nextGetOrderError; + opal::Outcome OrderCoffee(const OrderCoffeeInput& input, const opal::server::RequestContext&) override { lastOrderCoffee = input; if (nextOrderCoffeeError.has_value()) return *nextOrderCoffeeError; return nextOrderCoffeeOutput; } std::optional lastOrderCoffee; OrderCoffeeOutput nextOrderCoffeeOutput{}; - std::optional nextOrderCoffeeError; + std::optional nextOrderCoffeeError; }; enum class TransportKind { kLoopback, kSocket }; @@ -181,14 +181,14 @@ class CafeIntegrationTest : public ::testing::TestWithParam { void SetUp() override { handler_ = std::make_shared(); server_ = std::make_unique(handler_); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries if (GetParam() == TransportKind::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); config.http_client = loopback; } else { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(server_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } @@ -201,7 +201,7 @@ class CafeIntegrationTest : public ::testing::TestWithParam { std::shared_ptr handler_; std::unique_ptr server_; - std::unique_ptr socket_server_; + std::unique_ptr socket_server_; std::unique_ptr client_; }; @@ -260,13 +260,13 @@ TEST_P(CafeIntegrationTest, OrderCoffeeMaximalRoundTrips) { TEST_P(CafeIntegrationTest, GetOrderOrderNotFoundMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const OrderNotFound detail = RandomOrderNotFound(rng); - smithy::Error error = smithy::Error::Modeled("OrderNotFound", "integration"); + opal::Error error = opal::Error::Modeled("OrderNotFound", "integration"); error.set_detail(detail); handler_->nextGetOrderError = error; const GetOrderInput input = RandomGetOrderInput(rng); const auto outcome = client_->GetOrder(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "OrderNotFound"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -275,13 +275,13 @@ TEST_P(CafeIntegrationTest, GetOrderOrderNotFoundMapsAcrossTheWire) { TEST_P(CafeIntegrationTest, OrderCoffeeOutOfBeansMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const OutOfBeans detail = RandomOutOfBeans(rng); - smithy::Error error = smithy::Error::Modeled("OutOfBeans", "integration"); + opal::Error error = opal::Error::Modeled("OutOfBeans", "integration"); error.set_detail(detail); handler_->nextOrderCoffeeError = error; const OrderCoffeeInput input = RandomOrderCoffeeInput(rng); const auto outcome = client_->OrderCoffee(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "OutOfBeans"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -290,17 +290,17 @@ TEST_P(CafeIntegrationTest, OrderCoffeeOutOfBeansMapsAcrossTheWire) { TEST(CafeIntegrationUnknownMembers, GetOrderToleratesUnknownResponseMembers) { auto handler = std::make_shared(); CafeServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::cbor::Decode(smithy::Blob::FromString(response.body)); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::cbor::Decode(opal::Blob::FromString(response.body)); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::cbor::Encode(smithy::Document(std::move(map))).ToString(); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::cbor::Encode(opal::Document(std::move(map))).ToString(); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *CafeClient::Create(std::move(config)); @@ -316,17 +316,17 @@ TEST(CafeIntegrationUnknownMembers, GetOrderToleratesUnknownResponseMembers) { TEST(CafeIntegrationUnknownMembers, OrderCoffeeToleratesUnknownResponseMembers) { auto handler = std::make_shared(); CafeServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::cbor::Decode(smithy::Blob::FromString(response.body)); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::cbor::Decode(opal::Blob::FromString(response.body)); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::cbor::Encode(smithy::Document(std::move(map))).ToString(); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::cbor::Encode(opal::Document(std::move(map))).ToString(); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *CafeClient::Create(std::move(config)); diff --git a/examples/cafe/generated/tests/smoke_test.cc b/examples/cafe/generated/tests/smoke_test.cc index 3f4efd6a..26010033 100644 --- a/examples/cafe/generated/tests/smoke_test.cc +++ b/examples/cafe/generated/tests/smoke_test.cc @@ -45,11 +45,11 @@ OrderCoffeeOutput MinimalOrderCoffeeOutput() { class SmokeHandler : public CafeHandler { public: - smithy::Outcome GetOrder(const GetOrderInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetOrder(const GetOrderInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalGetOrderOutput(); } - smithy::Outcome OrderCoffee(const OrderCoffeeInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OrderCoffee(const OrderCoffeeInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalOrderCoffeeOutput(); } @@ -57,9 +57,9 @@ class SmokeHandler : public CafeHandler { CafeClient MakeClient(std::shared_ptr handler) { CafeServer server(std::move(handler)); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = loopback; // Create cannot fail when a transport is injected. @@ -95,9 +95,9 @@ TEST(CafeSmokeTest, OrderCoffeeRoundTrips) { TEST(CafeSmokeTest, ModeledErrorsMapAcrossTheWire) { class FailingHandler final : public SmokeHandler { public: - smithy::Outcome GetOrder(const GetOrderInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetOrder(const GetOrderInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("OrderNotFound", "smoke"); + opal::Error error = opal::Error::Modeled("OrderNotFound", "smoke"); auto detail = [] { OrderNotFound v{}; v.orderId = "0"; @@ -116,7 +116,7 @@ TEST(CafeSmokeTest, ModeledErrorsMapAcrossTheWire) { }(); const auto outcome = client.GetOrder(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "OrderNotFound"); EXPECT_EQ(outcome.error().message(), "smoke"); EXPECT_NE(outcome.error().detail(), nullptr); diff --git a/examples/cafe/generated_client_test.cc b/examples/cafe/generated_client_test.cc index 4f1a3f07..906e1a8d 100644 --- a/examples/cafe/generated_client_test.cc +++ b/examples/cafe/generated_client_test.cc @@ -18,37 +18,36 @@ namespace example::cafe { namespace { -using smithy::Blob; -using smithy::Document; -using smithy::DocumentMap; +using opal::Blob; +using opal::Document; +using opal::DocumentMap; -class CapturingTransport : public smithy::http::HttpClient { +class CapturingTransport : public opal::http::HttpClient { public: - smithy::Outcome Send( - const smithy::http::HttpRequest& request) override { + opal::Outcome Send(const opal::http::HttpRequest& request) override { last_request = request; return next_response; } - smithy::http::HttpRequest last_request; - smithy::http::HttpResponse next_response{200, {}, ""}; + opal::http::HttpRequest last_request; + opal::http::HttpResponse next_response{200, {}, ""}; }; class CafeClientTest : public testing::Test { protected: void SetUp() override { transport_ = std::make_shared(); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = transport_; auto client = CafeClient::Create(std::move(config)); ASSERT_TRUE(client.ok()) << client.error().message(); client_ = std::make_unique(std::move(*client)); } - static std::string EncodeBody(Document doc) { return smithy::cbor::Encode(doc).ToString(); } + static std::string EncodeBody(Document doc) { return opal::cbor::Encode(doc).ToString(); } - static smithy::Outcome DecodeBody(const std::string& body) { - return smithy::cbor::Decode(Blob::FromString(body)); + static opal::Outcome DecodeBody(const std::string& body) { + return opal::cbor::Decode(Blob::FromString(body)); } std::shared_ptr transport_; @@ -93,8 +92,8 @@ TEST_F(CafeClientTest, IdempotencyTokenAutoFills) { DocumentMap output; output.emplace("orderId", Document("o-2")); DocumentMap ready; - ready.emplace("readyAt", Document::FromTimestamp(smithy::Timestamp::FromEpochMilliseconds(5500), - smithy::TimestampFormat::kEpochSeconds)); + ready.emplace("readyAt", Document::FromTimestamp(opal::Timestamp::FromEpochMilliseconds(5500), + opal::TimestampFormat::kEpochSeconds)); DocumentMap status; status.emplace("ready", Document(std::move(ready))); output.emplace("status", Document(std::move(status))); @@ -130,7 +129,7 @@ TEST_F(CafeClientTest, ModeledErrorsDeserialize) { const auto result = client_->GetOrder(GetOrderInput{.orderId = "missing"}); ASSERT_FALSE(result.ok()); - EXPECT_EQ(result.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(result.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(result.error().code(), "OrderNotFound"); EXPECT_EQ(result.error().message(), "no such order"); EXPECT_FALSE(result.error().retryable()); @@ -211,7 +210,7 @@ TEST_F(CafeClientTest, MissingRequiredMemberIsASerdeError) { const auto result = client_->OrderCoffee(OrderCoffeeInput{.coffeeType = CoffeeType(CoffeeType::Value::kDrip)}); ASSERT_FALSE(result.ok()); - EXPECT_EQ(result.error().kind(), smithy::ErrorKind::kSerialization); + EXPECT_EQ(result.error().kind(), opal::ErrorKind::kSerialization); EXPECT_NE(result.error().message().find("status"), std::string::npos); } @@ -232,7 +231,7 @@ TEST_F(CafeClientTest, ApiKeyHeaderComesFromConfig) { EXPECT_FALSE(transport_->last_request.headers.Get("x-api-key").has_value()); auto transport = std::make_shared(); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = transport; config.api_key = [] { return std::string("cafe-key"); }; auto client = CafeClient::Create(std::move(config)); @@ -257,7 +256,7 @@ TEST_F(CafeClientTest, SmallOrderBodiesAreNotCompressed) { TEST_F(CafeClientTest, ThresholdZeroCompressesEverything) { auto transport = std::make_shared(); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = transport; config.request_min_compression_size_bytes = 0; auto client = CafeClient::Create(std::move(config)); @@ -267,7 +266,7 @@ TEST_F(CafeClientTest, ThresholdZeroCompressesEverything) { (void)client->OrderCoffee(OrderCoffeeInput{.coffeeType = CoffeeType::FromString("LATTE")}); EXPECT_EQ(transport->last_request.headers.Get("content-encoding"), "gzip"); - const auto decompressed = smithy::GzipDecompress(transport->last_request.body); + const auto decompressed = opal::GzipDecompress(transport->last_request.body); ASSERT_TRUE(decompressed.ok()) << decompressed.error().message(); const auto doc = DecodeBody(*decompressed); ASSERT_TRUE(doc.ok()); @@ -282,7 +281,7 @@ TEST_F(CafeClientTest, LargeOrderBodiesCompressAtTheDefaultThreshold) { transport_->next_response.body = EncodeBody(Document(DocumentMap{})); (void)client_->OrderCoffee(input); EXPECT_EQ(transport_->last_request.headers.Get("content-encoding"), "gzip"); - const auto decompressed = smithy::GzipDecompress(transport_->last_request.body); + const auto decompressed = opal::GzipDecompress(transport_->last_request.body); ASSERT_TRUE(decompressed.ok()); const auto doc = DecodeBody(*decompressed); ASSERT_TRUE(doc.ok()); diff --git a/examples/cafe/generated_types_test.cc b/examples/cafe/generated_types_test.cc index a6b14e60..427ec69f 100644 --- a/examples/cafe/generated_types_test.cc +++ b/examples/cafe/generated_types_test.cc @@ -46,9 +46,9 @@ TEST(GeneratedTypeOrderingTest, UnionsOrderByEngagedMemberThenValue) { } TEST(GeneratedTypeOrderingTest, UnionsWithUnitMembersStayOrdered) { - // MilkOption's `none` member is smithy::Unit; if Unit ever lost its <=>, + // MilkOption's `none` member is opal::Unit; if Unit ever lost its <=>, // this union's defaulted ordering would silently delete. - EXPECT_TRUE(MilkOption::FromNone(smithy::Unit{}) < + EXPECT_TRUE(MilkOption::FromNone(opal::Unit{}) < MilkOption::FromDairy(DairyMilk{.percentFat = 2.0f})); } @@ -111,7 +111,7 @@ TEST(GeneratedTypeHashingTest, EnumsKeyUnorderedSetsIncludingUnknownText) { TEST(GeneratedTypeHashingTest, UnionsHashByEngagedMemberAndValue) { std::unordered_set options; options.insert(MilkOption{}); - options.insert(MilkOption::FromNone(smithy::Unit{})); // engaged none != empty + options.insert(MilkOption::FromNone(opal::Unit{})); // engaged none != empty options.insert(MilkOption::FromDairy(DairyMilk{.percentFat = 2.0F})); options.insert(MilkOption::FromDairy(DairyMilk{.percentFat = 2.0F})); EXPECT_EQ(options.size(), 3u); @@ -147,7 +147,7 @@ TEST(GeneratedTypePrintingTest, EnumsPrintWireTextIncludingUnknownValues) { TEST(GeneratedTypePrintingTest, UnionsPrintEngagedMemberOrEmpty) { EXPECT_EQ(MilkOption{}.DebugString(), "MilkOption()"); - EXPECT_EQ(MilkOption::FromNone(smithy::Unit{}).DebugString(), "MilkOption(none = Unit{})"); + EXPECT_EQ(MilkOption::FromNone(opal::Unit{}).DebugString(), "MilkOption(none = Unit{})"); EXPECT_EQ(OrderStatus::FromPending(PendingStatus{.position = 3}).DebugString(), "OrderStatus(pending = PendingStatus{.position = 3})"); } @@ -193,7 +193,7 @@ TEST(CafeGeneratedTypesTest, UnionFactoriesAndAccessors) { EXPECT_FALSE(dairy.is_alternative()); EXPECT_FLOAT_EQ(dairy.as_dairy().percentFat, 2.0F); - const MilkOption none = MilkOption::FromNone(smithy::Unit{}); + const MilkOption none = MilkOption::FromNone(opal::Unit{}); EXPECT_TRUE(none.is_none()); const MilkOption alt = MilkOption::FromAlternative(AlternativeMilk{.kind = "oat"}); @@ -204,7 +204,7 @@ TEST(CafeGeneratedTypesTest, UnionDefaultIsEmptyAndEqualityWorks) { const MilkOption unset; EXPECT_TRUE(unset.empty()); EXPECT_EQ(unset, MilkOption{}); - EXPECT_FALSE(unset == MilkOption::FromNone(smithy::Unit{})); + EXPECT_FALSE(unset == MilkOption::FromNone(opal::Unit{})); EXPECT_EQ(MilkOption::FromDairy(DairyMilk{.percentFat = 2.0F}), MilkOption::FromDairy(DairyMilk{.percentFat = 2.0F})); } @@ -215,8 +215,8 @@ TEST(CafeGeneratedTypesTest, NestedUnionInsideStructs) { .status = OrderStatus::FromPending(PendingStatus{.position = 3})}; ASSERT_TRUE(output.status.is_pending()); EXPECT_EQ(output.status.as_pending().position, 3); - output.status = OrderStatus::FromReady( - ReadyStatus{.readyAt = smithy::Timestamp::FromEpochMilliseconds(5000)}); + output.status = + OrderStatus::FromReady(ReadyStatus{.readyAt = opal::Timestamp::FromEpochMilliseconds(5000)}); EXPECT_TRUE(output.status.is_ready()); } diff --git a/examples/chat/async_hub_server_main.cc b/examples/chat/async_hub_server_main.cc index 7a847167..782898f9 100644 --- a/examples/chat/async_hub_server_main.cc +++ b/examples/chat/async_hub_server_main.cc @@ -45,7 +45,7 @@ using example::chat::RoomSummary; using example::chat::WatchAsyncServerStream; using example::chat::WatchInput; -using Registry = smithy::server::SessionRegistry; +using Registry = opal::server::SessionRegistry; // The fan-out state: ids are "/", exactly the hub_handler // scheme, over the async-delivery registry — no writer threads, no parked @@ -56,7 +56,7 @@ class AsyncHub { public: explicit AsyncHub(std::chrono::seconds grace) : registry_(RegistryOptions(this, grace)) {} - smithy::server::SessionRegistry& registry() { return registry_; } + opal::server::SessionRegistry& registry() { return registry_; } // A watcher seat's id is "/#watch-" — one predicate, one // spelling, for every roster/occupancy filter below. @@ -107,9 +107,9 @@ class AsyncHub { } private: - static smithy::server::SessionRegistry::Options RegistryOptions( + static opal::server::SessionRegistry::Options RegistryOptions( AsyncHub* hub, std::chrono::seconds grace) { - smithy::server::SessionRegistry::Options options; + opal::server::SessionRegistry::Options options; options.async_delivery = true; // ADR-0019: chains, not writer threads options.grace_period = grace; // ADR-0020: abrupt losses detach, not vanish options.on_expired = [hub](const std::string& id) { @@ -134,7 +134,7 @@ class AsyncHub { return ids; } - smithy::server::SessionRegistry registry_; + opal::server::SessionRegistry registry_; }; // The generated async handler (ADR-0021): each streaming method is one @@ -146,8 +146,8 @@ class HubHandler final : public example::chat::ChatAsyncHandler { AsyncHub& hub() { return hub_; } - smithy::eventstream::StreamTask Converse(ConverseInput input, - ConverseAsyncServerStream& stream) override { + opal::eventstream::StreamTask Converse(ConverseInput input, + ConverseAsyncServerStream& stream) override { const std::string room = input.room; const std::string name = input.nickname.value_or("anonymous"); const std::string id = room + "/" + name; @@ -163,7 +163,7 @@ class HubHandler final : public example::chat::ChatAsyncHandler { Kicked kicked; kicked.message = "nickname '" + name + "' is already in " + room; kicked.by = "hub"; - auto refusal = smithy::Error::Modeled("Kicked", *kicked.message); + auto refusal = opal::Error::Modeled("Kicked", *kicked.message); refusal.set_detail(std::move(kicked)); co_return refusal; } @@ -206,24 +206,24 @@ class HubHandler final : public example::chat::ChatAsyncHandler { } // An abrupt loss inside grace stays silent: the resumed session replays // the roster, and only expiry announces the departure (on_expired). - co_return smithy::Unit{}; // the generated wrapper closes the stream + co_return opal::Unit{}; // the generated wrapper closes the stream } - smithy::eventstream::StreamTask Watch(WatchInput input, WatchAsyncServerStream& stream) override { + opal::eventstream::StreamTask Watch(WatchInput input, WatchAsyncServerStream& stream) override { // A read-only seat in the room's fan-out: broadcasts reach it, the // roster ignores it, and it gets no reconnect grace (nothing to // resume). Rx is NoEvents, so the Receive only ever reports the close. const std::string id = input.room + "/#watch-" + std::to_string(watch_seq_.fetch_add(1)); if (!hub_.registry().Add(id, stream.Share())) { - co_return smithy::Error::Validation("watch seat admission failed"); + co_return opal::Error::Validation("watch seat admission failed"); } (void)co_await stream.Receive(); hub_.registry().Remove(id); - co_return smithy::Unit{}; + co_return opal::Unit{}; } - smithy::Outcome ListRooms( - const ListRoomsInput& /*input*/, const smithy::server::RequestContext& /*context*/) override { + opal::Outcome ListRooms( + const ListRoomsInput& /*input*/, const opal::server::RequestContext& /*context*/) override { return hub_.ListRooms(); } @@ -249,14 +249,14 @@ int main(int argc, char** argv) { // the shared-session seam; the unary table (ListRooms) is identical. example::chat::ChatServer server(handler); - smithy::http::BeastServerTransport::Options options; + opal::http::BeastServerTransport::Options options; options.address = "0.0.0.0"; options.port = argc > 1 ? std::atoi(argv[1]) : 8080; // 0 binds an ephemeral port options.handler_threads = 2; // launch points + unary requests; sessions hold no thread options.websocket_gate = server.StreamRouter()->Gate(); options.on_websocket_session = server.StreamRouter()->ServeSession(); - smithy::http::BeastServerTransport transport(options); - smithy::Outcome started = transport.Start(server.Handler()); + opal::http::BeastServerTransport transport(options); + opal::Outcome started = transport.Start(server.Handler()); if (!started.ok()) { std::fprintf(stderr, "async-hub: start failed: %s\n", started.error().message().c_str()); return 1; diff --git a/examples/chat/chat_browser_e2e_test.cc b/examples/chat/chat_browser_e2e_test.cc index 07c69eb5..da7465e9 100644 --- a/examples/chat/chat_browser_e2e_test.cc +++ b/examples/chat/chat_browser_e2e_test.cc @@ -36,7 +36,7 @@ namespace example::chat { namespace { -const std::string kJsonToken(smithy::eventstream::kJsonFramesSubprotocol); +const std::string kJsonToken(opal::eventstream::kJsonFramesSubprotocol); constexpr char kAllowedOrigin[] = "https://muchq.com"; // What a page on kAllowedOrigin does, and nothing more: offer the @@ -99,19 +99,19 @@ class ChatBrowserEndToEndTest : public testing::Test { protected: void SetUp() override { server_ = std::make_unique(std::make_shared()); - smithy::http::BeastServerTransport::Options options; + opal::http::BeastServerTransport::Options options; // The production browser wiring (ADR-0018): origin allowlist first, // then the generated router's refusals; JSON-text negotiation on. options.websocket_gate = - [origin = smithy::server::RequireOrigin({kAllowedOrigin}), + [origin = opal::server::RequireOrigin({kAllowedOrigin}), router = server_->StreamRouter()->Gate()]( - const smithy::http::HttpRequest& request) -> std::optional { + const opal::http::HttpRequest& request) -> std::optional { if (auto refusal = origin(request)) return refusal; return router(request); }; options.on_websocket = server_->StreamRouter()->Serve(); options.websocket_accept_json_frames = true; - transport_ = std::make_unique(options); + transport_ = std::make_unique(options); ASSERT_TRUE(transport_->Start(server_->Handler()).ok()); } @@ -120,7 +120,7 @@ class ChatBrowserEndToEndTest : public testing::Test { } std::unique_ptr server_; - std::unique_ptr transport_; + std::unique_ptr transport_; }; TEST_F(ChatBrowserEndToEndTest, ABrowserConversesInJsonTextFrames) { @@ -190,7 +190,7 @@ TEST_F(ChatBrowserEndToEndTest, ANativeClientStaysBinaryBesideTheBrowser) { // The generated client never offers the subprotocol: same port, same // gate chain (no Origin header — the allowlist only judges browsers), // binary wire as always. - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; config.endpoint = "http://127.0.0.1:" + std::to_string(transport_->port()); auto client = ChatClient::Create(std::move(config)); diff --git a/examples/chat/chat_e2e_beast_test.cc b/examples/chat/chat_e2e_beast_test.cc index 417ce653..b356af78 100644 --- a/examples/chat/chat_e2e_beast_test.cc +++ b/examples/chat/chat_e2e_beast_test.cc @@ -37,24 +37,24 @@ class ChatBeastEndToEndTest : public testing::Test { // the transport in two lines, unary dispatch untouched beside it. void Start(bool tls) { server_ = std::make_unique(std::make_shared()); - smithy::http::BeastServerTransport::Options options; + opal::http::BeastServerTransport::Options options; options.websocket_gate = server_->StreamRouter()->Gate(); options.on_websocket = server_->StreamRouter()->Serve(); if (tls) { - options.tls_certificate_chain_pem = smithy::testing::kTestCertificatePem; - options.tls_private_key_pem = smithy::testing::kTestPrivateKeyPem; + options.tls_certificate_chain_pem = opal::testing::kTestCertificatePem; + options.tls_private_key_pem = opal::testing::kTestPrivateKeyPem; } - transport_ = std::make_unique(options); + transport_ = std::make_unique(options); ASSERT_TRUE(transport_->Start(server_->Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; if (tls) { // One endpoint configures both directions: the unary transport and the // streaming dial derive wss/TLS from it (nothing configured twice). config.endpoint = "https://127.0.0.1:" + std::to_string(transport_->port()); - config.tls.ca_pem = smithy::testing::kTestCertificatePem; - auto http_client = smithy::http::BeastHttpClient::FromConfig(config); + config.tls.ca_pem = opal::testing::kTestCertificatePem; + auto http_client = opal::http::BeastHttpClient::FromConfig(config); ASSERT_TRUE(http_client.ok()) << http_client.error().message(); config.http_client = *http_client; } else { @@ -70,7 +70,7 @@ class ChatBeastEndToEndTest : public testing::Test { } std::unique_ptr server_; - std::unique_ptr transport_; + std::unique_ptr transport_; std::unique_ptr client_; }; @@ -215,7 +215,7 @@ TEST_F(ChatBeastEndToEndTest, ModeledMidStreamErrorSurfacesTypedOnTheClient) { auto outcome = stream->Receive(); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "Kicked"); EXPECT_EQ(outcome.error().message(), "kicked from lobby"); const Kicked* detail = outcome.error().detail(); @@ -229,7 +229,7 @@ TEST_F(ChatBeastEndToEndTest, GateRefusesAnUnknownStreamPathOnTheWire) { // No route matches /nope, so the gate answers 404 before any upgrade // exists, the dial fails, and the refusal error names the status the // router actually sent. - auto refused = smithy::http::BeastWebSocketClient::Dial( + auto refused = opal::http::BeastWebSocketClient::Dial( {.host = "127.0.0.1", .port = transport_->port(), .target = "/nope"}); ASSERT_FALSE(refused.ok()); EXPECT_NE(refused.error().message().find("refused: HTTP 404"), std::string::npos) diff --git a/examples/chat/chat_e2e_test.cc b/examples/chat/chat_e2e_test.cc index 0d6e2eb4..26886d63 100644 --- a/examples/chat/chat_e2e_test.cc +++ b/examples/chat/chat_e2e_test.cc @@ -185,7 +185,7 @@ TEST_F(ChatEndToEndTest, ModeledMidStreamErrorSurfacesTypedOnTheClient) { // and the typed detail all match what a failed unary call would carry. auto outcome = stream->Receive(); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "Kicked"); EXPECT_EQ(outcome.error().message(), "kicked from lobby"); const Kicked* detail = outcome.error().detail(); @@ -209,19 +209,19 @@ TEST_F(ChatEndToEndTest, UnknownEventTypeIsATerminalSerializationError) { auto stream = client_->Converse(input); ASSERT_TRUE(stream.ok()) << stream.error().message(); ASSERT_EQ(sessions_.size(), 1U); - const std::shared_ptr far = sessions_.back(); + const std::shared_ptr far = sessions_.back(); // A well-formed event message whose :event-type matches no RoomEvents // member — a newer peer's event, or a corrupted one. - ASSERT_TRUE(far->Send(smithy::eventstream::MakeEventMessage("presence", "application/json", - smithy::Blob::FromString("{}"))) + ASSERT_TRUE(far->Send(opal::eventstream::MakeEventMessage("presence", "application/json", + opal::Blob::FromString("{}"))) .ok()); // Undecodable is terminal (ADR-0016): the error is Serialization-kinded // and names the stray type... auto outcome = stream->Receive(); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kSerialization); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kSerialization); EXPECT_NE(outcome.error().message().find("presence"), std::string::npos) << outcome.error().message(); @@ -234,7 +234,7 @@ TEST_F(ChatEndToEndTest, UnknownEventTypeIsATerminalSerializationError) { TEST_F(ChatEndToEndTest, GateRefusesAnUnknownStreamPath) { const auto gate = server_->StreamRouter()->Gate(); - smithy::http::HttpRequest upgrade; + opal::http::HttpRequest upgrade; upgrade.method = "GET"; upgrade.target = "/nope"; const auto refusal = gate(upgrade); @@ -253,9 +253,9 @@ TEST_F(ChatEndToEndTest, GateRefusesAnUnknownStreamPath) { TEST(ChatStreamDialTest, StreamingWithoutEndpointOrDialerIsAValidationError) { // A client wired for unary only (http_client, no endpoint, no dialer) has // nowhere to dial a stream; the generated branch must name the fix. - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; - config.http_client = std::make_shared(); + config.http_client = std::make_shared(); auto client = ChatClient::Create(std::move(config)); ASSERT_TRUE(client.ok()) << client.error().message(); @@ -263,18 +263,18 @@ TEST(ChatStreamDialTest, StreamingWithoutEndpointOrDialerIsAValidationError) { input.room = "lobby"; auto stream = client->Converse(input); ASSERT_FALSE(stream.ok()); - EXPECT_EQ(stream.error().kind(), smithy::ErrorKind::kValidation); + EXPECT_EQ(stream.error().kind(), opal::ErrorKind::kValidation); EXPECT_NE(stream.error().message().find("endpoint or a websocket_dialer"), std::string::npos) << stream.error().message(); } TEST(ChatStreamDialTest, ADialerFailureSurfacesVerbatimFromTheStreamingOperation) { - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; - config.http_client = std::make_shared(); - config.websocket_dialer = [](const smithy::http::WebSocketDialRequest&) - -> smithy::Outcome> { - return smithy::Error::Transport("dial refused by probe"); + config.http_client = std::make_shared(); + config.websocket_dialer = [](const opal::http::WebSocketDialRequest&) + -> opal::Outcome> { + return opal::Error::Transport("dial refused by probe"); }; auto client = ChatClient::Create(std::move(config)); ASSERT_TRUE(client.ok()) << client.error().message(); @@ -285,7 +285,7 @@ TEST(ChatStreamDialTest, ADialerFailureSurfacesVerbatimFromTheStreamingOperation return input; }()); ASSERT_FALSE(stream.ok()); - EXPECT_EQ(stream.error().kind(), smithy::ErrorKind::kTransport); + EXPECT_EQ(stream.error().kind(), opal::ErrorKind::kTransport); EXPECT_EQ(stream.error().message(), "dial refused by probe"); } @@ -298,33 +298,33 @@ TEST(ChatStreamDialTest, ADialerFailureSurfacesVerbatimFromTheStreamingOperation // error-path complement of RoomHandler (room_handler.h). class ErrorScriptHandler final : public ChatHandler { public: - smithy::Outcome ListRooms(const ListRoomsInput&, - const smithy::server::RequestContext&) override { + opal::Outcome ListRooms(const ListRoomsInput&, + const opal::server::RequestContext&) override { return ListRoomsOutput{}; } - smithy::Outcome Converse(const ConverseInput&, ConverseServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Converse(const ConverseInput&, ConverseServerStream& stream, + const opal::server::RequestContext&) override { while (true) { auto event = stream.Receive(); - if (!event.ok() || !event->has_value()) return smithy::Unit{}; + if (!event.ok() || !event->has_value()) return opal::Unit{}; if (!(**event).is_message()) continue; const std::string& text = (**event).as_message().text; - if (text == "crash") return smithy::Error::Transport("secret-internal-detail"); - if (text == "reject") return smithy::Error::Validation("bad input"); - if (text == "roomfull") return smithy::Error::Modeled("RoomFull", "room is full"); + if (text == "crash") return opal::Error::Transport("secret-internal-detail"); + if (text == "reject") return opal::Error::Validation("bad input"); + if (text == "roomfull") return opal::Error::Modeled("RoomFull", "room is full"); ChatMessage echo; echo.text = text; - if (!stream.Send(RoomEvents::FromMessage(echo)).ok()) return smithy::Unit{}; + if (!stream.Send(RoomEvents::FromMessage(echo)).ok()) return opal::Unit{}; } } - smithy::Outcome Watch(const WatchInput&, WatchServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Watch(const WatchInput&, WatchServerStream& stream, + const opal::server::RequestContext&) override { ChatMessage message; message.text = "update"; (void)stream.Send(RoomEvents::FromMessage(message)); - return smithy::Unit{}; + return opal::Unit{}; } }; @@ -344,7 +344,7 @@ TEST_F(ScriptedChatTest, SendingAnEmptyUnionFailsValidationAndSparesTheSession) const auto refused = stream->Send(ChatEvents{}); // no member engaged ASSERT_FALSE(refused.ok()); - EXPECT_EQ(refused.error().kind(), smithy::ErrorKind::kValidation); + EXPECT_EQ(refused.error().kind(), opal::ErrorKind::kValidation); EXPECT_NE(refused.error().message().find("no event member engaged"), std::string::npos) << refused.error().message(); @@ -414,7 +414,7 @@ TEST_F(ScriptedChatTest, AnUndeclaredModeledErrorFallsThroughAsGenericModeled) { ASSERT_TRUE(stream->Send(ChatEvents::FromMessage(message)).ok()); auto outcome = stream->Receive(); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "RoomFull"); EXPECT_EQ(outcome.error().message(), "room is full"); EXPECT_FALSE(ConverseErrors::FromError(outcome.error()).is_kicked()); @@ -429,16 +429,16 @@ TEST_F(ScriptedChatTest, AnUndeclaredModeledErrorFallsThroughAsGenericModeled) { // "explode" (StreamTask's containment, end to end), an echo otherwise. class EchoAsyncHandler final : public ChatAsyncHandler { public: - smithy::eventstream::StreamTask Converse(ConverseInput input, - ConverseAsyncServerStream& stream) override { + opal::eventstream::StreamTask Converse(ConverseInput input, + ConverseAsyncServerStream& stream) override { const std::string name = input.nickname.value_or("anonymous"); (void)co_await stream.Send(RoomEvents::FromJoined(MemberJoined{.member = name})); while (true) { auto event = co_await stream.Receive(); - if (!event.ok() || !event->has_value()) co_return smithy::Unit{}; + if (!event.ok() || !event->has_value()) co_return opal::Unit{}; if ((*event)->is_leave()) { (void)co_await stream.Send(RoomEvents::FromLeft(MemberLeft{.member = name})); - co_return smithy::Unit{}; + co_return opal::Unit{}; } if (!(*event)->is_message()) continue; const ChatMessage& message = (*event)->as_message(); @@ -446,7 +446,7 @@ class EchoAsyncHandler final : public ChatAsyncHandler { Kicked kicked; kicked.message = "kicked from " + input.room; kicked.by = kModerator; - auto refusal = smithy::Error::Modeled("Kicked", *kicked.message); + auto refusal = opal::Error::Modeled("Kicked", *kicked.message); refusal.set_detail(std::move(kicked)); co_return refusal; } @@ -457,17 +457,17 @@ class EchoAsyncHandler final : public ChatAsyncHandler { } } - smithy::eventstream::StreamTask Watch(WatchInput input, WatchAsyncServerStream& stream) override { + opal::eventstream::StreamTask Watch(WatchInput input, WatchAsyncServerStream& stream) override { for (int i = 0; i < 3; ++i) { ChatMessage update; update.text = input.room + "-update-" + std::to_string(i); (void)co_await stream.Send(RoomEvents::FromMessage(update)); } - co_return smithy::Unit{}; + co_return opal::Unit{}; } - smithy::Outcome ListRooms(const ListRoomsInput&, - const smithy::server::RequestContext&) override { + opal::Outcome ListRooms(const ListRoomsInput&, + const opal::server::RequestContext&) override { ListRoomsOutput output; output.rooms.push_back(RoomSummary{.name = "lobby", .members = 2}); return output; @@ -551,7 +551,7 @@ TEST_F(AsyncChatEndToEndTest, AFailedTaskOutcomeSurfacesTypedOnTheClient) { ASSERT_TRUE(stream->Send(ChatEvents::FromMessage(message)).ok()); auto outcome = stream->Receive(); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "Kicked"); EXPECT_EQ(outcome.error().message(), "kicked from lobby"); const Kicked* detail = outcome.error().detail(); @@ -594,29 +594,29 @@ TEST_F(AsyncChatEndToEndTest, UnaryOperationSharesTheAsyncService) { // so the wrapper's exception send cannot complete inline. class FloodThenRefuseHandler final : public ChatAsyncHandler { public: - smithy::eventstream::StreamTask Converse(ConverseInput input, - ConverseAsyncServerStream& stream) override { + opal::eventstream::StreamTask Converse(ConverseInput input, + ConverseAsyncServerStream& stream) override { auto handle = stream.Share(); - for (std::size_t i = 0; i < smithy::http::InMemoryWebSocketPair::kQueueDepth; ++i) { + for (std::size_t i = 0; i < opal::http::InMemoryWebSocketPair::kQueueDepth; ++i) { ChatMessage fill; fill.text = "fill-" + std::to_string(i); - handle.SendAsync(RoomEvents::FromMessage(fill), [](const smithy::Outcome&) {}); + handle.SendAsync(RoomEvents::FromMessage(fill), [](const opal::Outcome&) {}); } Kicked kicked; kicked.message = "kicked from " + input.room; kicked.by = kModerator; - auto refusal = smithy::Error::Modeled("Kicked", *kicked.message); + auto refusal = opal::Error::Modeled("Kicked", *kicked.message); refusal.set_detail(std::move(kicked)); co_return refusal; } - smithy::eventstream::StreamTask Watch(WatchInput, WatchAsyncServerStream& stream) override { + opal::eventstream::StreamTask Watch(WatchInput, WatchAsyncServerStream& stream) override { (void)co_await stream.Receive(); - co_return smithy::Unit{}; + co_return opal::Unit{}; } - smithy::Outcome ListRooms(const ListRoomsInput&, - const smithy::server::RequestContext&) override { + opal::Outcome ListRooms(const ListRoomsInput&, + const opal::server::RequestContext&) override { return ListRoomsOutput{}; } }; @@ -636,7 +636,7 @@ TEST_F(AsyncRefusalTest, ATypedRefusalSurvivesAFullWire) { auto stream = client_->Converse(input); ASSERT_TRUE(stream.ok()) << stream.error().message(); - for (std::size_t i = 0; i < smithy::http::InMemoryWebSocketPair::kQueueDepth; ++i) { + for (std::size_t i = 0; i < opal::http::InMemoryWebSocketPair::kQueueDepth; ++i) { auto fill = stream->Receive(); ASSERT_TRUE(fill.ok() && fill->has_value()) << "fill " << i << " missing"; } diff --git a/examples/chat/generated/include/example/chat/client.h b/examples/chat/generated/include/example/chat/client.h index 2e67d543..38edcf02 100644 --- a/examples/chat/generated/include/example/chat/client.h +++ b/examples/chat/generated/include/example/chat/client.h @@ -25,20 +25,20 @@ namespace example::chat { /// The typed session Converse returns (ADR-0016): Tx = what this client /// sends, Rx = what the server sends. -using ConverseClientStream = smithy::eventstream::EventStream; +using ConverseClientStream = opal::eventstream::EventStream; /// The typed session Watch returns (ADR-0016): Tx = what this client /// sends, Rx = what the server sends. -using WatchClientStream = smithy::eventstream::EventStream; +using WatchClientStream = opal::eventstream::EventStream; /// simpleRestJson client for example.chat#Chat. -/// Modeled service errors surface as smithy::Error with kind kModeled, +/// Modeled service errors surface as opal::Error with kind kModeled, /// code() set to the error shape name, and the deserialized error /// structure attached. Dispatch on them through the per-operation /// Errors listings below rather than comparing code() text. class ChatClient { public: /// Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); + static opal::Outcome Create(opal::ClientConfig config); /// Bidirectional: the client streams ChatEvents up and receives RoomEvents /// down over one WebSocket session. Initial-request members ride the upgrade @@ -51,10 +51,10 @@ class ChatClient { /// (ADR-0016). Send carries input events, Receive yields output events /// (nullopt on the peer's clean close), and a received exception /// surfaces through Receive() as a modeled error, the unary shape. - smithy::Outcome Converse(const ConverseInput& input) const; + opal::Outcome Converse(const ConverseInput& input) const; /// Unary neighbor: an ordinary request/response on the same service, served /// by the same transport that upgrades the streaming operations. - smithy::Outcome ListRooms(const ListRoomsInput& input = {}) const; + opal::Outcome ListRooms(const ListRoomsInput& input = {}) const; /// Server-push: no input stream, so the client's transmit direction is the /// runtime's NoEvents — the client only listens to the room. /// @@ -63,18 +63,18 @@ class ChatClient { /// Receive is meaningful (nullopt on the peer's clean close — Send does /// not compile on a NoEvents direction), and a received exception /// surfaces through Receive() as a modeled error, the unary shape. - smithy::Outcome Watch(const WatchInput& input) const; + opal::Outcome Watch(const WatchInput& input) const; private: - ChatClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix); - smithy::Outcome Send(smithy::http::HttpRequest request) const; + ChatClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix); + opal::Outcome Send(opal::http::HttpRequest request) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; -/// The modeled errors of Converse, matched from a smithy::Error so dispatch is +/// The modeled errors of Converse, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -85,9 +85,9 @@ class ConverseErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static ConverseErrors FromError(const smithy::Error& error) { + static ConverseErrors FromError(const opal::Error& error) { ConverseErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "Kicked") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : Kicked{}); @@ -126,7 +126,7 @@ class ConverseErrors { switch (value_.index()) { case 1: out += "kicked = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -145,7 +145,7 @@ class ConverseErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("ConverseErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("ConverseErrors", requested, case_name()); } } @@ -162,8 +162,8 @@ template <> struct std::hash { std::size_t operator()(const example::chat::ConverseErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; diff --git a/examples/chat/generated/include/example/chat/serde.h b/examples/chat/generated/include/example/chat/serde.h index e0713ee2..c0d93fc2 100644 --- a/examples/chat/generated/include/example/chat/serde.h +++ b/examples/chat/generated/include/example/chat/serde.h @@ -12,53 +12,53 @@ namespace example::chat { // Document-pivot serde for every aggregate shape in the model closure. -// Serializers never fail; deserializers return smithy::Error on wire +// Serializers never fail; deserializers return opal::Error on wire // mismatches and enforce @required members. -smithy::Document SerializeLeaveNotice(const LeaveNotice& value); -smithy::Outcome DeserializeLeaveNotice(const smithy::Document& doc); +opal::Document SerializeLeaveNotice(const LeaveNotice& value); +opal::Outcome DeserializeLeaveNotice(const opal::Document& doc); -smithy::Document SerializeChatMessage(const ChatMessage& value); -smithy::Outcome DeserializeChatMessage(const smithy::Document& doc); +opal::Document SerializeChatMessage(const ChatMessage& value); +opal::Outcome DeserializeChatMessage(const opal::Document& doc); -smithy::Document SerializeChatEvents(const ChatEvents& value); -smithy::Outcome DeserializeChatEvents(const smithy::Document& doc); +opal::Document SerializeChatEvents(const ChatEvents& value); +opal::Outcome DeserializeChatEvents(const opal::Document& doc); -smithy::Document SerializeConverseInput(const ConverseInput& value); -smithy::Outcome DeserializeConverseInput(const smithy::Document& doc); +opal::Document SerializeConverseInput(const ConverseInput& value); +opal::Outcome DeserializeConverseInput(const opal::Document& doc); -smithy::Document SerializeMemberJoined(const MemberJoined& value); -smithy::Outcome DeserializeMemberJoined(const smithy::Document& doc); +opal::Document SerializeMemberJoined(const MemberJoined& value); +opal::Outcome DeserializeMemberJoined(const opal::Document& doc); -smithy::Document SerializeMemberLeft(const MemberLeft& value); -smithy::Outcome DeserializeMemberLeft(const smithy::Document& doc); +opal::Document SerializeMemberLeft(const MemberLeft& value); +opal::Outcome DeserializeMemberLeft(const opal::Document& doc); -smithy::Document SerializeRoomEvents(const RoomEvents& value); -smithy::Outcome DeserializeRoomEvents(const smithy::Document& doc); +opal::Document SerializeRoomEvents(const RoomEvents& value); +opal::Outcome DeserializeRoomEvents(const opal::Document& doc); -smithy::Document SerializeConverseOutput(const ConverseOutput& value); -smithy::Outcome DeserializeConverseOutput(const smithy::Document& doc); +opal::Document SerializeConverseOutput(const ConverseOutput& value); +opal::Outcome DeserializeConverseOutput(const opal::Document& doc); -smithy::Document SerializeKicked(const Kicked& value); -smithy::Outcome DeserializeKicked(const smithy::Document& doc); +opal::Document SerializeKicked(const Kicked& value); +opal::Outcome DeserializeKicked(const opal::Document& doc); -smithy::Document SerializeListRoomsInput(const ListRoomsInput& value); -smithy::Outcome DeserializeListRoomsInput(const smithy::Document& doc); +opal::Document SerializeListRoomsInput(const ListRoomsInput& value); +opal::Outcome DeserializeListRoomsInput(const opal::Document& doc); -smithy::Document SerializeRoomSummary(const RoomSummary& value); -smithy::Outcome DeserializeRoomSummary(const smithy::Document& doc); +opal::Document SerializeRoomSummary(const RoomSummary& value); +opal::Outcome DeserializeRoomSummary(const opal::Document& doc); -smithy::Document SerializeRoomSummaries(const std::vector& value); -smithy::Outcome> DeserializeRoomSummaries(const smithy::Document& doc); +opal::Document SerializeRoomSummaries(const std::vector& value); +opal::Outcome> DeserializeRoomSummaries(const opal::Document& doc); -smithy::Document SerializeListRoomsOutput(const ListRoomsOutput& value); -smithy::Outcome DeserializeListRoomsOutput(const smithy::Document& doc); +opal::Document SerializeListRoomsOutput(const ListRoomsOutput& value); +opal::Outcome DeserializeListRoomsOutput(const opal::Document& doc); -smithy::Document SerializeWatchInput(const WatchInput& value); -smithy::Outcome DeserializeWatchInput(const smithy::Document& doc); +opal::Document SerializeWatchInput(const WatchInput& value); +opal::Outcome DeserializeWatchInput(const opal::Document& doc); -smithy::Document SerializeWatchOutput(const WatchOutput& value); -smithy::Outcome DeserializeWatchOutput(const smithy::Document& doc); +opal::Document SerializeWatchOutput(const WatchOutput& value); +opal::Outcome DeserializeWatchOutput(const opal::Document& doc); } // namespace example::chat diff --git a/examples/chat/generated/include/example/chat/server.h b/examples/chat/generated/include/example/chat/server.h index 28af9963..b62fd1e2 100644 --- a/examples/chat/generated/include/example/chat/server.h +++ b/examples/chat/generated/include/example/chat/server.h @@ -17,22 +17,22 @@ namespace example::chat { /// The typed session a Converse handler borrows (ADR-0016): Tx = what this /// server sends, Rx = what the client sends. -using ConverseServerStream = smithy::eventstream::EventStream; +using ConverseServerStream = opal::eventstream::EventStream; /// The same session for an async handler (ADR-0021): co_await where the /// blocking sibling parks a thread; identical directions and Share(). -using ConverseAsyncServerStream = smithy::eventstream::AsyncEventStream; +using ConverseAsyncServerStream = opal::eventstream::AsyncEventStream; /// The typed session a Watch handler borrows (ADR-0016): Tx = what this /// server sends, Rx = what the client sends. -using WatchServerStream = smithy::eventstream::EventStream; +using WatchServerStream = opal::eventstream::EventStream; /// The same session for an async handler (ADR-0021): co_await where the /// blocking sibling parks a thread; identical directions and Share(). -using WatchAsyncServerStream = smithy::eventstream::AsyncEventStream; +using WatchAsyncServerStream = opal::eventstream::AsyncEventStream; /// Implement one method per operation. Return a modeled error as -/// smithy::Error::Modeled("", message), optionally with the +/// opal::Error::Modeled("", message), optionally with the /// typed error structure attached via set_detail() so it serializes fully. /// The context carries the raw request and routing captures — see -/// smithy::server::RequestContext; leave the parameter unnamed when unused. +/// opal::server::RequestContext; leave the parameter unnamed when unused. /// Implementations must be thread-safe: transports may invoke any mix of /// operations concurrently on the one handler instance. class ChatHandler { @@ -54,10 +54,10 @@ class ChatHandler { /// `stream` is valid only until this method returns; join any helper /// thread still using it. Blocks the transport's handler thread for /// the session's lifetime. - virtual smithy::Outcome Converse(const ConverseInput& input, ConverseServerStream& stream, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome Converse(const ConverseInput& input, ConverseServerStream& stream, const opal::server::RequestContext& context) = 0; /// Unary neighbor: an ordinary request/response on the same service, served /// by the same transport that upgrades the streaming operations. - virtual smithy::Outcome ListRooms(const ListRoomsInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome ListRooms(const ListRoomsInput& input, const opal::server::RequestContext& context) = 0; /// Server-push: no input stream, so the client's transmit direction is the /// runtime's NoEvents — the client only listens to the room. /// @@ -69,7 +69,7 @@ class ChatHandler { /// `stream` is valid only until this method returns; join any helper /// thread still using it. Blocks the transport's handler thread for /// the session's lifetime. - virtual smithy::Outcome Watch(const WatchInput& input, WatchServerStream& stream, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome Watch(const WatchInput& input, WatchServerStream& stream, const opal::server::RequestContext& context) = 0; }; /// ChatHandler's zero-thread sibling (ADR-0021): implement this and construct @@ -90,8 +90,8 @@ class ChatAsyncHandler { /// /// Async streaming operation (ADR-0021): a coroutine serving the whole /// session — co_await stream.Receive()/Send() until done. - /// co_return smithy::Unit{} for a clean close, or an error — modeled as - /// smithy::Error::Modeled("", message) + set_detail(), + /// co_return opal::Unit{} for a clean close, or an error — modeled as + /// opal::Error::Modeled("", message) + set_detail(), /// like a blocking handler — which ends the stream with one best-effort /// exception message before the close. `input` is the coroutine's own /// copy: the upgrade request (and its RequestContext) is gone by the @@ -100,10 +100,10 @@ class ChatAsyncHandler { /// task completes. Code before the first co_await runs on the launching /// handler thread (brief blocking is fine there); every later resumption /// is a transport completion context — never block those. - virtual smithy::eventstream::StreamTask Converse(ConverseInput input, ConverseAsyncServerStream& stream) = 0; + virtual opal::eventstream::StreamTask Converse(ConverseInput input, ConverseAsyncServerStream& stream) = 0; /// Unary neighbor: an ordinary request/response on the same service, served /// by the same transport that upgrades the streaming operations. - virtual smithy::Outcome ListRooms(const ListRoomsInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome ListRooms(const ListRoomsInput& input, const opal::server::RequestContext& context) = 0; /// Server-push: no input stream, so the client's transmit direction is the /// runtime's NoEvents — the client only listens to the room. /// @@ -112,8 +112,8 @@ class ChatAsyncHandler { /// `co_await stream.Receive()` to learn the client closed, and push /// through stream.Share() (typically a registry) — a Send-only loop on /// a quiet stream never notices the client left. - /// co_return smithy::Unit{} for a clean close, or an error — modeled as - /// smithy::Error::Modeled("", message) + set_detail(), + /// co_return opal::Unit{} for a clean close, or an error — modeled as + /// opal::Error::Modeled("", message) + set_detail(), /// like a blocking handler — which ends the stream with one best-effort /// exception message before the close. `input` is the coroutine's own /// copy: the upgrade request (and its RequestContext) is gone by the @@ -122,12 +122,12 @@ class ChatAsyncHandler { /// task completes. Code before the first co_await runs on the launching /// handler thread (brief blocking is fine there); every later resumption /// is a transport completion context — never block those. - virtual smithy::eventstream::StreamTask Watch(WatchInput input, WatchAsyncServerStream& stream) = 0; + virtual opal::eventstream::StreamTask Watch(WatchInput input, WatchAsyncServerStream& stream) = 0; }; /// simpleRestJson server for example.chat#Chat: routing, deserialization, handler dispatch, /// response serialization, and modeled-error mapping. Pass Handler() to any -/// smithy::http::HttpServerTransport. +/// opal::http::HttpServerTransport. class ChatServer { public: explicit ChatServer(std::shared_ptr handler); @@ -137,7 +137,7 @@ class ChatServer { /// constructor chosen decides which two-line mount applies (StreamRouter). explicit ChatServer(std::shared_ptr handler); - smithy::http::RequestHandler Handler() const; + opal::http::RequestHandler Handler() const; /// The WebSocket router carrying every streaming route (ADR-0016), ready /// to mount on the transport in two lines — the serve line keyed to the @@ -146,11 +146,11 @@ class ChatServer { /// options.on_websocket = server.StreamRouter()->Serve(); // blocking handler /// options.on_websocket_session = /// server.StreamRouter()->ServeSession(); // async handler (ADR-0021) - std::shared_ptr StreamRouter() const; + std::shared_ptr StreamRouter() const; private: - std::shared_ptr router_; - std::shared_ptr stream_router_; + std::shared_ptr router_; + std::shared_ptr stream_router_; }; } // namespace example::chat diff --git a/examples/chat/generated/include/example/chat/types.h b/examples/chat/generated/include/example/chat/types.h index 6e257259..e3ec7f2f 100644 --- a/examples/chat/generated/include/example/chat/types.h +++ b/examples/chat/generated/include/example/chat/types.h @@ -31,7 +31,7 @@ struct LeaveNotice { out += sep; sep = ", "; out += ".reason = "; - smithy::DebugAppend(out, *this->reason); + opal::DebugAppend(out, *this->reason); } out += '}'; } @@ -56,12 +56,12 @@ struct ChatMessage { out += sep; sep = ", "; out += ".text = "; - smithy::DebugAppend(out, this->text); + opal::DebugAppend(out, this->text); if (this->sender.has_value()) { out += sep; sep = ", "; out += ".sender = "; - smithy::DebugAppend(out, *this->sender); + opal::DebugAppend(out, *this->sender); } out += '}'; } @@ -129,11 +129,11 @@ class ChatEvents { switch (value_.index()) { case 1: out += "message = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "leave = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -152,7 +152,7 @@ class ChatEvents { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("ChatEvents", requested, case_name()); + opal::internal::FatalWrongUnionAccess("ChatEvents", requested, case_name()); } } @@ -172,18 +172,18 @@ struct ConverseInput { out += sep; sep = ", "; out += ".room = "; - smithy::DebugAppend(out, this->room); + opal::DebugAppend(out, this->room); if (this->nickname.has_value()) { out += sep; sep = ", "; out += ".nickname = "; - smithy::DebugAppend(out, *this->nickname); + opal::DebugAppend(out, *this->nickname); } if (this->events.has_value()) { out += sep; sep = ", "; out += ".events = "; - smithy::DebugAppend(out, *this->events); + opal::DebugAppend(out, *this->events); } out += '}'; } @@ -207,7 +207,7 @@ struct MemberJoined { out += sep; sep = ", "; out += ".member = "; - smithy::DebugAppend(out, this->member); + opal::DebugAppend(out, this->member); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -230,7 +230,7 @@ struct MemberLeft { out += sep; sep = ", "; out += ".member = "; - smithy::DebugAppend(out, this->member); + opal::DebugAppend(out, this->member); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -309,15 +309,15 @@ class RoomEvents { switch (value_.index()) { case 1: out += "message = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "joined = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "left = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; default: break; @@ -336,7 +336,7 @@ class RoomEvents { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("RoomEvents", requested, case_name()); + opal::internal::FatalWrongUnionAccess("RoomEvents", requested, case_name()); } } @@ -355,7 +355,7 @@ struct ConverseOutput { out += sep; sep = ", "; out += ".events = "; - smithy::DebugAppend(out, *this->events); + opal::DebugAppend(out, *this->events); } out += '}'; } @@ -383,12 +383,12 @@ struct Kicked { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, *this->message); + opal::DebugAppend(out, *this->message); } out += sep; sep = ", "; out += ".by = "; - smithy::DebugAppend(out, this->by); + opal::DebugAppend(out, this->by); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -428,11 +428,11 @@ struct RoomSummary { out += sep; sep = ", "; out += ".name = "; - smithy::DebugAppend(out, this->name); + opal::DebugAppend(out, this->name); out += sep; sep = ", "; out += ".members = "; - smithy::DebugAppend(out, this->members); + opal::DebugAppend(out, this->members); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -455,7 +455,7 @@ struct ListRoomsOutput { out += sep; sep = ", "; out += ".rooms = "; - smithy::DebugAppend(out, this->rooms); + opal::DebugAppend(out, this->rooms); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -478,7 +478,7 @@ struct WatchInput { out += sep; sep = ", "; out += ".room = "; - smithy::DebugAppend(out, this->room); + opal::DebugAppend(out, this->room); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -502,7 +502,7 @@ struct WatchOutput { out += sep; sep = ", "; out += ".events = "; - smithy::DebugAppend(out, *this->events); + opal::DebugAppend(out, *this->events); } out += '}'; } @@ -525,7 +525,7 @@ template <> struct std::hash { std::size_t operator()(const example::chat::LeaveNotice& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.reason)); + seed = opal::HashCombine(seed, opal::HashValue(value.reason)); return seed; } }; @@ -534,8 +534,8 @@ template <> struct std::hash { std::size_t operator()(const example::chat::ChatMessage& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.text)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sender)); + seed = opal::HashCombine(seed, opal::HashValue(value.text)); + seed = opal::HashCombine(seed, opal::HashValue(value.sender)); return seed; } }; @@ -544,8 +544,8 @@ template <> struct std::hash { std::size_t operator()(const example::chat::ChatEvents& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -553,9 +553,9 @@ template <> struct std::hash { std::size_t operator()(const example::chat::ConverseInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.room)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.nickname)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.events)); + seed = opal::HashCombine(seed, opal::HashValue(value.room)); + seed = opal::HashCombine(seed, opal::HashValue(value.nickname)); + seed = opal::HashCombine(seed, opal::HashValue(value.events)); return seed; } }; @@ -564,7 +564,7 @@ template <> struct std::hash { std::size_t operator()(const example::chat::MemberJoined& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.member)); + seed = opal::HashCombine(seed, opal::HashValue(value.member)); return seed; } }; @@ -573,7 +573,7 @@ template <> struct std::hash { std::size_t operator()(const example::chat::MemberLeft& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.member)); + seed = opal::HashCombine(seed, opal::HashValue(value.member)); return seed; } }; @@ -582,8 +582,8 @@ template <> struct std::hash { std::size_t operator()(const example::chat::RoomEvents& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -591,7 +591,7 @@ template <> struct std::hash { std::size_t operator()(const example::chat::ConverseOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.events)); + seed = opal::HashCombine(seed, opal::HashValue(value.events)); return seed; } }; @@ -600,8 +600,8 @@ template <> struct std::hash { std::size_t operator()(const example::chat::Kicked& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.by)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.by)); return seed; } }; @@ -615,8 +615,8 @@ template <> struct std::hash { std::size_t operator()(const example::chat::RoomSummary& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.name)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.members)); + seed = opal::HashCombine(seed, opal::HashValue(value.name)); + seed = opal::HashCombine(seed, opal::HashValue(value.members)); return seed; } }; @@ -625,7 +625,7 @@ template <> struct std::hash { std::size_t operator()(const example::chat::ListRoomsOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.rooms)); + seed = opal::HashCombine(seed, opal::HashValue(value.rooms)); return seed; } }; @@ -634,7 +634,7 @@ template <> struct std::hash { std::size_t operator()(const example::chat::WatchInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.room)); + seed = opal::HashCombine(seed, opal::HashValue(value.room)); return seed; } }; @@ -643,7 +643,7 @@ template <> struct std::hash { std::size_t operator()(const example::chat::WatchOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.events)); + seed = opal::HashCombine(seed, opal::HashValue(value.events)); return seed; } }; diff --git a/examples/chat/generated/src/client.cc b/examples/chat/generated/src/client.cc index 56801c97..cc7b7366 100644 --- a/examples/chat/generated/src/client.cc +++ b/examples/chat/generated/src/client.cc @@ -44,51 +44,51 @@ struct ParsedError { int status = 0; std::string code = "UnknownError"; std::string message; - smithy::Document doc; + opal::Document doc; }; // [[maybe_unused]]: only unary response paths parse wire errors; a // service whose operations all stream never calls this. -[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) { +[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) { ParsedError parsed; parsed.status = response.status; parsed.message = "HTTP " + std::to_string(response.status); - auto doc = smithy::json::Decode(response.body); + auto doc = opal::json::Decode(response.body); if (doc.ok()) parsed.doc = *std::move(doc); const auto type_header = response.headers.Get("x-error-type"); if (type_header.has_value()) parsed.code = helpers::SanitizeErrorCode(*type_header); if (parsed.doc.is_map()) { - const smithy::Document* type = parsed.doc.Find("__type"); + const opal::Document* type = parsed.doc.Find("__type"); if (type == nullptr) type = parsed.doc.Find("code"); if (parsed.code == "UnknownError" && type != nullptr && type->is_string()) parsed.code = helpers::SanitizeErrorCode(type->as_string()); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } return parsed; } -smithy::Error GenericError(ParsedError parsed) { +opal::Error GenericError(ParsedError parsed) { const bool retryable = parsed.status >= 500; - if (parsed.code == "UnknownError") return smithy::Error(smithy::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); - return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); + if (parsed.code == "UnknownError") return opal::Error(opal::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); + return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); } // Strict text parsing for label/query/header bindings ([[maybe_unused]]: // emitted for every service; not every service binds numeric values). // Trailing text, floats-for-ints, and out-of-range values are rejected // (the malformed-request suites pin this). -[[maybe_unused]] smithy::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { +[[maybe_unused]] opal::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { std::int64_t value = 0; const char* first = text.data(); const char* last = first + text.size(); const auto result = std::from_chars(first, last, value, 10); if (text.empty() || result.ec != std::errc() || result.ptr != last || value < min_value || value > max_value) { - return smithy::Error::Serialization("invalid integer: " + text); + return opal::Error::Serialization("invalid integer: " + text); } return value; } -[[maybe_unused]] smithy::Outcome ParseDoubleText(const std::string& text) { +[[maybe_unused]] opal::Outcome ParseDoubleText(const std::string& text) { if (text == "NaN") return std::numeric_limits::quiet_NaN(); if (text == "Infinity") return std::numeric_limits::infinity(); if (text == "-Infinity") return -std::numeric_limits::infinity(); @@ -96,21 +96,21 @@ smithy::Error GenericError(ParsedError parsed) { return (c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' || c == '+' || c == '-'; }; if (text.empty() || text.front() == '+' || !std::all_of(text.begin(), text.end(), valid_char)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } char* parse_end = nullptr; const double value = std::strtod(text.c_str(), &parse_end); if (parse_end != text.c_str() + text.size() || !std::isfinite(value)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } return value; } -smithy::Error MakeKickedError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeKickedError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("Kicked", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("Kicked", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeKicked(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -122,9 +122,9 @@ smithy::Error MakeKickedError(const smithy::http::HttpResponse& response, Parsed // TLS come from the same endpoint the unary transport uses (nothing is // configured twice); config.websocket_dialer overrides the Beast dialer the // way http_client overrides the unary transport. -smithy::Outcome> DialStream(const smithy::ClientConfig& config, smithy::http::WebSocketDialRequest request) { +opal::Outcome> DialStream(const opal::ClientConfig& config, opal::http::WebSocketDialRequest request) { if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); request.host = endpoint->host; request.port = endpoint->port; @@ -133,153 +133,153 @@ smithy::Outcome> DialStream(const smith } if (config.websocket_dialer) return config.websocket_dialer(request); if (request.host.empty()) { - return smithy::Error::Validation("ChatClient: config needs an endpoint or a websocket_dialer"); + return opal::Error::Validation("ChatClient: config needs an endpoint or a websocket_dialer"); } - return smithy::http::BeastWebSocketClient::Dialer()(request); + return opal::http::BeastWebSocketClient::Dialer()(request); } // One event per message (ADR-0016): the engaged member's structure is the // payload, its member name the :event-type. -smithy::Outcome EncodeConverseEvent(const types::ChatEvents& event) { +opal::Outcome EncodeConverseEvent(const types::ChatEvents& event) { if (event.is_message()) { - return smithy::eventstream::MakeEventMessage("message", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeChatMessage(event.as_message())))); + return opal::eventstream::MakeEventMessage("message", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeChatMessage(event.as_message())))); } if (event.is_leave()) { - return smithy::eventstream::MakeEventMessage("leave", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeLeaveNotice(event.as_leave())))); + return opal::eventstream::MakeEventMessage("leave", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeLeaveNotice(event.as_leave())))); } - return smithy::Error::Validation("ChatEvents: no event member engaged"); + return opal::Error::Validation("ChatEvents: no event member engaged"); } -smithy::Outcome DecodeConverseEvent(const smithy::eventstream::Message& message) { - auto envelope = smithy::eventstream::ParseEnvelope(message); +opal::Outcome DecodeConverseEvent(const opal::eventstream::Message& message) { + auto envelope = opal::eventstream::ParseEnvelope(message); if (!envelope) return std::move(envelope).error(); - if (envelope->kind == smithy::eventstream::EventEnvelope::Kind::kException) { + if (envelope->kind == opal::eventstream::EventEnvelope::Kind::kException) { // A received exception is terminal (ADR-0016): the EventStream closes the // session and surfaces this error, exactly the unary shape. ParsedError parsed; parsed.code = helpers::SanitizeErrorCode(envelope->type); - auto exception_doc = smithy::json::Decode(envelope->payload.ToString()); + auto exception_doc = opal::json::Decode(envelope->payload.ToString()); if (exception_doc.ok() && exception_doc->is_map()) { parsed.doc = *std::move(exception_doc); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } // MakeError's header-patch source; exception messages carry none. - smithy::http::HttpResponse response; + opal::http::HttpResponse response; if (parsed.code == "Kicked") return helpers::MakeKickedError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); } if (envelope->type == "message") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeChatMessage(*doc); if (!event) return std::move(event).error(); return types::RoomEvents::FromMessage(*std::move(event)); } if (envelope->type == "joined") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeMemberJoined(*doc); if (!event) return std::move(event).error(); return types::RoomEvents::FromJoined(*std::move(event)); } if (envelope->type == "left") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeMemberLeft(*doc); if (!event) return std::move(event).error(); return types::RoomEvents::FromLeft(*std::move(event)); } - return smithy::Error::Serialization("Converse: unknown event type: " + envelope->type); + return opal::Error::Serialization("Converse: unknown event type: " + envelope->type); } -smithy::Outcome DecodeWatchEvent(const smithy::eventstream::Message& message) { - auto envelope = smithy::eventstream::ParseEnvelope(message); +opal::Outcome DecodeWatchEvent(const opal::eventstream::Message& message) { + auto envelope = opal::eventstream::ParseEnvelope(message); if (!envelope) return std::move(envelope).error(); - if (envelope->kind == smithy::eventstream::EventEnvelope::Kind::kException) { + if (envelope->kind == opal::eventstream::EventEnvelope::Kind::kException) { // A received exception is terminal (ADR-0016): the EventStream closes the // session and surfaces this error, exactly the unary shape. ParsedError parsed; parsed.code = helpers::SanitizeErrorCode(envelope->type); - auto exception_doc = smithy::json::Decode(envelope->payload.ToString()); + auto exception_doc = opal::json::Decode(envelope->payload.ToString()); if (exception_doc.ok() && exception_doc->is_map()) { parsed.doc = *std::move(exception_doc); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } return helpers::GenericError(std::move(parsed)); } if (envelope->type == "message") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeChatMessage(*doc); if (!event) return std::move(event).error(); return types::RoomEvents::FromMessage(*std::move(event)); } if (envelope->type == "joined") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeMemberJoined(*doc); if (!event) return std::move(event).error(); return types::RoomEvents::FromJoined(*std::move(event)); } if (envelope->type == "left") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeMemberLeft(*doc); if (!event) return std::move(event).error(); return types::RoomEvents::FromLeft(*std::move(event)); } - return smithy::Error::Serialization("Watch: unknown event type: " + envelope->type); + return opal::Error::Serialization("Watch: unknown event type: " + envelope->type); } } // namespace helpers } // namespace -smithy::Outcome ChatClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome ChatClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { // The built-in socket transport is plaintext-only; https needs a - // TLS-capable transport (e.g. smithy::http::BeastHttpClient). + // TLS-capable transport (e.g. opal::http::BeastHttpClient). if (endpoint->tls()) { - return smithy::Error::Validation("ChatClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + return opal::Error::Validation("ChatClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); } - transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); } } if (transport == nullptr) { - return smithy::Error::Validation("ChatClient: config needs an endpoint or an http_client"); + return opal::Error::Validation("ChatClient: config needs an endpoint or an http_client"); } return ChatClient(std::move(config), std::move(transport), std::move(prefix)); } -ChatClient::ChatClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix) +ChatClient::ChatClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} -smithy::Outcome ChatClient::Send(smithy::http::HttpRequest request) const { +opal::Outcome ChatClient::Send(opal::http::HttpRequest request) const { // Operations with a non-document response payload set their own accept. if (!request.headers.Get("accept").has_value()) request.headers.Set("accept", "application/json"); request.headers.Set("user-agent", config_.user_agent); if (!request.body.empty()) { request.headers.Set("content-length", std::to_string(request.body.size())); } - return smithy::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); + return opal::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); } -smithy::Outcome ChatClient::Converse(const ConverseInput& input) const { +opal::Outcome ChatClient::Converse(const ConverseInput& input) const { std::string target = path_prefix_; target += "/rooms"; target += "/"; - target += smithy::http::EncodePathSegment(input.room); + target += opal::http::EncodePathSegment(input.room); target += "/converse"; - smithy::http::WebSocketDialRequest request; + opal::http::WebSocketDialRequest request; request.target = std::move(target); if (input.nickname.has_value()) { request.headers.Set("x-chat-nickname", (*input.nickname)); @@ -290,28 +290,28 @@ smithy::Outcome ChatClient::Converse(const ConverseInput& return ConverseClientStream(*std::move(socket), helpers::EncodeConverseEvent, helpers::DecodeConverseEvent); } -smithy::Outcome ChatClient::ListRooms(const ListRoomsInput& input) const { +opal::Outcome ChatClient::ListRooms(const ListRoomsInput& input) const { (void)input; std::string target = path_prefix_; target += "/rooms"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializeListRoomsOutput(*body_doc); } -smithy::Outcome ChatClient::Watch(const WatchInput& input) const { +opal::Outcome ChatClient::Watch(const WatchInput& input) const { std::string target = path_prefix_; target += "/rooms"; target += "/"; - target += smithy::http::EncodePathSegment(input.room); + target += opal::http::EncodePathSegment(input.room); target += "/watch"; - smithy::http::WebSocketDialRequest request; + opal::http::WebSocketDialRequest request; request.target = std::move(target); request.headers.Set("user-agent", config_.user_agent); auto socket = helpers::DialStream(config_, std::move(request)); diff --git a/examples/chat/generated/src/serde.cc b/examples/chat/generated/src/serde.cc index d328c0e0..d009702b 100644 --- a/examples/chat/generated/src/serde.cc +++ b/examples/chat/generated/src/serde.cc @@ -10,22 +10,22 @@ namespace example::chat { namespace types = ::example::chat; -smithy::Document SerializeLeaveNotice(const LeaveNotice& value) { - smithy::DocumentMap map; +opal::Document SerializeLeaveNotice(const LeaveNotice& value) { + opal::DocumentMap map; if (value.reason.has_value()) { - map.emplace("reason", smithy::Document((*value.reason))); + map.emplace("reason", opal::Document((*value.reason))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeLeaveNotice(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("LeaveNotice: expected a map on the wire"); +opal::Outcome DeserializeLeaveNotice(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("LeaveNotice: expected a map on the wire"); LeaveNotice out; { - const smithy::Document* member = doc.Find("reason"); + const opal::Document* member = doc.Find("reason"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("LeaveNotice.reason: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("LeaveNotice.reason: unexpected type on the wire"); parsed_member = member->as_string(); out.reason = std::move(parsed_member); } @@ -33,31 +33,31 @@ smithy::Outcome DeserializeLeaveNotice(const smithy::Document& doc) return out; } -smithy::Document SerializeChatMessage(const ChatMessage& value) { - smithy::DocumentMap map; - map.emplace("text", smithy::Document(value.text)); +opal::Document SerializeChatMessage(const ChatMessage& value) { + opal::DocumentMap map; + map.emplace("text", opal::Document(value.text)); if (value.sender.has_value()) { - map.emplace("sender", smithy::Document((*value.sender))); + map.emplace("sender", opal::Document((*value.sender))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeChatMessage(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ChatMessage: expected a map on the wire"); +opal::Outcome DeserializeChatMessage(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ChatMessage: expected a map on the wire"); ChatMessage out; { - const smithy::Document* member = doc.Find("text"); + const opal::Document* member = doc.Find("text"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("ChatMessage: missing required member: text"); + return opal::Error::Serialization("ChatMessage: missing required member: text"); } - if (!member->is_string()) return smithy::Error::Serialization("ChatMessage.text: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ChatMessage.text: unexpected type on the wire"); out.text = member->as_string(); } { - const smithy::Document* member = doc.Find("sender"); + const opal::Document* member = doc.Find("sender"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("ChatMessage.sender: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ChatMessage.sender: unexpected type on the wire"); parsed_member = member->as_string(); out.sender = std::move(parsed_member); } @@ -65,21 +65,21 @@ smithy::Outcome DeserializeChatMessage(const smithy::Document& doc) return out; } -smithy::Document SerializeChatEvents(const ChatEvents& value) { - smithy::DocumentMap map; +opal::Document SerializeChatEvents(const ChatEvents& value) { + opal::DocumentMap map; if (value.is_message()) { map.emplace("message", SerializeChatMessage(value.as_message())); } if (value.is_leave()) { map.emplace("leave", SerializeLeaveNotice(value.as_leave())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeChatEvents(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ChatEvents: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("ChatEvents: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("message"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeChatEvents(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ChatEvents: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("ChatEvents: expected exactly one union member"); + if (const opal::Document* member = doc.Find("message"); member != nullptr && !member->is_null()) { ChatMessage parsed_member{}; { auto parsed = DeserializeChatMessage(*member); @@ -88,7 +88,7 @@ smithy::Outcome DeserializeChatEvents(const smithy::Document& doc) { } return ChatEvents::FromMessage(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("leave"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("leave"); member != nullptr && !member->is_null()) { LeaveNotice parsed_member{}; { auto parsed = DeserializeLeaveNotice(*member); @@ -97,43 +97,43 @@ smithy::Outcome DeserializeChatEvents(const smithy::Document& doc) { } return ChatEvents::FromLeave(std::move(parsed_member)); } - return smithy::Error::Serialization("ChatEvents: unknown or missing union member"); + return opal::Error::Serialization("ChatEvents: unknown or missing union member"); } -smithy::Document SerializeConverseInput(const ConverseInput& value) { - smithy::DocumentMap map; - map.emplace("room", smithy::Document(value.room)); +opal::Document SerializeConverseInput(const ConverseInput& value) { + opal::DocumentMap map; + map.emplace("room", opal::Document(value.room)); if (value.nickname.has_value()) { - map.emplace("nickname", smithy::Document((*value.nickname))); + map.emplace("nickname", opal::Document((*value.nickname))); } if (value.events.has_value()) { map.emplace("events", SerializeChatEvents((*value.events))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeConverseInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ConverseInput: expected a map on the wire"); +opal::Outcome DeserializeConverseInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ConverseInput: expected a map on the wire"); ConverseInput out; { - const smithy::Document* member = doc.Find("room"); + const opal::Document* member = doc.Find("room"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("ConverseInput: missing required member: room"); + return opal::Error::Serialization("ConverseInput: missing required member: room"); } - if (!member->is_string()) return smithy::Error::Serialization("ConverseInput.room: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ConverseInput.room: unexpected type on the wire"); out.room = member->as_string(); } { - const smithy::Document* member = doc.Find("nickname"); + const opal::Document* member = doc.Find("nickname"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("ConverseInput.nickname: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ConverseInput.nickname: unexpected type on the wire"); parsed_member = member->as_string(); out.nickname = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("events"); + const opal::Document* member = doc.Find("events"); if (member != nullptr && !member->is_null()) { types::ChatEvents parsed_member{}; { @@ -147,48 +147,48 @@ smithy::Outcome DeserializeConverseInput(const smithy::Document& return out; } -smithy::Document SerializeMemberJoined(const MemberJoined& value) { - smithy::DocumentMap map; - map.emplace("member", smithy::Document(value.member)); - return smithy::Document(std::move(map)); +opal::Document SerializeMemberJoined(const MemberJoined& value) { + opal::DocumentMap map; + map.emplace("member", opal::Document(value.member)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeMemberJoined(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("MemberJoined: expected a map on the wire"); +opal::Outcome DeserializeMemberJoined(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("MemberJoined: expected a map on the wire"); MemberJoined out; { - const smithy::Document* member = doc.Find("member"); + const opal::Document* member = doc.Find("member"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("MemberJoined: missing required member: member"); + return opal::Error::Serialization("MemberJoined: missing required member: member"); } - if (!member->is_string()) return smithy::Error::Serialization("MemberJoined.member: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("MemberJoined.member: unexpected type on the wire"); out.member = member->as_string(); } return out; } -smithy::Document SerializeMemberLeft(const MemberLeft& value) { - smithy::DocumentMap map; - map.emplace("member", smithy::Document(value.member)); - return smithy::Document(std::move(map)); +opal::Document SerializeMemberLeft(const MemberLeft& value) { + opal::DocumentMap map; + map.emplace("member", opal::Document(value.member)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeMemberLeft(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("MemberLeft: expected a map on the wire"); +opal::Outcome DeserializeMemberLeft(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("MemberLeft: expected a map on the wire"); MemberLeft out; { - const smithy::Document* member = doc.Find("member"); + const opal::Document* member = doc.Find("member"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("MemberLeft: missing required member: member"); + return opal::Error::Serialization("MemberLeft: missing required member: member"); } - if (!member->is_string()) return smithy::Error::Serialization("MemberLeft.member: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("MemberLeft.member: unexpected type on the wire"); out.member = member->as_string(); } return out; } -smithy::Document SerializeRoomEvents(const RoomEvents& value) { - smithy::DocumentMap map; +opal::Document SerializeRoomEvents(const RoomEvents& value) { + opal::DocumentMap map; if (value.is_message()) { map.emplace("message", SerializeChatMessage(value.as_message())); } @@ -198,13 +198,13 @@ smithy::Document SerializeRoomEvents(const RoomEvents& value) { if (value.is_left()) { map.emplace("left", SerializeMemberLeft(value.as_left())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRoomEvents(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RoomEvents: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("RoomEvents: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("message"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeRoomEvents(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RoomEvents: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("RoomEvents: expected exactly one union member"); + if (const opal::Document* member = doc.Find("message"); member != nullptr && !member->is_null()) { ChatMessage parsed_member{}; { auto parsed = DeserializeChatMessage(*member); @@ -213,7 +213,7 @@ smithy::Outcome DeserializeRoomEvents(const smithy::Document& doc) { } return RoomEvents::FromMessage(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("joined"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("joined"); member != nullptr && !member->is_null()) { MemberJoined parsed_member{}; { auto parsed = DeserializeMemberJoined(*member); @@ -222,7 +222,7 @@ smithy::Outcome DeserializeRoomEvents(const smithy::Document& doc) { } return RoomEvents::FromJoined(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("left"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("left"); member != nullptr && !member->is_null()) { MemberLeft parsed_member{}; { auto parsed = DeserializeMemberLeft(*member); @@ -231,22 +231,22 @@ smithy::Outcome DeserializeRoomEvents(const smithy::Document& doc) { } return RoomEvents::FromLeft(std::move(parsed_member)); } - return smithy::Error::Serialization("RoomEvents: unknown or missing union member"); + return opal::Error::Serialization("RoomEvents: unknown or missing union member"); } -smithy::Document SerializeConverseOutput(const ConverseOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeConverseOutput(const ConverseOutput& value) { + opal::DocumentMap map; if (value.events.has_value()) { map.emplace("events", SerializeRoomEvents((*value.events))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeConverseOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ConverseOutput: expected a map on the wire"); +opal::Outcome DeserializeConverseOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ConverseOutput: expected a map on the wire"); ConverseOutput out; { - const smithy::Document* member = doc.Find("events"); + const opal::Document* member = doc.Find("events"); if (member != nullptr && !member->is_null()) { types::RoomEvents parsed_member{}; { @@ -260,95 +260,95 @@ smithy::Outcome DeserializeConverseOutput(const smithy::Document return out; } -smithy::Document SerializeKicked(const Kicked& value) { - smithy::DocumentMap map; +opal::Document SerializeKicked(const Kicked& value) { + opal::DocumentMap map; if (value.message.has_value()) { - map.emplace("message", smithy::Document((*value.message))); + map.emplace("message", opal::Document((*value.message))); } - map.emplace("by", smithy::Document(value.by)); - return smithy::Document(std::move(map)); + map.emplace("by", opal::Document(value.by)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeKicked(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Kicked: expected a map on the wire"); +opal::Outcome DeserializeKicked(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Kicked: expected a map on the wire"); Kicked out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("Kicked.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Kicked.message: unexpected type on the wire"); parsed_member = member->as_string(); out.message = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("by"); + const opal::Document* member = doc.Find("by"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Kicked: missing required member: by"); + return opal::Error::Serialization("Kicked: missing required member: by"); } - if (!member->is_string()) return smithy::Error::Serialization("Kicked.by: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Kicked.by: unexpected type on the wire"); out.by = member->as_string(); } return out; } -smithy::Document SerializeListRoomsInput(const ListRoomsInput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeListRoomsInput(const ListRoomsInput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeListRoomsInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ListRoomsInput: expected a map on the wire"); +opal::Outcome DeserializeListRoomsInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ListRoomsInput: expected a map on the wire"); ListRoomsInput out; return out; } -smithy::Document SerializeRoomSummary(const RoomSummary& value) { - smithy::DocumentMap map; - map.emplace("name", smithy::Document(value.name)); - map.emplace("members", smithy::Document(static_cast(value.members))); - return smithy::Document(std::move(map)); +opal::Document SerializeRoomSummary(const RoomSummary& value) { + opal::DocumentMap map; + map.emplace("name", opal::Document(value.name)); + map.emplace("members", opal::Document(static_cast(value.members))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRoomSummary(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RoomSummary: expected a map on the wire"); +opal::Outcome DeserializeRoomSummary(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RoomSummary: expected a map on the wire"); RoomSummary out; { - const smithy::Document* member = doc.Find("name"); + const opal::Document* member = doc.Find("name"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("RoomSummary: missing required member: name"); + return opal::Error::Serialization("RoomSummary: missing required member: name"); } - if (!member->is_string()) return smithy::Error::Serialization("RoomSummary.name: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RoomSummary.name: unexpected type on the wire"); out.name = member->as_string(); } { - const smithy::Document* member = doc.Find("members"); + const opal::Document* member = doc.Find("members"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("RoomSummary: missing required member: members"); + return opal::Error::Serialization("RoomSummary: missing required member: members"); } - if (!member->is_int()) return smithy::Error::Serialization("RoomSummary.members: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("RoomSummary.members: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("RoomSummary.members: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("RoomSummary.members: value out of range"); out.members = static_cast(member->as_int()); } return out; } -smithy::Document SerializeRoomSummaries(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeRoomSummaries(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { list.push_back(SerializeRoomSummary(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeRoomSummaries(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeRoomSummaries(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); RoomSummary parsed_item{}; { auto parsed = DeserializeRoomSummary(*item); @@ -360,19 +360,19 @@ smithy::Outcome> DeserializeRoomSummaries(const smithy: return out; } -smithy::Document SerializeListRoomsOutput(const ListRoomsOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeListRoomsOutput(const ListRoomsOutput& value) { + opal::DocumentMap map; map.emplace("rooms", SerializeRoomSummaries(value.rooms)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeListRoomsOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ListRoomsOutput: expected a map on the wire"); +opal::Outcome DeserializeListRoomsOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ListRoomsOutput: expected a map on the wire"); ListRoomsOutput out; { - const smithy::Document* member = doc.Find("rooms"); + const opal::Document* member = doc.Find("rooms"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("ListRoomsOutput: missing required member: rooms"); + return opal::Error::Serialization("ListRoomsOutput: missing required member: rooms"); } { auto parsed = DeserializeRoomSummaries(*member); @@ -383,39 +383,39 @@ smithy::Outcome DeserializeListRoomsOutput(const smithy::Docume return out; } -smithy::Document SerializeWatchInput(const WatchInput& value) { - smithy::DocumentMap map; - map.emplace("room", smithy::Document(value.room)); - return smithy::Document(std::move(map)); +opal::Document SerializeWatchInput(const WatchInput& value) { + opal::DocumentMap map; + map.emplace("room", opal::Document(value.room)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeWatchInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("WatchInput: expected a map on the wire"); +opal::Outcome DeserializeWatchInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("WatchInput: expected a map on the wire"); WatchInput out; { - const smithy::Document* member = doc.Find("room"); + const opal::Document* member = doc.Find("room"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("WatchInput: missing required member: room"); + return opal::Error::Serialization("WatchInput: missing required member: room"); } - if (!member->is_string()) return smithy::Error::Serialization("WatchInput.room: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("WatchInput.room: unexpected type on the wire"); out.room = member->as_string(); } return out; } -smithy::Document SerializeWatchOutput(const WatchOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeWatchOutput(const WatchOutput& value) { + opal::DocumentMap map; if (value.events.has_value()) { map.emplace("events", SerializeRoomEvents((*value.events))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeWatchOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("WatchOutput: expected a map on the wire"); +opal::Outcome DeserializeWatchOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("WatchOutput: expected a map on the wire"); WatchOutput out; { - const smithy::Document* member = doc.Find("events"); + const opal::Document* member = doc.Find("events"); if (member != nullptr && !member->is_null()) { types::RoomEvents parsed_member{}; { diff --git a/examples/chat/generated/src/server.cc b/examples/chat/generated/src/server.cc index ab632a58..0d4d404e 100644 --- a/examples/chat/generated/src/server.cc +++ b/examples/chat/generated/src/server.cc @@ -35,18 +35,18 @@ namespace helpers { // emitted for every service; not every service binds numeric values). // Trailing text, floats-for-ints, and out-of-range values are rejected // (the malformed-request suites pin this). -[[maybe_unused]] smithy::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { +[[maybe_unused]] opal::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { std::int64_t value = 0; const char* first = text.data(); const char* last = first + text.size(); const auto result = std::from_chars(first, last, value, 10); if (text.empty() || result.ec != std::errc() || result.ptr != last || value < min_value || value > max_value) { - return smithy::Error::Serialization("invalid integer: " + text); + return opal::Error::Serialization("invalid integer: " + text); } return value; } -[[maybe_unused]] smithy::Outcome ParseDoubleText(const std::string& text) { +[[maybe_unused]] opal::Outcome ParseDoubleText(const std::string& text) { if (text == "NaN") return std::numeric_limits::quiet_NaN(); if (text == "Infinity") return std::numeric_limits::infinity(); if (text == "-Infinity") return -std::numeric_limits::infinity(); @@ -54,12 +54,12 @@ namespace helpers { return (c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' || c == '+' || c == '-'; }; if (text.empty() || text.front() == '+' || !std::all_of(text.begin(), text.end(), valid_char)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } char* parse_end = nullptr; const double value = std::strtod(text.c_str(), &parse_end); if (parse_end != text.c_str() + text.size() || !std::isfinite(value)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } return value; } @@ -70,31 +70,31 @@ namespace helpers { return status >= 200 && status != 204 && status != 205 && status != 304; } -smithy::http::HttpResponse JsonError(int status, const std::string& code, const std::string& message, smithy::DocumentMap body) { - if (!code.empty()) body.insert_or_assign("__type", smithy::Document(code)); - if (!message.empty()) body.insert_or_assign("message", smithy::Document(message)); - smithy::http::HttpResponse response; +opal::http::HttpResponse JsonError(int status, const std::string& code, const std::string& message, opal::DocumentMap body) { + if (!code.empty()) body.insert_or_assign("__type", opal::Document(code)); + if (!message.empty()) body.insert_or_assign("message", opal::Document(message)); + opal::http::HttpResponse response; response.status = status; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body))); + response.body = opal::json::Encode(opal::Document(std::move(body))); return response; } // [[maybe_unused]]: only unary routes map handler errors here; a service // whose operations all stream reports errors on the stream instead. -[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& error) { +[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& error) { std::vector> header_values; (void)header_values; - if (error.kind() == smithy::ErrorKind::kModeled) { + if (error.kind() == opal::ErrorKind::kModeled) { if (error.code() == "Kicked") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeKicked(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } auto response = helpers::JsonError(403, "", "", std::move(body)); response.headers.Set("x-error-type", error.code()); @@ -103,7 +103,7 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const } return helpers::JsonError(400, error.code(), error.message(), {}); } - if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) { + if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) { auto response = helpers::JsonError(400, "", error.message(), {}); response.headers.Set("x-error-type", "SerializationException"); return response; @@ -112,7 +112,7 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const return helpers::JsonError(500, "InternalFailure", "internal failure", {}); } -smithy::Outcome ParseConverseInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseConverseInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -127,7 +127,7 @@ smithy::Outcome ParseConverseInput(const smithy::http::Htt return input; } -smithy::Outcome ParseListRoomsInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseListRoomsInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -135,18 +135,18 @@ smithy::Outcome ParseListRoomsInput(const smithy::http::H return input; } -smithy::http::HttpResponse BuildListRoomsResponse(const types::ListRoomsOutput& output) { +opal::http::HttpResponse BuildListRoomsResponse(const types::ListRoomsOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; + opal::DocumentMap body_map; body_map.emplace("rooms", SerializeRoomSummaries(output.rooms)); response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseWatchInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseWatchInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -160,52 +160,52 @@ smithy::Outcome ParseWatchInput(const smithy::http::HttpReque // One event per message (ADR-0016): the engaged member's structure is the // payload, its member name the :event-type. -smithy::Outcome EncodeConverseEvent(const types::RoomEvents& event) { +opal::Outcome EncodeConverseEvent(const types::RoomEvents& event) { if (event.is_message()) { - return smithy::eventstream::MakeEventMessage("message", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeChatMessage(event.as_message())))); + return opal::eventstream::MakeEventMessage("message", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeChatMessage(event.as_message())))); } if (event.is_joined()) { - return smithy::eventstream::MakeEventMessage("joined", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeMemberJoined(event.as_joined())))); + return opal::eventstream::MakeEventMessage("joined", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeMemberJoined(event.as_joined())))); } if (event.is_left()) { - return smithy::eventstream::MakeEventMessage("left", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeMemberLeft(event.as_left())))); + return opal::eventstream::MakeEventMessage("left", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeMemberLeft(event.as_left())))); } - return smithy::Error::Validation("RoomEvents: no event member engaged"); + return opal::Error::Validation("RoomEvents: no event member engaged"); } -smithy::Outcome DecodeConverseEvent(const smithy::eventstream::Message& message) { - auto envelope = smithy::eventstream::ParseEnvelope(message); +opal::Outcome DecodeConverseEvent(const opal::eventstream::Message& message) { + auto envelope = opal::eventstream::ParseEnvelope(message); if (!envelope) return std::move(envelope).error(); - if (envelope->kind == smithy::eventstream::EventEnvelope::Kind::kException) { + if (envelope->kind == opal::eventstream::EventEnvelope::Kind::kException) { // Clients send events, never exceptions; treat one as a terminal protocol // violation carrying the peer's claimed identity. - return smithy::Error::Modeled(envelope->type, "peer sent an exception message"); + return opal::Error::Modeled(envelope->type, "peer sent an exception message"); } if (envelope->type == "message") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeChatMessage(*doc); if (!event) return std::move(event).error(); return types::ChatEvents::FromMessage(*std::move(event)); } if (envelope->type == "leave") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeLeaveNotice(*doc); if (!event) return std::move(event).error(); return types::ChatEvents::FromLeave(*std::move(event)); } - return smithy::Error::Serialization("Converse: unknown event type: " + envelope->type); + return opal::Error::Serialization("Converse: unknown event type: " + envelope->type); } // A handler failure ends the stream with one exception message before the // close (ADR-0016). -smithy::eventstream::Message BuildConverseExceptionMessage(const smithy::Error& error) { +opal::eventstream::Message BuildConverseExceptionMessage(const opal::Error& error) { std::string type = "InternalFailure"; // Never leak internal detail on unexpected failures. std::string message = "internal failure"; - smithy::DocumentMap body; - if (error.kind() == smithy::ErrorKind::kModeled) { + opal::DocumentMap body; + if (error.kind() == opal::ErrorKind::kModeled) { type = error.code(); message = error.message(); if (error.code() == "Kicked") { @@ -213,16 +213,16 @@ smithy::eventstream::Message BuildConverseExceptionMessage(const smithy::Error& body = SerializeKicked(*detail).as_map(); } } - } else if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) { + } else if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) { type = "SerializationException"; message = error.message(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !message.empty()) { - body.emplace("message", smithy::Document(std::move(message))); + body.emplace("message", opal::Document(std::move(message))); } - return smithy::eventstream::MakeExceptionMessage(type, "application/json", smithy::Blob::FromString(smithy::json::Encode(smithy::Document(std::move(body))))); + return opal::eventstream::MakeExceptionMessage(type, "application/json", opal::Blob::FromString(opal::json::Encode(opal::Document(std::move(body))))); } // The async route's launch wrapper (ADR-0021): its frame owns the typed @@ -231,56 +231,56 @@ smithy::eventstream::Message BuildConverseExceptionMessage(const smithy::Error& // this frame (and the stream it owns) outlives the write — closing a // busy wire can cancel it. Best-effort, like the blocking route: a send // the terminated session refuses is discarded. -smithy::eventstream::Detached ServeConverseAsync(std::shared_ptr handler, types::ConverseInput input, std::shared_ptr socket) { +opal::eventstream::Detached ServeConverseAsync(std::shared_ptr handler, types::ConverseInput input, std::shared_ptr socket) { types::ConverseAsyncServerStream stream(socket, helpers::EncodeConverseEvent, helpers::DecodeConverseEvent); auto outcome = co_await handler->Converse(std::move(input), stream); if (!outcome.ok()) { - (void)co_await smithy::eventstream::SendMessage(socket, helpers::BuildConverseExceptionMessage(outcome.error())); + (void)co_await opal::eventstream::SendMessage(socket, helpers::BuildConverseExceptionMessage(outcome.error())); } stream.Close(); } // One event per message (ADR-0016): the engaged member's structure is the // payload, its member name the :event-type. -smithy::Outcome EncodeWatchEvent(const types::RoomEvents& event) { +opal::Outcome EncodeWatchEvent(const types::RoomEvents& event) { if (event.is_message()) { - return smithy::eventstream::MakeEventMessage("message", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeChatMessage(event.as_message())))); + return opal::eventstream::MakeEventMessage("message", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeChatMessage(event.as_message())))); } if (event.is_joined()) { - return smithy::eventstream::MakeEventMessage("joined", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeMemberJoined(event.as_joined())))); + return opal::eventstream::MakeEventMessage("joined", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeMemberJoined(event.as_joined())))); } if (event.is_left()) { - return smithy::eventstream::MakeEventMessage("left", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeMemberLeft(event.as_left())))); + return opal::eventstream::MakeEventMessage("left", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeMemberLeft(event.as_left())))); } - return smithy::Error::Validation("RoomEvents: no event member engaged"); + return opal::Error::Validation("RoomEvents: no event member engaged"); } // Watch models no events in this direction: any received message is a // protocol violation and therefore terminal (ADR-0016). -smithy::Outcome DecodeWatchEvent(const smithy::eventstream::Message&) { - return smithy::Error::Serialization("Watch: no events are modeled in this direction"); +opal::Outcome DecodeWatchEvent(const opal::eventstream::Message&) { + return opal::Error::Serialization("Watch: no events are modeled in this direction"); } // A handler failure ends the stream with one exception message before the // close (ADR-0016). -smithy::eventstream::Message BuildWatchExceptionMessage(const smithy::Error& error) { +opal::eventstream::Message BuildWatchExceptionMessage(const opal::Error& error) { std::string type = "InternalFailure"; // Never leak internal detail on unexpected failures. std::string message = "internal failure"; - smithy::DocumentMap body; - if (error.kind() == smithy::ErrorKind::kModeled) { + opal::DocumentMap body; + if (error.kind() == opal::ErrorKind::kModeled) { type = error.code(); message = error.message(); - } else if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) { + } else if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) { type = "SerializationException"; message = error.message(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !message.empty()) { - body.emplace("message", smithy::Document(std::move(message))); + body.emplace("message", opal::Document(std::move(message))); } - return smithy::eventstream::MakeExceptionMessage(type, "application/json", smithy::Blob::FromString(smithy::json::Encode(smithy::Document(std::move(body))))); + return opal::eventstream::MakeExceptionMessage(type, "application/json", opal::Blob::FromString(opal::json::Encode(opal::Document(std::move(body))))); } // The async route's launch wrapper (ADR-0021): its frame owns the typed @@ -289,11 +289,11 @@ smithy::eventstream::Message BuildWatchExceptionMessage(const smithy::Error& err // this frame (and the stream it owns) outlives the write — closing a // busy wire can cancel it. Best-effort, like the blocking route: a send // the terminated session refuses is discarded. -smithy::eventstream::Detached ServeWatchAsync(std::shared_ptr handler, types::WatchInput input, std::shared_ptr socket) { +opal::eventstream::Detached ServeWatchAsync(std::shared_ptr handler, types::WatchInput input, std::shared_ptr socket) { types::WatchAsyncServerStream stream(socket, helpers::EncodeWatchEvent, helpers::DecodeWatchEvent); auto outcome = co_await handler->Watch(std::move(input), stream); if (!outcome.ok()) { - (void)co_await smithy::eventstream::SendMessage(socket, helpers::BuildWatchExceptionMessage(outcome.error())); + (void)co_await opal::eventstream::SendMessage(socket, helpers::BuildWatchExceptionMessage(outcome.error())); } stream.Close(); } @@ -302,12 +302,12 @@ smithy::eventstream::Detached ServeWatchAsync(std::shared_ptr handler) - : router_(std::make_shared()), - stream_router_(std::make_shared()) { + : router_(std::make_shared()), + stream_router_(std::make_shared()) { // The route table is derived from the model's @http traits; conflicts are // a modeling error surfaced by Router::Add (checked at generation time in a // later phase), so registration results are intentionally discarded. - (void)router_->Add("GET", "/rooms", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/rooms", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept @@ -317,12 +317,12 @@ ChatServer::ChatServer(std::shared_ptr handler) error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseListRoomsInput(request, context, &validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); auto outcome = handler->ListRooms(*input, context); @@ -332,8 +332,8 @@ ChatServer::ChatServer(std::shared_ptr handler) // Streaming routes (ADR-0016) live on the WebSocket router; the upgrade // path bypasses the HTTP chain (ADR-0015), so they never collide with // the unary table above. - (void)stream_router_->Add("GET", "/rooms/{room}/converse", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, smithy::http::WebSocket& socket) { - std::vector validation_failures; + (void)stream_router_->Add("GET", "/rooms/{room}/converse", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context, opal::http::WebSocket& socket) { + std::vector validation_failures; auto input = helpers::ParseConverseInput(request, context, &validation_failures); if (!input) { (void)socket.Send(helpers::BuildConverseExceptionMessage(input.error())); @@ -347,8 +347,8 @@ ChatServer::ChatServer(std::shared_ptr handler) } stream.Close(); }, "Converse"); - (void)stream_router_->Add("GET", "/rooms/{room}/watch", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, smithy::http::WebSocket& socket) { - std::vector validation_failures; + (void)stream_router_->Add("GET", "/rooms/{room}/watch", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context, opal::http::WebSocket& socket) { + std::vector validation_failures; auto input = helpers::ParseWatchInput(request, context, &validation_failures); if (!input) { (void)socket.Send(helpers::BuildWatchExceptionMessage(input.error())); @@ -365,12 +365,12 @@ ChatServer::ChatServer(std::shared_ptr handler) } ChatServer::ChatServer(std::shared_ptr handler) - : router_(std::make_shared()), - stream_router_(std::make_shared()) { + : router_(std::make_shared()), + stream_router_(std::make_shared()) { // The same unary table; every streaming route rides the shared-session // seam (ADR-0021) — an AddSession launch point per operation, so serving // a stream parks no handler thread. - (void)router_->Add("GET", "/rooms", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/rooms", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept @@ -380,20 +380,20 @@ ChatServer::ChatServer(std::shared_ptr handler) error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseListRoomsInput(request, context, &validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); auto outcome = handler->ListRooms(*input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); return helpers::BuildListRoomsResponse(*outcome); }, "ListRooms"); - (void)stream_router_->AddSession("GET", "/rooms/{room}/converse", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::shared_ptr socket) { - std::vector validation_failures; + (void)stream_router_->AddSession("GET", "/rooms/{room}/converse", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::shared_ptr socket) { + std::vector validation_failures; auto input = helpers::ParseConverseInput(request, context, &validation_failures); if (!input) { (void)socket->Send(helpers::BuildConverseExceptionMessage(input.error())); @@ -402,8 +402,8 @@ ChatServer::ChatServer(std::shared_ptr handler) } helpers::ServeConverseAsync(handler, *std::move(input), std::move(socket)); }, "Converse"); - (void)stream_router_->AddSession("GET", "/rooms/{room}/watch", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::shared_ptr socket) { - std::vector validation_failures; + (void)stream_router_->AddSession("GET", "/rooms/{room}/watch", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::shared_ptr socket) { + std::vector validation_failures; auto input = helpers::ParseWatchInput(request, context, &validation_failures); if (!input) { (void)socket->Send(helpers::BuildWatchExceptionMessage(input.error())); @@ -414,12 +414,12 @@ ChatServer::ChatServer(std::shared_ptr handler) }, "Watch"); } -smithy::http::RequestHandler ChatServer::Handler() const { +opal::http::RequestHandler ChatServer::Handler() const { auto router = router_; - return [router](const smithy::http::HttpRequest& request) { return router->Route(request); }; + return [router](const opal::http::HttpRequest& request) { return router->Route(request); }; } -std::shared_ptr ChatServer::StreamRouter() const { +std::shared_ptr ChatServer::StreamRouter() const { return stream_router_; } diff --git a/examples/chat/generated/tests/integration_test.cc b/examples/chat/generated/tests/integration_test.cc index 76a5b045..2fffd276 100644 --- a/examples/chat/generated/tests/integration_test.cc +++ b/examples/chat/generated/tests/integration_test.cc @@ -169,25 +169,25 @@ class ScriptedHandler final : public ChatHandler { public: // Streaming operation (ADR-0016): no generated unary-shaped test drives // this; the stub closes the stream so the interface stays implemented. - smithy::Outcome Converse(const ConverseInput& input, ConverseServerStream& stream, const smithy::server::RequestContext&) override { + opal::Outcome Converse(const ConverseInput& input, ConverseServerStream& stream, const opal::server::RequestContext&) override { (void)input; stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } - smithy::Outcome ListRooms(const ListRoomsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome ListRooms(const ListRoomsInput& input, const opal::server::RequestContext&) override { lastListRooms = input; if (nextListRoomsError.has_value()) return *nextListRoomsError; return nextListRoomsOutput; } std::optional lastListRooms; ListRoomsOutput nextListRoomsOutput{}; - std::optional nextListRoomsError; + std::optional nextListRoomsError; // Streaming operation (ADR-0016): no generated unary-shaped test drives // this; the stub closes the stream so the interface stays implemented. - smithy::Outcome Watch(const WatchInput& input, WatchServerStream& stream, const smithy::server::RequestContext&) override { + opal::Outcome Watch(const WatchInput& input, WatchServerStream& stream, const opal::server::RequestContext&) override { (void)input; stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } }; @@ -198,14 +198,14 @@ class ChatIntegrationTest : public ::testing::TestWithParam { void SetUp() override { handler_ = std::make_shared(); server_ = std::make_unique(handler_); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries if (GetParam() == TransportKind::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); config.http_client = loopback; } else { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(server_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } @@ -218,7 +218,7 @@ class ChatIntegrationTest : public ::testing::TestWithParam { std::shared_ptr handler_; std::unique_ptr server_; - std::unique_ptr socket_server_; + std::unique_ptr socket_server_; std::unique_ptr client_; }; @@ -251,17 +251,17 @@ TEST_P(ChatIntegrationTest, ListRoomsMaximalRoundTrips) { TEST(ChatIntegrationUnknownMembers, ListRoomsToleratesUnknownResponseMembers) { auto handler = std::make_shared(); ChatServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *ChatClient::Create(std::move(config)); diff --git a/examples/chat/generated/tests/smoke_test.cc b/examples/chat/generated/tests/smoke_test.cc index e04fc637..b907529b 100644 --- a/examples/chat/generated/tests/smoke_test.cc +++ b/examples/chat/generated/tests/smoke_test.cc @@ -29,29 +29,29 @@ class SmokeHandler : public ChatHandler { public: // Streaming operation (ADR-0016): no generated unary-shaped test drives // this; the stub closes the stream so the interface stays implemented. - smithy::Outcome Converse(const ConverseInput& input, ConverseServerStream& stream, const smithy::server::RequestContext&) override { + opal::Outcome Converse(const ConverseInput& input, ConverseServerStream& stream, const opal::server::RequestContext&) override { (void)input; stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } - smithy::Outcome ListRooms(const ListRoomsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome ListRooms(const ListRoomsInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalListRoomsOutput(); } // Streaming operation (ADR-0016): no generated unary-shaped test drives // this; the stub closes the stream so the interface stays implemented. - smithy::Outcome Watch(const WatchInput& input, WatchServerStream& stream, const smithy::server::RequestContext&) override { + opal::Outcome Watch(const WatchInput& input, WatchServerStream& stream, const opal::server::RequestContext&) override { (void)input; stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } }; ChatClient MakeClient(std::shared_ptr handler) { ChatServer server(std::move(handler)); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = loopback; // Create cannot fail when a transport is injected. diff --git a/examples/chat/hub_client_main.cc b/examples/chat/hub_client_main.cc index b0aa7f00..1a2512db 100644 --- a/examples/chat/hub_client_main.cc +++ b/examples/chat/hub_client_main.cc @@ -39,9 +39,7 @@ namespace { // One line out, flushed — the shell test reads these through a pipe. void Emit(const std::string& line) { std::cout << line << "\n" << std::flush; } -void EmitError(const smithy::Error& error) { - Emit("error " + error.code() + ": " + error.message()); -} +void EmitError(const opal::Error& error) { Emit("error " + error.code() + ": " + error.message()); } void PrintEvent(const example::chat::RoomEvents& event) { if (event.is_joined()) { @@ -81,7 +79,7 @@ int Run(int argc, char** argv) { const std::string room = argv[2]; const std::string name = argv[3]; - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; config.endpoint = "http://127.0.0.1:" + std::to_string(port); auto client = example::chat::ChatClient::Create(std::move(config)); diff --git a/examples/chat/hub_e2e_test.cc b/examples/chat/hub_e2e_test.cc index 91481d9d..c3f49b79 100644 --- a/examples/chat/hub_e2e_test.cc +++ b/examples/chat/hub_e2e_test.cc @@ -162,7 +162,7 @@ TEST_F(HubEndToEndTest, ANicknameCollisionIsRefusedWithTheTypedError) { ASSERT_TRUE(impostor.ok()) << impostor.error().message(); auto outcome = impostor->Receive(); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "Kicked"); const Kicked* detail = outcome.error().detail(); ASSERT_NE(detail, nullptr); @@ -243,7 +243,7 @@ TEST_F(HubEndToEndTest, ASlowConsumerIsDisconnectedNotWaitedFor) { // ada floods; sloth never reads. Reading each round's own echo asserts // liveness and keeps ada's wire drained; the hub's left-announcement for // the disconnected sloth interleaves whenever the policy fires. - constexpr int kFlood = 5 * smithy::http::InMemoryWebSocketPair::kQueueDepth; + constexpr int kFlood = 5 * opal::http::InMemoryWebSocketPair::kQueueDepth; bool sloth_left = false; for (int i = 0; i < kFlood; ++i) { ASSERT_TRUE(ada.Send(Say("tick-" + std::to_string(i))).ok()); diff --git a/examples/chat/hub_handler.h b/examples/chat/hub_handler.h index 983db431..eb4329b8 100644 --- a/examples/chat/hub_handler.h +++ b/examples/chat/hub_handler.h @@ -4,7 +4,7 @@ // The multi-client hub (issue #112): the consumer pattern the Go-style // WebSocket hub hand-rolls, built on the two runtime primitives that make // it safe and short — owning session handles (EventStream::Share) and the -// queued fan-out registry (smithy::server::SessionRegistry). Every session +// queued fan-out registry (opal::server::SessionRegistry). Every session // registers its handle under a SessionKey id; room traffic fans out through // the registry's bounded per-session queues, so one slow client never // stalls a room (the default policy disconnects it instead); and shutdown @@ -55,15 +55,15 @@ struct SessionKey { class HubHandler final : public ChatHandler { public: - using Registry = smithy::server::SessionRegistry; + using Registry = opal::server::SessionRegistry; HubHandler() = default; explicit HubHandler(Registry::Options options) : registry_(std::move(options)) {} // The unary neighbor reports live occupancy straight from the registry: // one converse member per id (watchers observe without counting). - smithy::Outcome ListRooms(const ListRoomsInput&, - const smithy::server::RequestContext&) override { + opal::Outcome ListRooms(const ListRoomsInput&, + const opal::server::RequestContext&) override { std::map occupancy; for (const std::string& id : registry_.Ids()) { const SessionKey key = SessionKey::Parse(id); @@ -76,8 +76,8 @@ class HubHandler final : public ChatHandler { return output; } - smithy::Outcome Converse(const ConverseInput& input, ConverseServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Converse(const ConverseInput& input, ConverseServerStream& stream, + const opal::server::RequestContext&) override { const SessionKey key{.room = input.room, .name = input.nickname.value_or("anonymous")}; const std::string id = key.Id(); @@ -85,7 +85,7 @@ class HubHandler final : public ChatHandler { // Add's atomicity doubles as the nickname reservation. if (!registry_.Add(id, stream.Share())) { const std::string reason = "nickname '" + key.name + "' is already in " + key.room; - smithy::Error taken = smithy::Error::Modeled("Kicked", reason); + opal::Error taken = opal::Error::Modeled("Kicked", reason); taken.set_detail(Kicked{.message = reason, .by = "hub"}); return taken; // one typed exception message, then the close } @@ -118,11 +118,11 @@ class HubHandler final : public ChatHandler { registry_.Remove(id); registry_.Broadcast(RoomIds(key), RoomEvents::FromLeft(MemberLeft{.member = key.name})); if (left_cleanly) (void)stream.Send(RoomEvents::FromLeft(MemberLeft{.member = key.name})); - return smithy::Unit{}; // the generated caller closes the session + return opal::Unit{}; // the generated caller closes the session } - smithy::Outcome Watch(const WatchInput& input, WatchServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Watch(const WatchInput& input, WatchServerStream& stream, + const opal::server::RequestContext&) override { // Watchers hold the same handle type as conversers (both directions // transmit RoomEvents), so one registry fans out to both. const SessionKey key{.room = input.room, .name = "#watch-" + std::to_string(++next_watcher_)}; @@ -131,7 +131,7 @@ class HubHandler final : public ChatHandler { // wire failure, or the hub closing the session (drain / slow-consumer). (void)stream.Receive(); registry_.Remove(key.Id()); - return smithy::Unit{}; + return opal::Unit{}; } // The graceful-shutdown step (issue #112 proposal 3), for main() to run diff --git a/examples/chat/hub_server_main.cc b/examples/chat/hub_server_main.cc index ebd3d2df..058924d4 100644 --- a/examples/chat/hub_server_main.cc +++ b/examples/chat/hub_server_main.cc @@ -30,13 +30,13 @@ int main(int argc, char** argv) { auto handler = std::make_shared(); example::chat::ChatServer server(handler); - smithy::http::BeastServerTransport::Options options; + opal::http::BeastServerTransport::Options options; options.address = "0.0.0.0"; options.port = argc > 1 ? std::atoi(argv[1]) : 8080; // 0 binds an ephemeral port options.websocket_gate = server.StreamRouter()->Gate(); options.on_websocket = server.StreamRouter()->Serve(); - smithy::http::BeastServerTransport transport(options); - smithy::Outcome started = transport.Start(server.Handler()); + opal::http::BeastServerTransport transport(options); + opal::Outcome started = transport.Start(server.Handler()); if (!started.ok()) { std::fprintf(stderr, "chat-hub: start failed: %s\n", started.error().message().c_str()); return 1; diff --git a/examples/chat/room_handler.h b/examples/chat/room_handler.h index f95bffa8..20c4968f 100644 --- a/examples/chat/room_handler.h +++ b/examples/chat/room_handler.h @@ -18,54 +18,54 @@ inline constexpr char kModerator[] = "moderator"; class RoomHandler final : public ChatHandler { public: - smithy::Outcome ListRooms(const ListRoomsInput&, - const smithy::server::RequestContext&) override { + opal::Outcome ListRooms(const ListRoomsInput&, + const opal::server::RequestContext&) override { ListRoomsOutput output; output.rooms.push_back(RoomSummary{.name = "lobby", .members = 2}); return output; } - smithy::Outcome Converse(const ConverseInput& input, ConverseServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Converse(const ConverseInput& input, ConverseServerStream& stream, + const opal::server::RequestContext&) override { // The nickname rode the upgrade request's headers; announce the joiner. MemberJoined joined; joined.member = input.nickname.value_or("anonymous"); - if (!stream.Send(RoomEvents::FromJoined(joined)).ok()) return smithy::Unit{}; + if (!stream.Send(RoomEvents::FromJoined(joined)).ok()) return opal::Unit{}; while (true) { auto event = stream.Receive(); - if (!event.ok()) return smithy::Unit{}; // wire failed: nothing to add - if (!event->has_value()) return smithy::Unit{}; // client closed cleanly + if (!event.ok()) return opal::Unit{}; // wire failed: nothing to add + if (!event->has_value()) return opal::Unit{}; // client closed cleanly const ChatEvents& received = **event; if (received.is_message()) { const ChatMessage& message = received.as_message(); if (message.text == "kick me") { // The modeled mid-stream error: one exception message, then close. - smithy::Error kicked = smithy::Error::Modeled("Kicked", "kicked from " + input.room); + opal::Error kicked = opal::Error::Modeled("Kicked", "kicked from " + input.room); kicked.set_detail(Kicked{.message = "kicked from " + input.room, .by = kModerator}); return kicked; } ChatMessage broadcast; broadcast.text = message.text; broadcast.sender = message.sender.value_or(joined.member); - if (!stream.Send(RoomEvents::FromMessage(broadcast)).ok()) return smithy::Unit{}; + if (!stream.Send(RoomEvents::FromMessage(broadcast)).ok()) return opal::Unit{}; } else if (received.is_leave()) { MemberLeft left; left.member = joined.member; (void)stream.Send(RoomEvents::FromLeft(left)); - return smithy::Unit{}; // the server's side of a clean close + return opal::Unit{}; // the server's side of a clean close } } } - smithy::Outcome Watch(const WatchInput& input, WatchServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Watch(const WatchInput& input, WatchServerStream& stream, + const opal::server::RequestContext&) override { for (int i = 0; i < 3; ++i) { ChatMessage message; message.text = input.room + "-update-" + std::to_string(i); message.sender = "room"; - if (!stream.Send(RoomEvents::FromMessage(message)).ok()) return smithy::Unit{}; + if (!stream.Send(RoomEvents::FromMessage(message)).ok()) return opal::Unit{}; } - return smithy::Unit{}; // push, then close + return opal::Unit{}; // push, then close } }; diff --git a/examples/chat/stream_test_fixture.h b/examples/chat/stream_test_fixture.h index 5ebae88e..d97e68d9 100644 --- a/examples/chat/stream_test_fixture.h +++ b/examples/chat/stream_test_fixture.h @@ -50,17 +50,16 @@ class StreamTestFixture : public testing::Test { void Start(std::unique_ptr server, bool session_seam) { server_ = std::move(server); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; config.http_client = loopback; // the unary neighbor's transport - config.websocket_dialer = [this, - session_seam](const smithy::http::WebSocketDialRequest& request) - -> smithy::Outcome> { + config.websocket_dialer = [this, session_seam](const opal::http::WebSocketDialRequest& request) + -> opal::Outcome> { last_dialed_target_ = request.target; - auto [near, far] = smithy::http::InMemoryWebSocketPair::Create(); - smithy::http::HttpRequest upgrade; + auto [near, far] = opal::http::InMemoryWebSocketPair::Create(); + opal::http::HttpRequest upgrade; upgrade.method = "GET"; upgrade.target = request.target; upgrade.headers = request.headers; @@ -91,7 +90,7 @@ class StreamTestFixture : public testing::Test { std::unique_ptr server_; std::unique_ptr client_; // Every dialed far end — closed in TearDown even when left unserved. - std::vector> sessions_; + std::vector> sessions_; std::vector threads_; std::string last_dialed_target_; // Cleared by a test that wants the dialed pair's far end raw — held in diff --git a/examples/jsonrpc2/accumulate_handler.h b/examples/jsonrpc2/accumulate_handler.h index 1341febd..45287c59 100644 --- a/examples/jsonrpc2/accumulate_handler.h +++ b/examples/jsonrpc2/accumulate_handler.h @@ -18,42 +18,41 @@ namespace example::calculator { inline constexpr double kAccumulateLimit = 100.0; -inline smithy::Error MakeOverflowError() { - smithy::Error overflow = smithy::Error::Modeled("Overflow", "accumulator over the limit"); +inline opal::Error MakeOverflowError() { + opal::Error overflow = opal::Error::Modeled("Overflow", "accumulator over the limit"); overflow.set_detail(Overflow{.message = "accumulator over the limit", .limit = kAccumulateLimit}); return overflow; } class AccumulatingCalculator final : public CalculatorHandler { public: - smithy::Outcome Add(const AddInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Add(const AddInput& input, + const opal::server::RequestContext&) override { return AddOutput{.sum = input.a + input.b}; } - smithy::Outcome Divide(const DivideInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Divide(const DivideInput& input, + const opal::server::RequestContext&) override { if (input.divisor == 0) { - smithy::Error error = smithy::Error::Modeled("DivisionByZero", "division by zero"); + opal::Error error = opal::Error::Modeled("DivisionByZero", "division by zero"); error.set_detail(DivisionByZero{.message = "division by zero"}); return error; } return DivideOutput{.quotient = input.dividend / input.divisor}; } - smithy::Outcome Accumulate(const AccumulateInput& input, - AccumulateServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Accumulate(const AccumulateInput& input, AccumulateServerStream& stream, + const opal::server::RequestContext&) override { double total = input.start.value_or(0.0); while (true) { auto term = stream.Receive(); - if (!term.ok() || !term->has_value()) return smithy::Unit{}; // wire failed or client left + if (!term.ok() || !term->has_value()) return opal::Unit{}; // wire failed or client left const double value = (**term).as_add().value; - if (value == 0) return smithy::Unit{}; // the "=" key: clean end, terminal result + if (value == 0) return opal::Unit{}; // the "=" key: clean end, terminal result total += value; if (total > kAccumulateLimit) return MakeOverflowError(); if (!stream.Send(Totals::FromTotal(RunningTotal{.value = total})).ok()) { - return smithy::Unit{}; + return opal::Unit{}; } } } @@ -61,33 +60,33 @@ class AccumulatingCalculator final : public CalculatorHandler { class AsyncAccumulatingCalculator final : public CalculatorAsyncHandler { public: - smithy::Outcome Add(const AddInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Add(const AddInput& input, + const opal::server::RequestContext&) override { return AddOutput{.sum = input.a + input.b}; } - smithy::Outcome Divide(const DivideInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Divide(const DivideInput& input, + const opal::server::RequestContext&) override { if (input.divisor == 0) { - smithy::Error error = smithy::Error::Modeled("DivisionByZero", "division by zero"); + opal::Error error = opal::Error::Modeled("DivisionByZero", "division by zero"); error.set_detail(DivisionByZero{.message = "division by zero"}); return error; } return DivideOutput{.quotient = input.dividend / input.divisor}; } - smithy::eventstream::StreamTask Accumulate(AccumulateInput input, - AccumulateAsyncServerStream& stream) override { + opal::eventstream::StreamTask Accumulate(AccumulateInput input, + AccumulateAsyncServerStream& stream) override { double total = input.start.value_or(0.0); while (true) { auto term = co_await stream.Receive(); - if (!term.ok() || !term->has_value()) co_return smithy::Unit{}; + if (!term.ok() || !term->has_value()) co_return opal::Unit{}; const double value = (**term).as_add().value; - if (value == 0) co_return smithy::Unit{}; + if (value == 0) co_return opal::Unit{}; total += value; if (total > kAccumulateLimit) co_return MakeOverflowError(); auto sent = co_await stream.Send(Totals::FromTotal(RunningTotal{.value = total})); - if (!sent.ok()) co_return smithy::Unit{}; + if (!sent.ok()) co_return opal::Unit{}; } } }; diff --git a/examples/jsonrpc2/generated/include/example/calculator/client.h b/examples/jsonrpc2/generated/include/example/calculator/client.h index f00c129b..feadd1bc 100644 --- a/examples/jsonrpc2/generated/include/example/calculator/client.h +++ b/examples/jsonrpc2/generated/include/example/calculator/client.h @@ -25,17 +25,17 @@ namespace example::calculator { /// The typed session Accumulate returns (ADR-0016): Tx = what this client /// sends, Rx = what the server sends. -using AccumulateClientStream = smithy::eventstream::EventStream; +using AccumulateClientStream = opal::eventstream::EventStream; /// jsonRpc2 client for example.calculator#Calculator. -/// Modeled service errors surface as smithy::Error with kind kModeled, +/// Modeled service errors surface as opal::Error with kind kModeled, /// code() set to the error shape name, and the deserialized error /// structure attached. Dispatch on them through the per-operation /// Errors listings below rather than comparing code() text. class CalculatorClient { public: /// Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); + static opal::Outcome Create(opal::ClientConfig config); /// A running-total session over the JSON-RPC stream wire (ADR-0023): the /// opening call's params seed the accumulator, each streamed term answers @@ -46,22 +46,22 @@ class CalculatorClient { /// (ADR-0016). Send carries input events, Receive yields output events /// (nullopt on the peer's clean close), and a received exception /// surfaces through Receive() as a modeled error, the unary shape. - smithy::Outcome Accumulate(const AccumulateInput& input) const; + opal::Outcome Accumulate(const AccumulateInput& input) const; /// Adds two numbers. - smithy::Outcome Add(const AddInput& input) const; + opal::Outcome Add(const AddInput& input) const; /// Divides dividend by divisor; dividing by zero is a modeled error. - smithy::Outcome Divide(const DivideInput& input) const; + opal::Outcome Divide(const DivideInput& input) const; private: - CalculatorClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix); - smithy::Outcome Send(smithy::http::HttpRequest request) const; + CalculatorClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix); + opal::Outcome Send(opal::http::HttpRequest request) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; -/// The modeled errors of Accumulate, matched from a smithy::Error so dispatch is +/// The modeled errors of Accumulate, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -72,9 +72,9 @@ class AccumulateErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static AccumulateErrors FromError(const smithy::Error& error) { + static AccumulateErrors FromError(const opal::Error& error) { AccumulateErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "Overflow") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : Overflow{}); @@ -113,7 +113,7 @@ class AccumulateErrors { switch (value_.index()) { case 1: out += "overflow = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -132,14 +132,14 @@ class AccumulateErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("AccumulateErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("AccumulateErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of Divide, matched from a smithy::Error so dispatch is +/// The modeled errors of Divide, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -150,9 +150,9 @@ class DivideErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static DivideErrors FromError(const smithy::Error& error) { + static DivideErrors FromError(const opal::Error& error) { DivideErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "DivisionByZero") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : DivisionByZero{}); @@ -191,7 +191,7 @@ class DivideErrors { switch (value_.index()) { case 1: out += "division_by_zero = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -210,7 +210,7 @@ class DivideErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("DivideErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("DivideErrors", requested, case_name()); } } @@ -227,8 +227,8 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::AccumulateErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -236,8 +236,8 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::DivideErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; diff --git a/examples/jsonrpc2/generated/include/example/calculator/serde.h b/examples/jsonrpc2/generated/include/example/calculator/serde.h index 387982ff..38eaff64 100644 --- a/examples/jsonrpc2/generated/include/example/calculator/serde.h +++ b/examples/jsonrpc2/generated/include/example/calculator/serde.h @@ -10,44 +10,44 @@ namespace example::calculator { // Document-pivot serde for every aggregate shape in the model closure. -// Serializers never fail; deserializers return smithy::Error on wire +// Serializers never fail; deserializers return opal::Error on wire // mismatches and enforce @required members. -smithy::Document SerializeTerm(const Term& value); -smithy::Outcome DeserializeTerm(const smithy::Document& doc); +opal::Document SerializeTerm(const Term& value); +opal::Outcome DeserializeTerm(const opal::Document& doc); -smithy::Document SerializeTerms(const Terms& value); -smithy::Outcome DeserializeTerms(const smithy::Document& doc); +opal::Document SerializeTerms(const Terms& value); +opal::Outcome DeserializeTerms(const opal::Document& doc); -smithy::Document SerializeAccumulateInput(const AccumulateInput& value); -smithy::Outcome DeserializeAccumulateInput(const smithy::Document& doc); +opal::Document SerializeAccumulateInput(const AccumulateInput& value); +opal::Outcome DeserializeAccumulateInput(const opal::Document& doc); -smithy::Document SerializeRunningTotal(const RunningTotal& value); -smithy::Outcome DeserializeRunningTotal(const smithy::Document& doc); +opal::Document SerializeRunningTotal(const RunningTotal& value); +opal::Outcome DeserializeRunningTotal(const opal::Document& doc); -smithy::Document SerializeTotals(const Totals& value); -smithy::Outcome DeserializeTotals(const smithy::Document& doc); +opal::Document SerializeTotals(const Totals& value); +opal::Outcome DeserializeTotals(const opal::Document& doc); -smithy::Document SerializeAccumulateOutput(const AccumulateOutput& value); -smithy::Outcome DeserializeAccumulateOutput(const smithy::Document& doc); +opal::Document SerializeAccumulateOutput(const AccumulateOutput& value); +opal::Outcome DeserializeAccumulateOutput(const opal::Document& doc); -smithy::Document SerializeOverflow(const Overflow& value); -smithy::Outcome DeserializeOverflow(const smithy::Document& doc); +opal::Document SerializeOverflow(const Overflow& value); +opal::Outcome DeserializeOverflow(const opal::Document& doc); -smithy::Document SerializeAddInput(const AddInput& value); -smithy::Outcome DeserializeAddInput(const smithy::Document& doc); +opal::Document SerializeAddInput(const AddInput& value); +opal::Outcome DeserializeAddInput(const opal::Document& doc); -smithy::Document SerializeAddOutput(const AddOutput& value); -smithy::Outcome DeserializeAddOutput(const smithy::Document& doc); +opal::Document SerializeAddOutput(const AddOutput& value); +opal::Outcome DeserializeAddOutput(const opal::Document& doc); -smithy::Document SerializeDivideInput(const DivideInput& value); -smithy::Outcome DeserializeDivideInput(const smithy::Document& doc); +opal::Document SerializeDivideInput(const DivideInput& value); +opal::Outcome DeserializeDivideInput(const opal::Document& doc); -smithy::Document SerializeDivideOutput(const DivideOutput& value); -smithy::Outcome DeserializeDivideOutput(const smithy::Document& doc); +opal::Document SerializeDivideOutput(const DivideOutput& value); +opal::Outcome DeserializeDivideOutput(const opal::Document& doc); -smithy::Document SerializeDivisionByZero(const DivisionByZero& value); -smithy::Outcome DeserializeDivisionByZero(const smithy::Document& doc); +opal::Document SerializeDivisionByZero(const DivisionByZero& value); +opal::Outcome DeserializeDivisionByZero(const opal::Document& doc); } // namespace example::calculator diff --git a/examples/jsonrpc2/generated/include/example/calculator/server.h b/examples/jsonrpc2/generated/include/example/calculator/server.h index 5a008f93..35a4be0a 100644 --- a/examples/jsonrpc2/generated/include/example/calculator/server.h +++ b/examples/jsonrpc2/generated/include/example/calculator/server.h @@ -17,16 +17,16 @@ namespace example::calculator { /// The typed session a Accumulate handler borrows (ADR-0016): Tx = what this /// server sends, Rx = what the client sends. -using AccumulateServerStream = smithy::eventstream::EventStream; +using AccumulateServerStream = opal::eventstream::EventStream; /// The same session for an async handler (ADR-0021): co_await where the /// blocking sibling parks a thread; identical directions and Share(). -using AccumulateAsyncServerStream = smithy::eventstream::AsyncEventStream; +using AccumulateAsyncServerStream = opal::eventstream::AsyncEventStream; /// Implement one method per operation. Return a modeled error as -/// smithy::Error::Modeled("", message), optionally with the +/// opal::Error::Modeled("", message), optionally with the /// typed error structure attached via set_detail() so it serializes fully. /// The context carries the raw request and routing captures — see -/// smithy::server::RequestContext; leave the parameter unnamed when unused. +/// opal::server::RequestContext; leave the parameter unnamed when unused. /// Implementations must be thread-safe: transports may invoke any mix of /// operations concurrently on the one handler instance. class CalculatorHandler { @@ -46,11 +46,11 @@ class CalculatorHandler { /// `stream` is valid only until this method returns; join any helper /// thread still using it. Blocks the transport's handler thread for /// the session's lifetime. - virtual smithy::Outcome Accumulate(const AccumulateInput& input, AccumulateServerStream& stream, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome Accumulate(const AccumulateInput& input, AccumulateServerStream& stream, const opal::server::RequestContext& context) = 0; /// Adds two numbers. - virtual smithy::Outcome Add(const AddInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome Add(const AddInput& input, const opal::server::RequestContext& context) = 0; /// Divides dividend by divisor; dividing by zero is a modeled error. - virtual smithy::Outcome Divide(const DivideInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome Divide(const DivideInput& input, const opal::server::RequestContext& context) = 0; }; /// CalculatorHandler's zero-thread sibling (ADR-0021): implement this and construct @@ -69,8 +69,8 @@ class CalculatorAsyncHandler { /// /// Async streaming operation (ADR-0021): a coroutine serving the whole /// session — co_await stream.Receive()/Send() until done. - /// co_return smithy::Unit{} for a clean close, or an error — modeled as - /// smithy::Error::Modeled("", message) + set_detail(), + /// co_return opal::Unit{} for a clean close, or an error — modeled as + /// opal::Error::Modeled("", message) + set_detail(), /// like a blocking handler — which ends the stream with one best-effort /// exception message before the close. `input` is the coroutine's own /// copy: the upgrade request (and its RequestContext) is gone by the @@ -79,16 +79,16 @@ class CalculatorAsyncHandler { /// task completes. Code before the first co_await runs on the launching /// handler thread (brief blocking is fine there); every later resumption /// is a transport completion context — never block those. - virtual smithy::eventstream::StreamTask Accumulate(AccumulateInput input, AccumulateAsyncServerStream& stream) = 0; + virtual opal::eventstream::StreamTask Accumulate(AccumulateInput input, AccumulateAsyncServerStream& stream) = 0; /// Adds two numbers. - virtual smithy::Outcome Add(const AddInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome Add(const AddInput& input, const opal::server::RequestContext& context) = 0; /// Divides dividend by divisor; dividing by zero is a modeled error. - virtual smithy::Outcome Divide(const DivideInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome Divide(const DivideInput& input, const opal::server::RequestContext& context) = 0; }; /// jsonRpc2 server for example.calculator#Calculator: routing, deserialization, handler dispatch, /// response serialization, and modeled-error mapping. Pass Handler() to any -/// smithy::http::HttpServerTransport. +/// opal::http::HttpServerTransport. class CalculatorServer { public: explicit CalculatorServer(std::shared_ptr handler); @@ -98,7 +98,7 @@ class CalculatorServer { /// constructor chosen decides which two-line mount applies (StreamRouter). explicit CalculatorServer(std::shared_ptr handler); - smithy::http::RequestHandler Handler() const; + opal::http::RequestHandler Handler() const; /// The WebSocket router carrying every streaming route (ADR-0016), ready /// to mount on the transport in two lines — the serve line keyed to the @@ -107,11 +107,11 @@ class CalculatorServer { /// options.on_websocket = server.StreamRouter()->Serve(); // blocking handler /// options.on_websocket_session = /// server.StreamRouter()->ServeSession(); // async handler (ADR-0021) - std::shared_ptr StreamRouter() const; + std::shared_ptr StreamRouter() const; private: - std::shared_ptr router_; - std::shared_ptr stream_router_; + std::shared_ptr router_; + std::shared_ptr stream_router_; }; } // namespace example::calculator diff --git a/examples/jsonrpc2/generated/include/example/calculator/types.h b/examples/jsonrpc2/generated/include/example/calculator/types.h index f6187c04..316a2219 100644 --- a/examples/jsonrpc2/generated/include/example/calculator/types.h +++ b/examples/jsonrpc2/generated/include/example/calculator/types.h @@ -28,7 +28,7 @@ struct Term { out += sep; sep = ", "; out += ".value = "; - smithy::DebugAppend(out, this->value); + opal::DebugAppend(out, this->value); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -80,7 +80,7 @@ class Terms { switch (value_.index()) { case 1: out += "add = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -99,7 +99,7 @@ class Terms { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("Terms", requested, case_name()); + opal::internal::FatalWrongUnionAccess("Terms", requested, case_name()); } } @@ -119,13 +119,13 @@ struct AccumulateInput { out += sep; sep = ", "; out += ".start = "; - smithy::DebugAppend(out, *this->start); + opal::DebugAppend(out, *this->start); } if (this->terms.has_value()) { out += sep; sep = ", "; out += ".terms = "; - smithy::DebugAppend(out, *this->terms); + opal::DebugAppend(out, *this->terms); } out += '}'; } @@ -149,7 +149,7 @@ struct RunningTotal { out += sep; sep = ", "; out += ".value = "; - smithy::DebugAppend(out, this->value); + opal::DebugAppend(out, this->value); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -201,7 +201,7 @@ class Totals { switch (value_.index()) { case 1: out += "total = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -220,7 +220,7 @@ class Totals { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("Totals", requested, case_name()); + opal::internal::FatalWrongUnionAccess("Totals", requested, case_name()); } } @@ -239,7 +239,7 @@ struct AccumulateOutput { out += sep; sep = ", "; out += ".totals = "; - smithy::DebugAppend(out, *this->totals); + opal::DebugAppend(out, *this->totals); } out += '}'; } @@ -266,11 +266,11 @@ struct Overflow { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); out += sep; sep = ", "; out += ".limit = "; - smithy::DebugAppend(out, this->limit); + opal::DebugAppend(out, this->limit); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -294,11 +294,11 @@ struct AddInput { out += sep; sep = ", "; out += ".a = "; - smithy::DebugAppend(out, this->a); + opal::DebugAppend(out, this->a); out += sep; sep = ", "; out += ".b = "; - smithy::DebugAppend(out, this->b); + opal::DebugAppend(out, this->b); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -321,7 +321,7 @@ struct AddOutput { out += sep; sep = ", "; out += ".sum = "; - smithy::DebugAppend(out, this->sum); + opal::DebugAppend(out, this->sum); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -346,16 +346,16 @@ struct DivideInput { out += sep; sep = ", "; out += ".dividend = "; - smithy::DebugAppend(out, this->dividend); + opal::DebugAppend(out, this->dividend); out += sep; sep = ", "; out += ".divisor = "; - smithy::DebugAppend(out, this->divisor); + opal::DebugAppend(out, this->divisor); if (this->requestToken.has_value()) { out += sep; sep = ", "; out += ".requestToken = "; - smithy::DebugAppend(out, *this->requestToken); + opal::DebugAppend(out, *this->requestToken); } out += '}'; } @@ -379,7 +379,7 @@ struct DivideOutput { out += sep; sep = ", "; out += ".quotient = "; - smithy::DebugAppend(out, this->quotient); + opal::DebugAppend(out, this->quotient); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -402,7 +402,7 @@ struct DivisionByZero { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -424,7 +424,7 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::Term& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.value)); + seed = opal::HashCombine(seed, opal::HashValue(value.value)); return seed; } }; @@ -433,8 +433,8 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::Terms& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -442,8 +442,8 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::AccumulateInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.start)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.terms)); + seed = opal::HashCombine(seed, opal::HashValue(value.start)); + seed = opal::HashCombine(seed, opal::HashValue(value.terms)); return seed; } }; @@ -452,7 +452,7 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::RunningTotal& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.value)); + seed = opal::HashCombine(seed, opal::HashValue(value.value)); return seed; } }; @@ -461,8 +461,8 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::Totals& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -470,7 +470,7 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::AccumulateOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.totals)); + seed = opal::HashCombine(seed, opal::HashValue(value.totals)); return seed; } }; @@ -479,8 +479,8 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::Overflow& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.limit)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.limit)); return seed; } }; @@ -489,8 +489,8 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::AddInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.a)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.b)); + seed = opal::HashCombine(seed, opal::HashValue(value.a)); + seed = opal::HashCombine(seed, opal::HashValue(value.b)); return seed; } }; @@ -499,7 +499,7 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::AddOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sum)); + seed = opal::HashCombine(seed, opal::HashValue(value.sum)); return seed; } }; @@ -508,9 +508,9 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::DivideInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.dividend)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.divisor)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.requestToken)); + seed = opal::HashCombine(seed, opal::HashValue(value.dividend)); + seed = opal::HashCombine(seed, opal::HashValue(value.divisor)); + seed = opal::HashCombine(seed, opal::HashValue(value.requestToken)); return seed; } }; @@ -519,7 +519,7 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::DivideOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.quotient)); + seed = opal::HashCombine(seed, opal::HashValue(value.quotient)); return seed; } }; @@ -528,7 +528,7 @@ template <> struct std::hash { std::size_t operator()(const example::calculator::DivisionByZero& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); return seed; } }; diff --git a/examples/jsonrpc2/generated/src/client.cc b/examples/jsonrpc2/generated/src/client.cc index 1e9e5914..ca17bf89 100644 --- a/examples/jsonrpc2/generated/src/client.cc +++ b/examples/jsonrpc2/generated/src/client.cc @@ -39,43 +39,43 @@ struct ParsedError { int status = 0; std::string code = "UnknownError"; std::string message; - smithy::Document doc; + opal::Document doc; }; // [[maybe_unused]]: only unary response paths parse wire errors; a // service whose operations all stream never calls this. -[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) { +[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) { ParsedError parsed; parsed.status = response.status; parsed.message = "HTTP " + std::to_string(response.status); - auto doc = smithy::json::Decode(response.body); + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return parsed; - const smithy::Document* error = doc->Find("error"); + const opal::Document* error = doc->Find("error"); if (error == nullptr || !error->is_map()) return parsed; - if (const smithy::Document* code = error->Find("code"); code != nullptr && code->is_int()) { + if (const opal::Document* code = error->Find("code"); code != nullptr && code->is_int()) { const std::int64_t rpc_code = code->as_int(); parsed.status = rpc_code >= 100 && rpc_code < 600 ? static_cast(rpc_code) : (rpc_code == -32603 ? 500 : 400); } - if (const smithy::Document* message = error->Find("message"); message != nullptr && message->is_string()) parsed.message = message->as_string(); - if (const smithy::Document* data = error->Find("data"); data != nullptr) parsed.doc = *data; + if (const opal::Document* message = error->Find("message"); message != nullptr && message->is_string()) parsed.message = message->as_string(); + if (const opal::Document* data = error->Find("data"); data != nullptr) parsed.doc = *data; if (parsed.doc.is_map()) { - const smithy::Document* type = parsed.doc.Find("__type"); + const opal::Document* type = parsed.doc.Find("__type"); if (type != nullptr && type->is_string()) parsed.code = helpers::SanitizeErrorCode(type->as_string()); } return parsed; } -smithy::Error GenericError(ParsedError parsed) { +opal::Error GenericError(ParsedError parsed) { const bool retryable = parsed.status >= 500; - if (parsed.code == "UnknownError") return smithy::Error(smithy::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); - return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); + if (parsed.code == "UnknownError") return opal::Error(opal::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); + return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); } -smithy::Error MakeDivisionByZeroError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeDivisionByZeroError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("DivisionByZero", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("DivisionByZero", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeDivisionByZero(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -83,11 +83,11 @@ smithy::Error MakeDivisionByZeroError(const smithy::http::HttpResponse& response return error; } -smithy::Error MakeOverflowError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeOverflowError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("Overflow", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("Overflow", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeOverflow(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -95,7 +95,7 @@ smithy::Error MakeOverflowError(const smithy::http::HttpResponse& response, Pars return error; } -smithy::Error ParseDivideError(const smithy::http::HttpResponse& response) { +opal::Error ParseDivideError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "DivisionByZero") return helpers::MakeDivisionByZeroError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); @@ -105,9 +105,9 @@ smithy::Error ParseDivideError(const smithy::http::HttpResponse& response) { // TLS come from the same endpoint the unary transport uses (nothing is // configured twice); config.websocket_dialer overrides the Beast dialer the // way http_client overrides the unary transport. -smithy::Outcome> DialStream(const smithy::ClientConfig& config, smithy::http::WebSocketDialRequest request) { +opal::Outcome> DialStream(const opal::ClientConfig& config, opal::http::WebSocketDialRequest request) { if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); request.host = endpoint->host; request.port = endpoint->port; @@ -116,91 +116,91 @@ smithy::Outcome> DialStream(const smith } if (config.websocket_dialer) return config.websocket_dialer(request); if (request.host.empty()) { - return smithy::Error::Validation("CalculatorClient: config needs an endpoint or a websocket_dialer"); + return opal::Error::Validation("CalculatorClient: config needs an endpoint or a websocket_dialer"); } - return smithy::http::BeastWebSocketClient::Dialer()(request); + return opal::http::BeastWebSocketClient::Dialer()(request); } // One event per message (ADR-0016): the engaged member's structure is the // payload, its member name the :event-type. -smithy::Outcome EncodeAccumulateEvent(const types::Terms& event) { +opal::Outcome EncodeAccumulateEvent(const types::Terms& event) { if (event.is_add()) { - return smithy::eventstream::MakeEventMessage("add", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeTerm(event.as_add())))); + return opal::eventstream::MakeEventMessage("add", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeTerm(event.as_add())))); } - return smithy::Error::Validation("Terms: no event member engaged"); + return opal::Error::Validation("Terms: no event member engaged"); } -smithy::Outcome DecodeAccumulateEvent(const smithy::eventstream::Message& message) { - auto envelope = smithy::eventstream::ParseEnvelope(message); +opal::Outcome DecodeAccumulateEvent(const opal::eventstream::Message& message) { + auto envelope = opal::eventstream::ParseEnvelope(message); if (!envelope) return std::move(envelope).error(); - if (envelope->kind == smithy::eventstream::EventEnvelope::Kind::kException) { + if (envelope->kind == opal::eventstream::EventEnvelope::Kind::kException) { // A received exception is terminal (ADR-0016): the EventStream closes the // session and surfaces this error, exactly the unary shape. ParsedError parsed; parsed.code = helpers::SanitizeErrorCode(envelope->type); - auto exception_doc = smithy::json::Decode(envelope->payload.ToString()); + auto exception_doc = opal::json::Decode(envelope->payload.ToString()); if (exception_doc.ok() && exception_doc->is_map()) { parsed.doc = *std::move(exception_doc); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } // MakeError's header-patch source; exception messages carry none. - smithy::http::HttpResponse response; + opal::http::HttpResponse response; if (parsed.code == "Overflow") return helpers::MakeOverflowError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); } if (envelope->type == "total") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeRunningTotal(*doc); if (!event) return std::move(event).error(); return types::Totals::FromTotal(*std::move(event)); } - return smithy::Error::Serialization("Accumulate: unknown event type: " + envelope->type); + return opal::Error::Serialization("Accumulate: unknown event type: " + envelope->type); } } // namespace helpers } // namespace -smithy::Outcome CalculatorClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome CalculatorClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { // The built-in socket transport is plaintext-only; https needs a - // TLS-capable transport (e.g. smithy::http::BeastHttpClient). + // TLS-capable transport (e.g. opal::http::BeastHttpClient). if (endpoint->tls()) { - return smithy::Error::Validation("CalculatorClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + return opal::Error::Validation("CalculatorClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); } - transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); } } if (transport == nullptr) { - return smithy::Error::Validation("CalculatorClient: config needs an endpoint or an http_client"); + return opal::Error::Validation("CalculatorClient: config needs an endpoint or an http_client"); } return CalculatorClient(std::move(config), std::move(transport), std::move(prefix)); } -CalculatorClient::CalculatorClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix) +CalculatorClient::CalculatorClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} -smithy::Outcome CalculatorClient::Send(smithy::http::HttpRequest request) const { +opal::Outcome CalculatorClient::Send(opal::http::HttpRequest request) const { // Operations with a non-document response payload set their own accept. if (!request.headers.Get("accept").has_value()) request.headers.Set("accept", "application/json"); request.headers.Set("user-agent", config_.user_agent); if (!request.body.empty()) { request.headers.Set("content-length", std::to_string(request.body.size())); } - return smithy::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); + return opal::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); } -smithy::Outcome CalculatorClient::Accumulate(const AccumulateInput& input) const { - smithy::http::WebSocketDialRequest request; +opal::Outcome CalculatorClient::Accumulate(const AccumulateInput& input) const { + opal::http::WebSocketDialRequest request; // The shared endpoint (ADR-0023): the same target the unary POST uses — // the operation rides the opening envelope, and every frame is text. request.target = path_prefix_ + "/"; @@ -210,68 +210,68 @@ smithy::Outcome CalculatorClient::Accumulate(const Accum if (!socket) return std::move(socket).error(); // The opening request envelope: selects the operation and carries the // initial-request members (the :initial-request seam, realized). - smithy::DocumentMap params = SerializeAccumulateInput(input).as_map(); + opal::DocumentMap params = SerializeAccumulateInput(input).as_map(); // The union is the session, never a params member. params.erase("terms"); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("method", smithy::Document("Accumulate")); - envelope.emplace("id", smithy::Document(1)); - envelope.emplace("params", smithy::Document(std::move(params))); - smithy::eventstream::Message opening; - opening.payload = smithy::Blob::FromString(smithy::json::Encode(smithy::Document(std::move(envelope)))); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("method", opal::Document("Accumulate")); + envelope.emplace("id", opal::Document(1)); + envelope.emplace("params", opal::Document(std::move(params))); + opal::eventstream::Message opening; + opening.payload = opal::Blob::FromString(opal::json::Encode(opal::Document(std::move(envelope)))); auto sent = (*socket)->Send(opening); if (!sent) return std::move(sent).error(); return AccumulateClientStream( - std::make_shared(*std::move(socket), smithy::Document(1), smithy::eventstream::JsonRpcStreamSocket::Role::kClient), + std::make_shared(*std::move(socket), opal::Document(1), opal::eventstream::JsonRpcStreamSocket::Role::kClient), helpers::EncodeAccumulateEvent, helpers::DecodeAccumulateEvent); } -smithy::Outcome CalculatorClient::Add(const AddInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome CalculatorClient::Add(const AddInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/"; request.headers.Set("content-type", "application/json"); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("method", smithy::Document("Add")); - envelope.emplace("id", smithy::Document(1)); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("method", opal::Document("Add")); + envelope.emplace("id", opal::Document(1)); envelope.emplace("params", SerializeAddInput(input)); - request.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + request.body = opal::json::Encode(opal::Document(std::move(envelope))); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); - auto envelope_doc = smithy::json::Decode(response->body); + auto envelope_doc = opal::json::Decode(response->body); // Errors are JSON-RPC envelopes on HTTP 200; non-200 means the request // never reached the protocol layer (router 404, proxy) and parses generically. const bool is_error = !envelope_doc.ok() || !envelope_doc->is_map() || envelope_doc->Find("error") != nullptr; if (response->status != 200 || is_error) return helpers::GenericError(helpers::ParseError(*response)); - const smithy::Document* result = envelope_doc->Find("result"); - if (result == nullptr) return smithy::Error::Serialization("jsonRpc2: response has no result member"); + const opal::Document* result = envelope_doc->Find("result"); + if (result == nullptr) return opal::Error::Serialization("jsonRpc2: response has no result member"); return DeserializeAddOutput(*result); } -smithy::Outcome CalculatorClient::Divide(const DivideInput& input) const { +opal::Outcome CalculatorClient::Divide(const DivideInput& input) const { DivideInput prepared = input; - if (!prepared.requestToken.has_value()) prepared.requestToken = smithy::GenerateUuidV4(); - smithy::http::HttpRequest request; + if (!prepared.requestToken.has_value()) prepared.requestToken = opal::GenerateUuidV4(); + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/"; request.headers.Set("content-type", "application/json"); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("method", smithy::Document("Divide")); - envelope.emplace("id", smithy::Document(1)); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("method", opal::Document("Divide")); + envelope.emplace("id", opal::Document(1)); envelope.emplace("params", SerializeDivideInput(prepared)); - request.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + request.body = opal::json::Encode(opal::Document(std::move(envelope))); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); - auto envelope_doc = smithy::json::Decode(response->body); + auto envelope_doc = opal::json::Decode(response->body); // Errors are JSON-RPC envelopes on HTTP 200; non-200 means the request // never reached the protocol layer (router 404, proxy) and parses generically. const bool is_error = !envelope_doc.ok() || !envelope_doc->is_map() || envelope_doc->Find("error") != nullptr; if (response->status != 200 || is_error) return helpers::ParseDivideError(*response); - const smithy::Document* result = envelope_doc->Find("result"); - if (result == nullptr) return smithy::Error::Serialization("jsonRpc2: response has no result member"); + const opal::Document* result = envelope_doc->Find("result"); + if (result == nullptr) return opal::Error::Serialization("jsonRpc2: response has no result member"); return DeserializeDivideOutput(*result); } diff --git a/examples/jsonrpc2/generated/src/serde.cc b/examples/jsonrpc2/generated/src/serde.cc index b360271e..42f440ed 100644 --- a/examples/jsonrpc2/generated/src/serde.cc +++ b/examples/jsonrpc2/generated/src/serde.cc @@ -10,41 +10,41 @@ namespace example::calculator { namespace types = ::example::calculator; -smithy::Document SerializeTerm(const Term& value) { - smithy::DocumentMap map; - map.emplace("value", smithy::Document(static_cast(value.value))); - return smithy::Document(std::move(map)); +opal::Document SerializeTerm(const Term& value) { + opal::DocumentMap map; + map.emplace("value", opal::Document(static_cast(value.value))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeTerm(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Term: expected a map on the wire"); +opal::Outcome DeserializeTerm(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Term: expected a map on the wire"); Term out; { - const smithy::Document* member = doc.Find("value"); + const opal::Document* member = doc.Find("value"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Term: missing required member: value"); + return opal::Error::Serialization("Term: missing required member: value"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("Term.value: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("Term.value: expected a number"); out.value = static_cast(*parsed); } } return out; } -smithy::Document SerializeTerms(const Terms& value) { - smithy::DocumentMap map; +opal::Document SerializeTerms(const Terms& value) { + opal::DocumentMap map; if (value.is_add()) { map.emplace("add", SerializeTerm(value.as_add())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeTerms(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Terms: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("Terms: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("add"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeTerms(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Terms: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("Terms: expected exactly one union member"); + if (const opal::Document* member = doc.Find("add"); member != nullptr && !member->is_null()) { Term parsed_member{}; { auto parsed = DeserializeTerm(*member); @@ -53,37 +53,37 @@ smithy::Outcome DeserializeTerms(const smithy::Document& doc) { } return Terms::FromAdd(std::move(parsed_member)); } - return smithy::Error::Serialization("Terms: unknown or missing union member"); + return opal::Error::Serialization("Terms: unknown or missing union member"); } -smithy::Document SerializeAccumulateInput(const AccumulateInput& value) { - smithy::DocumentMap map; +opal::Document SerializeAccumulateInput(const AccumulateInput& value) { + opal::DocumentMap map; if (value.start.has_value()) { - map.emplace("start", smithy::Document(static_cast((*value.start)))); + map.emplace("start", opal::Document(static_cast((*value.start)))); } if (value.terms.has_value()) { map.emplace("terms", SerializeTerms((*value.terms))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeAccumulateInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("AccumulateInput: expected a map on the wire"); +opal::Outcome DeserializeAccumulateInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("AccumulateInput: expected a map on the wire"); AccumulateInput out; { - const smithy::Document* member = doc.Find("start"); + const opal::Document* member = doc.Find("start"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("AccumulateInput.start: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("AccumulateInput.start: expected a number"); parsed_member = static_cast(*parsed); } out.start = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("terms"); + const opal::Document* member = doc.Find("terms"); if (member != nullptr && !member->is_null()) { types::Terms parsed_member{}; { @@ -97,41 +97,41 @@ smithy::Outcome DeserializeAccumulateInput(const smithy::Docume return out; } -smithy::Document SerializeRunningTotal(const RunningTotal& value) { - smithy::DocumentMap map; - map.emplace("value", smithy::Document(static_cast(value.value))); - return smithy::Document(std::move(map)); +opal::Document SerializeRunningTotal(const RunningTotal& value) { + opal::DocumentMap map; + map.emplace("value", opal::Document(static_cast(value.value))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRunningTotal(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RunningTotal: expected a map on the wire"); +opal::Outcome DeserializeRunningTotal(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RunningTotal: expected a map on the wire"); RunningTotal out; { - const smithy::Document* member = doc.Find("value"); + const opal::Document* member = doc.Find("value"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("RunningTotal: missing required member: value"); + return opal::Error::Serialization("RunningTotal: missing required member: value"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("RunningTotal.value: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("RunningTotal.value: expected a number"); out.value = static_cast(*parsed); } } return out; } -smithy::Document SerializeTotals(const Totals& value) { - smithy::DocumentMap map; +opal::Document SerializeTotals(const Totals& value) { + opal::DocumentMap map; if (value.is_total()) { map.emplace("total", SerializeRunningTotal(value.as_total())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeTotals(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Totals: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("Totals: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("total"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeTotals(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Totals: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("Totals: expected exactly one union member"); + if (const opal::Document* member = doc.Find("total"); member != nullptr && !member->is_null()) { RunningTotal parsed_member{}; { auto parsed = DeserializeRunningTotal(*member); @@ -140,22 +140,22 @@ smithy::Outcome DeserializeTotals(const smithy::Document& doc) { } return Totals::FromTotal(std::move(parsed_member)); } - return smithy::Error::Serialization("Totals: unknown or missing union member"); + return opal::Error::Serialization("Totals: unknown or missing union member"); } -smithy::Document SerializeAccumulateOutput(const AccumulateOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeAccumulateOutput(const AccumulateOutput& value) { + opal::DocumentMap map; if (value.totals.has_value()) { map.emplace("totals", SerializeTotals((*value.totals))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeAccumulateOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("AccumulateOutput: expected a map on the wire"); +opal::Outcome DeserializeAccumulateOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("AccumulateOutput: expected a map on the wire"); AccumulateOutput out; { - const smithy::Document* member = doc.Find("totals"); + const opal::Document* member = doc.Find("totals"); if (member != nullptr && !member->is_null()) { types::Totals parsed_member{}; { @@ -169,136 +169,136 @@ smithy::Outcome DeserializeAccumulateOutput(const smithy::Docu return out; } -smithy::Document SerializeOverflow(const Overflow& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); - map.emplace("limit", smithy::Document(static_cast(value.limit))); - return smithy::Document(std::move(map)); +opal::Document SerializeOverflow(const Overflow& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); + map.emplace("limit", opal::Document(static_cast(value.limit))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOverflow(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Overflow: expected a map on the wire"); +opal::Outcome DeserializeOverflow(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Overflow: expected a map on the wire"); Overflow out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Overflow: missing required member: message"); + return opal::Error::Serialization("Overflow: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("Overflow.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Overflow.message: unexpected type on the wire"); out.message = member->as_string(); } { - const smithy::Document* member = doc.Find("limit"); + const opal::Document* member = doc.Find("limit"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Overflow: missing required member: limit"); + return opal::Error::Serialization("Overflow: missing required member: limit"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("Overflow.limit: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("Overflow.limit: expected a number"); out.limit = static_cast(*parsed); } } return out; } -smithy::Document SerializeAddInput(const AddInput& value) { - smithy::DocumentMap map; - map.emplace("a", smithy::Document(static_cast(value.a))); - map.emplace("b", smithy::Document(static_cast(value.b))); - return smithy::Document(std::move(map)); +opal::Document SerializeAddInput(const AddInput& value) { + opal::DocumentMap map; + map.emplace("a", opal::Document(static_cast(value.a))); + map.emplace("b", opal::Document(static_cast(value.b))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeAddInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("AddInput: expected a map on the wire"); +opal::Outcome DeserializeAddInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("AddInput: expected a map on the wire"); AddInput out; { - const smithy::Document* member = doc.Find("a"); + const opal::Document* member = doc.Find("a"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AddInput: missing required member: a"); + return opal::Error::Serialization("AddInput: missing required member: a"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("AddInput.a: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("AddInput.a: expected a number"); out.a = static_cast(*parsed); } } { - const smithy::Document* member = doc.Find("b"); + const opal::Document* member = doc.Find("b"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AddInput: missing required member: b"); + return opal::Error::Serialization("AddInput: missing required member: b"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("AddInput.b: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("AddInput.b: expected a number"); out.b = static_cast(*parsed); } } return out; } -smithy::Document SerializeAddOutput(const AddOutput& value) { - smithy::DocumentMap map; - map.emplace("sum", smithy::Document(static_cast(value.sum))); - return smithy::Document(std::move(map)); +opal::Document SerializeAddOutput(const AddOutput& value) { + opal::DocumentMap map; + map.emplace("sum", opal::Document(static_cast(value.sum))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeAddOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("AddOutput: expected a map on the wire"); +opal::Outcome DeserializeAddOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("AddOutput: expected a map on the wire"); AddOutput out; { - const smithy::Document* member = doc.Find("sum"); + const opal::Document* member = doc.Find("sum"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AddOutput: missing required member: sum"); + return opal::Error::Serialization("AddOutput: missing required member: sum"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("AddOutput.sum: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("AddOutput.sum: expected a number"); out.sum = static_cast(*parsed); } } return out; } -smithy::Document SerializeDivideInput(const DivideInput& value) { - smithy::DocumentMap map; - map.emplace("dividend", smithy::Document(static_cast(value.dividend))); - map.emplace("divisor", smithy::Document(static_cast(value.divisor))); +opal::Document SerializeDivideInput(const DivideInput& value) { + opal::DocumentMap map; + map.emplace("dividend", opal::Document(static_cast(value.dividend))); + map.emplace("divisor", opal::Document(static_cast(value.divisor))); if (value.requestToken.has_value()) { - map.emplace("requestToken", smithy::Document((*value.requestToken))); + map.emplace("requestToken", opal::Document((*value.requestToken))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeDivideInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("DivideInput: expected a map on the wire"); +opal::Outcome DeserializeDivideInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("DivideInput: expected a map on the wire"); DivideInput out; { - const smithy::Document* member = doc.Find("dividend"); + const opal::Document* member = doc.Find("dividend"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("DivideInput: missing required member: dividend"); + return opal::Error::Serialization("DivideInput: missing required member: dividend"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("DivideInput.dividend: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("DivideInput.dividend: expected a number"); out.dividend = static_cast(*parsed); } } { - const smithy::Document* member = doc.Find("divisor"); + const opal::Document* member = doc.Find("divisor"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("DivideInput: missing required member: divisor"); + return opal::Error::Serialization("DivideInput: missing required member: divisor"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("DivideInput.divisor: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("DivideInput.divisor: expected a number"); out.divisor = static_cast(*parsed); } } { - const smithy::Document* member = doc.Find("requestToken"); + const opal::Document* member = doc.Find("requestToken"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("DivideInput.requestToken: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("DivideInput.requestToken: unexpected type on the wire"); parsed_member = member->as_string(); out.requestToken = std::move(parsed_member); } @@ -306,44 +306,44 @@ smithy::Outcome DeserializeDivideInput(const smithy::Document& doc) return out; } -smithy::Document SerializeDivideOutput(const DivideOutput& value) { - smithy::DocumentMap map; - map.emplace("quotient", smithy::Document(static_cast(value.quotient))); - return smithy::Document(std::move(map)); +opal::Document SerializeDivideOutput(const DivideOutput& value) { + opal::DocumentMap map; + map.emplace("quotient", opal::Document(static_cast(value.quotient))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeDivideOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("DivideOutput: expected a map on the wire"); +opal::Outcome DeserializeDivideOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("DivideOutput: expected a map on the wire"); DivideOutput out; { - const smithy::Document* member = doc.Find("quotient"); + const opal::Document* member = doc.Find("quotient"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("DivideOutput: missing required member: quotient"); + return opal::Error::Serialization("DivideOutput: missing required member: quotient"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("DivideOutput.quotient: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("DivideOutput.quotient: expected a number"); out.quotient = static_cast(*parsed); } } return out; } -smithy::Document SerializeDivisionByZero(const DivisionByZero& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); - return smithy::Document(std::move(map)); +opal::Document SerializeDivisionByZero(const DivisionByZero& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeDivisionByZero(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("DivisionByZero: expected a map on the wire"); +opal::Outcome DeserializeDivisionByZero(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("DivisionByZero: expected a map on the wire"); DivisionByZero out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("DivisionByZero: missing required member: message"); + return opal::Error::Serialization("DivisionByZero: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("DivisionByZero.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("DivisionByZero.message: unexpected type on the wire"); out.message = member->as_string(); } return out; diff --git a/examples/jsonrpc2/generated/src/server.cc b/examples/jsonrpc2/generated/src/server.cc index 0acb9597..fdabee7c 100644 --- a/examples/jsonrpc2/generated/src/server.cc +++ b/examples/jsonrpc2/generated/src/server.cc @@ -24,65 +24,65 @@ namespace types = ::example::calculator; namespace { namespace helpers { -smithy::http::HttpResponse JsonRpcError(int code, const std::string& type, const std::string& message, smithy::DocumentMap data, const smithy::Document& id) { - if (!type.empty()) data.insert_or_assign("__type", smithy::Document(type)); +opal::http::HttpResponse JsonRpcError(int code, const std::string& type, const std::string& message, opal::DocumentMap data, const opal::Document& id) { + if (!type.empty()) data.insert_or_assign("__type", opal::Document(type)); std::string text = message; if (text.empty()) { const auto it = data.find("message"); if (it != data.end() && it->second.is_string()) text = it->second.as_string(); } - smithy::DocumentMap error; - error.emplace("code", smithy::Document(code)); - error.emplace("message", smithy::Document(std::move(text))); - if (!data.empty()) error.emplace("data", smithy::Document(std::move(data))); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("error", smithy::Document(std::move(error))); + opal::DocumentMap error; + error.emplace("code", opal::Document(code)); + error.emplace("message", opal::Document(std::move(text))); + if (!data.empty()) error.emplace("data", opal::Document(std::move(data))); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("error", opal::Document(std::move(error))); envelope.emplace("id", id); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + response.body = opal::json::Encode(opal::Document(std::move(envelope))); return response; } // [[maybe_unused]]: only unary routes map handler errors here; a service // whose operations all stream reports errors on the stream instead. -[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& error, const smithy::Document& id) { - if (error.kind() == smithy::ErrorKind::kModeled) { +[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& error, const opal::Document& id) { + if (error.kind() == opal::ErrorKind::kModeled) { if (error.code() == "DivisionByZero") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeDivisionByZero(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::JsonRpcError(422, "example.calculator#DivisionByZero", "", std::move(body), id); } if (error.code() == "Overflow") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeOverflow(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::JsonRpcError(400, "example.calculator#Overflow", "", std::move(body), id); } return helpers::JsonRpcError(400, error.code(), error.message(), {}, id); } - if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) return helpers::JsonRpcError(400, "SerializationException", error.message(), {}, id); + if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) return helpers::JsonRpcError(400, "SerializationException", error.message(), {}, id); // Never leak internal detail on unexpected failures. return helpers::JsonRpcError(500, "InternalFailure", "internal failure", {}, id); } template -smithy::http::HttpResponse HandleAdd(Handler& handler, const smithy::Document& params, const smithy::Document& id, const smithy::server::RequestContext& context) { +opal::http::HttpResponse HandleAdd(Handler& handler, const opal::Document& params, const opal::Document& id, const opal::server::RequestContext& context) { types::AddInput input{}; if (!params.is_map()) return helpers::JsonRpcError(-32602, "SerializationException", "params must be an object", {}, id); auto parsed = DeserializeAddInput(params); @@ -90,19 +90,19 @@ smithy::http::HttpResponse HandleAdd(Handler& handler, const smithy::Document& p input = *std::move(parsed); auto outcome = handler.Add(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error(), id); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); envelope.emplace("result", SerializeAddOutput(*outcome)); envelope.emplace("id", id); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + response.body = opal::json::Encode(opal::Document(std::move(envelope))); return response; } template -smithy::http::HttpResponse HandleDivide(Handler& handler, const smithy::Document& params, const smithy::Document& id, const smithy::server::RequestContext& context) { +opal::http::HttpResponse HandleDivide(Handler& handler, const opal::Document& params, const opal::Document& id, const opal::server::RequestContext& context) { types::DivideInput input{}; if (!params.is_map()) return helpers::JsonRpcError(-32602, "SerializationException", "params must be an object", {}, id); auto parsed = DeserializeDivideInput(params); @@ -110,35 +110,35 @@ smithy::http::HttpResponse HandleDivide(Handler& handler, const smithy::Document input = *std::move(parsed); auto outcome = handler.Divide(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error(), id); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); envelope.emplace("result", SerializeDivideOutput(*outcome)); envelope.emplace("id", id); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + response.body = opal::json::Encode(opal::Document(std::move(envelope))); return response; } // One JSON-RPC envelope as the raw-text message the stream wire carries // (ADR-0023): the unary emitters build the envelope, streams reuse their // bodies verbatim — one error identity, one spelling. -smithy::eventstream::Message JsonRpcStreamText(const smithy::http::HttpResponse& response) { - smithy::eventstream::Message message; - message.payload = smithy::Blob::FromString(response.body); +opal::eventstream::Message JsonRpcStreamText(const opal::http::HttpResponse& response) { + opal::eventstream::Message message; + message.payload = opal::Blob::FromString(response.body); return message; } // The terminal result envelope that ends a clean stream: result stays {} // while initial-response members remain deferred (ADR-0016/0023). -smithy::eventstream::Message BuildJsonRpcTerminalResult(const smithy::Document& id) { - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("result", smithy::Document(smithy::DocumentMap{})); +opal::eventstream::Message BuildJsonRpcTerminalResult(const opal::Document& id) { + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("result", opal::Document(opal::DocumentMap{})); envelope.emplace("id", id); - smithy::eventstream::Message message; - message.payload = smithy::Blob::FromString(smithy::json::Encode(smithy::Document(std::move(envelope)))); + opal::eventstream::Message message; + message.payload = opal::Blob::FromString(opal::json::Encode(opal::Document(std::move(envelope)))); return message; } @@ -147,13 +147,13 @@ smithy::eventstream::Message BuildJsonRpcTerminalResult(const smithy::Document& // compares bodies, so no decoder detail leaks into the wire. struct JsonRpcOpening { bool ok = false; - smithy::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) + opal::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) std::string method; - smithy::Document params{smithy::DocumentMap{}}; - smithy::eventstream::Message refusal; // when !ok: send, then close + opal::Document params{opal::DocumentMap{}}; + opal::eventstream::Message refusal; // when !ok: send, then close }; -JsonRpcOpening ParseJsonRpcOpening(const smithy::eventstream::Message& message) { +JsonRpcOpening ParseJsonRpcOpening(const opal::eventstream::Message& message) { JsonRpcOpening opening; if (!message.headers.empty()) { // Only the raw-text wire reaches this route; a framed message means a @@ -161,7 +161,7 @@ JsonRpcOpening ParseJsonRpcOpening(const smithy::eventstream::Message& message) opening.refusal = helpers::JsonRpcStreamText(helpers::JsonRpcError(-32600, "SerializationException", "the opening message must be one JSON-RPC request envelope", {}, opening.id)); return opening; } - auto decoded = smithy::json::Decode(message.payload.ToString()); + auto decoded = opal::json::Decode(message.payload.ToString()); if (!decoded) { opening.refusal = helpers::JsonRpcStreamText(helpers::JsonRpcError(-32700, "SerializationException", "request body is not valid JSON", {}, opening.id)); return opening; @@ -170,13 +170,13 @@ JsonRpcOpening ParseJsonRpcOpening(const smithy::eventstream::Message& message) opening.refusal = helpers::JsonRpcStreamText(helpers::JsonRpcError(-32600, "SerializationException", "request is not a JSON-RPC 2.0 call", {}, opening.id)); return opening; } - if (const smithy::Document* id_doc = decoded->Find("id"); id_doc != nullptr) opening.id = *id_doc; - const smithy::Document* version = decoded->Find("jsonrpc"); + if (const opal::Document* id_doc = decoded->Find("id"); id_doc != nullptr) opening.id = *id_doc; + const opal::Document* version = decoded->Find("jsonrpc"); if (version == nullptr || !version->is_string() || version->as_string() != "2.0") { opening.refusal = helpers::JsonRpcStreamText(helpers::JsonRpcError(-32600, "SerializationException", "expected jsonrpc: \"2.0\"", {}, opening.id)); return opening; } - const smithy::Document* method = decoded->Find("method"); + const opal::Document* method = decoded->Find("method"); if (method == nullptr || !method->is_string()) { opening.refusal = helpers::JsonRpcStreamText(helpers::JsonRpcError(-32600, "SerializationException", "expected a string method member", {}, opening.id)); return opening; @@ -188,7 +188,7 @@ JsonRpcOpening ParseJsonRpcOpening(const smithy::eventstream::Message& message) return opening; } // Absent/null params deserialize like an empty object. - const smithy::Document* params = decoded->Find("params"); + const opal::Document* params = decoded->Find("params"); if (params != nullptr && !params->is_null()) opening.params = *params; opening.method = method->as_string(); opening.ok = true; @@ -197,29 +197,29 @@ JsonRpcOpening ParseJsonRpcOpening(const smithy::eventstream::Message& message) // One event per message (ADR-0016): the engaged member's structure is the // payload, its member name the :event-type. -smithy::Outcome EncodeAccumulateEvent(const types::Totals& event) { +opal::Outcome EncodeAccumulateEvent(const types::Totals& event) { if (event.is_total()) { - return smithy::eventstream::MakeEventMessage("total", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeRunningTotal(event.as_total())))); + return opal::eventstream::MakeEventMessage("total", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeRunningTotal(event.as_total())))); } - return smithy::Error::Validation("Totals: no event member engaged"); + return opal::Error::Validation("Totals: no event member engaged"); } -smithy::Outcome DecodeAccumulateEvent(const smithy::eventstream::Message& message) { - auto envelope = smithy::eventstream::ParseEnvelope(message); +opal::Outcome DecodeAccumulateEvent(const opal::eventstream::Message& message) { + auto envelope = opal::eventstream::ParseEnvelope(message); if (!envelope) return std::move(envelope).error(); - if (envelope->kind == smithy::eventstream::EventEnvelope::Kind::kException) { + if (envelope->kind == opal::eventstream::EventEnvelope::Kind::kException) { // Clients send events, never exceptions; treat one as a terminal protocol // violation carrying the peer's claimed identity. - return smithy::Error::Modeled(envelope->type, "peer sent an exception message"); + return opal::Error::Modeled(envelope->type, "peer sent an exception message"); } if (envelope->type == "add") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeTerm(*doc); if (!event) return std::move(event).error(); return types::Terms::FromAdd(*std::move(event)); } - return smithy::Error::Serialization("Accumulate: unknown event type: " + envelope->type); + return opal::Error::Serialization("Accumulate: unknown event type: " + envelope->type); } // The async route's launch wrapper (ADR-0021), on the JSON-RPC wire @@ -228,22 +228,22 @@ smithy::Outcome DecodeAccumulateEvent(const smithy::eventstream::M // completion, the unary error identity otherwise — is AWAITED so this // frame (and the stream it owns) outlives the write. Best-effort, like // every terminal send: a send the dead session refuses is discarded. -smithy::eventstream::Detached ServeAccumulateAsync(std::shared_ptr handler, types::AccumulateInput input, std::shared_ptr socket, smithy::Document id) { - auto wrapped = std::make_shared(socket, id, smithy::eventstream::JsonRpcStreamSocket::Role::kServer); +opal::eventstream::Detached ServeAccumulateAsync(std::shared_ptr handler, types::AccumulateInput input, std::shared_ptr socket, opal::Document id) { + auto wrapped = std::make_shared(socket, id, opal::eventstream::JsonRpcStreamSocket::Role::kServer); types::AccumulateAsyncServerStream stream(wrapped, helpers::EncodeAccumulateEvent, helpers::DecodeAccumulateEvent); auto outcome = co_await handler->Accumulate(std::move(input), stream); // Built OUTSIDE the co_await expression on purpose: a conditional // operator inside a co_await full expression miscompiles on GCC (the // branch temporaries become frame slots and the wrong branch runs). - smithy::eventstream::Message terminal = + opal::eventstream::Message terminal = outcome.ok() ? BuildJsonRpcTerminalResult(id) : helpers::JsonRpcStreamText(helpers::ErrorToResponse(outcome.error(), id)); - (void)co_await smithy::eventstream::SendMessage(socket, std::move(terminal)); + (void)co_await opal::eventstream::SendMessage(socket, std::move(terminal)); stream.Close(); } // The blocking seam's shared-endpoint driver (ADR-0023). -void ServeJsonRpcStream(types::CalculatorHandler& handler, const smithy::server::RequestContext& context, smithy::http::WebSocket& socket) { +void ServeJsonRpcStream(types::CalculatorHandler& handler, const opal::server::RequestContext& context, opal::http::WebSocket& socket) { auto first = socket.Receive(); // A wire that failed or closed before the opening call is a non-event. if (!first.ok() || !first->has_value()) return; @@ -264,7 +264,7 @@ void ServeJsonRpcStream(types::CalculatorHandler& handler, const smithy::server: input = *std::move(parsed); // The union is the session, never an opening member (ADR-0023). input.terms.reset(); - smithy::eventstream::JsonRpcStreamSocket wrapped(socket, opening.id, smithy::eventstream::JsonRpcStreamSocket::Role::kServer); + opal::eventstream::JsonRpcStreamSocket wrapped(socket, opening.id, opal::eventstream::JsonRpcStreamSocket::Role::kServer); types::AccumulateServerStream stream(wrapped, helpers::EncodeAccumulateEvent, helpers::DecodeAccumulateEvent); auto outcome = handler.Accumulate(input, stream, context); // The terminal response rides the raw socket: the wrapper only speaks @@ -282,12 +282,12 @@ void ServeJsonRpcStream(types::CalculatorHandler& handler, const smithy::server: // The session seam's shared-endpoint driver (ADR-0021/0023): the opening // envelope is read inside this Detached frame — a client that upgrades // and never calls costs no parked thread. -smithy::eventstream::Detached ServeJsonRpcSession(std::shared_ptr handler, std::shared_ptr socket) { - auto first = co_await smithy::eventstream::ReceiveMessage(socket); +opal::eventstream::Detached ServeJsonRpcSession(std::shared_ptr handler, std::shared_ptr socket) { + auto first = co_await opal::eventstream::ReceiveMessage(socket); if (!first.ok() || !first->has_value()) co_return; const JsonRpcOpening opening = helpers::ParseJsonRpcOpening(**first); if (!opening.ok) { - (void)co_await smithy::eventstream::SendMessage(socket, opening.refusal); + (void)co_await opal::eventstream::SendMessage(socket, opening.refusal); socket->Close(); co_return; } @@ -295,7 +295,7 @@ smithy::eventstream::Detached ServeJsonRpcSession(std::shared_ptrClose(); co_return; } @@ -305,7 +305,7 @@ smithy::eventstream::Detached ServeJsonRpcSession(std::shared_ptrClose(); co_return; } @@ -314,34 +314,34 @@ smithy::eventstream::Detached ServeJsonRpcSession(std::shared_ptr handler) - : router_(std::make_shared()), - stream_router_(std::make_shared()) { + : router_(std::make_shared()), + stream_router_(std::make_shared()) { // The route table is derived from the model's @http traits; conflicts are // a modeling error surfaced by Router::Add (checked at generation time in a // later phase), so registration results are intentionally discarded. - (void)router_->Add("POST", "/", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { - smithy::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) + (void)router_->Add("POST", "/", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { + opal::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) // A present Content-Type must carry application/json (parameters ignored). - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { return helpers::JsonRpcError(-32600, "UnsupportedMediaTypeException", "expected content-type: application/json", {}, id); } - auto decoded = smithy::json::Decode(request.body); + auto decoded = opal::json::Decode(request.body); // Envelope failure messages are fixed strings: the conformance suite // compares bodies exactly, so no decoder detail leaks into the wire. if (!decoded) return helpers::JsonRpcError(-32700, "SerializationException", "request body is not valid JSON", {}, id); if (!decoded->is_map()) return helpers::JsonRpcError(-32600, "SerializationException", "request is not a JSON-RPC 2.0 call", {}, id); - if (const smithy::Document* id_doc = decoded->Find("id"); id_doc != nullptr) id = *id_doc; - const smithy::Document* version = decoded->Find("jsonrpc"); + if (const opal::Document* id_doc = decoded->Find("id"); id_doc != nullptr) id = *id_doc; + const opal::Document* version = decoded->Find("jsonrpc"); if (version == nullptr || !version->is_string() || version->as_string() != "2.0") { return helpers::JsonRpcError(-32600, "SerializationException", "expected jsonrpc: \"2.0\"", {}, id); } - const smithy::Document* method = decoded->Find("method"); + const opal::Document* method = decoded->Find("method"); if (method == nullptr || !method->is_string()) { return helpers::JsonRpcError(-32600, "SerializationException", "expected a string method member", {}, id); } // Absent/null params deserialize like an empty object. - const smithy::Document empty_params{smithy::DocumentMap{}}; - const smithy::Document* params = decoded->Find("params"); + const opal::Document empty_params{opal::DocumentMap{}}; + const opal::Document* params = decoded->Find("params"); if (params == nullptr || params->is_null()) params = &empty_params; const std::string& method_name = method->as_string(); if (method_name == "Add") { @@ -361,41 +361,41 @@ CalculatorServer::CalculatorServer(std::shared_ptr handler) // the unary table above. // One shared-endpoint stream route (ADR-0023): the wire routes on the // opening envelope's method, exactly like the unary POST "/" above. - (void)stream_router_->Add("GET", "/", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, smithy::http::WebSocket& socket) { + (void)stream_router_->Add("GET", "/", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context, opal::http::WebSocket& socket) { (void)request; helpers::ServeJsonRpcStream(*handler, context, socket); }, "Calculator"); } CalculatorServer::CalculatorServer(std::shared_ptr handler) - : router_(std::make_shared()), - stream_router_(std::make_shared()) { + : router_(std::make_shared()), + stream_router_(std::make_shared()) { // The same unary table; every streaming route rides the shared-session // seam (ADR-0021) — an AddSession launch point per operation, so serving // a stream parks no handler thread. - (void)router_->Add("POST", "/", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { - smithy::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) + (void)router_->Add("POST", "/", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { + opal::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) // A present Content-Type must carry application/json (parameters ignored). - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { return helpers::JsonRpcError(-32600, "UnsupportedMediaTypeException", "expected content-type: application/json", {}, id); } - auto decoded = smithy::json::Decode(request.body); + auto decoded = opal::json::Decode(request.body); // Envelope failure messages are fixed strings: the conformance suite // compares bodies exactly, so no decoder detail leaks into the wire. if (!decoded) return helpers::JsonRpcError(-32700, "SerializationException", "request body is not valid JSON", {}, id); if (!decoded->is_map()) return helpers::JsonRpcError(-32600, "SerializationException", "request is not a JSON-RPC 2.0 call", {}, id); - if (const smithy::Document* id_doc = decoded->Find("id"); id_doc != nullptr) id = *id_doc; - const smithy::Document* version = decoded->Find("jsonrpc"); + if (const opal::Document* id_doc = decoded->Find("id"); id_doc != nullptr) id = *id_doc; + const opal::Document* version = decoded->Find("jsonrpc"); if (version == nullptr || !version->is_string() || version->as_string() != "2.0") { return helpers::JsonRpcError(-32600, "SerializationException", "expected jsonrpc: \"2.0\"", {}, id); } - const smithy::Document* method = decoded->Find("method"); + const opal::Document* method = decoded->Find("method"); if (method == nullptr || !method->is_string()) { return helpers::JsonRpcError(-32600, "SerializationException", "expected a string method member", {}, id); } // Absent/null params deserialize like an empty object. - const smithy::Document empty_params{smithy::DocumentMap{}}; - const smithy::Document* params = decoded->Find("params"); + const opal::Document empty_params{opal::DocumentMap{}}; + const opal::Document* params = decoded->Find("params"); if (params == nullptr || params->is_null()) params = &empty_params; const std::string& method_name = method->as_string(); if (method_name == "Add") { @@ -410,19 +410,19 @@ CalculatorServer::CalculatorServer(std::shared_ptr handl } return helpers::JsonRpcError(-32601, "UnknownOperationException", "unknown method: " + method_name, {}, id); }); - (void)stream_router_->AddSession("GET", "/", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::shared_ptr socket) { + (void)stream_router_->AddSession("GET", "/", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::shared_ptr socket) { (void)request; (void)context; helpers::ServeJsonRpcSession(handler, std::move(socket)); }, "Calculator"); } -smithy::http::RequestHandler CalculatorServer::Handler() const { +opal::http::RequestHandler CalculatorServer::Handler() const { auto router = router_; - return [router](const smithy::http::HttpRequest& request) { return router->Route(request); }; + return [router](const opal::http::HttpRequest& request) { return router->Route(request); }; } -std::shared_ptr CalculatorServer::StreamRouter() const { +std::shared_ptr CalculatorServer::StreamRouter() const { return stream_router_; } diff --git a/examples/jsonrpc2/generated/tests/integration_test.cc b/examples/jsonrpc2/generated/tests/integration_test.cc index 77e141b7..9dafcbad 100644 --- a/examples/jsonrpc2/generated/tests/integration_test.cc +++ b/examples/jsonrpc2/generated/tests/integration_test.cc @@ -143,27 +143,27 @@ class ScriptedHandler final : public CalculatorHandler { public: // Streaming operation (ADR-0016): no generated unary-shaped test drives // this; the stub closes the stream so the interface stays implemented. - smithy::Outcome Accumulate(const AccumulateInput& input, AccumulateServerStream& stream, const smithy::server::RequestContext&) override { + opal::Outcome Accumulate(const AccumulateInput& input, AccumulateServerStream& stream, const opal::server::RequestContext&) override { (void)input; stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } - smithy::Outcome Add(const AddInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Add(const AddInput& input, const opal::server::RequestContext&) override { lastAdd = input; if (nextAddError.has_value()) return *nextAddError; return nextAddOutput; } std::optional lastAdd; AddOutput nextAddOutput{}; - std::optional nextAddError; - smithy::Outcome Divide(const DivideInput& input, const smithy::server::RequestContext&) override { + std::optional nextAddError; + opal::Outcome Divide(const DivideInput& input, const opal::server::RequestContext&) override { lastDivide = input; if (nextDivideError.has_value()) return *nextDivideError; return nextDivideOutput; } std::optional lastDivide; DivideOutput nextDivideOutput{}; - std::optional nextDivideError; + std::optional nextDivideError; }; enum class TransportKind { kLoopback, kSocket }; @@ -173,14 +173,14 @@ class CalculatorIntegrationTest : public ::testing::TestWithParam void SetUp() override { handler_ = std::make_shared(); server_ = std::make_unique(handler_); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries if (GetParam() == TransportKind::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); config.http_client = loopback; } else { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(server_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } @@ -193,7 +193,7 @@ class CalculatorIntegrationTest : public ::testing::TestWithParam std::shared_ptr handler_; std::unique_ptr server_; - std::unique_ptr socket_server_; + std::unique_ptr socket_server_; std::unique_ptr client_; }; @@ -252,13 +252,13 @@ TEST_P(CalculatorIntegrationTest, DivideMaximalRoundTrips) { TEST_P(CalculatorIntegrationTest, DivideDivisionByZeroMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const DivisionByZero detail = RandomDivisionByZero(rng); - smithy::Error error = smithy::Error::Modeled("DivisionByZero", "integration"); + opal::Error error = opal::Error::Modeled("DivisionByZero", "integration"); error.set_detail(detail); handler_->nextDivideError = error; const DivideInput input = RandomDivideInput(rng); const auto outcome = client_->Divide(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "DivisionByZero"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -267,17 +267,17 @@ TEST_P(CalculatorIntegrationTest, DivideDivisionByZeroMapsAcrossTheWire) { TEST(CalculatorIntegrationUnknownMembers, AddToleratesUnknownResponseMembers) { auto handler = std::make_shared(); CalculatorServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *CalculatorClient::Create(std::move(config)); @@ -293,17 +293,17 @@ TEST(CalculatorIntegrationUnknownMembers, AddToleratesUnknownResponseMembers) { TEST(CalculatorIntegrationUnknownMembers, DivideToleratesUnknownResponseMembers) { auto handler = std::make_shared(); CalculatorServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *CalculatorClient::Create(std::move(config)); diff --git a/examples/jsonrpc2/generated/tests/smoke_test.cc b/examples/jsonrpc2/generated/tests/smoke_test.cc index 58e3a15a..be67b6eb 100644 --- a/examples/jsonrpc2/generated/tests/smoke_test.cc +++ b/examples/jsonrpc2/generated/tests/smoke_test.cc @@ -36,16 +36,16 @@ class SmokeHandler : public CalculatorHandler { public: // Streaming operation (ADR-0016): no generated unary-shaped test drives // this; the stub closes the stream so the interface stays implemented. - smithy::Outcome Accumulate(const AccumulateInput& input, AccumulateServerStream& stream, const smithy::server::RequestContext&) override { + opal::Outcome Accumulate(const AccumulateInput& input, AccumulateServerStream& stream, const opal::server::RequestContext&) override { (void)input; stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } - smithy::Outcome Add(const AddInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Add(const AddInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalAddOutput(); } - smithy::Outcome Divide(const DivideInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Divide(const DivideInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalDivideOutput(); } @@ -53,9 +53,9 @@ class SmokeHandler : public CalculatorHandler { CalculatorClient MakeClient(std::shared_ptr handler) { CalculatorServer server(std::move(handler)); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = loopback; // Create cannot fail when a transport is injected. @@ -89,9 +89,9 @@ TEST(CalculatorSmokeTest, DivideRoundTrips) { TEST(CalculatorSmokeTest, ModeledErrorsMapAcrossTheWire) { class FailingHandler final : public SmokeHandler { public: - smithy::Outcome Divide(const DivideInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Divide(const DivideInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("DivisionByZero", "smoke"); + opal::Error error = opal::Error::Modeled("DivisionByZero", "smoke"); auto detail = [] { DivisionByZero v{}; return v; @@ -109,7 +109,7 @@ TEST(CalculatorSmokeTest, ModeledErrorsMapAcrossTheWire) { }(); const auto outcome = client.Divide(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "DivisionByZero"); EXPECT_EQ(outcome.error().message(), "smoke"); EXPECT_NE(outcome.error().detail(), nullptr); diff --git a/examples/jsonrpc2/interop_wire_test.cc b/examples/jsonrpc2/interop_wire_test.cc index a61b9d1b..42398b38 100644 --- a/examples/jsonrpc2/interop_wire_test.cc +++ b/examples/jsonrpc2/interop_wire_test.cc @@ -22,15 +22,15 @@ namespace { class Handler final : public CalculatorHandler { public: - smithy::Outcome Add(const AddInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Add(const AddInput& input, + const opal::server::RequestContext&) override { return AddOutput{.sum = input.a + input.b}; } - smithy::Outcome Divide(const DivideInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome Divide(const DivideInput& input, + const opal::server::RequestContext&) override { if (input.divisor == 0) { - smithy::Error error = smithy::Error::Modeled("DivisionByZero", "division by zero"); + opal::Error error = opal::Error::Modeled("DivisionByZero", "division by zero"); error.set_detail(DivisionByZero{.message = "division by zero"}); return error; } @@ -40,16 +40,16 @@ class Handler final : public CalculatorHandler { // Streaming rides the WebSocket endpoint, not the POST wire this suite // drives; the stub keeps the interface implemented (stream_e2e_test.cc // owns the real flows). - smithy::Outcome Accumulate(const AccumulateInput&, AccumulateServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Accumulate(const AccumulateInput&, AccumulateServerStream& stream, + const opal::server::RequestContext&) override { stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } }; -smithy::http::HttpResponse Call(const std::string& body) { +opal::http::HttpResponse Call(const std::string& body) { CalculatorServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); @@ -64,12 +64,12 @@ TEST(JsonRpc2InteropTest, HandRolledCallWithStringIdRoundTrips) { const auto response = Call(R"({"jsonrpc":"2.0","method":"Add","params":{"a":2,"b":3},"id":"abc-123"})"); EXPECT_EQ(response.status, 200); - auto doc = smithy::json::Decode(response.body); + auto doc = opal::json::Decode(response.body); ASSERT_TRUE(doc.ok()) << response.body; ASSERT_TRUE(doc->is_map()); EXPECT_EQ(doc->Find("jsonrpc")->as_string(), "2.0"); EXPECT_EQ(doc->Find("id")->as_string(), "abc-123"); - const smithy::Document* result = doc->Find("result"); + const opal::Document* result = doc->Find("result"); ASSERT_NE(result, nullptr) << response.body; EXPECT_EQ(result->Find("sum")->AsNumber(), 5.0); } @@ -78,13 +78,13 @@ TEST(JsonRpc2InteropTest, ModeledErrorsArriveAsJsonRpcErrorObjects) { const auto response = Call(R"({"jsonrpc":"2.0","method":"Divide","params":{"dividend":1,"divisor":0},"id":7})"); EXPECT_EQ(response.status, 200); // JSON-RPC errors are HTTP 200 envelopes. - auto doc = smithy::json::Decode(response.body); + auto doc = opal::json::Decode(response.body); ASSERT_TRUE(doc.ok()) << response.body; - const smithy::Document* error = doc->Find("error"); + const opal::Document* error = doc->Find("error"); ASSERT_NE(error, nullptr) << response.body; EXPECT_EQ(error->Find("code")->as_int(), 422); // @httpError(422) EXPECT_EQ(error->Find("message")->as_string(), "division by zero"); - const smithy::Document* data = error->Find("data"); + const opal::Document* data = error->Find("data"); ASSERT_NE(data, nullptr); EXPECT_EQ(data->Find("__type")->as_string(), "example.calculator#DivisionByZero"); EXPECT_EQ(doc->Find("id")->as_int(), 7); @@ -92,34 +92,33 @@ TEST(JsonRpc2InteropTest, ModeledErrorsArriveAsJsonRpcErrorObjects) { // A JSON-RPC responder that was never generated from the model: it dispatches // on the envelope itself, the way any off-the-shelf JSON-RPC library would. -class HandRolledPeer final : public smithy::http::HttpClient { +class HandRolledPeer final : public opal::http::HttpClient { public: - smithy::Outcome Send( - const smithy::http::HttpRequest& request) override { - auto doc = smithy::json::Decode(request.body); - if (!doc.ok() || !doc->is_map()) return smithy::http::HttpResponse{400, {}, ""}; + opal::Outcome Send(const opal::http::HttpRequest& request) override { + auto doc = opal::json::Decode(request.body); + if (!doc.ok() || !doc->is_map()) return opal::http::HttpResponse{400, {}, ""}; last_envelope = *std::move(doc); const std::string& method = last_envelope.Find("method")->as_string(); std::string result; if (method == "Add") { - const smithy::Document* params = last_envelope.Find("params"); + const opal::Document* params = last_envelope.Find("params"); const double sum = params->Find("a")->AsNumber() + params->Find("b")->AsNumber(); result = R"({"jsonrpc":"2.0","result":{"sum":)" + std::to_string(sum) + R"(},"id":1})"; } else { result = R"({"jsonrpc":"2.0","error":{"code":422,"message":"nope","data":)" R"({"__type":"example.calculator#DivisionByZero","message":"nope"}},"id":1})"; } - smithy::http::HttpResponse response{200, {}, std::move(result)}; + opal::http::HttpResponse response{200, {}, std::move(result)}; response.headers.Set("content-type", "application/json"); return response; } - smithy::Document last_envelope; + opal::Document last_envelope; }; TEST(JsonRpc2InteropTest, GeneratedClientTalksToAHandRolledPeer) { auto peer = std::make_shared(); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = peer; auto client = CalculatorClient::Create(std::move(config)); ASSERT_TRUE(client.ok()) << client.error().message(); @@ -146,10 +145,10 @@ TEST(JsonRpc2InteropTest, GeneratedClientTalksToAHandRolledPeer) { // 400 class. The constant is chosen so the pre-fix code lands *inside* the // 100-599 window (as a retryable 503): a value that truncates outside it // would classify as 400 under old and new code alike and pin nothing. -class HugeErrorCodePeer final : public smithy::http::HttpClient { +class HugeErrorCodePeer final : public opal::http::HttpClient { public: - smithy::Outcome Send(const smithy::http::HttpRequest&) override { - smithy::http::HttpResponse response{ + opal::Outcome Send(const opal::http::HttpRequest&) override { + opal::http::HttpResponse response{ 200, {}, R"({"jsonrpc":"2.0","error":{"code":21474836983,"message":"kaboom"},"id":1})"}; response.headers.Set("content-type", "application/json"); return response; @@ -157,7 +156,7 @@ class HugeErrorCodePeer final : public smithy::http::HttpClient { }; TEST(JsonRpc2InteropTest, ErrorCodesBeyondInt32AreNotTruncatedIntoTheHttpRange) { - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = std::make_shared(); auto client = CalculatorClient::Create(std::move(config)); ASSERT_TRUE(client.ok()) << client.error().message(); @@ -175,15 +174,15 @@ TEST(JsonRpc2InteropTest, ErrorCodesBeyondInt32AreNotTruncatedIntoTheHttpRange) // one passes through untouched. TEST(JsonRpc2InteropTest, IdempotencyTokenAutoFills) { auto peer = std::make_shared(); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = peer; auto client = CalculatorClient::Create(std::move(config)); ASSERT_TRUE(client.ok()) << client.error().message(); (void)client->Divide(DivideInput{.dividend = 4, .divisor = 2}); - const smithy::Document* params = peer->last_envelope.Find("params"); + const opal::Document* params = peer->last_envelope.Find("params"); ASSERT_NE(params, nullptr); - const smithy::Document* token = params->Find("requestToken"); + const opal::Document* token = params->Find("requestToken"); ASSERT_NE(token, nullptr) << "unset @idempotencyToken must be auto-filled"; EXPECT_EQ(token->as_string().size(), 36u); // UUIDv4 text form @@ -200,25 +199,25 @@ TEST(JsonRpc2InteropTest, IdempotencyTokenAutoFills) { TEST(JsonRpc2InteropTest, EnvelopeDispatchThreadsTheRequestContext) { class ContextProbe final : public CalculatorHandler { public: - smithy::Outcome Add(const AddInput&, - const smithy::server::RequestContext& context) override { + opal::Outcome Add(const AddInput&, + const opal::server::RequestContext& context) override { const bool threaded = context.request != nullptr && context.request->method == "POST" && context.request->headers.Get("x-probe").value_or("") == "42"; return AddOutput{.sum = threaded ? 1.0 : 0.0}; } - smithy::Outcome Divide(const DivideInput&, - const smithy::server::RequestContext&) override { + opal::Outcome Divide(const DivideInput&, + const opal::server::RequestContext&) override { return DivideOutput{.quotient = 0}; } - smithy::Outcome Accumulate(const AccumulateInput&, AccumulateServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome Accumulate(const AccumulateInput&, AccumulateServerStream& stream, + const opal::server::RequestContext&) override { stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } }; CalculatorServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); diff --git a/examples/jsonrpc2/stream_e2e_beast_test.cc b/examples/jsonrpc2/stream_e2e_beast_test.cc index 1766803b..870247d6 100644 --- a/examples/jsonrpc2/stream_e2e_beast_test.cc +++ b/examples/jsonrpc2/stream_e2e_beast_test.cc @@ -27,9 +27,9 @@ namespace example::calculator { namespace { -smithy::eventstream::Message RawText(std::string text) { - smithy::eventstream::Message message; - message.payload = smithy::Blob::FromString(std::move(text)); +opal::eventstream::Message RawText(std::string text) { + opal::eventstream::Message message; + message.payload = opal::Blob::FromString(std::move(text)); return message; } @@ -43,7 +43,7 @@ class AccumulateBeastEndToEndTest : public testing::Test { session_seam ? std::make_unique(std::make_shared()) : std::make_unique(std::make_shared()); - smithy::http::BeastServerTransport::Options options; + opal::http::BeastServerTransport::Options options; options.websocket_gate = server_->StreamRouter()->Gate(); if (session_seam) { options.on_websocket_session = server_->StreamRouter()->ServeSession(); @@ -52,20 +52,20 @@ class AccumulateBeastEndToEndTest : public testing::Test { } options.websocket_raw_text_frames = true; if (tls) { - options.tls_certificate_chain_pem = smithy::testing::kTestCertificatePem; - options.tls_private_key_pem = smithy::testing::kTestPrivateKeyPem; + options.tls_certificate_chain_pem = opal::testing::kTestCertificatePem; + options.tls_private_key_pem = opal::testing::kTestPrivateKeyPem; } - transport_ = std::make_unique(options); + transport_ = std::make_unique(options); ASSERT_TRUE(transport_->Start(server_->Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; if (tls) { // One endpoint configures both directions: the unary transport and // the streaming dial derive wss/TLS from it (nothing twice). config.endpoint = "https://127.0.0.1:" + std::to_string(transport_->port()); - config.tls.ca_pem = smithy::testing::kTestCertificatePem; - auto http_client = smithy::http::BeastHttpClient::FromConfig(config); + config.tls.ca_pem = opal::testing::kTestCertificatePem; + auto http_client = opal::http::BeastHttpClient::FromConfig(config); ASSERT_TRUE(http_client.ok()) << http_client.error().message(); config.http_client = *http_client; } else { @@ -98,7 +98,7 @@ class AccumulateBeastEndToEndTest : public testing::Test { } std::unique_ptr server_; - std::unique_ptr transport_; + std::unique_ptr transport_; std::unique_ptr client_; }; @@ -122,7 +122,7 @@ TEST_F(AccumulateBeastEndToEndTest, TheModeledOverflowIsTypedOverTheRealWire) { ASSERT_TRUE(stream->Send(Terms::FromAdd(Term{.value = 20})).ok()); auto outcome = stream->Receive(); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "Overflow"); const Overflow* detail = outcome.error().detail(); ASSERT_NE(detail, nullptr); @@ -156,7 +156,7 @@ TEST_F(AccumulateBeastEndToEndTest, ABrowserShapedPeerExchangesThePinnedText) { // arrives — expressed through the raw-text dial: every frame below is // one text WebSocket message carrying exactly these bytes. Start(/*session_seam=*/true); - auto peer = smithy::http::BeastWebSocketClient::Dial( + auto peer = opal::http::BeastWebSocketClient::Dial( {.host = "127.0.0.1", .port = transport_->port(), .raw_text_frames = true}); ASSERT_TRUE(peer.ok()) << peer.error().message(); @@ -195,7 +195,7 @@ TEST_F(AccumulateBeastEndToEndTest, AMidStreamViolationEarnsTheReservedCodeOverT // the opening id, and the close rides behind the write — the peer reads // the envelope, then the clean close, in that order. Start(/*session_seam=*/true); - auto peer = smithy::http::BeastWebSocketClient::Dial( + auto peer = opal::http::BeastWebSocketClient::Dial( {.host = "127.0.0.1", .port = transport_->port(), .raw_text_frames = true}); ASSERT_TRUE(peer.ok()) << peer.error().message(); diff --git a/examples/jsonrpc2/stream_e2e_test.cc b/examples/jsonrpc2/stream_e2e_test.cc index 15afc3e5..60960864 100644 --- a/examples/jsonrpc2/stream_e2e_test.cc +++ b/examples/jsonrpc2/stream_e2e_test.cc @@ -25,9 +25,9 @@ namespace { // One raw wire frame: a headerless message whose payload is the envelope // text — exactly what a browser's WebSocket send() puts on a real wire. -smithy::eventstream::Message RawText(std::string text) { - smithy::eventstream::Message message; - message.payload = smithy::Blob::FromString(std::move(text)); +opal::eventstream::Message RawText(std::string text) { + opal::eventstream::Message message; + message.payload = opal::Blob::FromString(std::move(text)); return message; } @@ -74,7 +74,7 @@ class AccumulateEndToEndTest : public StreamTestFixture { ASSERT_TRUE(stream->Send(Terms::FromAdd(Term{.value = 20})).ok()); auto outcome = stream->Receive(); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "Overflow"); const Overflow* detail = outcome.error().detail(); ASSERT_NE(detail, nullptr); @@ -118,7 +118,7 @@ TEST_F(AccumulateEndToEndTest, TheWireIsPlainJsonRpcTextEndToEnd) { // params, and observes a well-formed response for its call, then the // close. Byte-pinned: the runtime's JSON output is deterministic. StartWithAsync(std::make_shared()); - auto [near, far] = smithy::http::InMemoryWebSocketPair::Create(); + auto [near, far] = opal::http::InMemoryWebSocketPair::Create(); sessions_.push_back(near); sessions_.push_back(far); Serve("/", far); @@ -155,7 +155,7 @@ TEST_F(AccumulateEndToEndTest, AUnaryMethodOnTheStreamEndpointIsUnknown) { // The stream endpoint dispatches streaming operations only; a unary // method name earns the reserved -32601 as a terminal error, then close. StartWithAsync(std::make_shared()); - auto [near, far] = smithy::http::InMemoryWebSocketPair::Create(); + auto [near, far] = opal::http::InMemoryWebSocketPair::Create(); sessions_.push_back(near); sessions_.push_back(far); Serve("/", far); diff --git a/examples/jsonrpc2/stream_test_fixture.h b/examples/jsonrpc2/stream_test_fixture.h index 998e8ec8..b50d2070 100644 --- a/examples/jsonrpc2/stream_test_fixture.h +++ b/examples/jsonrpc2/stream_test_fixture.h @@ -46,15 +46,15 @@ class StreamTestFixture : public testing::Test { void Start(std::unique_ptr server, bool session_seam) { server_ = std::move(server); session_seam_ = session_seam; - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; config.http_client = loopback; // the unary neighbors' transport - config.websocket_dialer = [this](const smithy::http::WebSocketDialRequest& request) - -> smithy::Outcome> { + config.websocket_dialer = [this](const opal::http::WebSocketDialRequest& request) + -> opal::Outcome> { last_dialed_target_ = request.target; - auto [near, far] = smithy::http::InMemoryWebSocketPair::Create(); + auto [near, far] = opal::http::InMemoryWebSocketPair::Create(); sessions_.push_back(far); Serve(request.target, far); return near; @@ -67,8 +67,8 @@ class StreamTestFixture : public testing::Test { // Routes one server end through the generated StreamRouter, the way the // transport would after the upgrade. Also used directly by wire-level // tests that speak raw envelopes on the near end instead of dialing. - void Serve(const std::string& target, std::shared_ptr session) { - smithy::http::HttpRequest upgrade; + void Serve(const std::string& target, std::shared_ptr session) { + opal::http::HttpRequest upgrade; upgrade.method = "GET"; upgrade.target = target; if (session_seam_) { @@ -89,7 +89,7 @@ class StreamTestFixture : public testing::Test { std::unique_ptr server_; std::unique_ptr client_; // Every dialed or hand-made far end — closed in TearDown regardless. - std::vector> sessions_; + std::vector> sessions_; std::vector threads_; std::string last_dialed_target_; bool session_seam_ = false; diff --git a/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/client.h b/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/client.h index c6006a56..59b217d4 100644 --- a/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/client.h +++ b/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/client.h @@ -23,30 +23,30 @@ namespace example::roundtrip::jsonrpc { /// jsonRpc2 client for example.roundtrip#RoundTripJsonRpc. -/// Modeled service errors surface as smithy::Error with kind kModeled, +/// Modeled service errors surface as opal::Error with kind kModeled, /// code() set to the error shape name, and the deserialized error /// structure attached. Dispatch on them through the per-operation /// Errors listings below rather than comparing code() text. class RoundTripJsonRpcClient { public: /// Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); + static opal::Outcome Create(opal::ClientConfig config); /// The RPC variant round-trips the same kitchen sink over CBOR — compressed, /// so the rpcv2Cbor decompress path and jsonRpc2's shared-endpoint /// anyCompressed branch both land in compiled goldens (issue #68). - smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input) const; + opal::Outcome PutSinkRpc(const PutSinkRpcInput& input) const; private: - RoundTripJsonRpcClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix); - smithy::Outcome Send(smithy::http::HttpRequest request) const; + RoundTripJsonRpcClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix); + opal::Outcome Send(opal::http::HttpRequest request) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; -/// The modeled errors of PutSinkRpc, matched from a smithy::Error so dispatch is +/// The modeled errors of PutSinkRpc, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -57,9 +57,9 @@ class PutSinkRpcErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static PutSinkRpcErrors FromError(const smithy::Error& error) { + static PutSinkRpcErrors FromError(const opal::Error& error) { PutSinkRpcErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "SinkNotFound") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : SinkNotFound{}); @@ -111,11 +111,11 @@ class PutSinkRpcErrors { switch (value_.index()) { case 1: out += "sink_not_found = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "sink_quota_exceeded = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -134,7 +134,7 @@ class PutSinkRpcErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("PutSinkRpcErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("PutSinkRpcErrors", requested, case_name()); } } @@ -151,8 +151,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::jsonrpc::PutSinkRpcErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; diff --git a/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/serde.h b/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/serde.h index 9f5f5b08..6cdbf6ff 100644 --- a/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/serde.h +++ b/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/serde.h @@ -16,41 +16,41 @@ namespace example::roundtrip::jsonrpc { // Document-pivot serde for every aggregate shape in the model closure. -// Serializers never fail; deserializers return smithy::Error on wire +// Serializers never fail; deserializers return opal::Error on wire // mismatches and enforce @required members. -smithy::Document SerializeStringMap(const std::map& value); -smithy::Outcome> DeserializeStringMap(const smithy::Document& doc); +opal::Document SerializeStringMap(const std::map& value); +opal::Outcome> DeserializeStringMap(const opal::Document& doc); -smithy::Document SerializeNestedConfig(const NestedConfig& value); -smithy::Outcome DeserializeNestedConfig(const smithy::Document& doc); +opal::Document SerializeNestedConfig(const NestedConfig& value); +opal::Outcome DeserializeNestedConfig(const opal::Document& doc); -smithy::Document SerializeSinkChoice(const SinkChoice& value); -smithy::Outcome DeserializeSinkChoice(const smithy::Document& doc); +opal::Document SerializeSinkChoice(const SinkChoice& value); +opal::Outcome DeserializeSinkChoice(const opal::Document& doc); -smithy::Document SerializeStringList(const std::vector& value); -smithy::Outcome> DeserializeStringList(const smithy::Document& doc); +opal::Document SerializeStringList(const std::vector& value); +opal::Outcome> DeserializeStringList(const opal::Document& doc); -smithy::Document SerializeSparseIntegerList(const std::vector>& value); -smithy::Outcome>> DeserializeSparseIntegerList(const smithy::Document& doc); +opal::Document SerializeSparseIntegerList(const std::vector>& value); +opal::Outcome>> DeserializeSparseIntegerList(const opal::Document& doc); -smithy::Document SerializeUniqueStringList(const std::vector& value); -smithy::Outcome> DeserializeUniqueStringList(const smithy::Document& doc); +opal::Document SerializeUniqueStringList(const std::vector& value); +opal::Outcome> DeserializeUniqueStringList(const opal::Document& doc); -smithy::Document SerializeKitchenSink(const KitchenSink& value); -smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc); +opal::Document SerializeKitchenSink(const KitchenSink& value); +opal::Outcome DeserializeKitchenSink(const opal::Document& doc); -smithy::Document SerializeSinkNotFound(const SinkNotFound& value); -smithy::Outcome DeserializeSinkNotFound(const smithy::Document& doc); +opal::Document SerializeSinkNotFound(const SinkNotFound& value); +opal::Outcome DeserializeSinkNotFound(const opal::Document& doc); -smithy::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value); -smithy::Outcome DeserializeSinkQuotaExceeded(const smithy::Document& doc); +opal::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value); +opal::Outcome DeserializeSinkQuotaExceeded(const opal::Document& doc); -smithy::Document SerializePutSinkRpcInput(const PutSinkRpcInput& value); -smithy::Outcome DeserializePutSinkRpcInput(const smithy::Document& doc); +opal::Document SerializePutSinkRpcInput(const PutSinkRpcInput& value); +opal::Outcome DeserializePutSinkRpcInput(const opal::Document& doc); -smithy::Document SerializePutSinkRpcOutput(const PutSinkRpcOutput& value); -smithy::Outcome DeserializePutSinkRpcOutput(const smithy::Document& doc); +opal::Document SerializePutSinkRpcOutput(const PutSinkRpcOutput& value); +opal::Outcome DeserializePutSinkRpcOutput(const opal::Document& doc); } // namespace example::roundtrip::jsonrpc diff --git a/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/server.h b/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/server.h index 6d3964cb..b14a6b1d 100644 --- a/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/server.h +++ b/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/server.h @@ -13,10 +13,10 @@ namespace example::roundtrip::jsonrpc { /// Implement one method per operation. Return a modeled error as -/// smithy::Error::Modeled("", message), optionally with the +/// opal::Error::Modeled("", message), optionally with the /// typed error structure attached via set_detail() so it serializes fully. /// The context carries the raw request and routing captures — see -/// smithy::server::RequestContext; leave the parameter unnamed when unused. +/// opal::server::RequestContext; leave the parameter unnamed when unused. /// Implementations must be thread-safe: transports may invoke any mix of /// operations concurrently on the one handler instance. class RoundTripJsonRpcHandler { @@ -26,20 +26,20 @@ class RoundTripJsonRpcHandler { /// The RPC variant round-trips the same kitchen sink over CBOR — compressed, /// so the rpcv2Cbor decompress path and jsonRpc2's shared-endpoint /// anyCompressed branch both land in compiled goldens (issue #68). - virtual smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome PutSinkRpc(const PutSinkRpcInput& input, const opal::server::RequestContext& context) = 0; }; /// jsonRpc2 server for example.roundtrip#RoundTripJsonRpc: routing, deserialization, handler dispatch, /// response serialization, and modeled-error mapping. Pass Handler() to any -/// smithy::http::HttpServerTransport. +/// opal::http::HttpServerTransport. class RoundTripJsonRpcServer { public: explicit RoundTripJsonRpcServer(std::shared_ptr handler); - smithy::http::RequestHandler Handler() const; + opal::http::RequestHandler Handler() const; private: - std::shared_ptr router_; + std::shared_ptr router_; }; } // namespace example::roundtrip::jsonrpc diff --git a/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/types.h b/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/types.h index 7012795e..fc0e5278 100644 --- a/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/types.h +++ b/examples/roundtrip/jsonrpc/generated/include/example/roundtrip/jsonrpc/types.h @@ -35,12 +35,12 @@ struct NestedConfig { out += sep; sep = ", "; out += ".label = "; - smithy::DebugAppend(out, this->label); + opal::DebugAppend(out, this->label); if (this->depth.has_value()) { out += sep; sep = ", "; out += ".depth = "; - smithy::DebugAppend(out, *this->depth); + opal::DebugAppend(out, *this->depth); } out += '}'; } @@ -119,15 +119,15 @@ class SinkChoice { switch (value_.index()) { case 1: out += "text = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "count = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "nested = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; default: break; @@ -146,7 +146,7 @@ class SinkChoice { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("SinkChoice", requested, case_name()); + opal::internal::FatalWrongUnionAccess("SinkChoice", requested, case_name()); } } @@ -230,12 +230,12 @@ struct KitchenSink { std::optional big{}; std::optional ratio{}; std::optional precise{}; - std::optional blob{}; + std::optional blob{}; std::optional priority{}; std::optional weight{}; - std::optional dateTime{}; - std::optional httpDate{}; - std::optional epoch{}; + std::optional dateTime{}; + std::optional httpDate{}; + std::optional epoch{}; std::optional> names{}; std::optional> uniqueNames{}; std::optional>> sparseNumbers{}; @@ -250,120 +250,120 @@ struct KitchenSink { out += sep; sep = ", "; out += ".name = "; - smithy::DebugAppend(out, this->name); + opal::DebugAppend(out, this->name); if (this->flag.has_value()) { out += sep; sep = ", "; out += ".flag = "; - smithy::DebugAppend(out, *this->flag); + opal::DebugAppend(out, *this->flag); } if (this->tiny.has_value()) { out += sep; sep = ", "; out += ".tiny = "; - smithy::DebugAppend(out, *this->tiny); + opal::DebugAppend(out, *this->tiny); } if (this->small.has_value()) { out += sep; sep = ", "; out += ".small = "; - smithy::DebugAppend(out, *this->small); + opal::DebugAppend(out, *this->small); } if (this->medium.has_value()) { out += sep; sep = ", "; out += ".medium = "; - smithy::DebugAppend(out, *this->medium); + opal::DebugAppend(out, *this->medium); } if (this->big.has_value()) { out += sep; sep = ", "; out += ".big = "; - smithy::DebugAppend(out, *this->big); + opal::DebugAppend(out, *this->big); } if (this->ratio.has_value()) { out += sep; sep = ", "; out += ".ratio = "; - smithy::DebugAppend(out, *this->ratio); + opal::DebugAppend(out, *this->ratio); } if (this->precise.has_value()) { out += sep; sep = ", "; out += ".precise = "; - smithy::DebugAppend(out, *this->precise); + opal::DebugAppend(out, *this->precise); } if (this->blob.has_value()) { out += sep; sep = ", "; out += ".blob = "; - smithy::DebugAppend(out, *this->blob); + opal::DebugAppend(out, *this->blob); } if (this->priority.has_value()) { out += sep; sep = ", "; out += ".priority = "; - smithy::DebugAppend(out, *this->priority); + opal::DebugAppend(out, *this->priority); } if (this->weight.has_value()) { out += sep; sep = ", "; out += ".weight = "; - smithy::DebugAppend(out, *this->weight); + opal::DebugAppend(out, *this->weight); } if (this->dateTime.has_value()) { out += sep; sep = ", "; out += ".dateTime = "; - smithy::DebugAppend(out, *this->dateTime); + opal::DebugAppend(out, *this->dateTime); } if (this->httpDate.has_value()) { out += sep; sep = ", "; out += ".httpDate = "; - smithy::DebugAppend(out, *this->httpDate); + opal::DebugAppend(out, *this->httpDate); } if (this->epoch.has_value()) { out += sep; sep = ", "; out += ".epoch = "; - smithy::DebugAppend(out, *this->epoch); + opal::DebugAppend(out, *this->epoch); } if (this->names.has_value()) { out += sep; sep = ", "; out += ".names = "; - smithy::DebugAppend(out, *this->names); + opal::DebugAppend(out, *this->names); } if (this->uniqueNames.has_value()) { out += sep; sep = ", "; out += ".uniqueNames = "; - smithy::DebugAppend(out, *this->uniqueNames); + opal::DebugAppend(out, *this->uniqueNames); } if (this->sparseNumbers.has_value()) { out += sep; sep = ", "; out += ".sparseNumbers = "; - smithy::DebugAppend(out, *this->sparseNumbers); + opal::DebugAppend(out, *this->sparseNumbers); } if (this->attributes.has_value()) { out += sep; sep = ", "; out += ".attributes = "; - smithy::DebugAppend(out, *this->attributes); + opal::DebugAppend(out, *this->attributes); } if (this->nested.has_value()) { out += sep; sep = ", "; out += ".nested = "; - smithy::DebugAppend(out, *this->nested); + opal::DebugAppend(out, *this->nested); } if (this->choice.has_value()) { out += sep; sep = ", "; out += ".choice = "; - smithy::DebugAppend(out, *this->choice); + opal::DebugAppend(out, *this->choice); } out += '}'; } @@ -388,12 +388,12 @@ struct SinkNotFound { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); if (this->resourceType.has_value()) { out += sep; sep = ", "; out += ".resourceType = "; - smithy::DebugAppend(out, *this->resourceType); + opal::DebugAppend(out, *this->resourceType); } out += '}'; } @@ -419,13 +419,13 @@ struct SinkQuotaExceeded { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, *this->message); + opal::DebugAppend(out, *this->message); } if (this->retryAfterSeconds.has_value()) { out += sep; sep = ", "; out += ".retryAfterSeconds = "; - smithy::DebugAppend(out, *this->retryAfterSeconds); + opal::DebugAppend(out, *this->retryAfterSeconds); } out += '}'; } @@ -450,12 +450,12 @@ struct PutSinkRpcInput { out += sep; sep = ", "; out += ".sinkId = "; - smithy::DebugAppend(out, this->sinkId); + opal::DebugAppend(out, this->sinkId); if (this->sink.has_value()) { out += sep; sep = ", "; out += ".sink = "; - smithy::DebugAppend(out, *this->sink); + opal::DebugAppend(out, *this->sink); } out += '}'; } @@ -480,12 +480,12 @@ struct PutSinkRpcOutput { out += sep; sep = ", "; out += ".sinkId = "; - smithy::DebugAppend(out, this->sinkId); + opal::DebugAppend(out, this->sinkId); if (this->sink.has_value()) { out += sep; sep = ", "; out += ".sink = "; - smithy::DebugAppend(out, *this->sink); + opal::DebugAppend(out, *this->sink); } out += '}'; } @@ -508,8 +508,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::jsonrpc::NestedConfig& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.label)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.depth)); + seed = opal::HashCombine(seed, opal::HashValue(value.label)); + seed = opal::HashCombine(seed, opal::HashValue(value.depth)); return seed; } }; @@ -518,16 +518,16 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::jsonrpc::SinkChoice& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> struct std::hash { std::size_t operator()(const example::roundtrip::jsonrpc::Priority& value) const noexcept { - return smithy::HashCombine(static_cast(value.value_), - smithy::HashValue(value.unknown_)); + return opal::HashCombine(static_cast(value.value_), + opal::HashValue(value.unknown_)); } }; @@ -535,26 +535,26 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::jsonrpc::KitchenSink& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.name)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.flag)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.tiny)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.small)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.medium)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.big)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.ratio)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.precise)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.blob)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.priority)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.weight)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.dateTime)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.httpDate)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.epoch)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.names)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.uniqueNames)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseNumbers)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.attributes)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.nested)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.choice)); + seed = opal::HashCombine(seed, opal::HashValue(value.name)); + seed = opal::HashCombine(seed, opal::HashValue(value.flag)); + seed = opal::HashCombine(seed, opal::HashValue(value.tiny)); + seed = opal::HashCombine(seed, opal::HashValue(value.small)); + seed = opal::HashCombine(seed, opal::HashValue(value.medium)); + seed = opal::HashCombine(seed, opal::HashValue(value.big)); + seed = opal::HashCombine(seed, opal::HashValue(value.ratio)); + seed = opal::HashCombine(seed, opal::HashValue(value.precise)); + seed = opal::HashCombine(seed, opal::HashValue(value.blob)); + seed = opal::HashCombine(seed, opal::HashValue(value.priority)); + seed = opal::HashCombine(seed, opal::HashValue(value.weight)); + seed = opal::HashCombine(seed, opal::HashValue(value.dateTime)); + seed = opal::HashCombine(seed, opal::HashValue(value.httpDate)); + seed = opal::HashCombine(seed, opal::HashValue(value.epoch)); + seed = opal::HashCombine(seed, opal::HashValue(value.names)); + seed = opal::HashCombine(seed, opal::HashValue(value.uniqueNames)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseNumbers)); + seed = opal::HashCombine(seed, opal::HashValue(value.attributes)); + seed = opal::HashCombine(seed, opal::HashValue(value.nested)); + seed = opal::HashCombine(seed, opal::HashValue(value.choice)); return seed; } }; @@ -563,8 +563,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::jsonrpc::SinkNotFound& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.resourceType)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.resourceType)); return seed; } }; @@ -573,8 +573,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::jsonrpc::SinkQuotaExceeded& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.retryAfterSeconds)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.retryAfterSeconds)); return seed; } }; @@ -583,8 +583,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::jsonrpc::PutSinkRpcInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sinkId)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sink)); + seed = opal::HashCombine(seed, opal::HashValue(value.sinkId)); + seed = opal::HashCombine(seed, opal::HashValue(value.sink)); return seed; } }; @@ -593,8 +593,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::jsonrpc::PutSinkRpcOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sinkId)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sink)); + seed = opal::HashCombine(seed, opal::HashValue(value.sinkId)); + seed = opal::HashCombine(seed, opal::HashValue(value.sink)); return seed; } }; diff --git a/examples/roundtrip/jsonrpc/generated/src/client.cc b/examples/roundtrip/jsonrpc/generated/src/client.cc index 94794e20..7af89bfc 100644 --- a/examples/roundtrip/jsonrpc/generated/src/client.cc +++ b/examples/roundtrip/jsonrpc/generated/src/client.cc @@ -34,43 +34,43 @@ struct ParsedError { int status = 0; std::string code = "UnknownError"; std::string message; - smithy::Document doc; + opal::Document doc; }; // [[maybe_unused]]: only unary response paths parse wire errors; a // service whose operations all stream never calls this. -[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) { +[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) { ParsedError parsed; parsed.status = response.status; parsed.message = "HTTP " + std::to_string(response.status); - auto doc = smithy::json::Decode(response.body); + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return parsed; - const smithy::Document* error = doc->Find("error"); + const opal::Document* error = doc->Find("error"); if (error == nullptr || !error->is_map()) return parsed; - if (const smithy::Document* code = error->Find("code"); code != nullptr && code->is_int()) { + if (const opal::Document* code = error->Find("code"); code != nullptr && code->is_int()) { const std::int64_t rpc_code = code->as_int(); parsed.status = rpc_code >= 100 && rpc_code < 600 ? static_cast(rpc_code) : (rpc_code == -32603 ? 500 : 400); } - if (const smithy::Document* message = error->Find("message"); message != nullptr && message->is_string()) parsed.message = message->as_string(); - if (const smithy::Document* data = error->Find("data"); data != nullptr) parsed.doc = *data; + if (const opal::Document* message = error->Find("message"); message != nullptr && message->is_string()) parsed.message = message->as_string(); + if (const opal::Document* data = error->Find("data"); data != nullptr) parsed.doc = *data; if (parsed.doc.is_map()) { - const smithy::Document* type = parsed.doc.Find("__type"); + const opal::Document* type = parsed.doc.Find("__type"); if (type != nullptr && type->is_string()) parsed.code = helpers::SanitizeErrorCode(type->as_string()); } return parsed; } -smithy::Error GenericError(ParsedError parsed) { +opal::Error GenericError(ParsedError parsed) { const bool retryable = parsed.status >= 500; - if (parsed.code == "UnknownError") return smithy::Error(smithy::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); - return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); + if (parsed.code == "UnknownError") return opal::Error(opal::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); + return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); } -smithy::Error MakeSinkNotFoundError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeSinkNotFoundError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("SinkNotFound", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("SinkNotFound", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeSinkNotFound(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -78,11 +78,11 @@ smithy::Error MakeSinkNotFoundError(const smithy::http::HttpResponse& response, return error; } -smithy::Error MakeSinkQuotaExceededError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeSinkQuotaExceededError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("SinkQuotaExceeded", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("SinkQuotaExceeded", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeSinkQuotaExceeded(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -90,7 +90,7 @@ smithy::Error MakeSinkQuotaExceededError(const smithy::http::HttpResponse& respo return error; } -smithy::Error ParsePutSinkRpcError(const smithy::http::HttpResponse& response) { +opal::Error ParsePutSinkRpcError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "SinkNotFound") return helpers::MakeSinkNotFoundError(response, std::move(parsed)); if (parsed.code == "SinkQuotaExceeded") return helpers::MakeSinkQuotaExceededError(response, std::move(parsed)); @@ -100,57 +100,57 @@ smithy::Error ParsePutSinkRpcError(const smithy::http::HttpResponse& response) { } // namespace helpers } // namespace -smithy::Outcome RoundTripJsonRpcClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome RoundTripJsonRpcClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { // The built-in socket transport is plaintext-only; https needs a - // TLS-capable transport (e.g. smithy::http::BeastHttpClient). + // TLS-capable transport (e.g. opal::http::BeastHttpClient). if (endpoint->tls()) { - return smithy::Error::Validation("RoundTripJsonRpcClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + return opal::Error::Validation("RoundTripJsonRpcClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); } - transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); } } if (transport == nullptr) { - return smithy::Error::Validation("RoundTripJsonRpcClient: config needs an endpoint or an http_client"); + return opal::Error::Validation("RoundTripJsonRpcClient: config needs an endpoint or an http_client"); } return RoundTripJsonRpcClient(std::move(config), std::move(transport), std::move(prefix)); } -RoundTripJsonRpcClient::RoundTripJsonRpcClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix) +RoundTripJsonRpcClient::RoundTripJsonRpcClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} -smithy::Outcome RoundTripJsonRpcClient::Send(smithy::http::HttpRequest request) const { +opal::Outcome RoundTripJsonRpcClient::Send(opal::http::HttpRequest request) const { // Operations with a non-document response payload set their own accept. if (!request.headers.Get("accept").has_value()) request.headers.Set("accept", "application/json"); request.headers.Set("user-agent", config_.user_agent); if (!request.body.empty()) { request.headers.Set("content-length", std::to_string(request.body.size())); } - return smithy::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); + return opal::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); } -smithy::Outcome RoundTripJsonRpcClient::PutSinkRpc(const PutSinkRpcInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome RoundTripJsonRpcClient::PutSinkRpc(const PutSinkRpcInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/"; request.headers.Set("content-type", "application/json"); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("method", smithy::Document("PutSinkRpc")); - envelope.emplace("id", smithy::Document(1)); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("method", opal::Document("PutSinkRpc")); + envelope.emplace("id", opal::Document(1)); envelope.emplace("params", SerializePutSinkRpcInput(input)); - request.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + request.body = opal::json::Encode(opal::Document(std::move(envelope))); // @requestCompression(gzip): applied last, appended to Content-Encoding. if (request.body.size() >= static_cast(config_.request_min_compression_size_bytes)) { - auto compressed = smithy::GzipCompress(request.body); + auto compressed = opal::GzipCompress(request.body); if (!compressed) return std::move(compressed).error(); request.body = *std::move(compressed); const auto existing_encoding = request.headers.Get("content-encoding"); @@ -158,13 +158,13 @@ smithy::Outcome RoundTripJsonRpcClient::PutSinkRpc(const PutSi } auto response = Send(std::move(request)); if (!response) return std::move(response).error(); - auto envelope_doc = smithy::json::Decode(response->body); + auto envelope_doc = opal::json::Decode(response->body); // Errors are JSON-RPC envelopes on HTTP 200; non-200 means the request // never reached the protocol layer (router 404, proxy) and parses generically. const bool is_error = !envelope_doc.ok() || !envelope_doc->is_map() || envelope_doc->Find("error") != nullptr; if (response->status != 200 || is_error) return helpers::ParsePutSinkRpcError(*response); - const smithy::Document* result = envelope_doc->Find("result"); - if (result == nullptr) return smithy::Error::Serialization("jsonRpc2: response has no result member"); + const opal::Document* result = envelope_doc->Find("result"); + if (result == nullptr) return opal::Error::Serialization("jsonRpc2: response has no result member"); return DeserializePutSinkRpcOutput(*result); } diff --git a/examples/roundtrip/jsonrpc/generated/src/serde.cc b/examples/roundtrip/jsonrpc/generated/src/serde.cc index 3cedb185..d997c375 100644 --- a/examples/roundtrip/jsonrpc/generated/src/serde.cc +++ b/examples/roundtrip/jsonrpc/generated/src/serde.cc @@ -10,55 +10,55 @@ namespace example::roundtrip::jsonrpc { namespace types = ::example::roundtrip::jsonrpc; -smithy::Document SerializeStringMap(const std::map& value) { - smithy::DocumentMap map; +opal::Document SerializeStringMap(const std::map& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { - map.emplace(key, smithy::Document(item)); + map.emplace(key, opal::Document(item)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome> DeserializeStringMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map: expected a map on the wire"); +opal::Outcome> DeserializeStringMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map: expected a map on the wire"); std::map out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::map{}: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::map{}: unexpected type on the wire"); parsed_item = item->as_string(); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeNestedConfig(const NestedConfig& value) { - smithy::DocumentMap map; - map.emplace("label", smithy::Document(value.label)); +opal::Document SerializeNestedConfig(const NestedConfig& value) { + opal::DocumentMap map; + map.emplace("label", opal::Document(value.label)); if (value.depth.has_value()) { - map.emplace("depth", smithy::Document(static_cast((*value.depth)))); + map.emplace("depth", opal::Document(static_cast((*value.depth)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNestedConfig(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("NestedConfig: expected a map on the wire"); +opal::Outcome DeserializeNestedConfig(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("NestedConfig: expected a map on the wire"); NestedConfig out; { - const smithy::Document* member = doc.Find("label"); + const opal::Document* member = doc.Find("label"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("NestedConfig: missing required member: label"); + return opal::Error::Serialization("NestedConfig: missing required member: label"); } - if (!member->is_string()) return smithy::Error::Serialization("NestedConfig.label: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("NestedConfig.label: unexpected type on the wire"); out.label = member->as_string(); } { - const smithy::Document* member = doc.Find("depth"); + const opal::Document* member = doc.Find("depth"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("NestedConfig.depth: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("NestedConfig.depth: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("NestedConfig.depth: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("NestedConfig.depth: value out of range"); parsed_member = static_cast(member->as_int()); out.depth = std::move(parsed_member); } @@ -66,37 +66,37 @@ smithy::Outcome DeserializeNestedConfig(const smithy::Document& do return out; } -smithy::Document SerializeSinkChoice(const SinkChoice& value) { - smithy::DocumentMap map; +opal::Document SerializeSinkChoice(const SinkChoice& value) { + opal::DocumentMap map; if (value.is_text()) { - map.emplace("text", smithy::Document(value.as_text())); + map.emplace("text", opal::Document(value.as_text())); } if (value.is_count()) { - map.emplace("count", smithy::Document(static_cast(value.as_count()))); + map.emplace("count", opal::Document(static_cast(value.as_count()))); } if (value.is_nested()) { map.emplace("nested", SerializeNestedConfig(value.as_nested())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSinkChoice(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SinkChoice: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("SinkChoice: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("text"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeSinkChoice(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SinkChoice: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("SinkChoice: expected exactly one union member"); + if (const opal::Document* member = doc.Find("text"); member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("SinkChoice.text: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkChoice.text: unexpected type on the wire"); parsed_member = member->as_string(); return SinkChoice::FromText(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("count"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("count"); member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SinkChoice.count: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("SinkChoice.count: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SinkChoice.count: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("SinkChoice.count: value out of range"); parsed_member = static_cast(member->as_int()); return SinkChoice::FromCount(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("nested"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("nested"); member != nullptr && !member->is_null()) { NestedConfig parsed_member{}; { auto parsed = DeserializeNestedConfig(*member); @@ -105,130 +105,130 @@ smithy::Outcome DeserializeSinkChoice(const smithy::Document& doc) { } return SinkChoice::FromNested(std::move(parsed_member)); } - return smithy::Error::Serialization("SinkChoice: unknown or missing union member"); + return opal::Error::Serialization("SinkChoice: unknown or missing union member"); } -smithy::Document SerializeStringList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeStringList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeStringList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeStringList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = item->as_string(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeSparseIntegerList(const std::vector>& value) { - smithy::DocumentList list; +opal::Document SerializeSparseIntegerList(const std::vector>& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { if (!item.has_value()) { list.emplace_back(nullptr); continue; } - list.push_back(smithy::Document(static_cast((*item)))); + list.push_back(opal::Document(static_cast((*item)))); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome>> DeserializeSparseIntegerList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector>: expected a list on the wire"); +opal::Outcome>> DeserializeSparseIntegerList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector>: expected a list on the wire"); std::vector> out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; if (item->is_null()) { out.emplace_back(std::nullopt); continue; } std::int32_t parsed_item{}; - if (!item->is_int()) return smithy::Error::Serialization("std::vector>[]: unexpected type on the wire"); - if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return smithy::Error::Serialization("std::vector>[]: value out of range"); + if (!item->is_int()) return opal::Error::Serialization("std::vector>[]: unexpected type on the wire"); + if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return opal::Error::Serialization("std::vector>[]: value out of range"); parsed_item = static_cast(item->as_int()); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeUniqueStringList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeUniqueStringList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeUniqueStringList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeUniqueStringList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = item->as_string(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeKitchenSink(const KitchenSink& value) { - smithy::DocumentMap map; - map.emplace("name", smithy::Document(value.name)); +opal::Document SerializeKitchenSink(const KitchenSink& value) { + opal::DocumentMap map; + map.emplace("name", opal::Document(value.name)); if (value.flag.has_value()) { - map.emplace("flag", smithy::Document((*value.flag))); + map.emplace("flag", opal::Document((*value.flag))); } if (value.tiny.has_value()) { - map.emplace("tiny", smithy::Document(static_cast((*value.tiny)))); + map.emplace("tiny", opal::Document(static_cast((*value.tiny)))); } if (value.small.has_value()) { - map.emplace("small", smithy::Document(static_cast((*value.small)))); + map.emplace("small", opal::Document(static_cast((*value.small)))); } if (value.medium.has_value()) { - map.emplace("medium", smithy::Document(static_cast((*value.medium)))); + map.emplace("medium", opal::Document(static_cast((*value.medium)))); } if (value.big.has_value()) { - map.emplace("big", smithy::Document(static_cast((*value.big)))); + map.emplace("big", opal::Document(static_cast((*value.big)))); } if (value.ratio.has_value()) { - map.emplace("ratio", smithy::Document(static_cast((*value.ratio)))); + map.emplace("ratio", opal::Document(static_cast((*value.ratio)))); } if (value.precise.has_value()) { - map.emplace("precise", smithy::Document(static_cast((*value.precise)))); + map.emplace("precise", opal::Document(static_cast((*value.precise)))); } if (value.blob.has_value()) { - map.emplace("blob", smithy::Document((*value.blob))); + map.emplace("blob", opal::Document((*value.blob))); } if (value.priority.has_value()) { - map.emplace("priority", smithy::Document(std::string((*value.priority).ToString()))); + map.emplace("priority", opal::Document(std::string((*value.priority).ToString()))); } if (value.weight.has_value()) { - map.emplace("weight", smithy::Document(static_cast((*value.weight)))); + map.emplace("weight", opal::Document(static_cast((*value.weight)))); } if (value.dateTime.has_value()) { - map.emplace("dateTime", smithy::Document::FromTimestamp((*value.dateTime), smithy::TimestampFormat::kDateTime)); + map.emplace("dateTime", opal::Document::FromTimestamp((*value.dateTime), opal::TimestampFormat::kDateTime)); } if (value.httpDate.has_value()) { - map.emplace("httpDate", smithy::Document::FromTimestamp((*value.httpDate), smithy::TimestampFormat::kHttpDate)); + map.emplace("httpDate", opal::Document::FromTimestamp((*value.httpDate), opal::TimestampFormat::kHttpDate)); } if (value.epoch.has_value()) { - map.emplace("epoch", smithy::Document::FromTimestamp((*value.epoch), smithy::TimestampFormat::kEpochSeconds)); + map.emplace("epoch", opal::Document::FromTimestamp((*value.epoch), opal::TimestampFormat::kEpochSeconds)); } if (value.names.has_value()) { map.emplace("names", SerializeStringList((*value.names))); @@ -248,100 +248,100 @@ smithy::Document SerializeKitchenSink(const KitchenSink& value) { if (value.choice.has_value()) { map.emplace("choice", SerializeSinkChoice((*value.choice))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("KitchenSink: expected a map on the wire"); +opal::Outcome DeserializeKitchenSink(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("KitchenSink: expected a map on the wire"); KitchenSink out; { - const smithy::Document* member = doc.Find("name"); + const opal::Document* member = doc.Find("name"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("KitchenSink: missing required member: name"); + return opal::Error::Serialization("KitchenSink: missing required member: name"); } - if (!member->is_string()) return smithy::Error::Serialization("KitchenSink.name: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("KitchenSink.name: unexpected type on the wire"); out.name = member->as_string(); } { - const smithy::Document* member = doc.Find("flag"); + const opal::Document* member = doc.Find("flag"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("KitchenSink.flag: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("KitchenSink.flag: unexpected type on the wire"); parsed_member = member->as_bool(); out.flag = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("tiny"); + const opal::Document* member = doc.Find("tiny"); if (member != nullptr && !member->is_null()) { std::int8_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.tiny: unexpected type on the wire"); - if (member->as_int() < -128 || member->as_int() > 127) return smithy::Error::Serialization("KitchenSink.tiny: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.tiny: unexpected type on the wire"); + if (member->as_int() < -128 || member->as_int() > 127) return opal::Error::Serialization("KitchenSink.tiny: value out of range"); parsed_member = static_cast(member->as_int()); out.tiny = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("small"); + const opal::Document* member = doc.Find("small"); if (member != nullptr && !member->is_null()) { std::int16_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.small: unexpected type on the wire"); - if (member->as_int() < -32768 || member->as_int() > 32767) return smithy::Error::Serialization("KitchenSink.small: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.small: unexpected type on the wire"); + if (member->as_int() < -32768 || member->as_int() > 32767) return opal::Error::Serialization("KitchenSink.small: value out of range"); parsed_member = static_cast(member->as_int()); out.small = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("medium"); + const opal::Document* member = doc.Find("medium"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.medium: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("KitchenSink.medium: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.medium: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("KitchenSink.medium: value out of range"); parsed_member = static_cast(member->as_int()); out.medium = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("big"); + const opal::Document* member = doc.Find("big"); if (member != nullptr && !member->is_null()) { std::int64_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.big: unexpected type on the wire"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.big: unexpected type on the wire"); parsed_member = static_cast(member->as_int()); out.big = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("ratio"); + const opal::Document* member = doc.Find("ratio"); if (member != nullptr && !member->is_null()) { float parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("KitchenSink.ratio: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("KitchenSink.ratio: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("KitchenSink.ratio: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("KitchenSink.ratio: value out of range"); parsed_member = *narrowed; } out.ratio = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("precise"); + const opal::Document* member = doc.Find("precise"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("KitchenSink.precise: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("KitchenSink.precise: expected a number"); parsed_member = static_cast(*parsed); } out.precise = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("blob"); + const opal::Document* member = doc.Find("blob"); if (member != nullptr && !member->is_null()) { - smithy::Blob parsed_member{}; + opal::Blob parsed_member{}; { - auto parsed = smithy::BlobFromDocument(*member); + auto parsed = opal::BlobFromDocument(*member); if (!parsed) return std::move(parsed).error(); parsed_member = std::move(*parsed); } @@ -349,30 +349,30 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("priority"); + const opal::Document* member = doc.Find("priority"); if (member != nullptr && !member->is_null()) { types::Priority parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("KitchenSink.priority: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("KitchenSink.priority: unexpected type on the wire"); parsed_member = types::Priority::FromString(member->as_string()); out.priority = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("weight"); + const opal::Document* member = doc.Find("weight"); if (member != nullptr && !member->is_null()) { types::Weight parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.weight: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("KitchenSink.weight: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.weight: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("KitchenSink.weight: value out of range"); parsed_member = static_cast(member->as_int()); out.weight = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("dateTime"); + const opal::Document* member = doc.Find("dateTime"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kDateTime); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kDateTime); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -380,11 +380,11 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("httpDate"); + const opal::Document* member = doc.Find("httpDate"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kHttpDate); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kHttpDate); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -392,11 +392,11 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("epoch"); + const opal::Document* member = doc.Find("epoch"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kEpochSeconds); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kEpochSeconds); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -404,7 +404,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("names"); + const opal::Document* member = doc.Find("names"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -416,7 +416,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("uniqueNames"); + const opal::Document* member = doc.Find("uniqueNames"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -428,7 +428,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("sparseNumbers"); + const opal::Document* member = doc.Find("sparseNumbers"); if (member != nullptr && !member->is_null()) { std::vector> parsed_member{}; { @@ -440,7 +440,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("attributes"); + const opal::Document* member = doc.Find("attributes"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -452,7 +452,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("nested"); + const opal::Document* member = doc.Find("nested"); if (member != nullptr && !member->is_null()) { types::NestedConfig parsed_member{}; { @@ -464,7 +464,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("choice"); + const opal::Document* member = doc.Find("choice"); if (member != nullptr && !member->is_null()) { types::SinkChoice parsed_member{}; { @@ -478,31 +478,31 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) return out; } -smithy::Document SerializeSinkNotFound(const SinkNotFound& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); +opal::Document SerializeSinkNotFound(const SinkNotFound& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); if (value.resourceType.has_value()) { - map.emplace("resourceType", smithy::Document((*value.resourceType))); + map.emplace("resourceType", opal::Document((*value.resourceType))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSinkNotFound(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SinkNotFound: expected a map on the wire"); +opal::Outcome DeserializeSinkNotFound(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SinkNotFound: expected a map on the wire"); SinkNotFound out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("SinkNotFound: missing required member: message"); + return opal::Error::Serialization("SinkNotFound: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("SinkNotFound.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkNotFound.message: unexpected type on the wire"); out.message = member->as_string(); } { - const smithy::Document* member = doc.Find("resourceType"); + const opal::Document* member = doc.Find("resourceType"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("SinkNotFound.resourceType: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkNotFound.resourceType: unexpected type on the wire"); parsed_member = member->as_string(); out.resourceType = std::move(parsed_member); } @@ -510,35 +510,35 @@ smithy::Outcome DeserializeSinkNotFound(const smithy::Document& do return out; } -smithy::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value) { - smithy::DocumentMap map; +opal::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value) { + opal::DocumentMap map; if (value.message.has_value()) { - map.emplace("message", smithy::Document((*value.message))); + map.emplace("message", opal::Document((*value.message))); } if (value.retryAfterSeconds.has_value()) { - map.emplace("retryAfterSeconds", smithy::Document(static_cast((*value.retryAfterSeconds)))); + map.emplace("retryAfterSeconds", opal::Document(static_cast((*value.retryAfterSeconds)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSinkQuotaExceeded(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SinkQuotaExceeded: expected a map on the wire"); +opal::Outcome DeserializeSinkQuotaExceeded(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SinkQuotaExceeded: expected a map on the wire"); SinkQuotaExceeded out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("SinkQuotaExceeded.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkQuotaExceeded.message: unexpected type on the wire"); parsed_member = member->as_string(); out.message = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("retryAfterSeconds"); + const opal::Document* member = doc.Find("retryAfterSeconds"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: value out of range"); parsed_member = static_cast(member->as_int()); out.retryAfterSeconds = std::move(parsed_member); } @@ -546,28 +546,28 @@ smithy::Outcome DeserializeSinkQuotaExceeded(const smithy::Do return out; } -smithy::Document SerializePutSinkRpcInput(const PutSinkRpcInput& value) { - smithy::DocumentMap map; - map.emplace("sinkId", smithy::Document(value.sinkId)); +opal::Document SerializePutSinkRpcInput(const PutSinkRpcInput& value) { + opal::DocumentMap map; + map.emplace("sinkId", opal::Document(value.sinkId)); if (value.sink.has_value()) { map.emplace("sink", SerializeKitchenSink((*value.sink))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePutSinkRpcInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PutSinkRpcInput: expected a map on the wire"); +opal::Outcome DeserializePutSinkRpcInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PutSinkRpcInput: expected a map on the wire"); PutSinkRpcInput out; { - const smithy::Document* member = doc.Find("sinkId"); + const opal::Document* member = doc.Find("sinkId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PutSinkRpcInput: missing required member: sinkId"); + return opal::Error::Serialization("PutSinkRpcInput: missing required member: sinkId"); } - if (!member->is_string()) return smithy::Error::Serialization("PutSinkRpcInput.sinkId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutSinkRpcInput.sinkId: unexpected type on the wire"); out.sinkId = member->as_string(); } { - const smithy::Document* member = doc.Find("sink"); + const opal::Document* member = doc.Find("sink"); if (member != nullptr && !member->is_null()) { types::KitchenSink parsed_member{}; { @@ -581,28 +581,28 @@ smithy::Outcome DeserializePutSinkRpcInput(const smithy::Docume return out; } -smithy::Document SerializePutSinkRpcOutput(const PutSinkRpcOutput& value) { - smithy::DocumentMap map; - map.emplace("sinkId", smithy::Document(value.sinkId)); +opal::Document SerializePutSinkRpcOutput(const PutSinkRpcOutput& value) { + opal::DocumentMap map; + map.emplace("sinkId", opal::Document(value.sinkId)); if (value.sink.has_value()) { map.emplace("sink", SerializeKitchenSink((*value.sink))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePutSinkRpcOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PutSinkRpcOutput: expected a map on the wire"); +opal::Outcome DeserializePutSinkRpcOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PutSinkRpcOutput: expected a map on the wire"); PutSinkRpcOutput out; { - const smithy::Document* member = doc.Find("sinkId"); + const opal::Document* member = doc.Find("sinkId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PutSinkRpcOutput: missing required member: sinkId"); + return opal::Error::Serialization("PutSinkRpcOutput: missing required member: sinkId"); } - if (!member->is_string()) return smithy::Error::Serialization("PutSinkRpcOutput.sinkId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutSinkRpcOutput.sinkId: unexpected type on the wire"); out.sinkId = member->as_string(); } { - const smithy::Document* member = doc.Find("sink"); + const opal::Document* member = doc.Find("sink"); if (member != nullptr && !member->is_null()) { types::KitchenSink parsed_member{}; { diff --git a/examples/roundtrip/jsonrpc/generated/src/server.cc b/examples/roundtrip/jsonrpc/generated/src/server.cc index f2819687..9cd1f4cc 100644 --- a/examples/roundtrip/jsonrpc/generated/src/server.cc +++ b/examples/roundtrip/jsonrpc/generated/src/server.cc @@ -22,70 +22,70 @@ namespace types = ::example::roundtrip::jsonrpc; namespace { namespace helpers { -smithy::http::HttpResponse JsonRpcError(int code, const std::string& type, const std::string& message, smithy::DocumentMap data, const smithy::Document& id) { - if (!type.empty()) data.insert_or_assign("__type", smithy::Document(type)); +opal::http::HttpResponse JsonRpcError(int code, const std::string& type, const std::string& message, opal::DocumentMap data, const opal::Document& id) { + if (!type.empty()) data.insert_or_assign("__type", opal::Document(type)); std::string text = message; if (text.empty()) { const auto it = data.find("message"); if (it != data.end() && it->second.is_string()) text = it->second.as_string(); } - smithy::DocumentMap error; - error.emplace("code", smithy::Document(code)); - error.emplace("message", smithy::Document(std::move(text))); - if (!data.empty()) error.emplace("data", smithy::Document(std::move(data))); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("error", smithy::Document(std::move(error))); + opal::DocumentMap error; + error.emplace("code", opal::Document(code)); + error.emplace("message", opal::Document(std::move(text))); + if (!data.empty()) error.emplace("data", opal::Document(std::move(data))); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("error", opal::Document(std::move(error))); envelope.emplace("id", id); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + response.body = opal::json::Encode(opal::Document(std::move(envelope))); return response; } // [[maybe_unused]]: only unary routes map handler errors here; a service // whose operations all stream reports errors on the stream instead. -[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& error, const smithy::Document& id) { - if (error.kind() == smithy::ErrorKind::kModeled) { +[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& error, const opal::Document& id) { + if (error.kind() == opal::ErrorKind::kModeled) { if (error.code() == "SinkNotFound") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeSinkNotFound(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::JsonRpcError(404, "example.roundtrip#SinkNotFound", "", std::move(body), id); } if (error.code() == "SinkQuotaExceeded") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeSinkQuotaExceeded(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::JsonRpcError(503, "example.roundtrip#SinkQuotaExceeded", "", std::move(body), id); } return helpers::JsonRpcError(400, error.code(), error.message(), {}, id); } - if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) return helpers::JsonRpcError(400, "SerializationException", error.message(), {}, id); + if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) return helpers::JsonRpcError(400, "SerializationException", error.message(), {}, id); // Never leak internal detail on unexpected failures. return helpers::JsonRpcError(500, "InternalFailure", "internal failure", {}, id); } // Constraint validation (smithy.framework#ValidationException): messages // and '/member' paths follow the official validation conformance suite. -void AddValidationFailure(std::vector* failures, std::string path, std::string message) { +void AddValidationFailure(std::vector* failures, std::string path, std::string message) { failures->push_back({std::move(path), std::move(message)}); } -void ValidateKitchenSink(const types::KitchenSink& value, const std::string& path, std::vector* failures) { +void ValidateKitchenSink(const types::KitchenSink& value, const std::string& path, std::vector* failures) { if (value.priority.has_value()) { const std::string member_path = path + "/priority"; if ((*value.priority).value() == Priority::Value::kUnknown) { @@ -114,7 +114,7 @@ void ValidateKitchenSink(const types::KitchenSink& value, const std::string& pat } } -void ValidatePutSinkRpcInput(const types::PutSinkRpcInput& value, const std::string& path, std::vector* failures) { +void ValidatePutSinkRpcInput(const types::PutSinkRpcInput& value, const std::string& path, std::vector* failures) { if (value.sink.has_value()) { const std::string member_path = path + "/sink"; helpers::ValidateKitchenSink((*value.sink), member_path, failures); @@ -123,43 +123,43 @@ void ValidatePutSinkRpcInput(const types::PutSinkRpcInput& value, const std::str // [[maybe_unused]]: only unary routes reject invalid input over HTTP; a // service whose operations all stream reports validation on the stream. -[[maybe_unused]] smithy::http::HttpResponse ValidationErrorResponse(const std::vector& failures, const smithy::Document& id) { +[[maybe_unused]] opal::http::HttpResponse ValidationErrorResponse(const std::vector& failures, const opal::Document& id) { std::string summary = std::to_string(failures.size()) + " validation error" + (failures.size() == 1 ? "" : "s") + " detected. "; - smithy::DocumentList field_list; + opal::DocumentList field_list; for (std::size_t i = 0; i < failures.size(); ++i) { if (i > 0) summary += "; "; summary += failures[i].message; - smithy::DocumentMap field; - field.emplace("message", smithy::Document(failures[i].message)); - field.emplace("path", smithy::Document(failures[i].path)); - field_list.push_back(smithy::Document(std::move(field))); + opal::DocumentMap field; + field.emplace("message", opal::Document(failures[i].message)); + field.emplace("path", opal::Document(failures[i].path)); + field_list.push_back(opal::Document(std::move(field))); } - smithy::DocumentMap body; - body.emplace("fieldList", smithy::Document(std::move(field_list))); - smithy::http::HttpResponse response = helpers::JsonRpcError(400, "smithy.framework#ValidationException", summary, std::move(body), id); + opal::DocumentMap body; + body.emplace("fieldList", opal::Document(std::move(field_list))); + opal::http::HttpResponse response = helpers::JsonRpcError(400, "smithy.framework#ValidationException", summary, std::move(body), id); return response; } template -smithy::http::HttpResponse HandlePutSinkRpc(Handler& handler, const smithy::Document& params, const smithy::Document& id, const smithy::server::RequestContext& context) { +opal::http::HttpResponse HandlePutSinkRpc(Handler& handler, const opal::Document& params, const opal::Document& id, const opal::server::RequestContext& context) { types::PutSinkRpcInput input{}; if (!params.is_map()) return helpers::JsonRpcError(-32602, "SerializationException", "params must be an object", {}, id); auto parsed = DeserializePutSinkRpcInput(params); if (!parsed) return helpers::JsonRpcError(-32602, "SerializationException", parsed.error().message(), {}, id); input = *std::move(parsed); - std::vector validation_failures; + std::vector validation_failures; helpers::ValidatePutSinkRpcInput(input, "", &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures, id); auto outcome = handler.PutSinkRpc(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error(), id); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); envelope.emplace("result", SerializePutSinkRpcOutput(*outcome)); envelope.emplace("id", id); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + response.body = opal::json::Encode(opal::Document(std::move(envelope))); return response; } @@ -167,42 +167,42 @@ smithy::http::HttpResponse HandlePutSinkRpc(Handler& handler, const smithy::Docu } // namespace RoundTripJsonRpcServer::RoundTripJsonRpcServer(std::shared_ptr handler) - : router_(std::make_shared()) { + : router_(std::make_shared()) { // The route table is derived from the model's @http traits; conflicts are // a modeling error surfaced by Router::Add (checked at generation time in a // later phase), so registration results are intentionally discarded. - (void)router_->Add("POST", "/", [handler](const smithy::http::HttpRequest& raw_request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { - smithy::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) - smithy::http::HttpRequest request = raw_request; + (void)router_->Add("POST", "/", [handler](const opal::http::HttpRequest& raw_request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { + opal::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) + opal::http::HttpRequest request = raw_request; // @requestCompression(gzip): decode before parsing. if (const auto request_encoding = request.headers.Get("content-encoding"); request_encoding.has_value() && (*request_encoding == "gzip" || request_encoding->ends_with(", gzip"))) { - auto decompressed = smithy::GzipDecompress(request.body); + auto decompressed = opal::GzipDecompress(request.body); if (!decompressed) { return helpers::JsonRpcError(-32700, "SerializationException", "invalid gzip request body", {}, id); } request.body = *std::move(decompressed); } // A present Content-Type must carry application/json (parameters ignored). - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { return helpers::JsonRpcError(-32600, "UnsupportedMediaTypeException", "expected content-type: application/json", {}, id); } - auto decoded = smithy::json::Decode(request.body); + auto decoded = opal::json::Decode(request.body); // Envelope failure messages are fixed strings: the conformance suite // compares bodies exactly, so no decoder detail leaks into the wire. if (!decoded) return helpers::JsonRpcError(-32700, "SerializationException", "request body is not valid JSON", {}, id); if (!decoded->is_map()) return helpers::JsonRpcError(-32600, "SerializationException", "request is not a JSON-RPC 2.0 call", {}, id); - if (const smithy::Document* id_doc = decoded->Find("id"); id_doc != nullptr) id = *id_doc; - const smithy::Document* version = decoded->Find("jsonrpc"); + if (const opal::Document* id_doc = decoded->Find("id"); id_doc != nullptr) id = *id_doc; + const opal::Document* version = decoded->Find("jsonrpc"); if (version == nullptr || !version->is_string() || version->as_string() != "2.0") { return helpers::JsonRpcError(-32600, "SerializationException", "expected jsonrpc: \"2.0\"", {}, id); } - const smithy::Document* method = decoded->Find("method"); + const opal::Document* method = decoded->Find("method"); if (method == nullptr || !method->is_string()) { return helpers::JsonRpcError(-32600, "SerializationException", "expected a string method member", {}, id); } // Absent/null params deserialize like an empty object. - const smithy::Document empty_params{smithy::DocumentMap{}}; - const smithy::Document* params = decoded->Find("params"); + const opal::Document empty_params{opal::DocumentMap{}}; + const opal::Document* params = decoded->Find("params"); if (params == nullptr || params->is_null()) params = &empty_params; const std::string& method_name = method->as_string(); if (method_name == "PutSinkRpc") { @@ -214,9 +214,9 @@ RoundTripJsonRpcServer::RoundTripJsonRpcServer(std::shared_ptrRoute(request); }; + return [router](const opal::http::HttpRequest& request) { return router->Route(request); }; } } // namespace example::roundtrip::jsonrpc diff --git a/examples/roundtrip/jsonrpc/generated/tests/integration_test.cc b/examples/roundtrip/jsonrpc/generated/tests/integration_test.cc index 5f2befa7..92e5f31d 100644 --- a/examples/roundtrip/jsonrpc/generated/tests/integration_test.cc +++ b/examples/roundtrip/jsonrpc/generated/tests/integration_test.cc @@ -128,12 +128,12 @@ struct Rng { if (rng.Coin()) v.big = static_cast(rng.Int(-4611686018427387904LL, 4611686018427387903LL)); if (rng.Coin()) v.ratio = static_cast(rng.Int(-8000000LL, 8000000LL)) / static_cast(8); if (rng.Coin()) v.precise = static_cast(rng.Int(-8000000LL, 8000000LL)) / static_cast(8); - if (rng.Coin()) v.blob = smithy::Blob::FromString(rng.Text(1, 9)); + if (rng.Coin()) v.blob = opal::Blob::FromString(rng.Text(1, 9)); if (rng.Coin()) v.priority = Priority::FromString(std::array{"low", "medium", "high"}[rng.engine() % 3]); if (rng.Coin()) v.weight = static_cast(std::array{1, 2}[rng.engine() % 2]); - if (rng.Coin()) v.dateTime = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); - if (rng.Coin()) v.httpDate = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); - if (rng.Coin()) v.epoch = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + if (rng.Coin()) v.dateTime = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + if (rng.Coin()) v.httpDate = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + if (rng.Coin()) v.epoch = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); if (rng.Coin()) v.names = RandomStringList(rng); if (rng.Coin()) v.uniqueNames = RandomUniqueStringList(rng); if (rng.Coin()) v.sparseNumbers = RandomSparseIntegerList(rng); @@ -173,14 +173,14 @@ struct Rng { class ScriptedHandler final : public RoundTripJsonRpcHandler { public: - smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PutSinkRpc(const PutSinkRpcInput& input, const opal::server::RequestContext&) override { lastPutSinkRpc = input; if (nextPutSinkRpcError.has_value()) return *nextPutSinkRpcError; return nextPutSinkRpcOutput; } std::optional lastPutSinkRpc; PutSinkRpcOutput nextPutSinkRpcOutput{}; - std::optional nextPutSinkRpcError; + std::optional nextPutSinkRpcError; }; enum class TransportKind { kLoopback, kSocket }; @@ -190,14 +190,14 @@ class RoundTripJsonRpcIntegrationTest : public ::testing::TestWithParam(); server_ = std::make_unique(handler_); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries if (GetParam() == TransportKind::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); config.http_client = loopback; } else { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(server_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } @@ -210,7 +210,7 @@ class RoundTripJsonRpcIntegrationTest : public ::testing::TestWithParam handler_; std::unique_ptr server_; - std::unique_ptr socket_server_; + std::unique_ptr socket_server_; std::unique_ptr client_; }; @@ -243,13 +243,13 @@ TEST_P(RoundTripJsonRpcIntegrationTest, PutSinkRpcMaximalRoundTrips) { TEST_P(RoundTripJsonRpcIntegrationTest, PutSinkRpcSinkNotFoundMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const SinkNotFound detail = RandomSinkNotFound(rng); - smithy::Error error = smithy::Error::Modeled("SinkNotFound", "integration"); + opal::Error error = opal::Error::Modeled("SinkNotFound", "integration"); error.set_detail(detail); handler_->nextPutSinkRpcError = error; const PutSinkRpcInput input = RandomPutSinkRpcInput(rng); const auto outcome = client_->PutSinkRpc(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "SinkNotFound"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -258,13 +258,13 @@ TEST_P(RoundTripJsonRpcIntegrationTest, PutSinkRpcSinkNotFoundMapsAcrossTheWire) TEST_P(RoundTripJsonRpcIntegrationTest, PutSinkRpcSinkQuotaExceededMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const SinkQuotaExceeded detail = RandomSinkQuotaExceeded(rng); - smithy::Error error = smithy::Error::Modeled("SinkQuotaExceeded", "integration"); + opal::Error error = opal::Error::Modeled("SinkQuotaExceeded", "integration"); error.set_detail(detail); handler_->nextPutSinkRpcError = error; const PutSinkRpcInput input = RandomPutSinkRpcInput(rng); const auto outcome = client_->PutSinkRpc(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "SinkQuotaExceeded"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -273,17 +273,17 @@ TEST_P(RoundTripJsonRpcIntegrationTest, PutSinkRpcSinkQuotaExceededMapsAcrossThe TEST(RoundTripJsonRpcIntegrationUnknownMembers, PutSinkRpcToleratesUnknownResponseMembers) { auto handler = std::make_shared(); RoundTripJsonRpcServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RoundTripJsonRpcClient::Create(std::move(config)); diff --git a/examples/roundtrip/jsonrpc/generated/tests/smoke_test.cc b/examples/roundtrip/jsonrpc/generated/tests/smoke_test.cc index e48c7511..e7bbedbd 100644 --- a/examples/roundtrip/jsonrpc/generated/tests/smoke_test.cc +++ b/examples/roundtrip/jsonrpc/generated/tests/smoke_test.cc @@ -27,7 +27,7 @@ PutSinkRpcOutput MinimalPutSinkRpcOutput() { class SmokeHandler : public RoundTripJsonRpcHandler { public: - smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PutSinkRpc(const PutSinkRpcInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalPutSinkRpcOutput(); } @@ -35,9 +35,9 @@ class SmokeHandler : public RoundTripJsonRpcHandler { RoundTripJsonRpcClient MakeClient(std::shared_ptr handler) { RoundTripJsonRpcServer server(std::move(handler)); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = loopback; // Create cannot fail when a transport is injected. @@ -60,9 +60,9 @@ TEST(RoundTripJsonRpcSmokeTest, PutSinkRpcRoundTrips) { TEST(RoundTripJsonRpcSmokeTest, ModeledErrorsMapAcrossTheWire) { class FailingHandler final : public SmokeHandler { public: - smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PutSinkRpc(const PutSinkRpcInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("SinkNotFound", "smoke"); + opal::Error error = opal::Error::Modeled("SinkNotFound", "smoke"); auto detail = [] { SinkNotFound v{}; return v; @@ -80,7 +80,7 @@ TEST(RoundTripJsonRpcSmokeTest, ModeledErrorsMapAcrossTheWire) { }(); const auto outcome = client.PutSinkRpc(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "SinkNotFound"); EXPECT_EQ(outcome.error().message(), "smoke"); EXPECT_NE(outcome.error().detail(), nullptr); diff --git a/examples/roundtrip/rest/api_key_wire_test.cc b/examples/roundtrip/rest/api_key_wire_test.cc index 49474b3b..1a48a9db 100644 --- a/examples/roundtrip/rest/api_key_wire_test.cc +++ b/examples/roundtrip/rest/api_key_wire_test.cc @@ -16,19 +16,18 @@ namespace example::roundtrip::rest { namespace { -class CapturingTransport final : public smithy::http::HttpClient { +class CapturingTransport final : public opal::http::HttpClient { public: - smithy::Outcome Send( - const smithy::http::HttpRequest& request) override { + opal::Outcome Send(const opal::http::HttpRequest& request) override { last_request = request; - return smithy::http::HttpResponse{200, {}, ""}; + return opal::http::HttpResponse{200, {}, ""}; } - smithy::http::HttpRequest last_request; + opal::http::HttpRequest last_request; }; RoundTripRestClient MakeClient(std::shared_ptr transport) { - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = std::move(transport); config.api_key = [] { return std::string("k&e y"); }; // needs encoding return *RoundTripRestClient::Create(std::move(config)); @@ -51,7 +50,7 @@ TEST(ApiKeyQueryTest, AppendsToAnExistingQueryString) { TEST(ApiKeyQueryTest, AbsentProviderLeavesTheTargetAlone) { auto transport = std::make_shared(); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = transport; auto client = RoundTripRestClient::Create(std::move(config)); ASSERT_TRUE(client.ok()); diff --git a/examples/roundtrip/rest/generated/include/example/roundtrip/rest/client.h b/examples/roundtrip/rest/generated/include/example/roundtrip/rest/client.h index e3d74c6f..e9013f9a 100644 --- a/examples/roundtrip/rest/generated/include/example/roundtrip/rest/client.h +++ b/examples/roundtrip/rest/generated/include/example/roundtrip/rest/client.h @@ -23,36 +23,36 @@ namespace example::roundtrip::rest { /// simpleRestJson client for example.roundtrip#RoundTripRest. -/// Modeled service errors surface as smithy::Error with kind kModeled, +/// Modeled service errors surface as opal::Error with kind kModeled, /// code() set to the error shape name, and the deserialized error /// structure attached. Dispatch on them through the per-operation /// Errors listings below rather than comparing code() text. class RoundTripRestClient { public: /// Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); + static opal::Outcome Create(opal::ClientConfig config); /// Read-only operation: no body in, body out. - smithy::Outcome DescribeSink(const DescribeSinkInput& input) const; + opal::Outcome DescribeSink(const DescribeSinkInput& input) const; /// Every binding location at once: label, query, @httpQueryParams, headers, /// prefix headers, and a JSON body full of aggregate shapes. Compressed and /// carrying required query/header members so the HTTP+JSON gzip path and the /// required-absence validation wiring both land in a compiled golden /// (issue #68: conditional emissions need fixtures on both branches). - smithy::Outcome PutSink(const PutSinkInput& input) const; + opal::Outcome PutSink(const PutSinkInput& input) const; /// Raw blob payload with an extra header member. - smithy::Outcome UploadAttachment(const UploadAttachmentInput& input) const; + opal::Outcome UploadAttachment(const UploadAttachmentInput& input) const; private: - RoundTripRestClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix); - smithy::Outcome Send(smithy::http::HttpRequest request) const; + RoundTripRestClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix); + opal::Outcome Send(opal::http::HttpRequest request) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; -/// The modeled errors of DescribeSink, matched from a smithy::Error so dispatch is +/// The modeled errors of DescribeSink, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -63,9 +63,9 @@ class DescribeSinkErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static DescribeSinkErrors FromError(const smithy::Error& error) { + static DescribeSinkErrors FromError(const opal::Error& error) { DescribeSinkErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "SinkNotFound") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : SinkNotFound{}); @@ -117,11 +117,11 @@ class DescribeSinkErrors { switch (value_.index()) { case 1: out += "sink_not_found = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "describe_sink_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -140,14 +140,14 @@ class DescribeSinkErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("DescribeSinkErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("DescribeSinkErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of PutSink, matched from a smithy::Error so dispatch is +/// The modeled errors of PutSink, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -158,9 +158,9 @@ class PutSinkErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static PutSinkErrors FromError(const smithy::Error& error) { + static PutSinkErrors FromError(const opal::Error& error) { PutSinkErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "SinkNotFound") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : SinkNotFound{}); @@ -212,11 +212,11 @@ class PutSinkErrors { switch (value_.index()) { case 1: out += "sink_not_found = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "sink_quota_exceeded = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -235,14 +235,14 @@ class PutSinkErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("PutSinkErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("PutSinkErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of UploadAttachment, matched from a smithy::Error so dispatch is +/// The modeled errors of UploadAttachment, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -253,9 +253,9 @@ class UploadAttachmentErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static UploadAttachmentErrors FromError(const smithy::Error& error) { + static UploadAttachmentErrors FromError(const opal::Error& error) { UploadAttachmentErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "SinkNotFound") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : SinkNotFound{}); @@ -294,7 +294,7 @@ class UploadAttachmentErrors { switch (value_.index()) { case 1: out += "sink_not_found = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -313,7 +313,7 @@ class UploadAttachmentErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("UploadAttachmentErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("UploadAttachmentErrors", requested, case_name()); } } @@ -330,8 +330,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::DescribeSinkErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -339,8 +339,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::PutSinkErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -348,8 +348,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::UploadAttachmentErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; diff --git a/examples/roundtrip/rest/generated/include/example/roundtrip/rest/serde.h b/examples/roundtrip/rest/generated/include/example/roundtrip/rest/serde.h index b30e4356..ffff58a7 100644 --- a/examples/roundtrip/rest/generated/include/example/roundtrip/rest/serde.h +++ b/examples/roundtrip/rest/generated/include/example/roundtrip/rest/serde.h @@ -16,62 +16,62 @@ namespace example::roundtrip::rest { // Document-pivot serde for every aggregate shape in the model closure. -// Serializers never fail; deserializers return smithy::Error on wire +// Serializers never fail; deserializers return opal::Error on wire // mismatches and enforce @required members. -smithy::Document SerializeDescribeSinkError(const DescribeSinkError& value); -smithy::Outcome DeserializeDescribeSinkError(const smithy::Document& doc); +opal::Document SerializeDescribeSinkError(const DescribeSinkError& value); +opal::Outcome DeserializeDescribeSinkError(const opal::Document& doc); -smithy::Document SerializeDescribeSinkInput(const DescribeSinkInput& value); -smithy::Outcome DeserializeDescribeSinkInput(const smithy::Document& doc); +opal::Document SerializeDescribeSinkInput(const DescribeSinkInput& value); +opal::Outcome DeserializeDescribeSinkInput(const opal::Document& doc); -smithy::Document SerializeStringMap(const std::map& value); -smithy::Outcome> DeserializeStringMap(const smithy::Document& doc); +opal::Document SerializeStringMap(const std::map& value); +opal::Outcome> DeserializeStringMap(const opal::Document& doc); -smithy::Document SerializeNestedConfig(const NestedConfig& value); -smithy::Outcome DeserializeNestedConfig(const smithy::Document& doc); +opal::Document SerializeNestedConfig(const NestedConfig& value); +opal::Outcome DeserializeNestedConfig(const opal::Document& doc); -smithy::Document SerializeSinkChoice(const SinkChoice& value); -smithy::Outcome DeserializeSinkChoice(const smithy::Document& doc); +opal::Document SerializeSinkChoice(const SinkChoice& value); +opal::Outcome DeserializeSinkChoice(const opal::Document& doc); -smithy::Document SerializeStringList(const std::vector& value); -smithy::Outcome> DeserializeStringList(const smithy::Document& doc); +opal::Document SerializeStringList(const std::vector& value); +opal::Outcome> DeserializeStringList(const opal::Document& doc); -smithy::Document SerializeSparseIntegerList(const std::vector>& value); -smithy::Outcome>> DeserializeSparseIntegerList(const smithy::Document& doc); +opal::Document SerializeSparseIntegerList(const std::vector>& value); +opal::Outcome>> DeserializeSparseIntegerList(const opal::Document& doc); -smithy::Document SerializeUniqueStringList(const std::vector& value); -smithy::Outcome> DeserializeUniqueStringList(const smithy::Document& doc); +opal::Document SerializeUniqueStringList(const std::vector& value); +opal::Outcome> DeserializeUniqueStringList(const opal::Document& doc); -smithy::Document SerializeKitchenSink(const KitchenSink& value); -smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc); +opal::Document SerializeKitchenSink(const KitchenSink& value); +opal::Outcome DeserializeKitchenSink(const opal::Document& doc); -smithy::Document SerializeDescribeSinkOutput(const DescribeSinkOutput& value); -smithy::Outcome DeserializeDescribeSinkOutput(const smithy::Document& doc); +opal::Document SerializeDescribeSinkOutput(const DescribeSinkOutput& value); +opal::Outcome DeserializeDescribeSinkOutput(const opal::Document& doc); -smithy::Document SerializeSinkNotFound(const SinkNotFound& value); -smithy::Outcome DeserializeSinkNotFound(const smithy::Document& doc); +opal::Document SerializeSinkNotFound(const SinkNotFound& value); +opal::Outcome DeserializeSinkNotFound(const opal::Document& doc); -smithy::Document SerializePutSinkInput(const PutSinkInput& value); -smithy::Outcome DeserializePutSinkInput(const smithy::Document& doc); +opal::Document SerializePutSinkInput(const PutSinkInput& value); +opal::Outcome DeserializePutSinkInput(const opal::Document& doc); -smithy::Document SerializePutSinkResponse(const PutSinkResponse& value); -smithy::Outcome DeserializePutSinkResponse(const smithy::Document& doc); +opal::Document SerializePutSinkResponse(const PutSinkResponse& value); +opal::Outcome DeserializePutSinkResponse(const opal::Document& doc); -smithy::Document SerializePutSinkOutput(const PutSinkOutput& value); -smithy::Outcome DeserializePutSinkOutput(const smithy::Document& doc); +opal::Document SerializePutSinkOutput(const PutSinkOutput& value); +opal::Outcome DeserializePutSinkOutput(const opal::Document& doc); -smithy::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value); -smithy::Outcome DeserializeSinkQuotaExceeded(const smithy::Document& doc); +opal::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value); +opal::Outcome DeserializeSinkQuotaExceeded(const opal::Document& doc); -smithy::Document SerializeReceipt(const Receipt& value); -smithy::Outcome DeserializeReceipt(const smithy::Document& doc); +opal::Document SerializeReceipt(const Receipt& value); +opal::Outcome DeserializeReceipt(const opal::Document& doc); -smithy::Document SerializeUploadAttachmentInput(const UploadAttachmentInput& value); -smithy::Outcome DeserializeUploadAttachmentInput(const smithy::Document& doc); +opal::Document SerializeUploadAttachmentInput(const UploadAttachmentInput& value); +opal::Outcome DeserializeUploadAttachmentInput(const opal::Document& doc); -smithy::Document SerializeUploadAttachmentOutput(const UploadAttachmentOutput& value); -smithy::Outcome DeserializeUploadAttachmentOutput(const smithy::Document& doc); +opal::Document SerializeUploadAttachmentOutput(const UploadAttachmentOutput& value); +opal::Outcome DeserializeUploadAttachmentOutput(const opal::Document& doc); } // namespace example::roundtrip::rest diff --git a/examples/roundtrip/rest/generated/include/example/roundtrip/rest/server.h b/examples/roundtrip/rest/generated/include/example/roundtrip/rest/server.h index 8bc08d46..c93a76a5 100644 --- a/examples/roundtrip/rest/generated/include/example/roundtrip/rest/server.h +++ b/examples/roundtrip/rest/generated/include/example/roundtrip/rest/server.h @@ -13,10 +13,10 @@ namespace example::roundtrip::rest { /// Implement one method per operation. Return a modeled error as -/// smithy::Error::Modeled("", message), optionally with the +/// opal::Error::Modeled("", message), optionally with the /// typed error structure attached via set_detail() so it serializes fully. /// The context carries the raw request and routing captures — see -/// smithy::server::RequestContext; leave the parameter unnamed when unused. +/// opal::server::RequestContext; leave the parameter unnamed when unused. /// Implementations must be thread-safe: transports may invoke any mix of /// operations concurrently on the one handler instance. class RoundTripRestHandler { @@ -24,28 +24,28 @@ class RoundTripRestHandler { virtual ~RoundTripRestHandler() = default; /// Read-only operation: no body in, body out. - virtual smithy::Outcome DescribeSink(const DescribeSinkInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome DescribeSink(const DescribeSinkInput& input, const opal::server::RequestContext& context) = 0; /// Every binding location at once: label, query, @httpQueryParams, headers, /// prefix headers, and a JSON body full of aggregate shapes. Compressed and /// carrying required query/header members so the HTTP+JSON gzip path and the /// required-absence validation wiring both land in a compiled golden /// (issue #68: conditional emissions need fixtures on both branches). - virtual smithy::Outcome PutSink(const PutSinkInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome PutSink(const PutSinkInput& input, const opal::server::RequestContext& context) = 0; /// Raw blob payload with an extra header member. - virtual smithy::Outcome UploadAttachment(const UploadAttachmentInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome UploadAttachment(const UploadAttachmentInput& input, const opal::server::RequestContext& context) = 0; }; /// simpleRestJson server for example.roundtrip#RoundTripRest: routing, deserialization, handler dispatch, /// response serialization, and modeled-error mapping. Pass Handler() to any -/// smithy::http::HttpServerTransport. +/// opal::http::HttpServerTransport. class RoundTripRestServer { public: explicit RoundTripRestServer(std::shared_ptr handler); - smithy::http::RequestHandler Handler() const; + opal::http::RequestHandler Handler() const; private: - std::shared_ptr router_; + std::shared_ptr router_; }; } // namespace example::roundtrip::rest diff --git a/examples/roundtrip/rest/generated/include/example/roundtrip/rest/types.h b/examples/roundtrip/rest/generated/include/example/roundtrip/rest/types.h index 97873dd2..1a3051d4 100644 --- a/examples/roundtrip/rest/generated/include/example/roundtrip/rest/types.h +++ b/examples/roundtrip/rest/generated/include/example/roundtrip/rest/types.h @@ -39,7 +39,7 @@ struct DescribeSinkError { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -62,7 +62,7 @@ struct DescribeSinkInput { out += sep; sep = ", "; out += ".sinkId = "; - smithy::DebugAppend(out, this->sinkId); + opal::DebugAppend(out, this->sinkId); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -86,12 +86,12 @@ struct NestedConfig { out += sep; sep = ", "; out += ".label = "; - smithy::DebugAppend(out, this->label); + opal::DebugAppend(out, this->label); if (this->depth.has_value()) { out += sep; sep = ", "; out += ".depth = "; - smithy::DebugAppend(out, *this->depth); + opal::DebugAppend(out, *this->depth); } out += '}'; } @@ -170,15 +170,15 @@ class SinkChoice { switch (value_.index()) { case 1: out += "text = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "count = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "nested = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; default: break; @@ -197,7 +197,7 @@ class SinkChoice { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("SinkChoice", requested, case_name()); + opal::internal::FatalWrongUnionAccess("SinkChoice", requested, case_name()); } } @@ -281,12 +281,12 @@ struct KitchenSink { std::optional big{}; std::optional ratio{}; std::optional precise{}; - std::optional blob{}; + std::optional blob{}; std::optional priority{}; std::optional weight{}; - std::optional dateTime{}; - std::optional httpDate{}; - std::optional epoch{}; + std::optional dateTime{}; + std::optional httpDate{}; + std::optional epoch{}; std::optional> names{}; std::optional> uniqueNames{}; std::optional>> sparseNumbers{}; @@ -301,120 +301,120 @@ struct KitchenSink { out += sep; sep = ", "; out += ".name = "; - smithy::DebugAppend(out, this->name); + opal::DebugAppend(out, this->name); if (this->flag.has_value()) { out += sep; sep = ", "; out += ".flag = "; - smithy::DebugAppend(out, *this->flag); + opal::DebugAppend(out, *this->flag); } if (this->tiny.has_value()) { out += sep; sep = ", "; out += ".tiny = "; - smithy::DebugAppend(out, *this->tiny); + opal::DebugAppend(out, *this->tiny); } if (this->small.has_value()) { out += sep; sep = ", "; out += ".small = "; - smithy::DebugAppend(out, *this->small); + opal::DebugAppend(out, *this->small); } if (this->medium.has_value()) { out += sep; sep = ", "; out += ".medium = "; - smithy::DebugAppend(out, *this->medium); + opal::DebugAppend(out, *this->medium); } if (this->big.has_value()) { out += sep; sep = ", "; out += ".big = "; - smithy::DebugAppend(out, *this->big); + opal::DebugAppend(out, *this->big); } if (this->ratio.has_value()) { out += sep; sep = ", "; out += ".ratio = "; - smithy::DebugAppend(out, *this->ratio); + opal::DebugAppend(out, *this->ratio); } if (this->precise.has_value()) { out += sep; sep = ", "; out += ".precise = "; - smithy::DebugAppend(out, *this->precise); + opal::DebugAppend(out, *this->precise); } if (this->blob.has_value()) { out += sep; sep = ", "; out += ".blob = "; - smithy::DebugAppend(out, *this->blob); + opal::DebugAppend(out, *this->blob); } if (this->priority.has_value()) { out += sep; sep = ", "; out += ".priority = "; - smithy::DebugAppend(out, *this->priority); + opal::DebugAppend(out, *this->priority); } if (this->weight.has_value()) { out += sep; sep = ", "; out += ".weight = "; - smithy::DebugAppend(out, *this->weight); + opal::DebugAppend(out, *this->weight); } if (this->dateTime.has_value()) { out += sep; sep = ", "; out += ".dateTime = "; - smithy::DebugAppend(out, *this->dateTime); + opal::DebugAppend(out, *this->dateTime); } if (this->httpDate.has_value()) { out += sep; sep = ", "; out += ".httpDate = "; - smithy::DebugAppend(out, *this->httpDate); + opal::DebugAppend(out, *this->httpDate); } if (this->epoch.has_value()) { out += sep; sep = ", "; out += ".epoch = "; - smithy::DebugAppend(out, *this->epoch); + opal::DebugAppend(out, *this->epoch); } if (this->names.has_value()) { out += sep; sep = ", "; out += ".names = "; - smithy::DebugAppend(out, *this->names); + opal::DebugAppend(out, *this->names); } if (this->uniqueNames.has_value()) { out += sep; sep = ", "; out += ".uniqueNames = "; - smithy::DebugAppend(out, *this->uniqueNames); + opal::DebugAppend(out, *this->uniqueNames); } if (this->sparseNumbers.has_value()) { out += sep; sep = ", "; out += ".sparseNumbers = "; - smithy::DebugAppend(out, *this->sparseNumbers); + opal::DebugAppend(out, *this->sparseNumbers); } if (this->attributes.has_value()) { out += sep; sep = ", "; out += ".attributes = "; - smithy::DebugAppend(out, *this->attributes); + opal::DebugAppend(out, *this->attributes); } if (this->nested.has_value()) { out += sep; sep = ", "; out += ".nested = "; - smithy::DebugAppend(out, *this->nested); + opal::DebugAppend(out, *this->nested); } if (this->choice.has_value()) { out += sep; sep = ", "; out += ".choice = "; - smithy::DebugAppend(out, *this->choice); + opal::DebugAppend(out, *this->choice); } out += '}'; } @@ -439,7 +439,7 @@ struct DescribeSinkOutput { out += sep; sep = ", "; out += ".sink = "; - smithy::DebugAppend(out, *this->sink); + opal::DebugAppend(out, *this->sink); } out += '}'; } @@ -464,12 +464,12 @@ struct SinkNotFound { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); if (this->resourceType.has_value()) { out += sep; sep = ", "; out += ".resourceType = "; - smithy::DebugAppend(out, *this->resourceType); + opal::DebugAppend(out, *this->resourceType); } out += '}'; } @@ -488,10 +488,10 @@ struct PutSinkInput { std::optional tag{}; std::int32_t limit{}; std::optional priority{}; - smithy::Timestamp created{}; + opal::Timestamp created{}; std::optional> metadata{}; std::optional sink{}; - std::optional freeform{}; + std::optional freeform{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -500,44 +500,44 @@ struct PutSinkInput { out += sep; sep = ", "; out += ".sinkId = "; - smithy::DebugAppend(out, this->sinkId); + opal::DebugAppend(out, this->sinkId); if (this->tag.has_value()) { out += sep; sep = ", "; out += ".tag = "; - smithy::DebugAppend(out, *this->tag); + opal::DebugAppend(out, *this->tag); } out += sep; sep = ", "; out += ".limit = "; - smithy::DebugAppend(out, this->limit); + opal::DebugAppend(out, this->limit); if (this->priority.has_value()) { out += sep; sep = ", "; out += ".priority = "; - smithy::DebugAppend(out, *this->priority); + opal::DebugAppend(out, *this->priority); } out += sep; sep = ", "; out += ".created = "; - smithy::DebugAppend(out, this->created); + opal::DebugAppend(out, this->created); if (this->metadata.has_value()) { out += sep; sep = ", "; out += ".metadata = "; - smithy::DebugAppend(out, *this->metadata); + opal::DebugAppend(out, *this->metadata); } if (this->sink.has_value()) { out += sep; sep = ", "; out += ".sink = "; - smithy::DebugAppend(out, *this->sink); + opal::DebugAppend(out, *this->sink); } if (this->freeform.has_value()) { out += sep; sep = ", "; out += ".freeform = "; - smithy::DebugAppend(out, *this->freeform); + opal::DebugAppend(out, *this->freeform); } out += '}'; } @@ -547,8 +547,8 @@ struct PutSinkInput { } friend bool operator==(const PutSinkInput&, const PutSinkInput&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. }; @@ -564,7 +564,7 @@ struct PutSinkResponse { out += sep; sep = ", "; out += ".note = "; - smithy::DebugAppend(out, *this->note); + opal::DebugAppend(out, *this->note); } out += '}'; } @@ -592,30 +592,30 @@ struct PutSinkOutput { out += sep; sep = ", "; out += ".sinkId = "; - smithy::DebugAppend(out, this->sinkId); + opal::DebugAppend(out, this->sinkId); if (this->revision.has_value()) { out += sep; sep = ", "; out += ".revision = "; - smithy::DebugAppend(out, *this->revision); + opal::DebugAppend(out, *this->revision); } if (this->echoedMetadata.has_value()) { out += sep; sep = ", "; out += ".echoedMetadata = "; - smithy::DebugAppend(out, *this->echoedMetadata); + opal::DebugAppend(out, *this->echoedMetadata); } if (this->sink.has_value()) { out += sep; sep = ", "; out += ".sink = "; - smithy::DebugAppend(out, *this->sink); + opal::DebugAppend(out, *this->sink); } if (this->echo.has_value()) { out += sep; sep = ", "; out += ".echo = "; - smithy::DebugAppend(out, *this->echo); + opal::DebugAppend(out, *this->echo); } out += '}'; } @@ -641,13 +641,13 @@ struct SinkQuotaExceeded { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, *this->message); + opal::DebugAppend(out, *this->message); } if (this->retryAfterSeconds.has_value()) { out += sep; sep = ", "; out += ".retryAfterSeconds = "; - smithy::DebugAppend(out, *this->retryAfterSeconds); + opal::DebugAppend(out, *this->retryAfterSeconds); } out += '}'; } @@ -672,12 +672,12 @@ struct Receipt { out += sep; sep = ", "; out += ".receiptId = "; - smithy::DebugAppend(out, this->receiptId); + opal::DebugAppend(out, this->receiptId); if (this->size.has_value()) { out += sep; sep = ", "; out += ".size = "; - smithy::DebugAppend(out, *this->size); + opal::DebugAppend(out, *this->size); } out += '}'; } @@ -694,7 +694,7 @@ struct Receipt { struct UploadAttachmentInput { std::string sinkId{}; std::optional name{}; - std::optional data{}; + std::optional data{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -703,18 +703,18 @@ struct UploadAttachmentInput { out += sep; sep = ", "; out += ".sinkId = "; - smithy::DebugAppend(out, this->sinkId); + opal::DebugAppend(out, this->sinkId); if (this->name.has_value()) { out += sep; sep = ", "; out += ".name = "; - smithy::DebugAppend(out, *this->name); + opal::DebugAppend(out, *this->name); } if (this->data.has_value()) { out += sep; sep = ", "; out += ".data = "; - smithy::DebugAppend(out, *this->data); + opal::DebugAppend(out, *this->data); } out += '}'; } @@ -739,7 +739,7 @@ struct UploadAttachmentOutput { out += sep; sep = ", "; out += ".receipt = "; - smithy::DebugAppend(out, *this->receipt); + opal::DebugAppend(out, *this->receipt); } out += '}'; } @@ -762,7 +762,7 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::DescribeSinkError& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); return seed; } }; @@ -771,7 +771,7 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::DescribeSinkInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sinkId)); + seed = opal::HashCombine(seed, opal::HashValue(value.sinkId)); return seed; } }; @@ -780,8 +780,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::NestedConfig& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.label)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.depth)); + seed = opal::HashCombine(seed, opal::HashValue(value.label)); + seed = opal::HashCombine(seed, opal::HashValue(value.depth)); return seed; } }; @@ -790,16 +790,16 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::SinkChoice& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::Priority& value) const noexcept { - return smithy::HashCombine(static_cast(value.value_), - smithy::HashValue(value.unknown_)); + return opal::HashCombine(static_cast(value.value_), + opal::HashValue(value.unknown_)); } }; @@ -807,26 +807,26 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::KitchenSink& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.name)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.flag)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.tiny)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.small)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.medium)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.big)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.ratio)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.precise)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.blob)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.priority)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.weight)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.dateTime)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.httpDate)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.epoch)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.names)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.uniqueNames)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseNumbers)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.attributes)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.nested)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.choice)); + seed = opal::HashCombine(seed, opal::HashValue(value.name)); + seed = opal::HashCombine(seed, opal::HashValue(value.flag)); + seed = opal::HashCombine(seed, opal::HashValue(value.tiny)); + seed = opal::HashCombine(seed, opal::HashValue(value.small)); + seed = opal::HashCombine(seed, opal::HashValue(value.medium)); + seed = opal::HashCombine(seed, opal::HashValue(value.big)); + seed = opal::HashCombine(seed, opal::HashValue(value.ratio)); + seed = opal::HashCombine(seed, opal::HashValue(value.precise)); + seed = opal::HashCombine(seed, opal::HashValue(value.blob)); + seed = opal::HashCombine(seed, opal::HashValue(value.priority)); + seed = opal::HashCombine(seed, opal::HashValue(value.weight)); + seed = opal::HashCombine(seed, opal::HashValue(value.dateTime)); + seed = opal::HashCombine(seed, opal::HashValue(value.httpDate)); + seed = opal::HashCombine(seed, opal::HashValue(value.epoch)); + seed = opal::HashCombine(seed, opal::HashValue(value.names)); + seed = opal::HashCombine(seed, opal::HashValue(value.uniqueNames)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseNumbers)); + seed = opal::HashCombine(seed, opal::HashValue(value.attributes)); + seed = opal::HashCombine(seed, opal::HashValue(value.nested)); + seed = opal::HashCombine(seed, opal::HashValue(value.choice)); return seed; } }; @@ -835,7 +835,7 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::DescribeSinkOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sink)); + seed = opal::HashCombine(seed, opal::HashValue(value.sink)); return seed; } }; @@ -844,8 +844,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::SinkNotFound& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.resourceType)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.resourceType)); return seed; } }; @@ -854,7 +854,7 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::PutSinkResponse& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.note)); + seed = opal::HashCombine(seed, opal::HashValue(value.note)); return seed; } }; @@ -863,11 +863,11 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::PutSinkOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sinkId)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.revision)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.echoedMetadata)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sink)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.echo)); + seed = opal::HashCombine(seed, opal::HashValue(value.sinkId)); + seed = opal::HashCombine(seed, opal::HashValue(value.revision)); + seed = opal::HashCombine(seed, opal::HashValue(value.echoedMetadata)); + seed = opal::HashCombine(seed, opal::HashValue(value.sink)); + seed = opal::HashCombine(seed, opal::HashValue(value.echo)); return seed; } }; @@ -876,8 +876,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::SinkQuotaExceeded& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.retryAfterSeconds)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.retryAfterSeconds)); return seed; } }; @@ -886,8 +886,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::Receipt& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.receiptId)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.size)); + seed = opal::HashCombine(seed, opal::HashValue(value.receiptId)); + seed = opal::HashCombine(seed, opal::HashValue(value.size)); return seed; } }; @@ -896,9 +896,9 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::UploadAttachmentInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sinkId)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.name)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.data)); + seed = opal::HashCombine(seed, opal::HashValue(value.sinkId)); + seed = opal::HashCombine(seed, opal::HashValue(value.name)); + seed = opal::HashCombine(seed, opal::HashValue(value.data)); return seed; } }; @@ -907,7 +907,7 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rest::UploadAttachmentOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.receipt)); + seed = opal::HashCombine(seed, opal::HashValue(value.receipt)); return seed; } }; diff --git a/examples/roundtrip/rest/generated/src/client.cc b/examples/roundtrip/rest/generated/src/client.cc index a6fe5441..05baa986 100644 --- a/examples/roundtrip/rest/generated/src/client.cc +++ b/examples/roundtrip/rest/generated/src/client.cc @@ -42,51 +42,51 @@ struct ParsedError { int status = 0; std::string code = "UnknownError"; std::string message; - smithy::Document doc; + opal::Document doc; }; // [[maybe_unused]]: only unary response paths parse wire errors; a // service whose operations all stream never calls this. -[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) { +[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) { ParsedError parsed; parsed.status = response.status; parsed.message = "HTTP " + std::to_string(response.status); - auto doc = smithy::json::Decode(response.body); + auto doc = opal::json::Decode(response.body); if (doc.ok()) parsed.doc = *std::move(doc); const auto type_header = response.headers.Get("x-error-type"); if (type_header.has_value()) parsed.code = helpers::SanitizeErrorCode(*type_header); if (parsed.doc.is_map()) { - const smithy::Document* type = parsed.doc.Find("__type"); + const opal::Document* type = parsed.doc.Find("__type"); if (type == nullptr) type = parsed.doc.Find("code"); if (parsed.code == "UnknownError" && type != nullptr && type->is_string()) parsed.code = helpers::SanitizeErrorCode(type->as_string()); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } return parsed; } -smithy::Error GenericError(ParsedError parsed) { +opal::Error GenericError(ParsedError parsed) { const bool retryable = parsed.status >= 500; - if (parsed.code == "UnknownError") return smithy::Error(smithy::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); - return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); + if (parsed.code == "UnknownError") return opal::Error(opal::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); + return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); } // Strict text parsing for label/query/header bindings ([[maybe_unused]]: // emitted for every service; not every service binds numeric values). // Trailing text, floats-for-ints, and out-of-range values are rejected // (the malformed-request suites pin this). -[[maybe_unused]] smithy::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { +[[maybe_unused]] opal::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { std::int64_t value = 0; const char* first = text.data(); const char* last = first + text.size(); const auto result = std::from_chars(first, last, value, 10); if (text.empty() || result.ec != std::errc() || result.ptr != last || value < min_value || value > max_value) { - return smithy::Error::Serialization("invalid integer: " + text); + return opal::Error::Serialization("invalid integer: " + text); } return value; } -[[maybe_unused]] smithy::Outcome ParseDoubleText(const std::string& text) { +[[maybe_unused]] opal::Outcome ParseDoubleText(const std::string& text) { if (text == "NaN") return std::numeric_limits::quiet_NaN(); if (text == "Infinity") return std::numeric_limits::infinity(); if (text == "-Infinity") return -std::numeric_limits::infinity(); @@ -94,21 +94,21 @@ smithy::Error GenericError(ParsedError parsed) { return (c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' || c == '+' || c == '-'; }; if (text.empty() || text.front() == '+' || !std::all_of(text.begin(), text.end(), valid_char)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } char* parse_end = nullptr; const double value = std::strtod(text.c_str(), &parse_end); if (parse_end != text.c_str() + text.size() || !std::isfinite(value)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } return value; } -smithy::Error MakeDescribeSinkErrorError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeDescribeSinkErrorError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("DescribeSinkError", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("DescribeSinkError", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeDescribeSinkError(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -116,11 +116,11 @@ smithy::Error MakeDescribeSinkErrorError(const smithy::http::HttpResponse& respo return error; } -smithy::Error MakeSinkNotFoundError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeSinkNotFoundError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("SinkNotFound", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("SinkNotFound", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeSinkNotFound(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -128,13 +128,13 @@ smithy::Error MakeSinkNotFoundError(const smithy::http::HttpResponse& response, return error; } -smithy::Error MakeSinkQuotaExceededError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeSinkQuotaExceededError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("SinkQuotaExceeded", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("SinkQuotaExceeded", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); if (const auto header_value = response.headers.Get("x-retry-after-seconds"); header_value.has_value()) { - if (auto parsed_num = helpers::ParseInt64Text(*header_value, -2147483648LL, 2147483647LL)) parsed.doc.as_map().insert_or_assign("retryAfterSeconds", smithy::Document(*parsed_num)); + if (auto parsed_num = helpers::ParseInt64Text(*header_value, -2147483648LL, 2147483647LL)) parsed.doc.as_map().insert_or_assign("retryAfterSeconds", opal::Document(*parsed_num)); } auto detail = DeserializeSinkQuotaExceeded(parsed.doc); if (detail.ok()) { @@ -143,7 +143,7 @@ smithy::Error MakeSinkQuotaExceededError(const smithy::http::HttpResponse& respo return error; } -smithy::Error ParseDescribeSinkError(const smithy::http::HttpResponse& response) { +opal::Error ParseDescribeSinkError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "DescribeSinkError") return helpers::MakeDescribeSinkErrorError(response, std::move(parsed)); if (parsed.code == "SinkNotFound") return helpers::MakeSinkNotFoundError(response, std::move(parsed)); @@ -152,7 +152,7 @@ smithy::Error ParseDescribeSinkError(const smithy::http::HttpResponse& response) return helpers::GenericError(std::move(parsed)); } -smithy::Error ParsePutSinkError(const smithy::http::HttpResponse& response) { +opal::Error ParsePutSinkError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "SinkNotFound") return helpers::MakeSinkNotFoundError(response, std::move(parsed)); if (parsed.code == "SinkQuotaExceeded") return helpers::MakeSinkQuotaExceededError(response, std::move(parsed)); @@ -161,7 +161,7 @@ smithy::Error ParsePutSinkError(const smithy::http::HttpResponse& response) { return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseUploadAttachmentError(const smithy::http::HttpResponse& response) { +opal::Error ParseUploadAttachmentError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "SinkNotFound") return helpers::MakeSinkNotFoundError(response, std::move(parsed)); if (parsed.code == "UnknownError" && parsed.status == 404) return helpers::MakeSinkNotFoundError(response, std::move(parsed)); @@ -171,80 +171,80 @@ smithy::Error ParseUploadAttachmentError(const smithy::http::HttpResponse& respo } // namespace helpers } // namespace -smithy::Outcome RoundTripRestClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome RoundTripRestClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { // The built-in socket transport is plaintext-only; https needs a - // TLS-capable transport (e.g. smithy::http::BeastHttpClient). + // TLS-capable transport (e.g. opal::http::BeastHttpClient). if (endpoint->tls()) { - return smithy::Error::Validation("RoundTripRestClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + return opal::Error::Validation("RoundTripRestClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); } - transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); } } if (transport == nullptr) { - return smithy::Error::Validation("RoundTripRestClient: config needs an endpoint or an http_client"); + return opal::Error::Validation("RoundTripRestClient: config needs an endpoint or an http_client"); } return RoundTripRestClient(std::move(config), std::move(transport), std::move(prefix)); } -RoundTripRestClient::RoundTripRestClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix) +RoundTripRestClient::RoundTripRestClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} -smithy::Outcome RoundTripRestClient::Send(smithy::http::HttpRequest request) const { +opal::Outcome RoundTripRestClient::Send(opal::http::HttpRequest request) const { // Operations with a non-document response payload set their own accept. if (!request.headers.Get("accept").has_value()) request.headers.Set("accept", "application/json"); request.headers.Set("user-agent", config_.user_agent); // @httpApiKeyAuth: attach the configured key where the model binds it. if (config_.api_key) { request.target += request.target.find('?') == std::string::npos ? "?" : "&"; - request.target += "api-key=" + smithy::http::EncodeQueryComponent(config_.api_key()); + request.target += "api-key=" + opal::http::EncodeQueryComponent(config_.api_key()); } if (!request.body.empty()) { request.headers.Set("content-length", std::to_string(request.body.size())); } - return smithy::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); + return opal::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); } -smithy::Outcome RoundTripRestClient::DescribeSink(const DescribeSinkInput& input) const { +opal::Outcome RoundTripRestClient::DescribeSink(const DescribeSinkInput& input) const { std::string target = path_prefix_; target += "/sinks"; target += "/"; - target += smithy::http::EncodePathSegment(input.sinkId); - smithy::http::HttpRequest request; + target += opal::http::EncodePathSegment(input.sinkId); + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseDescribeSinkError(*response); if (response->body.empty()) return DescribeSinkOutput{}; - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializeDescribeSinkOutput(*body_doc); } -smithy::Outcome RoundTripRestClient::PutSink(const PutSinkInput& input) const { +opal::Outcome RoundTripRestClient::PutSink(const PutSinkInput& input) const { std::string target = path_prefix_; target += "/sinks"; target += "/"; - target += smithy::http::EncodePathSegment(input.sinkId); - smithy::http::QueryString query; + target += opal::http::EncodePathSegment(input.sinkId); + opal::http::QueryString query; query.Add("limit", std::to_string(static_cast(input.limit))); if (input.tag.has_value()) { query.Add("tag", (*input.tag)); } target += query.ToString(); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = std::move(target); - request.headers.Set("x-sink-created", input.created.Format(smithy::TimestampFormat::kHttpDate)); + request.headers.Set("x-sink-created", input.created.Format(opal::TimestampFormat::kHttpDate)); if (input.priority.has_value()) { request.headers.Set("x-sink-priority", std::string((*input.priority).ToString())); } @@ -253,18 +253,18 @@ smithy::Outcome RoundTripRestClient::PutSink(const PutSinkInput& request.headers.Set("x-meta-" + map_key, map_value); } } - smithy::DocumentMap body_map; + opal::DocumentMap body_map; if (input.sink.has_value()) { body_map.emplace("sink", SerializeKitchenSink((*input.sink))); } if (input.freeform.has_value()) { body_map.emplace("freeform", (*input.freeform)); } - request.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + request.body = opal::json::Encode(opal::Document(std::move(body_map))); request.headers.Set("content-type", "application/json"); // @requestCompression(gzip): applied last, appended to Content-Encoding. if (request.body.size() >= static_cast(config_.request_min_compression_size_bytes)) { - auto compressed = smithy::GzipCompress(request.body); + auto compressed = opal::GzipCompress(request.body); if (!compressed) return std::move(compressed).error(); request.body = *std::move(compressed); const auto existing_encoding = request.headers.Get("content-encoding"); @@ -274,7 +274,7 @@ smithy::Outcome RoundTripRestClient::PutSink(const PutSinkInput& if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParsePutSinkError(*response); PutSinkOutput out{}; - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); auto parsed = DeserializePutSinkOutput(*body_doc); if (!parsed) return std::move(parsed).error(); @@ -285,20 +285,20 @@ smithy::Outcome RoundTripRestClient::PutSink(const PutSinkInput& out.revision = static_cast(*parsed_num); } for (const auto& [header_name, header_value] : response->headers.entries()) { - if (!smithy::http::HeaderNameStartsWith(header_name, "x-echo-")) continue; + if (!opal::http::HeaderNameStartsWith(header_name, "x-echo-")) continue; if (!out.echoedMetadata.has_value()) out.echoedMetadata.emplace(); (*out.echoedMetadata).insert_or_assign(header_name.substr(7), header_value); } return out; } -smithy::Outcome RoundTripRestClient::UploadAttachment(const UploadAttachmentInput& input) const { +opal::Outcome RoundTripRestClient::UploadAttachment(const UploadAttachmentInput& input) const { std::string target = path_prefix_; target += "/sinks"; target += "/"; - target += smithy::http::EncodePathSegment(input.sinkId); + target += opal::http::EncodePathSegment(input.sinkId); target += "/attachment"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = std::move(target); if (input.name.has_value()) { @@ -314,9 +314,9 @@ smithy::Outcome RoundTripRestClient::UploadAttachment(co if (response->status != 200) return helpers::ParseUploadAttachmentError(*response); UploadAttachmentOutput out{}; if (!response->body.empty()) { - auto payload_doc = smithy::json::Decode(response->body); + auto payload_doc = opal::json::Decode(response->body); if (!payload_doc) return std::move(payload_doc).error(); - const smithy::Document* payload_ptr = &*payload_doc; + const opal::Document* payload_ptr = &*payload_doc; if (!payload_ptr->is_map() || !payload_ptr->as_map().empty()) { types::Receipt parsed_payload{}; { diff --git a/examples/roundtrip/rest/generated/src/serde.cc b/examples/roundtrip/rest/generated/src/serde.cc index b5e6c258..8b1f1dd9 100644 --- a/examples/roundtrip/rest/generated/src/serde.cc +++ b/examples/roundtrip/rest/generated/src/serde.cc @@ -10,95 +10,95 @@ namespace example::roundtrip::rest { namespace types = ::example::roundtrip::rest; -smithy::Document SerializeDescribeSinkError(const DescribeSinkError& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); - return smithy::Document(std::move(map)); +opal::Document SerializeDescribeSinkError(const DescribeSinkError& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeDescribeSinkError(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("DescribeSinkError: expected a map on the wire"); +opal::Outcome DeserializeDescribeSinkError(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("DescribeSinkError: expected a map on the wire"); DescribeSinkError out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("DescribeSinkError: missing required member: message"); + return opal::Error::Serialization("DescribeSinkError: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("DescribeSinkError.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("DescribeSinkError.message: unexpected type on the wire"); out.message = member->as_string(); } return out; } -smithy::Document SerializeDescribeSinkInput(const DescribeSinkInput& value) { - smithy::DocumentMap map; - map.emplace("sinkId", smithy::Document(value.sinkId)); - return smithy::Document(std::move(map)); +opal::Document SerializeDescribeSinkInput(const DescribeSinkInput& value) { + opal::DocumentMap map; + map.emplace("sinkId", opal::Document(value.sinkId)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeDescribeSinkInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("DescribeSinkInput: expected a map on the wire"); +opal::Outcome DeserializeDescribeSinkInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("DescribeSinkInput: expected a map on the wire"); DescribeSinkInput out; { - const smithy::Document* member = doc.Find("sinkId"); + const opal::Document* member = doc.Find("sinkId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("DescribeSinkInput: missing required member: sinkId"); + return opal::Error::Serialization("DescribeSinkInput: missing required member: sinkId"); } - if (!member->is_string()) return smithy::Error::Serialization("DescribeSinkInput.sinkId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("DescribeSinkInput.sinkId: unexpected type on the wire"); out.sinkId = member->as_string(); } return out; } -smithy::Document SerializeStringMap(const std::map& value) { - smithy::DocumentMap map; +opal::Document SerializeStringMap(const std::map& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { - map.emplace(key, smithy::Document(item)); + map.emplace(key, opal::Document(item)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome> DeserializeStringMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map: expected a map on the wire"); +opal::Outcome> DeserializeStringMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map: expected a map on the wire"); std::map out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::map{}: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::map{}: unexpected type on the wire"); parsed_item = item->as_string(); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeNestedConfig(const NestedConfig& value) { - smithy::DocumentMap map; - map.emplace("label", smithy::Document(value.label)); +opal::Document SerializeNestedConfig(const NestedConfig& value) { + opal::DocumentMap map; + map.emplace("label", opal::Document(value.label)); if (value.depth.has_value()) { - map.emplace("depth", smithy::Document(static_cast((*value.depth)))); + map.emplace("depth", opal::Document(static_cast((*value.depth)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNestedConfig(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("NestedConfig: expected a map on the wire"); +opal::Outcome DeserializeNestedConfig(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("NestedConfig: expected a map on the wire"); NestedConfig out; { - const smithy::Document* member = doc.Find("label"); + const opal::Document* member = doc.Find("label"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("NestedConfig: missing required member: label"); + return opal::Error::Serialization("NestedConfig: missing required member: label"); } - if (!member->is_string()) return smithy::Error::Serialization("NestedConfig.label: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("NestedConfig.label: unexpected type on the wire"); out.label = member->as_string(); } { - const smithy::Document* member = doc.Find("depth"); + const opal::Document* member = doc.Find("depth"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("NestedConfig.depth: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("NestedConfig.depth: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("NestedConfig.depth: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("NestedConfig.depth: value out of range"); parsed_member = static_cast(member->as_int()); out.depth = std::move(parsed_member); } @@ -106,37 +106,37 @@ smithy::Outcome DeserializeNestedConfig(const smithy::Document& do return out; } -smithy::Document SerializeSinkChoice(const SinkChoice& value) { - smithy::DocumentMap map; +opal::Document SerializeSinkChoice(const SinkChoice& value) { + opal::DocumentMap map; if (value.is_text()) { - map.emplace("text", smithy::Document(value.as_text())); + map.emplace("text", opal::Document(value.as_text())); } if (value.is_count()) { - map.emplace("count", smithy::Document(static_cast(value.as_count()))); + map.emplace("count", opal::Document(static_cast(value.as_count()))); } if (value.is_nested()) { map.emplace("nested", SerializeNestedConfig(value.as_nested())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSinkChoice(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SinkChoice: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("SinkChoice: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("text"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeSinkChoice(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SinkChoice: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("SinkChoice: expected exactly one union member"); + if (const opal::Document* member = doc.Find("text"); member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("SinkChoice.text: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkChoice.text: unexpected type on the wire"); parsed_member = member->as_string(); return SinkChoice::FromText(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("count"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("count"); member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SinkChoice.count: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("SinkChoice.count: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SinkChoice.count: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("SinkChoice.count: value out of range"); parsed_member = static_cast(member->as_int()); return SinkChoice::FromCount(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("nested"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("nested"); member != nullptr && !member->is_null()) { NestedConfig parsed_member{}; { auto parsed = DeserializeNestedConfig(*member); @@ -145,130 +145,130 @@ smithy::Outcome DeserializeSinkChoice(const smithy::Document& doc) { } return SinkChoice::FromNested(std::move(parsed_member)); } - return smithy::Error::Serialization("SinkChoice: unknown or missing union member"); + return opal::Error::Serialization("SinkChoice: unknown or missing union member"); } -smithy::Document SerializeStringList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeStringList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeStringList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeStringList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = item->as_string(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeSparseIntegerList(const std::vector>& value) { - smithy::DocumentList list; +opal::Document SerializeSparseIntegerList(const std::vector>& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { if (!item.has_value()) { list.emplace_back(nullptr); continue; } - list.push_back(smithy::Document(static_cast((*item)))); + list.push_back(opal::Document(static_cast((*item)))); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome>> DeserializeSparseIntegerList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector>: expected a list on the wire"); +opal::Outcome>> DeserializeSparseIntegerList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector>: expected a list on the wire"); std::vector> out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; if (item->is_null()) { out.emplace_back(std::nullopt); continue; } std::int32_t parsed_item{}; - if (!item->is_int()) return smithy::Error::Serialization("std::vector>[]: unexpected type on the wire"); - if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return smithy::Error::Serialization("std::vector>[]: value out of range"); + if (!item->is_int()) return opal::Error::Serialization("std::vector>[]: unexpected type on the wire"); + if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return opal::Error::Serialization("std::vector>[]: value out of range"); parsed_item = static_cast(item->as_int()); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeUniqueStringList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeUniqueStringList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeUniqueStringList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeUniqueStringList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = item->as_string(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeKitchenSink(const KitchenSink& value) { - smithy::DocumentMap map; - map.emplace("name", smithy::Document(value.name)); +opal::Document SerializeKitchenSink(const KitchenSink& value) { + opal::DocumentMap map; + map.emplace("name", opal::Document(value.name)); if (value.flag.has_value()) { - map.emplace("flag", smithy::Document((*value.flag))); + map.emplace("flag", opal::Document((*value.flag))); } if (value.tiny.has_value()) { - map.emplace("tiny", smithy::Document(static_cast((*value.tiny)))); + map.emplace("tiny", opal::Document(static_cast((*value.tiny)))); } if (value.small.has_value()) { - map.emplace("small", smithy::Document(static_cast((*value.small)))); + map.emplace("small", opal::Document(static_cast((*value.small)))); } if (value.medium.has_value()) { - map.emplace("medium", smithy::Document(static_cast((*value.medium)))); + map.emplace("medium", opal::Document(static_cast((*value.medium)))); } if (value.big.has_value()) { - map.emplace("big", smithy::Document(static_cast((*value.big)))); + map.emplace("big", opal::Document(static_cast((*value.big)))); } if (value.ratio.has_value()) { - map.emplace("ratio", smithy::Document(static_cast((*value.ratio)))); + map.emplace("ratio", opal::Document(static_cast((*value.ratio)))); } if (value.precise.has_value()) { - map.emplace("precise", smithy::Document(static_cast((*value.precise)))); + map.emplace("precise", opal::Document(static_cast((*value.precise)))); } if (value.blob.has_value()) { - map.emplace("blob", smithy::Document((*value.blob))); + map.emplace("blob", opal::Document((*value.blob))); } if (value.priority.has_value()) { - map.emplace("priority", smithy::Document(std::string((*value.priority).ToString()))); + map.emplace("priority", opal::Document(std::string((*value.priority).ToString()))); } if (value.weight.has_value()) { - map.emplace("weight", smithy::Document(static_cast((*value.weight)))); + map.emplace("weight", opal::Document(static_cast((*value.weight)))); } if (value.dateTime.has_value()) { - map.emplace("dateTime", smithy::Document::FromTimestamp((*value.dateTime), smithy::TimestampFormat::kDateTime)); + map.emplace("dateTime", opal::Document::FromTimestamp((*value.dateTime), opal::TimestampFormat::kDateTime)); } if (value.httpDate.has_value()) { - map.emplace("httpDate", smithy::Document::FromTimestamp((*value.httpDate), smithy::TimestampFormat::kHttpDate)); + map.emplace("httpDate", opal::Document::FromTimestamp((*value.httpDate), opal::TimestampFormat::kHttpDate)); } if (value.epoch.has_value()) { - map.emplace("epoch", smithy::Document::FromTimestamp((*value.epoch), smithy::TimestampFormat::kEpochSeconds)); + map.emplace("epoch", opal::Document::FromTimestamp((*value.epoch), opal::TimestampFormat::kEpochSeconds)); } if (value.names.has_value()) { map.emplace("names", SerializeStringList((*value.names))); @@ -288,100 +288,100 @@ smithy::Document SerializeKitchenSink(const KitchenSink& value) { if (value.choice.has_value()) { map.emplace("choice", SerializeSinkChoice((*value.choice))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("KitchenSink: expected a map on the wire"); +opal::Outcome DeserializeKitchenSink(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("KitchenSink: expected a map on the wire"); KitchenSink out; { - const smithy::Document* member = doc.Find("name"); + const opal::Document* member = doc.Find("name"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("KitchenSink: missing required member: name"); + return opal::Error::Serialization("KitchenSink: missing required member: name"); } - if (!member->is_string()) return smithy::Error::Serialization("KitchenSink.name: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("KitchenSink.name: unexpected type on the wire"); out.name = member->as_string(); } { - const smithy::Document* member = doc.Find("flag"); + const opal::Document* member = doc.Find("flag"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("KitchenSink.flag: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("KitchenSink.flag: unexpected type on the wire"); parsed_member = member->as_bool(); out.flag = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("tiny"); + const opal::Document* member = doc.Find("tiny"); if (member != nullptr && !member->is_null()) { std::int8_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.tiny: unexpected type on the wire"); - if (member->as_int() < -128 || member->as_int() > 127) return smithy::Error::Serialization("KitchenSink.tiny: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.tiny: unexpected type on the wire"); + if (member->as_int() < -128 || member->as_int() > 127) return opal::Error::Serialization("KitchenSink.tiny: value out of range"); parsed_member = static_cast(member->as_int()); out.tiny = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("small"); + const opal::Document* member = doc.Find("small"); if (member != nullptr && !member->is_null()) { std::int16_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.small: unexpected type on the wire"); - if (member->as_int() < -32768 || member->as_int() > 32767) return smithy::Error::Serialization("KitchenSink.small: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.small: unexpected type on the wire"); + if (member->as_int() < -32768 || member->as_int() > 32767) return opal::Error::Serialization("KitchenSink.small: value out of range"); parsed_member = static_cast(member->as_int()); out.small = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("medium"); + const opal::Document* member = doc.Find("medium"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.medium: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("KitchenSink.medium: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.medium: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("KitchenSink.medium: value out of range"); parsed_member = static_cast(member->as_int()); out.medium = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("big"); + const opal::Document* member = doc.Find("big"); if (member != nullptr && !member->is_null()) { std::int64_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.big: unexpected type on the wire"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.big: unexpected type on the wire"); parsed_member = static_cast(member->as_int()); out.big = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("ratio"); + const opal::Document* member = doc.Find("ratio"); if (member != nullptr && !member->is_null()) { float parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("KitchenSink.ratio: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("KitchenSink.ratio: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("KitchenSink.ratio: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("KitchenSink.ratio: value out of range"); parsed_member = *narrowed; } out.ratio = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("precise"); + const opal::Document* member = doc.Find("precise"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("KitchenSink.precise: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("KitchenSink.precise: expected a number"); parsed_member = static_cast(*parsed); } out.precise = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("blob"); + const opal::Document* member = doc.Find("blob"); if (member != nullptr && !member->is_null()) { - smithy::Blob parsed_member{}; + opal::Blob parsed_member{}; { - auto parsed = smithy::BlobFromDocument(*member); + auto parsed = opal::BlobFromDocument(*member); if (!parsed) return std::move(parsed).error(); parsed_member = std::move(*parsed); } @@ -389,30 +389,30 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("priority"); + const opal::Document* member = doc.Find("priority"); if (member != nullptr && !member->is_null()) { types::Priority parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("KitchenSink.priority: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("KitchenSink.priority: unexpected type on the wire"); parsed_member = types::Priority::FromString(member->as_string()); out.priority = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("weight"); + const opal::Document* member = doc.Find("weight"); if (member != nullptr && !member->is_null()) { types::Weight parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.weight: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("KitchenSink.weight: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.weight: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("KitchenSink.weight: value out of range"); parsed_member = static_cast(member->as_int()); out.weight = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("dateTime"); + const opal::Document* member = doc.Find("dateTime"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kDateTime); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kDateTime); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -420,11 +420,11 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("httpDate"); + const opal::Document* member = doc.Find("httpDate"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kHttpDate); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kHttpDate); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -432,11 +432,11 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("epoch"); + const opal::Document* member = doc.Find("epoch"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kEpochSeconds); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kEpochSeconds); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -444,7 +444,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("names"); + const opal::Document* member = doc.Find("names"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -456,7 +456,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("uniqueNames"); + const opal::Document* member = doc.Find("uniqueNames"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -468,7 +468,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("sparseNumbers"); + const opal::Document* member = doc.Find("sparseNumbers"); if (member != nullptr && !member->is_null()) { std::vector> parsed_member{}; { @@ -480,7 +480,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("attributes"); + const opal::Document* member = doc.Find("attributes"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -492,7 +492,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("nested"); + const opal::Document* member = doc.Find("nested"); if (member != nullptr && !member->is_null()) { types::NestedConfig parsed_member{}; { @@ -504,7 +504,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("choice"); + const opal::Document* member = doc.Find("choice"); if (member != nullptr && !member->is_null()) { types::SinkChoice parsed_member{}; { @@ -518,19 +518,19 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) return out; } -smithy::Document SerializeDescribeSinkOutput(const DescribeSinkOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeDescribeSinkOutput(const DescribeSinkOutput& value) { + opal::DocumentMap map; if (value.sink.has_value()) { map.emplace("sink", SerializeKitchenSink((*value.sink))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeDescribeSinkOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("DescribeSinkOutput: expected a map on the wire"); +opal::Outcome DeserializeDescribeSinkOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("DescribeSinkOutput: expected a map on the wire"); DescribeSinkOutput out; { - const smithy::Document* member = doc.Find("sink"); + const opal::Document* member = doc.Find("sink"); if (member != nullptr && !member->is_null()) { types::KitchenSink parsed_member{}; { @@ -544,31 +544,31 @@ smithy::Outcome DeserializeDescribeSinkOutput(const smithy:: return out; } -smithy::Document SerializeSinkNotFound(const SinkNotFound& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); +opal::Document SerializeSinkNotFound(const SinkNotFound& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); if (value.resourceType.has_value()) { - map.emplace("resourceType", smithy::Document((*value.resourceType))); + map.emplace("resourceType", opal::Document((*value.resourceType))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSinkNotFound(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SinkNotFound: expected a map on the wire"); +opal::Outcome DeserializeSinkNotFound(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SinkNotFound: expected a map on the wire"); SinkNotFound out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("SinkNotFound: missing required member: message"); + return opal::Error::Serialization("SinkNotFound: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("SinkNotFound.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkNotFound.message: unexpected type on the wire"); out.message = member->as_string(); } { - const smithy::Document* member = doc.Find("resourceType"); + const opal::Document* member = doc.Find("resourceType"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("SinkNotFound.resourceType: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkNotFound.resourceType: unexpected type on the wire"); parsed_member = member->as_string(); out.resourceType = std::move(parsed_member); } @@ -576,17 +576,17 @@ smithy::Outcome DeserializeSinkNotFound(const smithy::Document& do return out; } -smithy::Document SerializePutSinkInput(const PutSinkInput& value) { - smithy::DocumentMap map; - map.emplace("sinkId", smithy::Document(value.sinkId)); +opal::Document SerializePutSinkInput(const PutSinkInput& value) { + opal::DocumentMap map; + map.emplace("sinkId", opal::Document(value.sinkId)); if (value.tag.has_value()) { - map.emplace("tag", smithy::Document((*value.tag))); + map.emplace("tag", opal::Document((*value.tag))); } - map.emplace("limit", smithy::Document(static_cast(value.limit))); + map.emplace("limit", opal::Document(static_cast(value.limit))); if (value.priority.has_value()) { - map.emplace("priority", smithy::Document(std::string((*value.priority).ToString()))); + map.emplace("priority", opal::Document(std::string((*value.priority).ToString()))); } - map.emplace("created", smithy::Document::FromTimestamp(value.created, smithy::TimestampFormat::kEpochSeconds)); + map.emplace("created", opal::Document::FromTimestamp(value.created, opal::TimestampFormat::kEpochSeconds)); if (value.metadata.has_value()) { map.emplace("metadata", SerializeStringMap((*value.metadata))); } @@ -596,60 +596,60 @@ smithy::Document SerializePutSinkInput(const PutSinkInput& value) { if (value.freeform.has_value()) { map.emplace("freeform", (*value.freeform)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePutSinkInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PutSinkInput: expected a map on the wire"); +opal::Outcome DeserializePutSinkInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PutSinkInput: expected a map on the wire"); PutSinkInput out; { - const smithy::Document* member = doc.Find("sinkId"); + const opal::Document* member = doc.Find("sinkId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PutSinkInput: missing required member: sinkId"); + return opal::Error::Serialization("PutSinkInput: missing required member: sinkId"); } - if (!member->is_string()) return smithy::Error::Serialization("PutSinkInput.sinkId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutSinkInput.sinkId: unexpected type on the wire"); out.sinkId = member->as_string(); } { - const smithy::Document* member = doc.Find("tag"); + const opal::Document* member = doc.Find("tag"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("PutSinkInput.tag: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutSinkInput.tag: unexpected type on the wire"); parsed_member = member->as_string(); out.tag = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("limit"); + const opal::Document* member = doc.Find("limit"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PutSinkInput: missing required member: limit"); + return opal::Error::Serialization("PutSinkInput: missing required member: limit"); } - if (!member->is_int()) return smithy::Error::Serialization("PutSinkInput.limit: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("PutSinkInput.limit: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("PutSinkInput.limit: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("PutSinkInput.limit: value out of range"); out.limit = static_cast(member->as_int()); } { - const smithy::Document* member = doc.Find("priority"); + const opal::Document* member = doc.Find("priority"); if (member != nullptr && !member->is_null()) { types::Priority parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("PutSinkInput.priority: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutSinkInput.priority: unexpected type on the wire"); parsed_member = types::Priority::FromString(member->as_string()); out.priority = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("created"); + const opal::Document* member = doc.Find("created"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PutSinkInput: missing required member: created"); + return opal::Error::Serialization("PutSinkInput: missing required member: created"); } { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kEpochSeconds); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kEpochSeconds); if (!parsed) return std::move(parsed).error(); out.created = *parsed; } } { - const smithy::Document* member = doc.Find("metadata"); + const opal::Document* member = doc.Find("metadata"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -661,7 +661,7 @@ smithy::Outcome DeserializePutSinkInput(const smithy::Document& do } } { - const smithy::Document* member = doc.Find("sink"); + const opal::Document* member = doc.Find("sink"); if (member != nullptr && !member->is_null()) { types::KitchenSink parsed_member{}; { @@ -673,9 +673,9 @@ smithy::Outcome DeserializePutSinkInput(const smithy::Document& do } } { - const smithy::Document* member = doc.Find("freeform"); + const opal::Document* member = doc.Find("freeform"); if (member != nullptr && !member->is_null()) { - smithy::Document parsed_member{}; + opal::Document parsed_member{}; parsed_member = *member; out.freeform = std::move(parsed_member); } @@ -683,22 +683,22 @@ smithy::Outcome DeserializePutSinkInput(const smithy::Document& do return out; } -smithy::Document SerializePutSinkResponse(const PutSinkResponse& value) { - smithy::DocumentMap map; +opal::Document SerializePutSinkResponse(const PutSinkResponse& value) { + opal::DocumentMap map; if (value.note.has_value()) { - map.emplace("note", smithy::Document((*value.note))); + map.emplace("note", opal::Document((*value.note))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePutSinkResponse(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PutSinkResponse: expected a map on the wire"); +opal::Outcome DeserializePutSinkResponse(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PutSinkResponse: expected a map on the wire"); PutSinkResponse out; { - const smithy::Document* member = doc.Find("note"); + const opal::Document* member = doc.Find("note"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("PutSinkResponse.note: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutSinkResponse.note: unexpected type on the wire"); parsed_member = member->as_string(); out.note = std::move(parsed_member); } @@ -706,11 +706,11 @@ smithy::Outcome DeserializePutSinkResponse(const smithy::Docume return out; } -smithy::Document SerializePutSinkOutput(const PutSinkOutput& value) { - smithy::DocumentMap map; - map.emplace("sinkId", smithy::Document(value.sinkId)); +opal::Document SerializePutSinkOutput(const PutSinkOutput& value) { + opal::DocumentMap map; + map.emplace("sinkId", opal::Document(value.sinkId)); if (value.revision.has_value()) { - map.emplace("revision", smithy::Document(static_cast((*value.revision)))); + map.emplace("revision", opal::Document(static_cast((*value.revision)))); } if (value.echoedMetadata.has_value()) { map.emplace("echoedMetadata", SerializeStringMap((*value.echoedMetadata))); @@ -721,32 +721,32 @@ smithy::Document SerializePutSinkOutput(const PutSinkOutput& value) { if (value.echo.has_value()) { map.emplace("echo", SerializePutSinkResponse((*value.echo))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePutSinkOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PutSinkOutput: expected a map on the wire"); +opal::Outcome DeserializePutSinkOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PutSinkOutput: expected a map on the wire"); PutSinkOutput out; { - const smithy::Document* member = doc.Find("sinkId"); + const opal::Document* member = doc.Find("sinkId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PutSinkOutput: missing required member: sinkId"); + return opal::Error::Serialization("PutSinkOutput: missing required member: sinkId"); } - if (!member->is_string()) return smithy::Error::Serialization("PutSinkOutput.sinkId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutSinkOutput.sinkId: unexpected type on the wire"); out.sinkId = member->as_string(); } { - const smithy::Document* member = doc.Find("revision"); + const opal::Document* member = doc.Find("revision"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("PutSinkOutput.revision: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("PutSinkOutput.revision: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("PutSinkOutput.revision: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("PutSinkOutput.revision: value out of range"); parsed_member = static_cast(member->as_int()); out.revision = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("echoedMetadata"); + const opal::Document* member = doc.Find("echoedMetadata"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -758,7 +758,7 @@ smithy::Outcome DeserializePutSinkOutput(const smithy::Document& } } { - const smithy::Document* member = doc.Find("sink"); + const opal::Document* member = doc.Find("sink"); if (member != nullptr && !member->is_null()) { types::KitchenSink parsed_member{}; { @@ -770,7 +770,7 @@ smithy::Outcome DeserializePutSinkOutput(const smithy::Document& } } { - const smithy::Document* member = doc.Find("echo"); + const opal::Document* member = doc.Find("echo"); if (member != nullptr && !member->is_null()) { types::PutSinkResponse parsed_member{}; { @@ -784,35 +784,35 @@ smithy::Outcome DeserializePutSinkOutput(const smithy::Document& return out; } -smithy::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value) { - smithy::DocumentMap map; +opal::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value) { + opal::DocumentMap map; if (value.message.has_value()) { - map.emplace("message", smithy::Document((*value.message))); + map.emplace("message", opal::Document((*value.message))); } if (value.retryAfterSeconds.has_value()) { - map.emplace("retryAfterSeconds", smithy::Document(static_cast((*value.retryAfterSeconds)))); + map.emplace("retryAfterSeconds", opal::Document(static_cast((*value.retryAfterSeconds)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSinkQuotaExceeded(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SinkQuotaExceeded: expected a map on the wire"); +opal::Outcome DeserializeSinkQuotaExceeded(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SinkQuotaExceeded: expected a map on the wire"); SinkQuotaExceeded out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("SinkQuotaExceeded.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkQuotaExceeded.message: unexpected type on the wire"); parsed_member = member->as_string(); out.message = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("retryAfterSeconds"); + const opal::Document* member = doc.Find("retryAfterSeconds"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: value out of range"); parsed_member = static_cast(member->as_int()); out.retryAfterSeconds = std::move(parsed_member); } @@ -820,31 +820,31 @@ smithy::Outcome DeserializeSinkQuotaExceeded(const smithy::Do return out; } -smithy::Document SerializeReceipt(const Receipt& value) { - smithy::DocumentMap map; - map.emplace("receiptId", smithy::Document(value.receiptId)); +opal::Document SerializeReceipt(const Receipt& value) { + opal::DocumentMap map; + map.emplace("receiptId", opal::Document(value.receiptId)); if (value.size.has_value()) { - map.emplace("size", smithy::Document(static_cast((*value.size)))); + map.emplace("size", opal::Document(static_cast((*value.size)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeReceipt(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Receipt: expected a map on the wire"); +opal::Outcome DeserializeReceipt(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Receipt: expected a map on the wire"); Receipt out; { - const smithy::Document* member = doc.Find("receiptId"); + const opal::Document* member = doc.Find("receiptId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Receipt: missing required member: receiptId"); + return opal::Error::Serialization("Receipt: missing required member: receiptId"); } - if (!member->is_string()) return smithy::Error::Serialization("Receipt.receiptId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Receipt.receiptId: unexpected type on the wire"); out.receiptId = member->as_string(); } { - const smithy::Document* member = doc.Find("size"); + const opal::Document* member = doc.Find("size"); if (member != nullptr && !member->is_null()) { std::int64_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("Receipt.size: unexpected type on the wire"); + if (!member->is_int()) return opal::Error::Serialization("Receipt.size: unexpected type on the wire"); parsed_member = static_cast(member->as_int()); out.size = std::move(parsed_member); } @@ -852,44 +852,44 @@ smithy::Outcome DeserializeReceipt(const smithy::Document& doc) { return out; } -smithy::Document SerializeUploadAttachmentInput(const UploadAttachmentInput& value) { - smithy::DocumentMap map; - map.emplace("sinkId", smithy::Document(value.sinkId)); +opal::Document SerializeUploadAttachmentInput(const UploadAttachmentInput& value) { + opal::DocumentMap map; + map.emplace("sinkId", opal::Document(value.sinkId)); if (value.name.has_value()) { - map.emplace("name", smithy::Document((*value.name))); + map.emplace("name", opal::Document((*value.name))); } if (value.data.has_value()) { - map.emplace("data", smithy::Document((*value.data))); + map.emplace("data", opal::Document((*value.data))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeUploadAttachmentInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("UploadAttachmentInput: expected a map on the wire"); +opal::Outcome DeserializeUploadAttachmentInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("UploadAttachmentInput: expected a map on the wire"); UploadAttachmentInput out; { - const smithy::Document* member = doc.Find("sinkId"); + const opal::Document* member = doc.Find("sinkId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("UploadAttachmentInput: missing required member: sinkId"); + return opal::Error::Serialization("UploadAttachmentInput: missing required member: sinkId"); } - if (!member->is_string()) return smithy::Error::Serialization("UploadAttachmentInput.sinkId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("UploadAttachmentInput.sinkId: unexpected type on the wire"); out.sinkId = member->as_string(); } { - const smithy::Document* member = doc.Find("name"); + const opal::Document* member = doc.Find("name"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("UploadAttachmentInput.name: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("UploadAttachmentInput.name: unexpected type on the wire"); parsed_member = member->as_string(); out.name = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("data"); + const opal::Document* member = doc.Find("data"); if (member != nullptr && !member->is_null()) { - smithy::Blob parsed_member{}; + opal::Blob parsed_member{}; { - auto parsed = smithy::BlobFromDocument(*member); + auto parsed = opal::BlobFromDocument(*member); if (!parsed) return std::move(parsed).error(); parsed_member = std::move(*parsed); } @@ -899,19 +899,19 @@ smithy::Outcome DeserializeUploadAttachmentInput(const sm return out; } -smithy::Document SerializeUploadAttachmentOutput(const UploadAttachmentOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeUploadAttachmentOutput(const UploadAttachmentOutput& value) { + opal::DocumentMap map; if (value.receipt.has_value()) { map.emplace("receipt", SerializeReceipt((*value.receipt))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeUploadAttachmentOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("UploadAttachmentOutput: expected a map on the wire"); +opal::Outcome DeserializeUploadAttachmentOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("UploadAttachmentOutput: expected a map on the wire"); UploadAttachmentOutput out; { - const smithy::Document* member = doc.Find("receipt"); + const opal::Document* member = doc.Find("receipt"); if (member != nullptr && !member->is_null()) { types::Receipt parsed_member{}; { diff --git a/examples/roundtrip/rest/generated/src/server.cc b/examples/roundtrip/rest/generated/src/server.cc index 59f02815..641763d3 100644 --- a/examples/roundtrip/rest/generated/src/server.cc +++ b/examples/roundtrip/rest/generated/src/server.cc @@ -37,18 +37,18 @@ namespace helpers { // emitted for every service; not every service binds numeric values). // Trailing text, floats-for-ints, and out-of-range values are rejected // (the malformed-request suites pin this). -[[maybe_unused]] smithy::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { +[[maybe_unused]] opal::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { std::int64_t value = 0; const char* first = text.data(); const char* last = first + text.size(); const auto result = std::from_chars(first, last, value, 10); if (text.empty() || result.ec != std::errc() || result.ptr != last || value < min_value || value > max_value) { - return smithy::Error::Serialization("invalid integer: " + text); + return opal::Error::Serialization("invalid integer: " + text); } return value; } -[[maybe_unused]] smithy::Outcome ParseDoubleText(const std::string& text) { +[[maybe_unused]] opal::Outcome ParseDoubleText(const std::string& text) { if (text == "NaN") return std::numeric_limits::quiet_NaN(); if (text == "Infinity") return std::numeric_limits::infinity(); if (text == "-Infinity") return -std::numeric_limits::infinity(); @@ -56,12 +56,12 @@ namespace helpers { return (c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' || c == '+' || c == '-'; }; if (text.empty() || text.front() == '+' || !std::all_of(text.begin(), text.end(), valid_char)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } char* parse_end = nullptr; const double value = std::strtod(text.c_str(), &parse_end); if (parse_end != text.c_str() + text.size() || !std::isfinite(value)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } return value; } @@ -72,31 +72,31 @@ namespace helpers { return status >= 200 && status != 204 && status != 205 && status != 304; } -smithy::http::HttpResponse JsonError(int status, const std::string& code, const std::string& message, smithy::DocumentMap body) { - if (!code.empty()) body.insert_or_assign("__type", smithy::Document(code)); - if (!message.empty()) body.insert_or_assign("message", smithy::Document(message)); - smithy::http::HttpResponse response; +opal::http::HttpResponse JsonError(int status, const std::string& code, const std::string& message, opal::DocumentMap body) { + if (!code.empty()) body.insert_or_assign("__type", opal::Document(code)); + if (!message.empty()) body.insert_or_assign("message", opal::Document(message)); + opal::http::HttpResponse response; response.status = status; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body))); + response.body = opal::json::Encode(opal::Document(std::move(body))); return response; } // [[maybe_unused]]: only unary routes map handler errors here; a service // whose operations all stream reports errors on the stream instead. -[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& error) { +[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& error) { std::vector> header_values; (void)header_values; - if (error.kind() == smithy::ErrorKind::kModeled) { + if (error.kind() == opal::ErrorKind::kModeled) { if (error.code() == "DescribeSinkError") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeDescribeSinkError(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } auto response = helpers::JsonError(410, "", "", std::move(body)); response.headers.Set("x-error-type", error.code()); @@ -104,14 +104,14 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const return response; } if (error.code() == "SinkNotFound") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeSinkNotFound(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } auto response = helpers::JsonError(404, "", "", std::move(body)); response.headers.Set("x-error-type", error.code()); @@ -119,14 +119,14 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const return response; } if (error.code() == "SinkQuotaExceeded") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeSinkQuotaExceeded(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } if (auto it = body.find("retryAfterSeconds"); it != body.end()) { if (it->second.is_int()) header_values.emplace_back("x-retry-after-seconds", std::to_string(it->second.as_int())); @@ -139,7 +139,7 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const } return helpers::JsonError(400, error.code(), error.message(), {}); } - if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) { + if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) { auto response = helpers::JsonError(400, "", error.message(), {}); response.headers.Set("x-error-type", "SerializationException"); return response; @@ -150,27 +150,27 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const // Constraint validation (smithy.framework#ValidationException): messages // and '/member' paths follow the official validation conformance suite. -void AddValidationFailure(std::vector* failures, std::string path, std::string message) { +void AddValidationFailure(std::vector* failures, std::string path, std::string message) { failures->push_back({std::move(path), std::move(message)}); } -void ValidateDescribeSinkInput(const types::DescribeSinkInput& value, const std::string& path, std::vector* failures) { +void ValidateDescribeSinkInput(const types::DescribeSinkInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/sinkId"; { - const std::size_t member_length = smithy::Utf8CodePointCount(value.sinkId); + const std::size_t member_length = opal::Utf8CodePointCount(value.sinkId); if (member_length < 1ULL || member_length > 32ULL) { helpers::AddValidationFailure(failures, member_path, "Value with length " + std::to_string(member_length) + " at '" + member_path + "' failed to satisfy constraint: Member must have length between 1 and 32, inclusive"); } } - static const smithy::Outcome kPattern0 = smithy::Regex::Compile(R"__smithy(^[A-Za-z0-9]+$)__smithy"); + static const opal::Outcome kPattern0 = opal::Regex::Compile(R"__smithy(^[A-Za-z0-9]+$)__smithy"); if (!kPattern0.ok() || !kPattern0->Search(value.sinkId)) { helpers::AddValidationFailure(failures, member_path, "Value at '" + member_path + "' failed to satisfy constraint: Member must satisfy regular expression pattern: " + std::string("^[A-Za-z0-9]+$")); } } } -void ValidateKitchenSink(const types::KitchenSink& value, const std::string& path, std::vector* failures) { +void ValidateKitchenSink(const types::KitchenSink& value, const std::string& path, std::vector* failures) { if (value.priority.has_value()) { const std::string member_path = path + "/priority"; if ((*value.priority).value() == Priority::Value::kUnknown) { @@ -199,16 +199,16 @@ void ValidateKitchenSink(const types::KitchenSink& value, const std::string& pat } } -void ValidatePutSinkInput(const types::PutSinkInput& value, const std::string& path, std::vector* failures) { +void ValidatePutSinkInput(const types::PutSinkInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/sinkId"; { - const std::size_t member_length = smithy::Utf8CodePointCount(value.sinkId); + const std::size_t member_length = opal::Utf8CodePointCount(value.sinkId); if (member_length < 1ULL || member_length > 32ULL) { helpers::AddValidationFailure(failures, member_path, "Value with length " + std::to_string(member_length) + " at '" + member_path + "' failed to satisfy constraint: Member must have length between 1 and 32, inclusive"); } } - static const smithy::Outcome kPattern1 = smithy::Regex::Compile(R"__smithy(^[A-Za-z0-9]+$)__smithy"); + static const opal::Outcome kPattern1 = opal::Regex::Compile(R"__smithy(^[A-Za-z0-9]+$)__smithy"); if (!kPattern1.ok() || !kPattern1->Search(value.sinkId)) { helpers::AddValidationFailure(failures, member_path, "Value at '" + member_path + "' failed to satisfy constraint: Member must satisfy regular expression pattern: " + std::string("^[A-Za-z0-9]+$")); } @@ -231,16 +231,16 @@ void ValidatePutSinkInput(const types::PutSinkInput& value, const std::string& p } } -void ValidateUploadAttachmentInput(const types::UploadAttachmentInput& value, const std::string& path, std::vector* failures) { +void ValidateUploadAttachmentInput(const types::UploadAttachmentInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/sinkId"; { - const std::size_t member_length = smithy::Utf8CodePointCount(value.sinkId); + const std::size_t member_length = opal::Utf8CodePointCount(value.sinkId); if (member_length < 1ULL || member_length > 32ULL) { helpers::AddValidationFailure(failures, member_path, "Value with length " + std::to_string(member_length) + " at '" + member_path + "' failed to satisfy constraint: Member must have length between 1 and 32, inclusive"); } } - static const smithy::Outcome kPattern2 = smithy::Regex::Compile(R"__smithy(^[A-Za-z0-9]+$)__smithy"); + static const opal::Outcome kPattern2 = opal::Regex::Compile(R"__smithy(^[A-Za-z0-9]+$)__smithy"); if (!kPattern2.ok() || !kPattern2->Search(value.sinkId)) { helpers::AddValidationFailure(failures, member_path, "Value at '" + member_path + "' failed to satisfy constraint: Member must satisfy regular expression pattern: " + std::string("^[A-Za-z0-9]+$")); } @@ -249,25 +249,25 @@ void ValidateUploadAttachmentInput(const types::UploadAttachmentInput& value, co // [[maybe_unused]]: only unary routes reject invalid input over HTTP; a // service whose operations all stream reports validation on the stream. -[[maybe_unused]] smithy::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { +[[maybe_unused]] opal::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { std::string summary = std::to_string(failures.size()) + " validation error" + (failures.size() == 1 ? "" : "s") + " detected. "; - smithy::DocumentList field_list; + opal::DocumentList field_list; for (std::size_t i = 0; i < failures.size(); ++i) { if (i > 0) summary += "; "; summary += failures[i].message; - smithy::DocumentMap field; - field.emplace("message", smithy::Document(failures[i].message)); - field.emplace("path", smithy::Document(failures[i].path)); - field_list.push_back(smithy::Document(std::move(field))); - } - smithy::DocumentMap body; - body.emplace("fieldList", smithy::Document(std::move(field_list))); - smithy::http::HttpResponse response = helpers::JsonError(400, "", summary, std::move(body)); + opal::DocumentMap field; + field.emplace("message", opal::Document(failures[i].message)); + field.emplace("path", opal::Document(failures[i].path)); + field_list.push_back(opal::Document(std::move(field))); + } + opal::DocumentMap body; + body.emplace("fieldList", opal::Document(std::move(field_list))); + opal::http::HttpResponse response = helpers::JsonError(400, "", summary, std::move(body)); response.headers.Set("x-error-type", "ValidationException"); return response; } -smithy::Outcome ParseDescribeSinkInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseDescribeSinkInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -279,20 +279,20 @@ smithy::Outcome ParseDescribeSinkInput(const smithy::h return input; } -smithy::http::HttpResponse BuildDescribeSinkResponse(const types::DescribeSinkOutput& output) { +opal::http::HttpResponse BuildDescribeSinkResponse(const types::DescribeSinkOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; + opal::DocumentMap body_map; if (output.sink.has_value()) { body_map.emplace("sink", SerializeKitchenSink((*output.sink))); } response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParsePutSinkInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParsePutSinkInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -302,7 +302,7 @@ smithy::Outcome ParsePutSinkInput(const smithy::http::HttpR input.sinkId = label_value; } if (const auto header_value = request.headers.Get("x-sink-created"); header_value.has_value()) { - auto parsed_ts = smithy::Timestamp::Parse((*header_value), smithy::TimestampFormat::kHttpDate); + auto parsed_ts = opal::Timestamp::Parse((*header_value), opal::TimestampFormat::kHttpDate); if (!parsed_ts) return std::move(parsed_ts).error(); input.created = *std::move(parsed_ts); } @@ -326,15 +326,15 @@ smithy::Outcome ParsePutSinkInput(const smithy::http::HttpR } if (!saw_limit) AddValidationFailure(validation_failures, "/limit", "Value at '/limit' failed to satisfy constraint: Member must not be null"); for (const auto& [header_name, header_value] : request.headers.entries()) { - if (!smithy::http::HeaderNameStartsWith(header_name, "x-meta-")) continue; + if (!opal::http::HeaderNameStartsWith(header_name, "x-meta-")) continue; if (!input.metadata.has_value()) input.metadata.emplace(); (*input.metadata).insert_or_assign(header_name.substr(7), header_value); } - auto body_doc = smithy::json::Decode(request.body.empty() ? "{}" : request.body); + auto body_doc = opal::json::Decode(request.body.empty() ? "{}" : request.body); if (!body_doc) return std::move(body_doc).error(); - if (!body_doc->is_map()) return smithy::Error::Serialization("PutSink: expected a JSON object body"); + if (!body_doc->is_map()) return opal::Error::Serialization("PutSink: expected a JSON object body"); { - const smithy::Document* member = body_doc->Find("sink"); + const opal::Document* member = body_doc->Find("sink"); if (member != nullptr && !member->is_null()) { types::KitchenSink parsed_member{}; { @@ -346,9 +346,9 @@ smithy::Outcome ParsePutSinkInput(const smithy::http::HttpR } } { - const smithy::Document* member = body_doc->Find("freeform"); + const opal::Document* member = body_doc->Find("freeform"); if (member != nullptr && !member->is_null()) { - smithy::Document parsed_member{}; + opal::Document parsed_member{}; parsed_member = *member; input.freeform = std::move(parsed_member); } @@ -356,9 +356,9 @@ smithy::Outcome ParsePutSinkInput(const smithy::http::HttpR return input; } -smithy::http::HttpResponse BuildPutSinkResponse(const types::PutSinkOutput& output) { +opal::http::HttpResponse BuildPutSinkResponse(const types::PutSinkOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; if (output.revision.has_value()) { response.headers.Set("x-sink-revision", std::to_string(static_cast((*output.revision)))); @@ -368,8 +368,8 @@ smithy::http::HttpResponse BuildPutSinkResponse(const types::PutSinkOutput& outp response.headers.Set("x-echo-" + map_key, map_value); } } - smithy::DocumentMap body_map; - body_map.emplace("sinkId", smithy::Document(output.sinkId)); + opal::DocumentMap body_map; + body_map.emplace("sinkId", opal::Document(output.sinkId)); if (output.sink.has_value()) { body_map.emplace("sink", SerializeKitchenSink((*output.sink))); } @@ -377,11 +377,11 @@ smithy::http::HttpResponse BuildPutSinkResponse(const types::PutSinkOutput& outp body_map.emplace("echo", SerializePutSinkResponse((*output.echo))); } response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseUploadAttachmentInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseUploadAttachmentInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -394,17 +394,17 @@ smithy::Outcome ParseUploadAttachmentInput(const s input.name = (*header_value); } if (!request.body.empty()) { - input.data = smithy::Blob::FromString(request.body); + input.data = opal::Blob::FromString(request.body); } return input; } -smithy::http::HttpResponse BuildUploadAttachmentResponse(const types::UploadAttachmentOutput& output) { +opal::http::HttpResponse BuildUploadAttachmentResponse(const types::UploadAttachmentOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; if (output.receipt.has_value()) { - response.body = smithy::json::Encode(SerializeReceipt((*output.receipt))); + response.body = opal::json::Encode(SerializeReceipt((*output.receipt))); } else { response.body = "{}"; } @@ -417,26 +417,26 @@ smithy::http::HttpResponse BuildUploadAttachmentResponse(const types::UploadAtta } // namespace RoundTripRestServer::RoundTripRestServer(std::shared_ptr handler) - : router_(std::make_shared()) { + : router_(std::make_shared()) { // The route table is derived from the model's @http traits; conflicts are // a modeling error surfaced by Router::Add (checked at generation time in a // later phase), so registration results are intentionally discarded. - (void)router_->Add("GET", "/sinks/{sinkId}", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/sinks/{sinkId}", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseDescribeSinkInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -446,11 +446,11 @@ RoundTripRestServer::RoundTripRestServer(std::shared_ptr h if (!outcome) return helpers::ErrorToResponse(outcome.error()); return helpers::BuildDescribeSinkResponse(*outcome); }, "DescribeSink"); - (void)router_->Add("PUT", "/sinks/{sinkId}", [handler](const smithy::http::HttpRequest& raw_request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { - smithy::http::HttpRequest request = raw_request; + (void)router_->Add("PUT", "/sinks/{sinkId}", [handler](const opal::http::HttpRequest& raw_request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { + opal::http::HttpRequest request = raw_request; // @requestCompression(gzip): decode before parsing. if (const auto request_encoding = request.headers.Get("content-encoding"); request_encoding.has_value() && (*request_encoding == "gzip" || request_encoding->ends_with(", gzip"))) { - auto decompressed = smithy::GzipDecompress(request.body); + auto decompressed = opal::GzipDecompress(request.body); if (!decompressed) { return helpers::JsonError(400, "", "invalid gzip request body", {}); } @@ -460,17 +460,17 @@ RoundTripRestServer::RoundTripRestServer(std::shared_ptr h // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParsePutSinkInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -480,17 +480,17 @@ RoundTripRestServer::RoundTripRestServer(std::shared_ptr h if (!outcome) return helpers::ErrorToResponse(outcome.error()); return helpers::BuildPutSinkResponse(*outcome); }, "PutSink"); - (void)router_->Add("POST", "/sinks/{sinkId}/attachment", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/sinks/{sinkId}/attachment", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseUploadAttachmentInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -502,9 +502,9 @@ RoundTripRestServer::RoundTripRestServer(std::shared_ptr h }, "UploadAttachment"); } -smithy::http::RequestHandler RoundTripRestServer::Handler() const { +opal::http::RequestHandler RoundTripRestServer::Handler() const { auto router = router_; - return [router](const smithy::http::HttpRequest& request) { return router->Route(request); }; + return [router](const opal::http::HttpRequest& request) { return router->Route(request); }; } } // namespace example::roundtrip::rest diff --git a/examples/roundtrip/rest/generated/tests/integration_test.cc b/examples/roundtrip/rest/generated/tests/integration_test.cc index c44b6b2b..c90ad6f9 100644 --- a/examples/roundtrip/rest/generated/tests/integration_test.cc +++ b/examples/roundtrip/rest/generated/tests/integration_test.cc @@ -140,12 +140,12 @@ struct Rng { if (rng.Coin()) v.big = static_cast(rng.Int(-4611686018427387904LL, 4611686018427387903LL)); if (rng.Coin()) v.ratio = static_cast(rng.Int(-8000000LL, 8000000LL)) / static_cast(8); if (rng.Coin()) v.precise = static_cast(rng.Int(-8000000LL, 8000000LL)) / static_cast(8); - if (rng.Coin()) v.blob = smithy::Blob::FromString(rng.Text(1, 9)); + if (rng.Coin()) v.blob = opal::Blob::FromString(rng.Text(1, 9)); if (rng.Coin()) v.priority = Priority::FromString(std::array{"low", "medium", "high"}[rng.engine() % 3]); if (rng.Coin()) v.weight = static_cast(std::array{1, 2}[rng.engine() % 2]); - if (rng.Coin()) v.dateTime = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); - if (rng.Coin()) v.httpDate = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); - if (rng.Coin()) v.epoch = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + if (rng.Coin()) v.dateTime = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + if (rng.Coin()) v.httpDate = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + if (rng.Coin()) v.epoch = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); if (rng.Coin()) v.names = RandomStringList(rng); if (rng.Coin()) v.uniqueNames = RandomUniqueStringList(rng); if (rng.Coin()) v.sparseNumbers = RandomSparseIntegerList(rng); @@ -174,10 +174,10 @@ struct Rng { if (rng.Coin()) v.tag = rng.Text(1, 9); v.limit = static_cast(rng.Int(1LL, 100LL)); if (rng.Coin()) v.priority = Priority::FromString(std::array{"low", "medium", "high"}[rng.engine() % 3]); - v.created = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + v.created = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); if (rng.Coin()) v.metadata = RandomStringMap(rng); if (rng.Coin()) v.sink = RandomKitchenSink(rng); - if (rng.Coin()) v.freeform = smithy::Document(smithy::DocumentMap{{"key", smithy::Document(rng.Int(0, 1000))}}); + if (rng.Coin()) v.freeform = opal::Document(opal::DocumentMap{{"key", opal::Document(rng.Int(0, 1000))}}); return v; } @@ -215,7 +215,7 @@ struct Rng { UploadAttachmentInput v{}; v.sinkId = std::string("0"); if (rng.Coin()) v.name = rng.Text(1, 9); - if (rng.Coin()) v.data = smithy::Blob::FromString(rng.Text(1, 9)); + if (rng.Coin()) v.data = opal::Blob::FromString(rng.Text(1, 9)); return v; } @@ -227,30 +227,30 @@ struct Rng { class ScriptedHandler final : public RoundTripRestHandler { public: - smithy::Outcome DescribeSink(const DescribeSinkInput& input, const smithy::server::RequestContext&) override { + opal::Outcome DescribeSink(const DescribeSinkInput& input, const opal::server::RequestContext&) override { lastDescribeSink = input; if (nextDescribeSinkError.has_value()) return *nextDescribeSinkError; return nextDescribeSinkOutput; } std::optional lastDescribeSink; DescribeSinkOutput nextDescribeSinkOutput{}; - std::optional nextDescribeSinkError; - smithy::Outcome PutSink(const PutSinkInput& input, const smithy::server::RequestContext&) override { + std::optional nextDescribeSinkError; + opal::Outcome PutSink(const PutSinkInput& input, const opal::server::RequestContext&) override { lastPutSink = input; if (nextPutSinkError.has_value()) return *nextPutSinkError; return nextPutSinkOutput; } std::optional lastPutSink; PutSinkOutput nextPutSinkOutput{}; - std::optional nextPutSinkError; - smithy::Outcome UploadAttachment(const UploadAttachmentInput& input, const smithy::server::RequestContext&) override { + std::optional nextPutSinkError; + opal::Outcome UploadAttachment(const UploadAttachmentInput& input, const opal::server::RequestContext&) override { lastUploadAttachment = input; if (nextUploadAttachmentError.has_value()) return *nextUploadAttachmentError; return nextUploadAttachmentOutput; } std::optional lastUploadAttachment; UploadAttachmentOutput nextUploadAttachmentOutput{}; - std::optional nextUploadAttachmentError; + std::optional nextUploadAttachmentError; }; enum class TransportKind { kLoopback, kSocket }; @@ -260,14 +260,14 @@ class RoundTripRestIntegrationTest : public ::testing::TestWithParam(); server_ = std::make_unique(handler_); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries if (GetParam() == TransportKind::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); config.http_client = loopback; } else { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(server_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } @@ -280,7 +280,7 @@ class RoundTripRestIntegrationTest : public ::testing::TestWithParam handler_; std::unique_ptr server_; - std::unique_ptr socket_server_; + std::unique_ptr socket_server_; std::unique_ptr client_; }; @@ -365,13 +365,13 @@ TEST_P(RoundTripRestIntegrationTest, UploadAttachmentMaximalRoundTrips) { TEST_P(RoundTripRestIntegrationTest, DescribeSinkSinkNotFoundMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const SinkNotFound detail = RandomSinkNotFound(rng); - smithy::Error error = smithy::Error::Modeled("SinkNotFound", "integration"); + opal::Error error = opal::Error::Modeled("SinkNotFound", "integration"); error.set_detail(detail); handler_->nextDescribeSinkError = error; const DescribeSinkInput input = RandomDescribeSinkInput(rng); const auto outcome = client_->DescribeSink(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "SinkNotFound"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -380,13 +380,13 @@ TEST_P(RoundTripRestIntegrationTest, DescribeSinkSinkNotFoundMapsAcrossTheWire) TEST_P(RoundTripRestIntegrationTest, DescribeSinkDescribeSinkErrorMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const DescribeSinkError detail = RandomDescribeSinkError(rng); - smithy::Error error = smithy::Error::Modeled("DescribeSinkError", "integration"); + opal::Error error = opal::Error::Modeled("DescribeSinkError", "integration"); error.set_detail(detail); handler_->nextDescribeSinkError = error; const DescribeSinkInput input = RandomDescribeSinkInput(rng); const auto outcome = client_->DescribeSink(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "DescribeSinkError"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -395,13 +395,13 @@ TEST_P(RoundTripRestIntegrationTest, DescribeSinkDescribeSinkErrorMapsAcrossTheW TEST_P(RoundTripRestIntegrationTest, PutSinkSinkNotFoundMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const SinkNotFound detail = RandomSinkNotFound(rng); - smithy::Error error = smithy::Error::Modeled("SinkNotFound", "integration"); + opal::Error error = opal::Error::Modeled("SinkNotFound", "integration"); error.set_detail(detail); handler_->nextPutSinkError = error; const PutSinkInput input = RandomPutSinkInput(rng); const auto outcome = client_->PutSink(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "SinkNotFound"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -410,13 +410,13 @@ TEST_P(RoundTripRestIntegrationTest, PutSinkSinkNotFoundMapsAcrossTheWire) { TEST_P(RoundTripRestIntegrationTest, PutSinkSinkQuotaExceededMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const SinkQuotaExceeded detail = RandomSinkQuotaExceeded(rng); - smithy::Error error = smithy::Error::Modeled("SinkQuotaExceeded", "integration"); + opal::Error error = opal::Error::Modeled("SinkQuotaExceeded", "integration"); error.set_detail(detail); handler_->nextPutSinkError = error; const PutSinkInput input = RandomPutSinkInput(rng); const auto outcome = client_->PutSink(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "SinkQuotaExceeded"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -425,13 +425,13 @@ TEST_P(RoundTripRestIntegrationTest, PutSinkSinkQuotaExceededMapsAcrossTheWire) TEST_P(RoundTripRestIntegrationTest, UploadAttachmentSinkNotFoundMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const SinkNotFound detail = RandomSinkNotFound(rng); - smithy::Error error = smithy::Error::Modeled("SinkNotFound", "integration"); + opal::Error error = opal::Error::Modeled("SinkNotFound", "integration"); error.set_detail(detail); handler_->nextUploadAttachmentError = error; const UploadAttachmentInput input = RandomUploadAttachmentInput(rng); const auto outcome = client_->UploadAttachment(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "SinkNotFound"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -440,17 +440,17 @@ TEST_P(RoundTripRestIntegrationTest, UploadAttachmentSinkNotFoundMapsAcrossTheWi TEST(RoundTripRestIntegrationUnknownMembers, DescribeSinkToleratesUnknownResponseMembers) { auto handler = std::make_shared(); RoundTripRestServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RoundTripRestClient::Create(std::move(config)); @@ -466,17 +466,17 @@ TEST(RoundTripRestIntegrationUnknownMembers, DescribeSinkToleratesUnknownRespons TEST(RoundTripRestIntegrationUnknownMembers, PutSinkToleratesUnknownResponseMembers) { auto handler = std::make_shared(); RoundTripRestServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RoundTripRestClient::Create(std::move(config)); diff --git a/examples/roundtrip/rest/generated/tests/smoke_test.cc b/examples/roundtrip/rest/generated/tests/smoke_test.cc index 5785bd4d..c96d7579 100644 --- a/examples/roundtrip/rest/generated/tests/smoke_test.cc +++ b/examples/roundtrip/rest/generated/tests/smoke_test.cc @@ -41,15 +41,15 @@ UploadAttachmentOutput MinimalUploadAttachmentOutput() { class SmokeHandler : public RoundTripRestHandler { public: - smithy::Outcome DescribeSink(const DescribeSinkInput& input, const smithy::server::RequestContext&) override { + opal::Outcome DescribeSink(const DescribeSinkInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalDescribeSinkOutput(); } - smithy::Outcome PutSink(const PutSinkInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PutSink(const PutSinkInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalPutSinkOutput(); } - smithy::Outcome UploadAttachment(const UploadAttachmentInput& input, const smithy::server::RequestContext&) override { + opal::Outcome UploadAttachment(const UploadAttachmentInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalUploadAttachmentOutput(); } @@ -57,9 +57,9 @@ class SmokeHandler : public RoundTripRestHandler { RoundTripRestClient MakeClient(std::shared_ptr handler) { RoundTripRestServer server(std::move(handler)); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = loopback; // Create cannot fail when a transport is injected. @@ -114,9 +114,9 @@ TEST(RoundTripRestSmokeTest, UploadAttachmentRoundTrips) { TEST(RoundTripRestSmokeTest, ModeledErrorsMapAcrossTheWire) { class FailingHandler final : public SmokeHandler { public: - smithy::Outcome DescribeSink(const DescribeSinkInput& input, const smithy::server::RequestContext&) override { + opal::Outcome DescribeSink(const DescribeSinkInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("SinkNotFound", "smoke"); + opal::Error error = opal::Error::Modeled("SinkNotFound", "smoke"); auto detail = [] { SinkNotFound v{}; return v; @@ -137,7 +137,7 @@ TEST(RoundTripRestSmokeTest, ModeledErrorsMapAcrossTheWire) { input.sinkId = "smoke"; const auto outcome = client.DescribeSink(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "SinkNotFound"); EXPECT_EQ(outcome.error().message(), "smoke"); EXPECT_NE(outcome.error().detail(), nullptr); diff --git a/examples/roundtrip/rest/numeric_bounds_wire_test.cc b/examples/roundtrip/rest/numeric_bounds_wire_test.cc index 5ac212c4..acd31db6 100644 --- a/examples/roundtrip/rest/numeric_bounds_wire_test.cc +++ b/examples/roundtrip/rest/numeric_bounds_wire_test.cc @@ -32,16 +32,16 @@ namespace { // --- Direct serde boundary: hostile Documents into the generated parser. --- -smithy::Document SinkDoc(const char* member, smithy::Document value) { - smithy::DocumentMap map; - map.emplace("name", smithy::Document(std::string("n"))); +opal::Document SinkDoc(const char* member, opal::Document value) { + opal::DocumentMap map; + map.emplace("name", opal::Document(std::string("n"))); map.emplace(member, std::move(value)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } TEST(NumericBoundsSerdeTest, IntEnumBeyondInt32FailsInsteadOfAliasing) { // 2^32+2 truncates to 2 (a valid Weight) under the old cast. - auto sink = DeserializeKitchenSink(SinkDoc("weight", smithy::Document(std::int64_t{4294967298}))); + auto sink = DeserializeKitchenSink(SinkDoc("weight", opal::Document(std::int64_t{4294967298}))); ASSERT_FALSE(sink.ok()); EXPECT_EQ(sink.error().message(), "KitchenSink.weight: value out of range"); } @@ -50,14 +50,14 @@ TEST(NumericBoundsSerdeTest, IntEnumKeepsUnknownInRangeValues) { // Model evolution: a value the client's model doesn't know yet still // parses (matching string enums' unknown handling); only servers reject // it, via validation. - auto sink = DeserializeKitchenSink(SinkDoc("weight", smithy::Document(std::int64_t{7}))); + auto sink = DeserializeKitchenSink(SinkDoc("weight", opal::Document(std::int64_t{7}))); ASSERT_TRUE(sink.ok()) << sink.error().message(); ASSERT_TRUE(sink->weight.has_value()); EXPECT_EQ(*sink->weight, static_cast(7)); } TEST(NumericBoundsSerdeTest, FloatBeyondRangeFailsInsteadOfUb) { - auto sink = DeserializeKitchenSink(SinkDoc("ratio", smithy::Document(1e300))); + auto sink = DeserializeKitchenSink(SinkDoc("ratio", opal::Document(1e300))); ASSERT_FALSE(sink.ok()); EXPECT_EQ(sink.error().message(), "KitchenSink.ratio: value out of range"); } @@ -65,18 +65,18 @@ TEST(NumericBoundsSerdeTest, FloatBeyondRangeFailsInsteadOfUb) { TEST(NumericBoundsSerdeTest, FloatEdgeAndNonFiniteValuesStillParse) { // The exact float maximum is in range... const double float_max = static_cast(std::numeric_limits::max()); - auto edge = DeserializeKitchenSink(SinkDoc("ratio", smithy::Document(float_max))); + auto edge = DeserializeKitchenSink(SinkDoc("ratio", opal::Document(float_max))); ASSERT_TRUE(edge.ok()) << edge.error().message(); EXPECT_EQ(*edge->ratio, std::numeric_limits::max()); // ...as is what a peer's shortest-round-trip printer (or our own // FormatFloat) puts on the wire for float max — a double slightly above // FLT_MAX that still rounds back to it. - auto shortest = DeserializeKitchenSink(SinkDoc("ratio", smithy::Document(3.4028235e38))); + auto shortest = DeserializeKitchenSink(SinkDoc("ratio", opal::Document(3.4028235e38))); ASSERT_TRUE(shortest.ok()) << shortest.error().message(); EXPECT_EQ(*shortest->ratio, std::numeric_limits::max()); // ...and the Smithy non-finite spellings narrow losslessly, never caught // in the overflow net. - auto inf = DeserializeKitchenSink(SinkDoc("ratio", smithy::Document(std::string("-Infinity")))); + auto inf = DeserializeKitchenSink(SinkDoc("ratio", opal::Document(std::string("-Infinity")))); ASSERT_TRUE(inf.ok()) << inf.error().message(); EXPECT_TRUE(std::isinf(*inf->ratio)); EXPECT_LT(*inf->ratio, 0.0F); @@ -86,19 +86,19 @@ TEST(NumericBoundsSerdeTest, FloatEdgeAndNonFiniteValuesStillParse) { class RecordingHandler : public RoundTripRestHandler { public: - smithy::Outcome DescribeSink(const DescribeSinkInput&, - const smithy::server::RequestContext&) override { + opal::Outcome DescribeSink(const DescribeSinkInput&, + const opal::server::RequestContext&) override { ++calls; return DescribeSinkOutput{}; } - smithy::Outcome PutSink(const PutSinkInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome PutSink(const PutSinkInput& input, + const opal::server::RequestContext&) override { ++calls; last_sink = input.sink; return PutSinkOutput{.sinkId = "s1"}; } - smithy::Outcome UploadAttachment( - const UploadAttachmentInput&, const smithy::server::RequestContext&) override { + opal::Outcome UploadAttachment( + const UploadAttachmentInput&, const opal::server::RequestContext&) override { ++calls; return UploadAttachmentOutput{}; } @@ -108,8 +108,8 @@ class RecordingHandler : public RoundTripRestHandler { class NumericBoundsServerTest : public testing::Test { protected: - smithy::http::HttpResponse PutSinkBody(const std::string& body) { - smithy::http::HttpRequest request; + opal::http::HttpResponse PutSinkBody(const std::string& body) { + opal::http::HttpRequest request; request.method = "PUT"; request.target = "/sinks/s1?limit=5"; request.headers.Set("content-type", "application/json"); @@ -141,9 +141,9 @@ TEST_F(NumericBoundsServerTest, UnknownIntEnumValueFailsValidationWithTheSuiteMe EXPECT_EQ(response.status, 400) << response.body; EXPECT_EQ(response.headers.Get("x-error-type").value_or(""), "ValidationException"); EXPECT_EQ(handler_->calls, 0); - auto body = smithy::json::Decode(response.body); + auto body = opal::json::Decode(response.body); ASSERT_TRUE(body.ok()) << response.body; - const smithy::Document* field_list = body->Find("fieldList"); + const opal::Document* field_list = body->Find("fieldList"); ASSERT_NE(field_list, nullptr) << response.body; ASSERT_EQ(field_list->as_list().size(), 1u) << response.body; const auto& failure = field_list->as_list()[0]; @@ -165,12 +165,12 @@ TEST_F(NumericBoundsServerTest, ValidValuesReachTheHandlerIntact) { // --- Client over the wire: hostile server responses into the generated // client. --- -class CannedTransport final : public smithy::http::HttpClient { +class CannedTransport final : public opal::http::HttpClient { public: explicit CannedTransport(std::string body) : body_(std::move(body)) {} - smithy::Outcome Send(const smithy::http::HttpRequest&) override { - smithy::http::HttpResponse response{200, {}, body_}; + opal::Outcome Send(const opal::http::HttpRequest&) override { + opal::http::HttpResponse response{200, {}, body_}; response.headers.Set("content-type", "application/json"); return response; } @@ -179,8 +179,8 @@ class CannedTransport final : public smithy::http::HttpClient { std::string body_; }; -smithy::Outcome Describe(const std::string& body) { - smithy::ClientConfig config; +opal::Outcome Describe(const std::string& body) { + opal::ClientConfig config; config.http_client = std::make_shared(body); auto client = RoundTripRestClient::Create(std::move(config)); if (!client.ok()) { diff --git a/examples/roundtrip/rest/typed_errors_test.cc b/examples/roundtrip/rest/typed_errors_test.cc index 91260ccc..53bd8e0e 100644 --- a/examples/roundtrip/rest/typed_errors_test.cc +++ b/examples/roundtrip/rest/typed_errors_test.cc @@ -3,7 +3,7 @@ // against the roundtrip rest golden, whose DescribeSink carries two modeled // errors — including DescribeSinkError, the operation-named collision // fixture the plural listing name exists to dodge. The wire half (server -// error → client smithy::Error with code + typed detail) is already pinned +// error → client opal::Error with code + typed detail) is already pinned // by the generated integration tests; this suite pins the typed view over // that Error. @@ -19,8 +19,8 @@ namespace example::roundtrip::rest { namespace { -smithy::Error SinkNotFoundError() { - smithy::Error error = smithy::Error::Modeled("SinkNotFound", "no sink: s1"); +opal::Error SinkNotFoundError() { + opal::Error error = opal::Error::Modeled("SinkNotFound", "no sink: s1"); error.set_detail(SinkNotFound{.message = "no sink: s1", .resourceType = "sink"}); return error; } @@ -37,7 +37,7 @@ TEST(TypedErrorsTest, MatchesTheModeledErrorAndCarriesTheDetail) { TEST(TypedErrorsTest, DetailLessCodeMatchStillDispatchesWithDefaultFields) { const auto typed = - DescribeSinkErrors::FromError(smithy::Error::Modeled("DescribeSinkError", "gone")); + DescribeSinkErrors::FromError(opal::Error::Modeled("DescribeSinkError", "gone")); ASSERT_TRUE(typed.is_describe_sink_error()); EXPECT_EQ(typed.as_describe_sink_error().message, ""); } @@ -46,24 +46,24 @@ TEST(TypedErrorsTest, OtherCodesAndOtherKindsStayEmpty) { // Another operation's modeled error: CreateSink's quota error is not in // DescribeSink's listing. EXPECT_TRUE( - DescribeSinkErrors::FromError(smithy::Error::Modeled("SinkQuotaExceeded", "full")).empty()); + DescribeSinkErrors::FromError(opal::Error::Modeled("SinkQuotaExceeded", "full")).empty()); // The kind gates matching: a non-modeled error never engages a member, // even with a matching code string. EXPECT_TRUE(DescribeSinkErrors::FromError( - smithy::Error(smithy::ErrorKind::kTransport, "SinkNotFound", "spoofed")) + opal::Error(opal::ErrorKind::kTransport, "SinkNotFound", "spoofed")) .empty()); - EXPECT_TRUE(DescribeSinkErrors::FromError(smithy::Error::Transport("boom")).empty()); + EXPECT_TRUE(DescribeSinkErrors::FromError(opal::Error::Transport("boom")).empty()); } TEST(TypedErrorsTest, VisitDispatchesExhaustivelyIncludingTheEmptyState) { - const auto describe = smithy::Overloaded{ + const auto describe = opal::Overloaded{ [](const SinkNotFound& e) { return "not-found:" + e.message; }, [](const DescribeSinkError&) { return std::string("gone"); }, [](std::monostate) { return std::string("unmodeled"); }, }; EXPECT_EQ(DescribeSinkErrors::FromError(SinkNotFoundError()).visit(describe), "not-found:no sink: s1"); - EXPECT_EQ(DescribeSinkErrors::FromError(smithy::Error::Transport("boom")).visit(describe), + EXPECT_EQ(DescribeSinkErrors::FromError(opal::Error::Transport("boom")).visit(describe), "unmodeled"); } diff --git a/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/client.h b/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/client.h index b19ba3f5..d318fc2d 100644 --- a/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/client.h +++ b/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/client.h @@ -23,35 +23,35 @@ namespace example::roundtrip::rpc { /// rpcv2Cbor client for example.roundtrip#RoundTripRpc. -/// Modeled service errors surface as smithy::Error with kind kModeled, +/// Modeled service errors surface as opal::Error with kind kModeled, /// code() set to the error shape name, and the deserialized error /// structure attached. Dispatch on them through the per-operation /// Errors listings below rather than comparing code() text. class RoundTripRpcClient { public: /// Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); + static opal::Outcome Create(opal::ClientConfig config); /// No-input, no-output operation: exists so the hand-written wire test can /// pin that the rpcv2Cbor server ignores request bodies sent to a no-input /// operation (issue #68 — the upstream conformance suite carries no such /// case, and #67 fixed a client/server asymmetry exactly here). - smithy::Outcome Ping(const PingInput& input = {}) const; + opal::Outcome Ping(const PingInput& input = {}) const; /// The RPC variant round-trips the same kitchen sink over CBOR — compressed, /// so the rpcv2Cbor decompress path and jsonRpc2's shared-endpoint /// anyCompressed branch both land in compiled goldens (issue #68). - smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input) const; + opal::Outcome PutSinkRpc(const PutSinkRpcInput& input) const; private: - RoundTripRpcClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix); - smithy::Outcome Send(smithy::http::HttpRequest request) const; + RoundTripRpcClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix); + opal::Outcome Send(opal::http::HttpRequest request) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; -/// The modeled errors of PutSinkRpc, matched from a smithy::Error so dispatch is +/// The modeled errors of PutSinkRpc, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -62,9 +62,9 @@ class PutSinkRpcErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static PutSinkRpcErrors FromError(const smithy::Error& error) { + static PutSinkRpcErrors FromError(const opal::Error& error) { PutSinkRpcErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "SinkNotFound") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : SinkNotFound{}); @@ -116,11 +116,11 @@ class PutSinkRpcErrors { switch (value_.index()) { case 1: out += "sink_not_found = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "sink_quota_exceeded = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -139,7 +139,7 @@ class PutSinkRpcErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("PutSinkRpcErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("PutSinkRpcErrors", requested, case_name()); } } @@ -156,8 +156,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rpc::PutSinkRpcErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; diff --git a/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/serde.h b/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/serde.h index d55fc633..cb1f0f93 100644 --- a/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/serde.h +++ b/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/serde.h @@ -16,47 +16,47 @@ namespace example::roundtrip::rpc { // Document-pivot serde for every aggregate shape in the model closure. -// Serializers never fail; deserializers return smithy::Error on wire +// Serializers never fail; deserializers return opal::Error on wire // mismatches and enforce @required members. -smithy::Document SerializeStringMap(const std::map& value); -smithy::Outcome> DeserializeStringMap(const smithy::Document& doc); +opal::Document SerializeStringMap(const std::map& value); +opal::Outcome> DeserializeStringMap(const opal::Document& doc); -smithy::Document SerializeNestedConfig(const NestedConfig& value); -smithy::Outcome DeserializeNestedConfig(const smithy::Document& doc); +opal::Document SerializeNestedConfig(const NestedConfig& value); +opal::Outcome DeserializeNestedConfig(const opal::Document& doc); -smithy::Document SerializeSinkChoice(const SinkChoice& value); -smithy::Outcome DeserializeSinkChoice(const smithy::Document& doc); +opal::Document SerializeSinkChoice(const SinkChoice& value); +opal::Outcome DeserializeSinkChoice(const opal::Document& doc); -smithy::Document SerializeStringList(const std::vector& value); -smithy::Outcome> DeserializeStringList(const smithy::Document& doc); +opal::Document SerializeStringList(const std::vector& value); +opal::Outcome> DeserializeStringList(const opal::Document& doc); -smithy::Document SerializeSparseIntegerList(const std::vector>& value); -smithy::Outcome>> DeserializeSparseIntegerList(const smithy::Document& doc); +opal::Document SerializeSparseIntegerList(const std::vector>& value); +opal::Outcome>> DeserializeSparseIntegerList(const opal::Document& doc); -smithy::Document SerializeUniqueStringList(const std::vector& value); -smithy::Outcome> DeserializeUniqueStringList(const smithy::Document& doc); +opal::Document SerializeUniqueStringList(const std::vector& value); +opal::Outcome> DeserializeUniqueStringList(const opal::Document& doc); -smithy::Document SerializeKitchenSink(const KitchenSink& value); -smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc); +opal::Document SerializeKitchenSink(const KitchenSink& value); +opal::Outcome DeserializeKitchenSink(const opal::Document& doc); -smithy::Document SerializeSinkNotFound(const SinkNotFound& value); -smithy::Outcome DeserializeSinkNotFound(const smithy::Document& doc); +opal::Document SerializeSinkNotFound(const SinkNotFound& value); +opal::Outcome DeserializeSinkNotFound(const opal::Document& doc); -smithy::Document SerializePingInput(const PingInput& value); -smithy::Outcome DeserializePingInput(const smithy::Document& doc); +opal::Document SerializePingInput(const PingInput& value); +opal::Outcome DeserializePingInput(const opal::Document& doc); -smithy::Document SerializePingOutput(const PingOutput& value); -smithy::Outcome DeserializePingOutput(const smithy::Document& doc); +opal::Document SerializePingOutput(const PingOutput& value); +opal::Outcome DeserializePingOutput(const opal::Document& doc); -smithy::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value); -smithy::Outcome DeserializeSinkQuotaExceeded(const smithy::Document& doc); +opal::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value); +opal::Outcome DeserializeSinkQuotaExceeded(const opal::Document& doc); -smithy::Document SerializePutSinkRpcInput(const PutSinkRpcInput& value); -smithy::Outcome DeserializePutSinkRpcInput(const smithy::Document& doc); +opal::Document SerializePutSinkRpcInput(const PutSinkRpcInput& value); +opal::Outcome DeserializePutSinkRpcInput(const opal::Document& doc); -smithy::Document SerializePutSinkRpcOutput(const PutSinkRpcOutput& value); -smithy::Outcome DeserializePutSinkRpcOutput(const smithy::Document& doc); +opal::Document SerializePutSinkRpcOutput(const PutSinkRpcOutput& value); +opal::Outcome DeserializePutSinkRpcOutput(const opal::Document& doc); } // namespace example::roundtrip::rpc diff --git a/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/server.h b/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/server.h index 5e952d47..9af615a0 100644 --- a/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/server.h +++ b/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/server.h @@ -13,10 +13,10 @@ namespace example::roundtrip::rpc { /// Implement one method per operation. Return a modeled error as -/// smithy::Error::Modeled("", message), optionally with the +/// opal::Error::Modeled("", message), optionally with the /// typed error structure attached via set_detail() so it serializes fully. /// The context carries the raw request and routing captures — see -/// smithy::server::RequestContext; leave the parameter unnamed when unused. +/// opal::server::RequestContext; leave the parameter unnamed when unused. /// Implementations must be thread-safe: transports may invoke any mix of /// operations concurrently on the one handler instance. class RoundTripRpcHandler { @@ -27,24 +27,24 @@ class RoundTripRpcHandler { /// pin that the rpcv2Cbor server ignores request bodies sent to a no-input /// operation (issue #68 — the upstream conformance suite carries no such /// case, and #67 fixed a client/server asymmetry exactly here). - virtual smithy::Outcome Ping(const PingInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome Ping(const PingInput& input, const opal::server::RequestContext& context) = 0; /// The RPC variant round-trips the same kitchen sink over CBOR — compressed, /// so the rpcv2Cbor decompress path and jsonRpc2's shared-endpoint /// anyCompressed branch both land in compiled goldens (issue #68). - virtual smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome PutSinkRpc(const PutSinkRpcInput& input, const opal::server::RequestContext& context) = 0; }; /// rpcv2Cbor server for example.roundtrip#RoundTripRpc: routing, deserialization, handler dispatch, /// response serialization, and modeled-error mapping. Pass Handler() to any -/// smithy::http::HttpServerTransport. +/// opal::http::HttpServerTransport. class RoundTripRpcServer { public: explicit RoundTripRpcServer(std::shared_ptr handler); - smithy::http::RequestHandler Handler() const; + opal::http::RequestHandler Handler() const; private: - std::shared_ptr router_; + std::shared_ptr router_; }; } // namespace example::roundtrip::rpc diff --git a/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/types.h b/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/types.h index ab023cba..52bcc883 100644 --- a/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/types.h +++ b/examples/roundtrip/rpc/generated/include/example/roundtrip/rpc/types.h @@ -35,12 +35,12 @@ struct NestedConfig { out += sep; sep = ", "; out += ".label = "; - smithy::DebugAppend(out, this->label); + opal::DebugAppend(out, this->label); if (this->depth.has_value()) { out += sep; sep = ", "; out += ".depth = "; - smithy::DebugAppend(out, *this->depth); + opal::DebugAppend(out, *this->depth); } out += '}'; } @@ -119,15 +119,15 @@ class SinkChoice { switch (value_.index()) { case 1: out += "text = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "count = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "nested = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; default: break; @@ -146,7 +146,7 @@ class SinkChoice { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("SinkChoice", requested, case_name()); + opal::internal::FatalWrongUnionAccess("SinkChoice", requested, case_name()); } } @@ -230,12 +230,12 @@ struct KitchenSink { std::optional big{}; std::optional ratio{}; std::optional precise{}; - std::optional blob{}; + std::optional blob{}; std::optional priority{}; std::optional weight{}; - std::optional dateTime{}; - std::optional httpDate{}; - std::optional epoch{}; + std::optional dateTime{}; + std::optional httpDate{}; + std::optional epoch{}; std::optional> names{}; std::optional> uniqueNames{}; std::optional>> sparseNumbers{}; @@ -250,120 +250,120 @@ struct KitchenSink { out += sep; sep = ", "; out += ".name = "; - smithy::DebugAppend(out, this->name); + opal::DebugAppend(out, this->name); if (this->flag.has_value()) { out += sep; sep = ", "; out += ".flag = "; - smithy::DebugAppend(out, *this->flag); + opal::DebugAppend(out, *this->flag); } if (this->tiny.has_value()) { out += sep; sep = ", "; out += ".tiny = "; - smithy::DebugAppend(out, *this->tiny); + opal::DebugAppend(out, *this->tiny); } if (this->small.has_value()) { out += sep; sep = ", "; out += ".small = "; - smithy::DebugAppend(out, *this->small); + opal::DebugAppend(out, *this->small); } if (this->medium.has_value()) { out += sep; sep = ", "; out += ".medium = "; - smithy::DebugAppend(out, *this->medium); + opal::DebugAppend(out, *this->medium); } if (this->big.has_value()) { out += sep; sep = ", "; out += ".big = "; - smithy::DebugAppend(out, *this->big); + opal::DebugAppend(out, *this->big); } if (this->ratio.has_value()) { out += sep; sep = ", "; out += ".ratio = "; - smithy::DebugAppend(out, *this->ratio); + opal::DebugAppend(out, *this->ratio); } if (this->precise.has_value()) { out += sep; sep = ", "; out += ".precise = "; - smithy::DebugAppend(out, *this->precise); + opal::DebugAppend(out, *this->precise); } if (this->blob.has_value()) { out += sep; sep = ", "; out += ".blob = "; - smithy::DebugAppend(out, *this->blob); + opal::DebugAppend(out, *this->blob); } if (this->priority.has_value()) { out += sep; sep = ", "; out += ".priority = "; - smithy::DebugAppend(out, *this->priority); + opal::DebugAppend(out, *this->priority); } if (this->weight.has_value()) { out += sep; sep = ", "; out += ".weight = "; - smithy::DebugAppend(out, *this->weight); + opal::DebugAppend(out, *this->weight); } if (this->dateTime.has_value()) { out += sep; sep = ", "; out += ".dateTime = "; - smithy::DebugAppend(out, *this->dateTime); + opal::DebugAppend(out, *this->dateTime); } if (this->httpDate.has_value()) { out += sep; sep = ", "; out += ".httpDate = "; - smithy::DebugAppend(out, *this->httpDate); + opal::DebugAppend(out, *this->httpDate); } if (this->epoch.has_value()) { out += sep; sep = ", "; out += ".epoch = "; - smithy::DebugAppend(out, *this->epoch); + opal::DebugAppend(out, *this->epoch); } if (this->names.has_value()) { out += sep; sep = ", "; out += ".names = "; - smithy::DebugAppend(out, *this->names); + opal::DebugAppend(out, *this->names); } if (this->uniqueNames.has_value()) { out += sep; sep = ", "; out += ".uniqueNames = "; - smithy::DebugAppend(out, *this->uniqueNames); + opal::DebugAppend(out, *this->uniqueNames); } if (this->sparseNumbers.has_value()) { out += sep; sep = ", "; out += ".sparseNumbers = "; - smithy::DebugAppend(out, *this->sparseNumbers); + opal::DebugAppend(out, *this->sparseNumbers); } if (this->attributes.has_value()) { out += sep; sep = ", "; out += ".attributes = "; - smithy::DebugAppend(out, *this->attributes); + opal::DebugAppend(out, *this->attributes); } if (this->nested.has_value()) { out += sep; sep = ", "; out += ".nested = "; - smithy::DebugAppend(out, *this->nested); + opal::DebugAppend(out, *this->nested); } if (this->choice.has_value()) { out += sep; sep = ", "; out += ".choice = "; - smithy::DebugAppend(out, *this->choice); + opal::DebugAppend(out, *this->choice); } out += '}'; } @@ -388,12 +388,12 @@ struct SinkNotFound { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); if (this->resourceType.has_value()) { out += sep; sep = ", "; out += ".resourceType = "; - smithy::DebugAppend(out, *this->resourceType); + opal::DebugAppend(out, *this->resourceType); } out += '}'; } @@ -451,13 +451,13 @@ struct SinkQuotaExceeded { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, *this->message); + opal::DebugAppend(out, *this->message); } if (this->retryAfterSeconds.has_value()) { out += sep; sep = ", "; out += ".retryAfterSeconds = "; - smithy::DebugAppend(out, *this->retryAfterSeconds); + opal::DebugAppend(out, *this->retryAfterSeconds); } out += '}'; } @@ -482,12 +482,12 @@ struct PutSinkRpcInput { out += sep; sep = ", "; out += ".sinkId = "; - smithy::DebugAppend(out, this->sinkId); + opal::DebugAppend(out, this->sinkId); if (this->sink.has_value()) { out += sep; sep = ", "; out += ".sink = "; - smithy::DebugAppend(out, *this->sink); + opal::DebugAppend(out, *this->sink); } out += '}'; } @@ -512,12 +512,12 @@ struct PutSinkRpcOutput { out += sep; sep = ", "; out += ".sinkId = "; - smithy::DebugAppend(out, this->sinkId); + opal::DebugAppend(out, this->sinkId); if (this->sink.has_value()) { out += sep; sep = ", "; out += ".sink = "; - smithy::DebugAppend(out, *this->sink); + opal::DebugAppend(out, *this->sink); } out += '}'; } @@ -540,8 +540,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rpc::NestedConfig& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.label)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.depth)); + seed = opal::HashCombine(seed, opal::HashValue(value.label)); + seed = opal::HashCombine(seed, opal::HashValue(value.depth)); return seed; } }; @@ -550,16 +550,16 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rpc::SinkChoice& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> struct std::hash { std::size_t operator()(const example::roundtrip::rpc::Priority& value) const noexcept { - return smithy::HashCombine(static_cast(value.value_), - smithy::HashValue(value.unknown_)); + return opal::HashCombine(static_cast(value.value_), + opal::HashValue(value.unknown_)); } }; @@ -567,26 +567,26 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rpc::KitchenSink& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.name)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.flag)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.tiny)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.small)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.medium)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.big)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.ratio)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.precise)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.blob)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.priority)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.weight)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.dateTime)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.httpDate)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.epoch)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.names)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.uniqueNames)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseNumbers)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.attributes)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.nested)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.choice)); + seed = opal::HashCombine(seed, opal::HashValue(value.name)); + seed = opal::HashCombine(seed, opal::HashValue(value.flag)); + seed = opal::HashCombine(seed, opal::HashValue(value.tiny)); + seed = opal::HashCombine(seed, opal::HashValue(value.small)); + seed = opal::HashCombine(seed, opal::HashValue(value.medium)); + seed = opal::HashCombine(seed, opal::HashValue(value.big)); + seed = opal::HashCombine(seed, opal::HashValue(value.ratio)); + seed = opal::HashCombine(seed, opal::HashValue(value.precise)); + seed = opal::HashCombine(seed, opal::HashValue(value.blob)); + seed = opal::HashCombine(seed, opal::HashValue(value.priority)); + seed = opal::HashCombine(seed, opal::HashValue(value.weight)); + seed = opal::HashCombine(seed, opal::HashValue(value.dateTime)); + seed = opal::HashCombine(seed, opal::HashValue(value.httpDate)); + seed = opal::HashCombine(seed, opal::HashValue(value.epoch)); + seed = opal::HashCombine(seed, opal::HashValue(value.names)); + seed = opal::HashCombine(seed, opal::HashValue(value.uniqueNames)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseNumbers)); + seed = opal::HashCombine(seed, opal::HashValue(value.attributes)); + seed = opal::HashCombine(seed, opal::HashValue(value.nested)); + seed = opal::HashCombine(seed, opal::HashValue(value.choice)); return seed; } }; @@ -595,8 +595,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rpc::SinkNotFound& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.resourceType)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.resourceType)); return seed; } }; @@ -615,8 +615,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rpc::SinkQuotaExceeded& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.retryAfterSeconds)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.retryAfterSeconds)); return seed; } }; @@ -625,8 +625,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rpc::PutSinkRpcInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sinkId)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sink)); + seed = opal::HashCombine(seed, opal::HashValue(value.sinkId)); + seed = opal::HashCombine(seed, opal::HashValue(value.sink)); return seed; } }; @@ -635,8 +635,8 @@ template <> struct std::hash { std::size_t operator()(const example::roundtrip::rpc::PutSinkRpcOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sinkId)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sink)); + seed = opal::HashCombine(seed, opal::HashValue(value.sinkId)); + seed = opal::HashCombine(seed, opal::HashValue(value.sink)); return seed; } }; diff --git a/examples/roundtrip/rpc/generated/src/client.cc b/examples/roundtrip/rpc/generated/src/client.cc index 046f4f6a..6f29cc31 100644 --- a/examples/roundtrip/rpc/generated/src/client.cc +++ b/examples/roundtrip/rpc/generated/src/client.cc @@ -32,38 +32,38 @@ struct ParsedError { int status = 0; std::string code = "UnknownError"; std::string message; - smithy::Document doc; + opal::Document doc; }; // [[maybe_unused]]: only unary response paths parse wire errors; a // service whose operations all stream never calls this. -[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) { +[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) { ParsedError parsed; parsed.status = response.status; parsed.message = "HTTP " + std::to_string(response.status); - auto doc = smithy::cbor::Decode(smithy::Blob::FromString(response.body)); + auto doc = opal::cbor::Decode(opal::Blob::FromString(response.body)); if (doc.ok()) parsed.doc = *std::move(doc); if (parsed.doc.is_map()) { - const smithy::Document* type = parsed.doc.Find("__type"); + const opal::Document* type = parsed.doc.Find("__type"); if (type == nullptr) type = parsed.doc.Find("code"); if (parsed.code == "UnknownError" && type != nullptr && type->is_string()) parsed.code = helpers::SanitizeErrorCode(type->as_string()); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } return parsed; } -smithy::Error GenericError(ParsedError parsed) { +opal::Error GenericError(ParsedError parsed) { const bool retryable = parsed.status >= 500; - if (parsed.code == "UnknownError") return smithy::Error(smithy::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); - return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); + if (parsed.code == "UnknownError") return opal::Error(opal::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); + return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); } -smithy::Error MakeSinkNotFoundError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeSinkNotFoundError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("SinkNotFound", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("SinkNotFound", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeSinkNotFound(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -71,11 +71,11 @@ smithy::Error MakeSinkNotFoundError(const smithy::http::HttpResponse& response, return error; } -smithy::Error MakeSinkQuotaExceededError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeSinkQuotaExceededError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("SinkQuotaExceeded", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("SinkQuotaExceeded", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeSinkQuotaExceeded(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -83,7 +83,7 @@ smithy::Error MakeSinkQuotaExceededError(const smithy::http::HttpResponse& respo return error; } -smithy::Error ParsePutSinkRpcError(const smithy::http::HttpResponse& response) { +opal::Error ParsePutSinkRpcError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "SinkNotFound") return helpers::MakeSinkNotFoundError(response, std::move(parsed)); if (parsed.code == "SinkQuotaExceeded") return helpers::MakeSinkQuotaExceededError(response, std::move(parsed)); @@ -93,46 +93,46 @@ smithy::Error ParsePutSinkRpcError(const smithy::http::HttpResponse& response) { } // namespace helpers } // namespace -smithy::Outcome RoundTripRpcClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome RoundTripRpcClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { // The built-in socket transport is plaintext-only; https needs a - // TLS-capable transport (e.g. smithy::http::BeastHttpClient). + // TLS-capable transport (e.g. opal::http::BeastHttpClient). if (endpoint->tls()) { - return smithy::Error::Validation("RoundTripRpcClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + return opal::Error::Validation("RoundTripRpcClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); } - transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); } } if (transport == nullptr) { - return smithy::Error::Validation("RoundTripRpcClient: config needs an endpoint or an http_client"); + return opal::Error::Validation("RoundTripRpcClient: config needs an endpoint or an http_client"); } return RoundTripRpcClient(std::move(config), std::move(transport), std::move(prefix)); } -RoundTripRpcClient::RoundTripRpcClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix) +RoundTripRpcClient::RoundTripRpcClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} -smithy::Outcome RoundTripRpcClient::Send(smithy::http::HttpRequest request) const { +opal::Outcome RoundTripRpcClient::Send(opal::http::HttpRequest request) const { // Operations with a non-document response payload set their own accept. if (!request.headers.Get("accept").has_value()) request.headers.Set("accept", "application/cbor"); request.headers.Set("user-agent", config_.user_agent); if (!request.body.empty()) { request.headers.Set("content-length", std::to_string(request.body.size())); } - return smithy::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); + return opal::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); } -smithy::Outcome RoundTripRpcClient::Ping(const PingInput& input) const { +opal::Outcome RoundTripRpcClient::Ping(const PingInput& input) const { (void)input; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RoundTripRpc/operation/Ping"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); @@ -142,16 +142,16 @@ smithy::Outcome RoundTripRpcClient::Ping(const PingInput& input) con return PingOutput{}; } -smithy::Outcome RoundTripRpcClient::PutSinkRpc(const PutSinkRpcInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome RoundTripRpcClient::PutSinkRpc(const PutSinkRpcInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RoundTripRpc/operation/PutSinkRpc"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializePutSinkRpcInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializePutSinkRpcInput(input)).ToString(); // @requestCompression(gzip): applied last, appended to Content-Encoding. if (request.body.size() >= static_cast(config_.request_min_compression_size_bytes)) { - auto compressed = smithy::GzipCompress(request.body); + auto compressed = opal::GzipCompress(request.body); if (!compressed) return std::move(compressed).error(); request.body = *std::move(compressed); const auto existing_encoding = request.headers.Get("content-encoding"); @@ -160,7 +160,7 @@ smithy::Outcome RoundTripRpcClient::PutSinkRpc(const PutSinkRp auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParsePutSinkRpcError(*response); - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializePutSinkRpcOutput(*body_doc); } diff --git a/examples/roundtrip/rpc/generated/src/serde.cc b/examples/roundtrip/rpc/generated/src/serde.cc index 307fa106..be4117d6 100644 --- a/examples/roundtrip/rpc/generated/src/serde.cc +++ b/examples/roundtrip/rpc/generated/src/serde.cc @@ -10,55 +10,55 @@ namespace example::roundtrip::rpc { namespace types = ::example::roundtrip::rpc; -smithy::Document SerializeStringMap(const std::map& value) { - smithy::DocumentMap map; +opal::Document SerializeStringMap(const std::map& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { - map.emplace(key, smithy::Document(item)); + map.emplace(key, opal::Document(item)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome> DeserializeStringMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map: expected a map on the wire"); +opal::Outcome> DeserializeStringMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map: expected a map on the wire"); std::map out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::map{}: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::map{}: unexpected type on the wire"); parsed_item = item->as_string(); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeNestedConfig(const NestedConfig& value) { - smithy::DocumentMap map; - map.emplace("label", smithy::Document(value.label)); +opal::Document SerializeNestedConfig(const NestedConfig& value) { + opal::DocumentMap map; + map.emplace("label", opal::Document(value.label)); if (value.depth.has_value()) { - map.emplace("depth", smithy::Document(static_cast((*value.depth)))); + map.emplace("depth", opal::Document(static_cast((*value.depth)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNestedConfig(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("NestedConfig: expected a map on the wire"); +opal::Outcome DeserializeNestedConfig(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("NestedConfig: expected a map on the wire"); NestedConfig out; { - const smithy::Document* member = doc.Find("label"); + const opal::Document* member = doc.Find("label"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("NestedConfig: missing required member: label"); + return opal::Error::Serialization("NestedConfig: missing required member: label"); } - if (!member->is_string()) return smithy::Error::Serialization("NestedConfig.label: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("NestedConfig.label: unexpected type on the wire"); out.label = member->as_string(); } { - const smithy::Document* member = doc.Find("depth"); + const opal::Document* member = doc.Find("depth"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("NestedConfig.depth: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("NestedConfig.depth: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("NestedConfig.depth: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("NestedConfig.depth: value out of range"); parsed_member = static_cast(member->as_int()); out.depth = std::move(parsed_member); } @@ -66,37 +66,37 @@ smithy::Outcome DeserializeNestedConfig(const smithy::Document& do return out; } -smithy::Document SerializeSinkChoice(const SinkChoice& value) { - smithy::DocumentMap map; +opal::Document SerializeSinkChoice(const SinkChoice& value) { + opal::DocumentMap map; if (value.is_text()) { - map.emplace("text", smithy::Document(value.as_text())); + map.emplace("text", opal::Document(value.as_text())); } if (value.is_count()) { - map.emplace("count", smithy::Document(static_cast(value.as_count()))); + map.emplace("count", opal::Document(static_cast(value.as_count()))); } if (value.is_nested()) { map.emplace("nested", SerializeNestedConfig(value.as_nested())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSinkChoice(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SinkChoice: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("SinkChoice: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("text"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeSinkChoice(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SinkChoice: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("SinkChoice: expected exactly one union member"); + if (const opal::Document* member = doc.Find("text"); member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("SinkChoice.text: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkChoice.text: unexpected type on the wire"); parsed_member = member->as_string(); return SinkChoice::FromText(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("count"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("count"); member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SinkChoice.count: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("SinkChoice.count: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SinkChoice.count: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("SinkChoice.count: value out of range"); parsed_member = static_cast(member->as_int()); return SinkChoice::FromCount(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("nested"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("nested"); member != nullptr && !member->is_null()) { NestedConfig parsed_member{}; { auto parsed = DeserializeNestedConfig(*member); @@ -105,130 +105,130 @@ smithy::Outcome DeserializeSinkChoice(const smithy::Document& doc) { } return SinkChoice::FromNested(std::move(parsed_member)); } - return smithy::Error::Serialization("SinkChoice: unknown or missing union member"); + return opal::Error::Serialization("SinkChoice: unknown or missing union member"); } -smithy::Document SerializeStringList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeStringList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeStringList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeStringList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = item->as_string(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeSparseIntegerList(const std::vector>& value) { - smithy::DocumentList list; +opal::Document SerializeSparseIntegerList(const std::vector>& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { if (!item.has_value()) { list.emplace_back(nullptr); continue; } - list.push_back(smithy::Document(static_cast((*item)))); + list.push_back(opal::Document(static_cast((*item)))); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome>> DeserializeSparseIntegerList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector>: expected a list on the wire"); +opal::Outcome>> DeserializeSparseIntegerList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector>: expected a list on the wire"); std::vector> out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; if (item->is_null()) { out.emplace_back(std::nullopt); continue; } std::int32_t parsed_item{}; - if (!item->is_int()) return smithy::Error::Serialization("std::vector>[]: unexpected type on the wire"); - if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return smithy::Error::Serialization("std::vector>[]: value out of range"); + if (!item->is_int()) return opal::Error::Serialization("std::vector>[]: unexpected type on the wire"); + if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return opal::Error::Serialization("std::vector>[]: value out of range"); parsed_item = static_cast(item->as_int()); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeUniqueStringList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeUniqueStringList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeUniqueStringList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeUniqueStringList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = item->as_string(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeKitchenSink(const KitchenSink& value) { - smithy::DocumentMap map; - map.emplace("name", smithy::Document(value.name)); +opal::Document SerializeKitchenSink(const KitchenSink& value) { + opal::DocumentMap map; + map.emplace("name", opal::Document(value.name)); if (value.flag.has_value()) { - map.emplace("flag", smithy::Document((*value.flag))); + map.emplace("flag", opal::Document((*value.flag))); } if (value.tiny.has_value()) { - map.emplace("tiny", smithy::Document(static_cast((*value.tiny)))); + map.emplace("tiny", opal::Document(static_cast((*value.tiny)))); } if (value.small.has_value()) { - map.emplace("small", smithy::Document(static_cast((*value.small)))); + map.emplace("small", opal::Document(static_cast((*value.small)))); } if (value.medium.has_value()) { - map.emplace("medium", smithy::Document(static_cast((*value.medium)))); + map.emplace("medium", opal::Document(static_cast((*value.medium)))); } if (value.big.has_value()) { - map.emplace("big", smithy::Document(static_cast((*value.big)))); + map.emplace("big", opal::Document(static_cast((*value.big)))); } if (value.ratio.has_value()) { - map.emplace("ratio", smithy::Document(static_cast((*value.ratio)))); + map.emplace("ratio", opal::Document(static_cast((*value.ratio)))); } if (value.precise.has_value()) { - map.emplace("precise", smithy::Document(static_cast((*value.precise)))); + map.emplace("precise", opal::Document(static_cast((*value.precise)))); } if (value.blob.has_value()) { - map.emplace("blob", smithy::Document((*value.blob))); + map.emplace("blob", opal::Document((*value.blob))); } if (value.priority.has_value()) { - map.emplace("priority", smithy::Document(std::string((*value.priority).ToString()))); + map.emplace("priority", opal::Document(std::string((*value.priority).ToString()))); } if (value.weight.has_value()) { - map.emplace("weight", smithy::Document(static_cast((*value.weight)))); + map.emplace("weight", opal::Document(static_cast((*value.weight)))); } if (value.dateTime.has_value()) { - map.emplace("dateTime", smithy::Document::FromTimestamp((*value.dateTime), smithy::TimestampFormat::kDateTime)); + map.emplace("dateTime", opal::Document::FromTimestamp((*value.dateTime), opal::TimestampFormat::kDateTime)); } if (value.httpDate.has_value()) { - map.emplace("httpDate", smithy::Document::FromTimestamp((*value.httpDate), smithy::TimestampFormat::kHttpDate)); + map.emplace("httpDate", opal::Document::FromTimestamp((*value.httpDate), opal::TimestampFormat::kHttpDate)); } if (value.epoch.has_value()) { - map.emplace("epoch", smithy::Document::FromTimestamp((*value.epoch), smithy::TimestampFormat::kEpochSeconds)); + map.emplace("epoch", opal::Document::FromTimestamp((*value.epoch), opal::TimestampFormat::kEpochSeconds)); } if (value.names.has_value()) { map.emplace("names", SerializeStringList((*value.names))); @@ -248,100 +248,100 @@ smithy::Document SerializeKitchenSink(const KitchenSink& value) { if (value.choice.has_value()) { map.emplace("choice", SerializeSinkChoice((*value.choice))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("KitchenSink: expected a map on the wire"); +opal::Outcome DeserializeKitchenSink(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("KitchenSink: expected a map on the wire"); KitchenSink out; { - const smithy::Document* member = doc.Find("name"); + const opal::Document* member = doc.Find("name"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("KitchenSink: missing required member: name"); + return opal::Error::Serialization("KitchenSink: missing required member: name"); } - if (!member->is_string()) return smithy::Error::Serialization("KitchenSink.name: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("KitchenSink.name: unexpected type on the wire"); out.name = member->as_string(); } { - const smithy::Document* member = doc.Find("flag"); + const opal::Document* member = doc.Find("flag"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("KitchenSink.flag: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("KitchenSink.flag: unexpected type on the wire"); parsed_member = member->as_bool(); out.flag = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("tiny"); + const opal::Document* member = doc.Find("tiny"); if (member != nullptr && !member->is_null()) { std::int8_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.tiny: unexpected type on the wire"); - if (member->as_int() < -128 || member->as_int() > 127) return smithy::Error::Serialization("KitchenSink.tiny: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.tiny: unexpected type on the wire"); + if (member->as_int() < -128 || member->as_int() > 127) return opal::Error::Serialization("KitchenSink.tiny: value out of range"); parsed_member = static_cast(member->as_int()); out.tiny = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("small"); + const opal::Document* member = doc.Find("small"); if (member != nullptr && !member->is_null()) { std::int16_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.small: unexpected type on the wire"); - if (member->as_int() < -32768 || member->as_int() > 32767) return smithy::Error::Serialization("KitchenSink.small: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.small: unexpected type on the wire"); + if (member->as_int() < -32768 || member->as_int() > 32767) return opal::Error::Serialization("KitchenSink.small: value out of range"); parsed_member = static_cast(member->as_int()); out.small = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("medium"); + const opal::Document* member = doc.Find("medium"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.medium: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("KitchenSink.medium: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.medium: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("KitchenSink.medium: value out of range"); parsed_member = static_cast(member->as_int()); out.medium = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("big"); + const opal::Document* member = doc.Find("big"); if (member != nullptr && !member->is_null()) { std::int64_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.big: unexpected type on the wire"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.big: unexpected type on the wire"); parsed_member = static_cast(member->as_int()); out.big = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("ratio"); + const opal::Document* member = doc.Find("ratio"); if (member != nullptr && !member->is_null()) { float parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("KitchenSink.ratio: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("KitchenSink.ratio: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("KitchenSink.ratio: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("KitchenSink.ratio: value out of range"); parsed_member = *narrowed; } out.ratio = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("precise"); + const opal::Document* member = doc.Find("precise"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("KitchenSink.precise: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("KitchenSink.precise: expected a number"); parsed_member = static_cast(*parsed); } out.precise = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("blob"); + const opal::Document* member = doc.Find("blob"); if (member != nullptr && !member->is_null()) { - smithy::Blob parsed_member{}; + opal::Blob parsed_member{}; { - auto parsed = smithy::BlobFromDocument(*member); + auto parsed = opal::BlobFromDocument(*member); if (!parsed) return std::move(parsed).error(); parsed_member = std::move(*parsed); } @@ -349,30 +349,30 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("priority"); + const opal::Document* member = doc.Find("priority"); if (member != nullptr && !member->is_null()) { types::Priority parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("KitchenSink.priority: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("KitchenSink.priority: unexpected type on the wire"); parsed_member = types::Priority::FromString(member->as_string()); out.priority = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("weight"); + const opal::Document* member = doc.Find("weight"); if (member != nullptr && !member->is_null()) { types::Weight parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("KitchenSink.weight: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("KitchenSink.weight: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("KitchenSink.weight: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("KitchenSink.weight: value out of range"); parsed_member = static_cast(member->as_int()); out.weight = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("dateTime"); + const opal::Document* member = doc.Find("dateTime"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kDateTime); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kDateTime); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -380,11 +380,11 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("httpDate"); + const opal::Document* member = doc.Find("httpDate"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kHttpDate); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kHttpDate); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -392,11 +392,11 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("epoch"); + const opal::Document* member = doc.Find("epoch"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kEpochSeconds); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kEpochSeconds); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -404,7 +404,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("names"); + const opal::Document* member = doc.Find("names"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -416,7 +416,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("uniqueNames"); + const opal::Document* member = doc.Find("uniqueNames"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -428,7 +428,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("sparseNumbers"); + const opal::Document* member = doc.Find("sparseNumbers"); if (member != nullptr && !member->is_null()) { std::vector> parsed_member{}; { @@ -440,7 +440,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("attributes"); + const opal::Document* member = doc.Find("attributes"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -452,7 +452,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("nested"); + const opal::Document* member = doc.Find("nested"); if (member != nullptr && !member->is_null()) { types::NestedConfig parsed_member{}; { @@ -464,7 +464,7 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) } } { - const smithy::Document* member = doc.Find("choice"); + const opal::Document* member = doc.Find("choice"); if (member != nullptr && !member->is_null()) { types::SinkChoice parsed_member{}; { @@ -478,31 +478,31 @@ smithy::Outcome DeserializeKitchenSink(const smithy::Document& doc) return out; } -smithy::Document SerializeSinkNotFound(const SinkNotFound& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); +opal::Document SerializeSinkNotFound(const SinkNotFound& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); if (value.resourceType.has_value()) { - map.emplace("resourceType", smithy::Document((*value.resourceType))); + map.emplace("resourceType", opal::Document((*value.resourceType))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSinkNotFound(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SinkNotFound: expected a map on the wire"); +opal::Outcome DeserializeSinkNotFound(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SinkNotFound: expected a map on the wire"); SinkNotFound out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("SinkNotFound: missing required member: message"); + return opal::Error::Serialization("SinkNotFound: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("SinkNotFound.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkNotFound.message: unexpected type on the wire"); out.message = member->as_string(); } { - const smithy::Document* member = doc.Find("resourceType"); + const opal::Document* member = doc.Find("resourceType"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("SinkNotFound.resourceType: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkNotFound.resourceType: unexpected type on the wire"); parsed_member = member->as_string(); out.resourceType = std::move(parsed_member); } @@ -510,57 +510,57 @@ smithy::Outcome DeserializeSinkNotFound(const smithy::Document& do return out; } -smithy::Document SerializePingInput(const PingInput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializePingInput(const PingInput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePingInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PingInput: expected a map on the wire"); +opal::Outcome DeserializePingInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PingInput: expected a map on the wire"); PingInput out; return out; } -smithy::Document SerializePingOutput(const PingOutput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializePingOutput(const PingOutput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePingOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PingOutput: expected a map on the wire"); +opal::Outcome DeserializePingOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PingOutput: expected a map on the wire"); PingOutput out; return out; } -smithy::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value) { - smithy::DocumentMap map; +opal::Document SerializeSinkQuotaExceeded(const SinkQuotaExceeded& value) { + opal::DocumentMap map; if (value.message.has_value()) { - map.emplace("message", smithy::Document((*value.message))); + map.emplace("message", opal::Document((*value.message))); } if (value.retryAfterSeconds.has_value()) { - map.emplace("retryAfterSeconds", smithy::Document(static_cast((*value.retryAfterSeconds)))); + map.emplace("retryAfterSeconds", opal::Document(static_cast((*value.retryAfterSeconds)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSinkQuotaExceeded(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SinkQuotaExceeded: expected a map on the wire"); +opal::Outcome DeserializeSinkQuotaExceeded(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SinkQuotaExceeded: expected a map on the wire"); SinkQuotaExceeded out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("SinkQuotaExceeded.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SinkQuotaExceeded.message: unexpected type on the wire"); parsed_member = member->as_string(); out.message = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("retryAfterSeconds"); + const opal::Document* member = doc.Find("retryAfterSeconds"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("SinkQuotaExceeded.retryAfterSeconds: value out of range"); parsed_member = static_cast(member->as_int()); out.retryAfterSeconds = std::move(parsed_member); } @@ -568,28 +568,28 @@ smithy::Outcome DeserializeSinkQuotaExceeded(const smithy::Do return out; } -smithy::Document SerializePutSinkRpcInput(const PutSinkRpcInput& value) { - smithy::DocumentMap map; - map.emplace("sinkId", smithy::Document(value.sinkId)); +opal::Document SerializePutSinkRpcInput(const PutSinkRpcInput& value) { + opal::DocumentMap map; + map.emplace("sinkId", opal::Document(value.sinkId)); if (value.sink.has_value()) { map.emplace("sink", SerializeKitchenSink((*value.sink))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePutSinkRpcInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PutSinkRpcInput: expected a map on the wire"); +opal::Outcome DeserializePutSinkRpcInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PutSinkRpcInput: expected a map on the wire"); PutSinkRpcInput out; { - const smithy::Document* member = doc.Find("sinkId"); + const opal::Document* member = doc.Find("sinkId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PutSinkRpcInput: missing required member: sinkId"); + return opal::Error::Serialization("PutSinkRpcInput: missing required member: sinkId"); } - if (!member->is_string()) return smithy::Error::Serialization("PutSinkRpcInput.sinkId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutSinkRpcInput.sinkId: unexpected type on the wire"); out.sinkId = member->as_string(); } { - const smithy::Document* member = doc.Find("sink"); + const opal::Document* member = doc.Find("sink"); if (member != nullptr && !member->is_null()) { types::KitchenSink parsed_member{}; { @@ -603,28 +603,28 @@ smithy::Outcome DeserializePutSinkRpcInput(const smithy::Docume return out; } -smithy::Document SerializePutSinkRpcOutput(const PutSinkRpcOutput& value) { - smithy::DocumentMap map; - map.emplace("sinkId", smithy::Document(value.sinkId)); +opal::Document SerializePutSinkRpcOutput(const PutSinkRpcOutput& value) { + opal::DocumentMap map; + map.emplace("sinkId", opal::Document(value.sinkId)); if (value.sink.has_value()) { map.emplace("sink", SerializeKitchenSink((*value.sink))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePutSinkRpcOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PutSinkRpcOutput: expected a map on the wire"); +opal::Outcome DeserializePutSinkRpcOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PutSinkRpcOutput: expected a map on the wire"); PutSinkRpcOutput out; { - const smithy::Document* member = doc.Find("sinkId"); + const opal::Document* member = doc.Find("sinkId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PutSinkRpcOutput: missing required member: sinkId"); + return opal::Error::Serialization("PutSinkRpcOutput: missing required member: sinkId"); } - if (!member->is_string()) return smithy::Error::Serialization("PutSinkRpcOutput.sinkId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutSinkRpcOutput.sinkId: unexpected type on the wire"); out.sinkId = member->as_string(); } { - const smithy::Document* member = doc.Find("sink"); + const opal::Document* member = doc.Find("sink"); if (member != nullptr && !member->is_null()) { types::KitchenSink parsed_member{}; { diff --git a/examples/roundtrip/rpc/generated/src/server.cc b/examples/roundtrip/rpc/generated/src/server.cc index 80885397..68a455f1 100644 --- a/examples/roundtrip/rpc/generated/src/server.cc +++ b/examples/roundtrip/rpc/generated/src/server.cc @@ -22,59 +22,59 @@ namespace types = ::example::roundtrip::rpc; namespace { namespace helpers { -smithy::http::HttpResponse CborError(int status, const std::string& code, const std::string& message, smithy::DocumentMap body) { - if (!code.empty()) body.insert_or_assign("__type", smithy::Document(code)); - if (!message.empty()) body.insert_or_assign("message", smithy::Document(message)); - smithy::http::HttpResponse response; +opal::http::HttpResponse CborError(int status, const std::string& code, const std::string& message, opal::DocumentMap body) { + if (!code.empty()) body.insert_or_assign("__type", opal::Document(code)); + if (!message.empty()) body.insert_or_assign("message", opal::Document(message)); + opal::http::HttpResponse response; response.status = status; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(smithy::Document(std::move(body))).ToString(); + response.body = opal::cbor::Encode(opal::Document(std::move(body))).ToString(); return response; } // [[maybe_unused]]: only unary routes map handler errors here; a service // whose operations all stream reports errors on the stream instead. -[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& error) { - if (error.kind() == smithy::ErrorKind::kModeled) { +[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& error) { + if (error.kind() == opal::ErrorKind::kModeled) { if (error.code() == "SinkNotFound") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeSinkNotFound(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::CborError(404, "example.roundtrip#SinkNotFound", "", std::move(body)); } if (error.code() == "SinkQuotaExceeded") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeSinkQuotaExceeded(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::CborError(503, "example.roundtrip#SinkQuotaExceeded", "", std::move(body)); } return helpers::CborError(400, error.code(), error.message(), {}); } - if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) return helpers::CborError(400, "SerializationException", error.message(), {}); + if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) return helpers::CborError(400, "SerializationException", error.message(), {}); // Never leak internal detail on unexpected failures. return helpers::CborError(500, "InternalFailure", "internal failure", {}); } // Constraint validation (smithy.framework#ValidationException): messages // and '/member' paths follow the official validation conformance suite. -void AddValidationFailure(std::vector* failures, std::string path, std::string message) { +void AddValidationFailure(std::vector* failures, std::string path, std::string message) { failures->push_back({std::move(path), std::move(message)}); } -void ValidateKitchenSink(const types::KitchenSink& value, const std::string& path, std::vector* failures) { +void ValidateKitchenSink(const types::KitchenSink& value, const std::string& path, std::vector* failures) { if (value.priority.has_value()) { const std::string member_path = path + "/priority"; if ((*value.priority).value() == Priority::Value::kUnknown) { @@ -103,7 +103,7 @@ void ValidateKitchenSink(const types::KitchenSink& value, const std::string& pat } } -void ValidatePutSinkRpcInput(const types::PutSinkRpcInput& value, const std::string& path, std::vector* failures) { +void ValidatePutSinkRpcInput(const types::PutSinkRpcInput& value, const std::string& path, std::vector* failures) { if (value.sink.has_value()) { const std::string member_path = path + "/sink"; helpers::ValidateKitchenSink((*value.sink), member_path, failures); @@ -112,20 +112,20 @@ void ValidatePutSinkRpcInput(const types::PutSinkRpcInput& value, const std::str // [[maybe_unused]]: only unary routes reject invalid input over HTTP; a // service whose operations all stream reports validation on the stream. -[[maybe_unused]] smithy::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { +[[maybe_unused]] opal::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { std::string summary = std::to_string(failures.size()) + " validation error" + (failures.size() == 1 ? "" : "s") + " detected. "; - smithy::DocumentList field_list; + opal::DocumentList field_list; for (std::size_t i = 0; i < failures.size(); ++i) { if (i > 0) summary += "; "; summary += failures[i].message; - smithy::DocumentMap field; - field.emplace("message", smithy::Document(failures[i].message)); - field.emplace("path", smithy::Document(failures[i].path)); - field_list.push_back(smithy::Document(std::move(field))); + opal::DocumentMap field; + field.emplace("message", opal::Document(failures[i].message)); + field.emplace("path", opal::Document(failures[i].path)); + field_list.push_back(opal::Document(std::move(field))); } - smithy::DocumentMap body; - body.emplace("fieldList", smithy::Document(std::move(field_list))); - smithy::http::HttpResponse response = helpers::CborError(400, "smithy.framework#ValidationException", summary, std::move(body)); + opal::DocumentMap body; + body.emplace("fieldList", opal::Document(std::move(field_list))); + opal::http::HttpResponse response = helpers::CborError(400, "smithy.framework#ValidationException", summary, std::move(body)); return response; } @@ -133,33 +133,33 @@ void ValidatePutSinkRpcInput(const types::PutSinkRpcInput& value, const std::str } // namespace RoundTripRpcServer::RoundTripRpcServer(std::shared_ptr handler) - : router_(std::make_shared()) { + : router_(std::make_shared()) { // The route table is derived from the model's @http traits; conflicts are // a modeling error surfaced by Router::Add (checked at generation time in a // later phase), so registration results are intentionally discarded. - (void)router_->Add("POST", "/service/RoundTripRpc/operation/Ping", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RoundTripRpc/operation/Ping", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } PingInput input{}; auto outcome = handler->Ping(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializePingOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializePingOutput(*outcome)).ToString(); return response; }, "Ping"); - (void)router_->Add("POST", "/service/RoundTripRpc/operation/PutSinkRpc", [handler](const smithy::http::HttpRequest& raw_request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { - smithy::http::HttpRequest request = raw_request; + (void)router_->Add("POST", "/service/RoundTripRpc/operation/PutSinkRpc", [handler](const opal::http::HttpRequest& raw_request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { + opal::http::HttpRequest request = raw_request; // @requestCompression(gzip): decode before parsing. if (const auto request_encoding = request.headers.Get("content-encoding"); request_encoding.has_value() && (*request_encoding == "gzip" || request_encoding->ends_with(", gzip"))) { - auto decompressed = smithy::GzipDecompress(request.body); + auto decompressed = opal::GzipDecompress(request.body); if (!decompressed) { return helpers::CborError(400, "SerializationException", "invalid gzip request body", {}); } @@ -170,36 +170,36 @@ RoundTripRpcServer::RoundTripRpcServer(std::shared_ptr hand } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } PutSinkRpcInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } auto parsed = DeserializePutSinkRpcInput(body_doc); if (!parsed) return helpers::CborError(400, "SerializationException", parsed.error().message(), {}); input = *std::move(parsed); - std::vector validation_failures; + std::vector validation_failures; helpers::ValidatePutSinkRpcInput(input, "", &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); auto outcome = handler->PutSinkRpc(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializePutSinkRpcOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializePutSinkRpcOutput(*outcome)).ToString(); return response; }, "PutSinkRpc"); } -smithy::http::RequestHandler RoundTripRpcServer::Handler() const { +opal::http::RequestHandler RoundTripRpcServer::Handler() const { auto router = router_; - return [router](const smithy::http::HttpRequest& request) { return router->Route(request); }; + return [router](const opal::http::HttpRequest& request) { return router->Route(request); }; } } // namespace example::roundtrip::rpc diff --git a/examples/roundtrip/rpc/generated/tests/integration_test.cc b/examples/roundtrip/rpc/generated/tests/integration_test.cc index ae1ad3e2..afdd9101 100644 --- a/examples/roundtrip/rpc/generated/tests/integration_test.cc +++ b/examples/roundtrip/rpc/generated/tests/integration_test.cc @@ -129,12 +129,12 @@ struct Rng { if (rng.Coin()) v.big = static_cast(rng.Int(-4611686018427387904LL, 4611686018427387903LL)); if (rng.Coin()) v.ratio = static_cast(rng.Int(-8000000LL, 8000000LL)) / static_cast(8); if (rng.Coin()) v.precise = static_cast(rng.Int(-8000000LL, 8000000LL)) / static_cast(8); - if (rng.Coin()) v.blob = smithy::Blob::FromString(rng.Text(1, 9)); + if (rng.Coin()) v.blob = opal::Blob::FromString(rng.Text(1, 9)); if (rng.Coin()) v.priority = Priority::FromString(std::array{"low", "medium", "high"}[rng.engine() % 3]); if (rng.Coin()) v.weight = static_cast(std::array{1, 2}[rng.engine() % 2]); - if (rng.Coin()) v.dateTime = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); - if (rng.Coin()) v.httpDate = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); - if (rng.Coin()) v.epoch = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + if (rng.Coin()) v.dateTime = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + if (rng.Coin()) v.httpDate = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + if (rng.Coin()) v.epoch = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); if (rng.Coin()) v.names = RandomStringList(rng); if (rng.Coin()) v.uniqueNames = RandomUniqueStringList(rng); if (rng.Coin()) v.sparseNumbers = RandomSparseIntegerList(rng); @@ -184,22 +184,22 @@ struct Rng { class ScriptedHandler final : public RoundTripRpcHandler { public: - smithy::Outcome Ping(const PingInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Ping(const PingInput& input, const opal::server::RequestContext&) override { lastPing = input; if (nextPingError.has_value()) return *nextPingError; return nextPingOutput; } std::optional lastPing; PingOutput nextPingOutput{}; - std::optional nextPingError; - smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input, const smithy::server::RequestContext&) override { + std::optional nextPingError; + opal::Outcome PutSinkRpc(const PutSinkRpcInput& input, const opal::server::RequestContext&) override { lastPutSinkRpc = input; if (nextPutSinkRpcError.has_value()) return *nextPutSinkRpcError; return nextPutSinkRpcOutput; } std::optional lastPutSinkRpc; PutSinkRpcOutput nextPutSinkRpcOutput{}; - std::optional nextPutSinkRpcError; + std::optional nextPutSinkRpcError; }; enum class TransportKind { kLoopback, kSocket }; @@ -209,14 +209,14 @@ class RoundTripRpcIntegrationTest : public ::testing::TestWithParam(); server_ = std::make_unique(handler_); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries if (GetParam() == TransportKind::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); config.http_client = loopback; } else { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(server_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } @@ -229,7 +229,7 @@ class RoundTripRpcIntegrationTest : public ::testing::TestWithParam handler_; std::unique_ptr server_; - std::unique_ptr socket_server_; + std::unique_ptr socket_server_; std::unique_ptr client_; }; @@ -288,13 +288,13 @@ TEST_P(RoundTripRpcIntegrationTest, PutSinkRpcMaximalRoundTrips) { TEST_P(RoundTripRpcIntegrationTest, PutSinkRpcSinkNotFoundMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const SinkNotFound detail = RandomSinkNotFound(rng); - smithy::Error error = smithy::Error::Modeled("SinkNotFound", "integration"); + opal::Error error = opal::Error::Modeled("SinkNotFound", "integration"); error.set_detail(detail); handler_->nextPutSinkRpcError = error; const PutSinkRpcInput input = RandomPutSinkRpcInput(rng); const auto outcome = client_->PutSinkRpc(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "SinkNotFound"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -303,13 +303,13 @@ TEST_P(RoundTripRpcIntegrationTest, PutSinkRpcSinkNotFoundMapsAcrossTheWire) { TEST_P(RoundTripRpcIntegrationTest, PutSinkRpcSinkQuotaExceededMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const SinkQuotaExceeded detail = RandomSinkQuotaExceeded(rng); - smithy::Error error = smithy::Error::Modeled("SinkQuotaExceeded", "integration"); + opal::Error error = opal::Error::Modeled("SinkQuotaExceeded", "integration"); error.set_detail(detail); handler_->nextPutSinkRpcError = error; const PutSinkRpcInput input = RandomPutSinkRpcInput(rng); const auto outcome = client_->PutSinkRpc(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "SinkQuotaExceeded"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -318,17 +318,17 @@ TEST_P(RoundTripRpcIntegrationTest, PutSinkRpcSinkQuotaExceededMapsAcrossTheWire TEST(RoundTripRpcIntegrationUnknownMembers, PingToleratesUnknownResponseMembers) { auto handler = std::make_shared(); RoundTripRpcServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::cbor::Decode(smithy::Blob::FromString(response.body)); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::cbor::Decode(opal::Blob::FromString(response.body)); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::cbor::Encode(smithy::Document(std::move(map))).ToString(); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::cbor::Encode(opal::Document(std::move(map))).ToString(); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RoundTripRpcClient::Create(std::move(config)); @@ -344,17 +344,17 @@ TEST(RoundTripRpcIntegrationUnknownMembers, PingToleratesUnknownResponseMembers) TEST(RoundTripRpcIntegrationUnknownMembers, PutSinkRpcToleratesUnknownResponseMembers) { auto handler = std::make_shared(); RoundTripRpcServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::cbor::Decode(smithy::Blob::FromString(response.body)); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::cbor::Decode(opal::Blob::FromString(response.body)); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::cbor::Encode(smithy::Document(std::move(map))).ToString(); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::cbor::Encode(opal::Document(std::move(map))).ToString(); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RoundTripRpcClient::Create(std::move(config)); diff --git a/examples/roundtrip/rpc/generated/tests/smoke_test.cc b/examples/roundtrip/rpc/generated/tests/smoke_test.cc index 326f58cb..b6f8d05c 100644 --- a/examples/roundtrip/rpc/generated/tests/smoke_test.cc +++ b/examples/roundtrip/rpc/generated/tests/smoke_test.cc @@ -34,11 +34,11 @@ PutSinkRpcOutput MinimalPutSinkRpcOutput() { class SmokeHandler : public RoundTripRpcHandler { public: - smithy::Outcome Ping(const PingInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Ping(const PingInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalPingOutput(); } - smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PutSinkRpc(const PutSinkRpcInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalPutSinkRpcOutput(); } @@ -46,9 +46,9 @@ class SmokeHandler : public RoundTripRpcHandler { RoundTripRpcClient MakeClient(std::shared_ptr handler) { RoundTripRpcServer server(std::move(handler)); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = loopback; // Create cannot fail when a transport is injected. @@ -82,9 +82,9 @@ TEST(RoundTripRpcSmokeTest, PutSinkRpcRoundTrips) { TEST(RoundTripRpcSmokeTest, ModeledErrorsMapAcrossTheWire) { class FailingHandler final : public SmokeHandler { public: - smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PutSinkRpc(const PutSinkRpcInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("SinkNotFound", "smoke"); + opal::Error error = opal::Error::Modeled("SinkNotFound", "smoke"); auto detail = [] { SinkNotFound v{}; return v; @@ -102,7 +102,7 @@ TEST(RoundTripRpcSmokeTest, ModeledErrorsMapAcrossTheWire) { }(); const auto outcome = client.PutSinkRpc(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "SinkNotFound"); EXPECT_EQ(outcome.error().message(), "smoke"); EXPECT_NE(outcome.error().detail(), nullptr); diff --git a/examples/roundtrip/rpc/no_input_body_wire_test.cc b/examples/roundtrip/rpc/no_input_body_wire_test.cc index 6442ce59..e48f709e 100644 --- a/examples/roundtrip/rpc/no_input_body_wire_test.cc +++ b/examples/roundtrip/rpc/no_input_body_wire_test.cc @@ -19,14 +19,13 @@ namespace { class RecordingHandler final : public RoundTripRpcHandler { public: - smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome PutSinkRpc(const PutSinkRpcInput& input, + const opal::server::RequestContext&) override { put_sink_calls++; return PutSinkRpcOutput{.sinkId = input.sinkId}; } - smithy::Outcome Ping(const PingInput&, - const smithy::server::RequestContext&) override { + opal::Outcome Ping(const PingInput&, const opal::server::RequestContext&) override { ping_calls++; return PingOutput{}; } @@ -35,8 +34,8 @@ class RecordingHandler final : public RoundTripRpcHandler { int put_sink_calls = 0; }; -smithy::http::HttpRequest CborRequest(const std::string& operation, std::string body) { - return smithy::testing::Rpcv2CborRequest("RoundTripRpc", operation, std::move(body)); +opal::http::HttpRequest CborRequest(const std::string& operation, std::string body) { + return opal::testing::Rpcv2CborRequest("RoundTripRpc", operation, std::move(body)); } TEST(NoInputBodyTest, GarbageBodyAtANoInputOperationIsIgnored) { @@ -69,12 +68,12 @@ TEST(NoInputBodyTest, TheSameGarbageAtAModeledInputOperationIsRejected) { TEST(NoInputBodyTest, RpcDispatchThreadsTheRequestContext) { class ContextProbe final : public RoundTripRpcHandler { public: - smithy::Outcome PutSinkRpc(const PutSinkRpcInput&, - const smithy::server::RequestContext&) override { + opal::Outcome PutSinkRpc(const PutSinkRpcInput&, + const opal::server::RequestContext&) override { return PutSinkRpcOutput{}; } - smithy::Outcome Ping(const PingInput&, - const smithy::server::RequestContext& context) override { + opal::Outcome Ping(const PingInput&, + const opal::server::RequestContext& context) override { threaded = context.request != nullptr && context.request->method == "POST" && context.request->headers.Get("x-probe").value_or("") == "42"; return PingOutput{}; diff --git a/examples/simplerestjson/generated/include/example/bookstore/client.h b/examples/simplerestjson/generated/include/example/bookstore/client.h index 7f8b636f..841df374 100644 --- a/examples/simplerestjson/generated/include/example/bookstore/client.h +++ b/examples/simplerestjson/generated/include/example/bookstore/client.h @@ -23,28 +23,28 @@ namespace example::bookstore { /// simpleRestJson client for example.bookstore#Bookstore. -/// Modeled service errors surface as smithy::Error with kind kModeled, +/// Modeled service errors surface as opal::Error with kind kModeled, /// code() set to the error shape name, and the deserialized error /// structure attached. Dispatch on them through the per-operation /// Errors listings below rather than comparing code() text. class BookstoreClient { public: /// Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); + static opal::Outcome Create(opal::ClientConfig config); - smithy::Outcome AddBook(const AddBookInput& input) const; - smithy::Outcome GetBook(const GetBookInput& input) const; + opal::Outcome AddBook(const AddBookInput& input) const; + opal::Outcome GetBook(const GetBookInput& input) const; private: - BookstoreClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix); - smithy::Outcome Send(smithy::http::HttpRequest request) const; + BookstoreClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix); + opal::Outcome Send(opal::http::HttpRequest request) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; -/// The modeled errors of GetBook, matched from a smithy::Error so dispatch is +/// The modeled errors of GetBook, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -55,9 +55,9 @@ class GetBookErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static GetBookErrors FromError(const smithy::Error& error) { + static GetBookErrors FromError(const opal::Error& error) { GetBookErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "BookNotFound") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : BookNotFound{}); @@ -96,7 +96,7 @@ class GetBookErrors { switch (value_.index()) { case 1: out += "book_not_found = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -115,7 +115,7 @@ class GetBookErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("GetBookErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("GetBookErrors", requested, case_name()); } } @@ -132,8 +132,8 @@ template <> struct std::hash { std::size_t operator()(const example::bookstore::GetBookErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; diff --git a/examples/simplerestjson/generated/include/example/bookstore/serde.h b/examples/simplerestjson/generated/include/example/bookstore/serde.h index 1d2c253c..2b1add65 100644 --- a/examples/simplerestjson/generated/include/example/bookstore/serde.h +++ b/examples/simplerestjson/generated/include/example/bookstore/serde.h @@ -10,23 +10,23 @@ namespace example::bookstore { // Document-pivot serde for every aggregate shape in the model closure. -// Serializers never fail; deserializers return smithy::Error on wire +// Serializers never fail; deserializers return opal::Error on wire // mismatches and enforce @required members. -smithy::Document SerializeAddBookInput(const AddBookInput& value); -smithy::Outcome DeserializeAddBookInput(const smithy::Document& doc); +opal::Document SerializeAddBookInput(const AddBookInput& value); +opal::Outcome DeserializeAddBookInput(const opal::Document& doc); -smithy::Document SerializeAddBookOutput(const AddBookOutput& value); -smithy::Outcome DeserializeAddBookOutput(const smithy::Document& doc); +opal::Document SerializeAddBookOutput(const AddBookOutput& value); +opal::Outcome DeserializeAddBookOutput(const opal::Document& doc); -smithy::Document SerializeBookNotFound(const BookNotFound& value); -smithy::Outcome DeserializeBookNotFound(const smithy::Document& doc); +opal::Document SerializeBookNotFound(const BookNotFound& value); +opal::Outcome DeserializeBookNotFound(const opal::Document& doc); -smithy::Document SerializeGetBookInput(const GetBookInput& value); -smithy::Outcome DeserializeGetBookInput(const smithy::Document& doc); +opal::Document SerializeGetBookInput(const GetBookInput& value); +opal::Outcome DeserializeGetBookInput(const opal::Document& doc); -smithy::Document SerializeGetBookOutput(const GetBookOutput& value); -smithy::Outcome DeserializeGetBookOutput(const smithy::Document& doc); +opal::Document SerializeGetBookOutput(const GetBookOutput& value); +opal::Outcome DeserializeGetBookOutput(const opal::Document& doc); } // namespace example::bookstore diff --git a/examples/simplerestjson/generated/include/example/bookstore/server.h b/examples/simplerestjson/generated/include/example/bookstore/server.h index b053ffe6..e865bb0a 100644 --- a/examples/simplerestjson/generated/include/example/bookstore/server.h +++ b/examples/simplerestjson/generated/include/example/bookstore/server.h @@ -13,31 +13,31 @@ namespace example::bookstore { /// Implement one method per operation. Return a modeled error as -/// smithy::Error::Modeled("", message), optionally with the +/// opal::Error::Modeled("", message), optionally with the /// typed error structure attached via set_detail() so it serializes fully. /// The context carries the raw request and routing captures — see -/// smithy::server::RequestContext; leave the parameter unnamed when unused. +/// opal::server::RequestContext; leave the parameter unnamed when unused. /// Implementations must be thread-safe: transports may invoke any mix of /// operations concurrently on the one handler instance. class BookstoreHandler { public: virtual ~BookstoreHandler() = default; - virtual smithy::Outcome AddBook(const AddBookInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome GetBook(const GetBookInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome AddBook(const AddBookInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome GetBook(const GetBookInput& input, const opal::server::RequestContext& context) = 0; }; /// simpleRestJson server for example.bookstore#Bookstore: routing, deserialization, handler dispatch, /// response serialization, and modeled-error mapping. Pass Handler() to any -/// smithy::http::HttpServerTransport. +/// opal::http::HttpServerTransport. class BookstoreServer { public: explicit BookstoreServer(std::shared_ptr handler); - smithy::http::RequestHandler Handler() const; + opal::http::RequestHandler Handler() const; private: - std::shared_ptr router_; + std::shared_ptr router_; }; } // namespace example::bookstore diff --git a/examples/simplerestjson/generated/include/example/bookstore/types.h b/examples/simplerestjson/generated/include/example/bookstore/types.h index df309791..723d54e7 100644 --- a/examples/simplerestjson/generated/include/example/bookstore/types.h +++ b/examples/simplerestjson/generated/include/example/bookstore/types.h @@ -27,11 +27,11 @@ struct AddBookInput { out += sep; sep = ", "; out += ".isbn = "; - smithy::DebugAppend(out, this->isbn); + opal::DebugAppend(out, this->isbn); out += sep; sep = ", "; out += ".title = "; - smithy::DebugAppend(out, this->title); + opal::DebugAppend(out, this->title); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -55,11 +55,11 @@ struct AddBookOutput { out += sep; sep = ", "; out += ".status = "; - smithy::DebugAppend(out, this->status); + opal::DebugAppend(out, this->status); out += sep; sep = ", "; out += ".isbn = "; - smithy::DebugAppend(out, this->isbn); + opal::DebugAppend(out, this->isbn); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -83,11 +83,11 @@ struct BookNotFound { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); out += sep; sep = ", "; out += ".isbn = "; - smithy::DebugAppend(out, this->isbn); + opal::DebugAppend(out, this->isbn); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -111,12 +111,12 @@ struct GetBookInput { out += sep; sep = ", "; out += ".isbn = "; - smithy::DebugAppend(out, this->isbn); + opal::DebugAppend(out, this->isbn); if (this->currency.has_value()) { out += sep; sep = ", "; out += ".currency = "; - smithy::DebugAppend(out, *this->currency); + opal::DebugAppend(out, *this->currency); } out += '}'; } @@ -142,16 +142,16 @@ struct GetBookOutput { out += sep; sep = ", "; out += ".isbn = "; - smithy::DebugAppend(out, this->isbn); + opal::DebugAppend(out, this->isbn); out += sep; sep = ", "; out += ".title = "; - smithy::DebugAppend(out, this->title); + opal::DebugAppend(out, this->title); if (this->price.has_value()) { out += sep; sep = ", "; out += ".price = "; - smithy::DebugAppend(out, *this->price); + opal::DebugAppend(out, *this->price); } out += '}'; } @@ -174,8 +174,8 @@ template <> struct std::hash { std::size_t operator()(const example::bookstore::AddBookInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.isbn)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.title)); + seed = opal::HashCombine(seed, opal::HashValue(value.isbn)); + seed = opal::HashCombine(seed, opal::HashValue(value.title)); return seed; } }; @@ -184,8 +184,8 @@ template <> struct std::hash { std::size_t operator()(const example::bookstore::AddBookOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.status)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.isbn)); + seed = opal::HashCombine(seed, opal::HashValue(value.status)); + seed = opal::HashCombine(seed, opal::HashValue(value.isbn)); return seed; } }; @@ -194,8 +194,8 @@ template <> struct std::hash { std::size_t operator()(const example::bookstore::BookNotFound& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.isbn)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.isbn)); return seed; } }; @@ -204,8 +204,8 @@ template <> struct std::hash { std::size_t operator()(const example::bookstore::GetBookInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.isbn)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.currency)); + seed = opal::HashCombine(seed, opal::HashValue(value.isbn)); + seed = opal::HashCombine(seed, opal::HashValue(value.currency)); return seed; } }; @@ -214,9 +214,9 @@ template <> struct std::hash { std::size_t operator()(const example::bookstore::GetBookOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.isbn)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.title)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.price)); + seed = opal::HashCombine(seed, opal::HashValue(value.isbn)); + seed = opal::HashCombine(seed, opal::HashValue(value.title)); + seed = opal::HashCombine(seed, opal::HashValue(value.price)); return seed; } }; diff --git a/examples/simplerestjson/generated/src/client.cc b/examples/simplerestjson/generated/src/client.cc index faf681bb..ac2acaeb 100644 --- a/examples/simplerestjson/generated/src/client.cc +++ b/examples/simplerestjson/generated/src/client.cc @@ -38,51 +38,51 @@ struct ParsedError { int status = 0; std::string code = "UnknownError"; std::string message; - smithy::Document doc; + opal::Document doc; }; // [[maybe_unused]]: only unary response paths parse wire errors; a // service whose operations all stream never calls this. -[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) { +[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) { ParsedError parsed; parsed.status = response.status; parsed.message = "HTTP " + std::to_string(response.status); - auto doc = smithy::json::Decode(response.body); + auto doc = opal::json::Decode(response.body); if (doc.ok()) parsed.doc = *std::move(doc); const auto type_header = response.headers.Get("x-error-type"); if (type_header.has_value()) parsed.code = helpers::SanitizeErrorCode(*type_header); if (parsed.doc.is_map()) { - const smithy::Document* type = parsed.doc.Find("__type"); + const opal::Document* type = parsed.doc.Find("__type"); if (type == nullptr) type = parsed.doc.Find("code"); if (parsed.code == "UnknownError" && type != nullptr && type->is_string()) parsed.code = helpers::SanitizeErrorCode(type->as_string()); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } return parsed; } -smithy::Error GenericError(ParsedError parsed) { +opal::Error GenericError(ParsedError parsed) { const bool retryable = parsed.status >= 500; - if (parsed.code == "UnknownError") return smithy::Error(smithy::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); - return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); + if (parsed.code == "UnknownError") return opal::Error(opal::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); + return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); } // Strict text parsing for label/query/header bindings ([[maybe_unused]]: // emitted for every service; not every service binds numeric values). // Trailing text, floats-for-ints, and out-of-range values are rejected // (the malformed-request suites pin this). -[[maybe_unused]] smithy::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { +[[maybe_unused]] opal::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { std::int64_t value = 0; const char* first = text.data(); const char* last = first + text.size(); const auto result = std::from_chars(first, last, value, 10); if (text.empty() || result.ec != std::errc() || result.ptr != last || value < min_value || value > max_value) { - return smithy::Error::Serialization("invalid integer: " + text); + return opal::Error::Serialization("invalid integer: " + text); } return value; } -[[maybe_unused]] smithy::Outcome ParseDoubleText(const std::string& text) { +[[maybe_unused]] opal::Outcome ParseDoubleText(const std::string& text) { if (text == "NaN") return std::numeric_limits::quiet_NaN(); if (text == "Infinity") return std::numeric_limits::infinity(); if (text == "-Infinity") return -std::numeric_limits::infinity(); @@ -90,21 +90,21 @@ smithy::Error GenericError(ParsedError parsed) { return (c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' || c == '+' || c == '-'; }; if (text.empty() || text.front() == '+' || !std::all_of(text.begin(), text.end(), valid_char)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } char* parse_end = nullptr; const double value = std::strtod(text.c_str(), &parse_end); if (parse_end != text.c_str() + text.size() || !std::isfinite(value)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } return value; } -smithy::Error MakeBookNotFoundError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeBookNotFoundError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("BookNotFound", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("BookNotFound", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeBookNotFound(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -112,7 +112,7 @@ smithy::Error MakeBookNotFoundError(const smithy::http::HttpResponse& response, return error; } -smithy::Error ParseGetBookError(const smithy::http::HttpResponse& response) { +opal::Error ParseGetBookError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "BookNotFound") return helpers::MakeBookNotFoundError(response, std::move(parsed)); if (parsed.code == "UnknownError" && parsed.status == 404) return helpers::MakeBookNotFoundError(response, std::move(parsed)); @@ -122,88 +122,88 @@ smithy::Error ParseGetBookError(const smithy::http::HttpResponse& response) { } // namespace helpers } // namespace -smithy::Outcome BookstoreClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome BookstoreClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { // The built-in socket transport is plaintext-only; https needs a - // TLS-capable transport (e.g. smithy::http::BeastHttpClient). + // TLS-capable transport (e.g. opal::http::BeastHttpClient). if (endpoint->tls()) { - return smithy::Error::Validation("BookstoreClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + return opal::Error::Validation("BookstoreClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); } - transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); } } if (transport == nullptr) { - return smithy::Error::Validation("BookstoreClient: config needs an endpoint or an http_client"); + return opal::Error::Validation("BookstoreClient: config needs an endpoint or an http_client"); } return BookstoreClient(std::move(config), std::move(transport), std::move(prefix)); } -BookstoreClient::BookstoreClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix) +BookstoreClient::BookstoreClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} -smithy::Outcome BookstoreClient::Send(smithy::http::HttpRequest request) const { +opal::Outcome BookstoreClient::Send(opal::http::HttpRequest request) const { // Operations with a non-document response payload set their own accept. if (!request.headers.Get("accept").has_value()) request.headers.Set("accept", "application/json"); request.headers.Set("user-agent", config_.user_agent); if (!request.body.empty()) { request.headers.Set("content-length", std::to_string(request.body.size())); } - return smithy::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); + return opal::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); } -smithy::Outcome BookstoreClient::AddBook(const AddBookInput& input) const { +opal::Outcome BookstoreClient::AddBook(const AddBookInput& input) const { std::string target = path_prefix_; target += "/books"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = std::move(target); - smithy::DocumentMap body_map; - body_map.emplace("isbn", smithy::Document(input.isbn)); - body_map.emplace("title", smithy::Document(input.title)); - request.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + opal::DocumentMap body_map; + body_map.emplace("isbn", opal::Document(input.isbn)); + body_map.emplace("title", opal::Document(input.title)); + request.body = opal::json::Encode(opal::Document(std::move(body_map))); request.headers.Set("content-type", "application/json"); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status < 200 || response->status >= 400) return helpers::GenericError(helpers::ParseError(*response)); AddBookOutput out{}; - auto body_doc = smithy::json::Decode(response->body.empty() ? "{}" : response->body); + auto body_doc = opal::json::Decode(response->body.empty() ? "{}" : response->body); if (!body_doc) return std::move(body_doc).error(); - if (!body_doc->is_map()) return smithy::Error::Serialization("AddBook: expected a JSON object body"); + if (!body_doc->is_map()) return opal::Error::Serialization("AddBook: expected a JSON object body"); { - const smithy::Document* member = body_doc->Find("isbn"); - if (member == nullptr || member->is_null()) return smithy::Error::Serialization("missing required member: isbn"); - if (!member->is_string()) return smithy::Error::Serialization("AddBookOutput.isbn: unexpected type on the wire"); + const opal::Document* member = body_doc->Find("isbn"); + if (member == nullptr || member->is_null()) return opal::Error::Serialization("missing required member: isbn"); + if (!member->is_string()) return opal::Error::Serialization("AddBookOutput.isbn: unexpected type on the wire"); out.isbn = member->as_string(); } out.status = static_cast(response->status); return out; } -smithy::Outcome BookstoreClient::GetBook(const GetBookInput& input) const { +opal::Outcome BookstoreClient::GetBook(const GetBookInput& input) const { std::string target = path_prefix_; target += "/books"; target += "/"; - target += smithy::http::EncodePathSegment(input.isbn); - smithy::http::QueryString query; + target += opal::http::EncodePathSegment(input.isbn); + opal::http::QueryString query; if (input.currency.has_value()) { query.Add("currency", (*input.currency)); } target += query.ToString(); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseGetBookError(*response); - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializeGetBookOutput(*body_doc); } diff --git a/examples/simplerestjson/generated/src/serde.cc b/examples/simplerestjson/generated/src/serde.cc index 28432927..6359c5b5 100644 --- a/examples/simplerestjson/generated/src/serde.cc +++ b/examples/simplerestjson/generated/src/serde.cc @@ -8,119 +8,119 @@ namespace example::bookstore { -smithy::Document SerializeAddBookInput(const AddBookInput& value) { - smithy::DocumentMap map; - map.emplace("isbn", smithy::Document(value.isbn)); - map.emplace("title", smithy::Document(value.title)); - return smithy::Document(std::move(map)); +opal::Document SerializeAddBookInput(const AddBookInput& value) { + opal::DocumentMap map; + map.emplace("isbn", opal::Document(value.isbn)); + map.emplace("title", opal::Document(value.title)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeAddBookInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("AddBookInput: expected a map on the wire"); +opal::Outcome DeserializeAddBookInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("AddBookInput: expected a map on the wire"); AddBookInput out; { - const smithy::Document* member = doc.Find("isbn"); + const opal::Document* member = doc.Find("isbn"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AddBookInput: missing required member: isbn"); + return opal::Error::Serialization("AddBookInput: missing required member: isbn"); } - if (!member->is_string()) return smithy::Error::Serialization("AddBookInput.isbn: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("AddBookInput.isbn: unexpected type on the wire"); out.isbn = member->as_string(); } { - const smithy::Document* member = doc.Find("title"); + const opal::Document* member = doc.Find("title"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AddBookInput: missing required member: title"); + return opal::Error::Serialization("AddBookInput: missing required member: title"); } - if (!member->is_string()) return smithy::Error::Serialization("AddBookInput.title: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("AddBookInput.title: unexpected type on the wire"); out.title = member->as_string(); } return out; } -smithy::Document SerializeAddBookOutput(const AddBookOutput& value) { - smithy::DocumentMap map; - map.emplace("status", smithy::Document(static_cast(value.status))); - map.emplace("isbn", smithy::Document(value.isbn)); - return smithy::Document(std::move(map)); +opal::Document SerializeAddBookOutput(const AddBookOutput& value) { + opal::DocumentMap map; + map.emplace("status", opal::Document(static_cast(value.status))); + map.emplace("isbn", opal::Document(value.isbn)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeAddBookOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("AddBookOutput: expected a map on the wire"); +opal::Outcome DeserializeAddBookOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("AddBookOutput: expected a map on the wire"); AddBookOutput out; { - const smithy::Document* member = doc.Find("status"); + const opal::Document* member = doc.Find("status"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AddBookOutput: missing required member: status"); + return opal::Error::Serialization("AddBookOutput: missing required member: status"); } - if (!member->is_int()) return smithy::Error::Serialization("AddBookOutput.status: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("AddBookOutput.status: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("AddBookOutput.status: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("AddBookOutput.status: value out of range"); out.status = static_cast(member->as_int()); } { - const smithy::Document* member = doc.Find("isbn"); + const opal::Document* member = doc.Find("isbn"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AddBookOutput: missing required member: isbn"); + return opal::Error::Serialization("AddBookOutput: missing required member: isbn"); } - if (!member->is_string()) return smithy::Error::Serialization("AddBookOutput.isbn: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("AddBookOutput.isbn: unexpected type on the wire"); out.isbn = member->as_string(); } return out; } -smithy::Document SerializeBookNotFound(const BookNotFound& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); - map.emplace("isbn", smithy::Document(value.isbn)); - return smithy::Document(std::move(map)); +opal::Document SerializeBookNotFound(const BookNotFound& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); + map.emplace("isbn", opal::Document(value.isbn)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeBookNotFound(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("BookNotFound: expected a map on the wire"); +opal::Outcome DeserializeBookNotFound(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("BookNotFound: expected a map on the wire"); BookNotFound out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("BookNotFound: missing required member: message"); + return opal::Error::Serialization("BookNotFound: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("BookNotFound.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("BookNotFound.message: unexpected type on the wire"); out.message = member->as_string(); } { - const smithy::Document* member = doc.Find("isbn"); + const opal::Document* member = doc.Find("isbn"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("BookNotFound: missing required member: isbn"); + return opal::Error::Serialization("BookNotFound: missing required member: isbn"); } - if (!member->is_string()) return smithy::Error::Serialization("BookNotFound.isbn: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("BookNotFound.isbn: unexpected type on the wire"); out.isbn = member->as_string(); } return out; } -smithy::Document SerializeGetBookInput(const GetBookInput& value) { - smithy::DocumentMap map; - map.emplace("isbn", smithy::Document(value.isbn)); +opal::Document SerializeGetBookInput(const GetBookInput& value) { + opal::DocumentMap map; + map.emplace("isbn", opal::Document(value.isbn)); if (value.currency.has_value()) { - map.emplace("currency", smithy::Document((*value.currency))); + map.emplace("currency", opal::Document((*value.currency))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetBookInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetBookInput: expected a map on the wire"); +opal::Outcome DeserializeGetBookInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetBookInput: expected a map on the wire"); GetBookInput out; { - const smithy::Document* member = doc.Find("isbn"); + const opal::Document* member = doc.Find("isbn"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetBookInput: missing required member: isbn"); + return opal::Error::Serialization("GetBookInput: missing required member: isbn"); } - if (!member->is_string()) return smithy::Error::Serialization("GetBookInput.isbn: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetBookInput.isbn: unexpected type on the wire"); out.isbn = member->as_string(); } { - const smithy::Document* member = doc.Find("currency"); + const opal::Document* member = doc.Find("currency"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("GetBookInput.currency: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetBookInput.currency: unexpected type on the wire"); parsed_member = member->as_string(); out.currency = std::move(parsed_member); } @@ -128,44 +128,44 @@ smithy::Outcome DeserializeGetBookInput(const smithy::Document& do return out; } -smithy::Document SerializeGetBookOutput(const GetBookOutput& value) { - smithy::DocumentMap map; - map.emplace("isbn", smithy::Document(value.isbn)); - map.emplace("title", smithy::Document(value.title)); +opal::Document SerializeGetBookOutput(const GetBookOutput& value) { + opal::DocumentMap map; + map.emplace("isbn", opal::Document(value.isbn)); + map.emplace("title", opal::Document(value.title)); if (value.price.has_value()) { - map.emplace("price", smithy::Document(static_cast((*value.price)))); + map.emplace("price", opal::Document(static_cast((*value.price)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetBookOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetBookOutput: expected a map on the wire"); +opal::Outcome DeserializeGetBookOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetBookOutput: expected a map on the wire"); GetBookOutput out; { - const smithy::Document* member = doc.Find("isbn"); + const opal::Document* member = doc.Find("isbn"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetBookOutput: missing required member: isbn"); + return opal::Error::Serialization("GetBookOutput: missing required member: isbn"); } - if (!member->is_string()) return smithy::Error::Serialization("GetBookOutput.isbn: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetBookOutput.isbn: unexpected type on the wire"); out.isbn = member->as_string(); } { - const smithy::Document* member = doc.Find("title"); + const opal::Document* member = doc.Find("title"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetBookOutput: missing required member: title"); + return opal::Error::Serialization("GetBookOutput: missing required member: title"); } - if (!member->is_string()) return smithy::Error::Serialization("GetBookOutput.title: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetBookOutput.title: unexpected type on the wire"); out.title = member->as_string(); } { - const smithy::Document* member = doc.Find("price"); + const opal::Document* member = doc.Find("price"); if (member != nullptr && !member->is_null()) { float parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("GetBookOutput.price: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("GetBookOutput.price: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("GetBookOutput.price: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("GetBookOutput.price: value out of range"); parsed_member = *narrowed; } out.price = std::move(parsed_member); diff --git a/examples/simplerestjson/generated/src/server.cc b/examples/simplerestjson/generated/src/server.cc index 5843473c..a8eaa490 100644 --- a/examples/simplerestjson/generated/src/server.cc +++ b/examples/simplerestjson/generated/src/server.cc @@ -34,18 +34,18 @@ namespace helpers { // emitted for every service; not every service binds numeric values). // Trailing text, floats-for-ints, and out-of-range values are rejected // (the malformed-request suites pin this). -[[maybe_unused]] smithy::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { +[[maybe_unused]] opal::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { std::int64_t value = 0; const char* first = text.data(); const char* last = first + text.size(); const auto result = std::from_chars(first, last, value, 10); if (text.empty() || result.ec != std::errc() || result.ptr != last || value < min_value || value > max_value) { - return smithy::Error::Serialization("invalid integer: " + text); + return opal::Error::Serialization("invalid integer: " + text); } return value; } -[[maybe_unused]] smithy::Outcome ParseDoubleText(const std::string& text) { +[[maybe_unused]] opal::Outcome ParseDoubleText(const std::string& text) { if (text == "NaN") return std::numeric_limits::quiet_NaN(); if (text == "Infinity") return std::numeric_limits::infinity(); if (text == "-Infinity") return -std::numeric_limits::infinity(); @@ -53,12 +53,12 @@ namespace helpers { return (c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' || c == '+' || c == '-'; }; if (text.empty() || text.front() == '+' || !std::all_of(text.begin(), text.end(), valid_char)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } char* parse_end = nullptr; const double value = std::strtod(text.c_str(), &parse_end); if (parse_end != text.c_str() + text.size() || !std::isfinite(value)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } return value; } @@ -69,31 +69,31 @@ namespace helpers { return status >= 200 && status != 204 && status != 205 && status != 304; } -smithy::http::HttpResponse JsonError(int status, const std::string& code, const std::string& message, smithy::DocumentMap body) { - if (!code.empty()) body.insert_or_assign("__type", smithy::Document(code)); - if (!message.empty()) body.insert_or_assign("message", smithy::Document(message)); - smithy::http::HttpResponse response; +opal::http::HttpResponse JsonError(int status, const std::string& code, const std::string& message, opal::DocumentMap body) { + if (!code.empty()) body.insert_or_assign("__type", opal::Document(code)); + if (!message.empty()) body.insert_or_assign("message", opal::Document(message)); + opal::http::HttpResponse response; response.status = status; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body))); + response.body = opal::json::Encode(opal::Document(std::move(body))); return response; } // [[maybe_unused]]: only unary routes map handler errors here; a service // whose operations all stream reports errors on the stream instead. -[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& error) { +[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& error) { std::vector> header_values; (void)header_values; - if (error.kind() == smithy::ErrorKind::kModeled) { + if (error.kind() == opal::ErrorKind::kModeled) { if (error.code() == "BookNotFound") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeBookNotFound(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } auto response = helpers::JsonError(404, "", "", std::move(body)); response.headers.Set("x-error-type", error.code()); @@ -102,7 +102,7 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const } return helpers::JsonError(400, error.code(), error.message(), {}); } - if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) { + if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) { auto response = helpers::JsonError(400, "", error.message(), {}); response.headers.Set("x-error-type", "SerializationException"); return response; @@ -113,74 +113,74 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const // Constraint validation (smithy.framework#ValidationException): messages // and '/member' paths follow the official validation conformance suite. -void AddValidationFailure(std::vector* failures, std::string path, std::string message) { +void AddValidationFailure(std::vector* failures, std::string path, std::string message) { failures->push_back({std::move(path), std::move(message)}); } // [[maybe_unused]]: only unary routes reject invalid input over HTTP; a // service whose operations all stream reports validation on the stream. -[[maybe_unused]] smithy::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { +[[maybe_unused]] opal::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { std::string summary = std::to_string(failures.size()) + " validation error" + (failures.size() == 1 ? "" : "s") + " detected. "; - smithy::DocumentList field_list; + opal::DocumentList field_list; for (std::size_t i = 0; i < failures.size(); ++i) { if (i > 0) summary += "; "; summary += failures[i].message; - smithy::DocumentMap field; - field.emplace("message", smithy::Document(failures[i].message)); - field.emplace("path", smithy::Document(failures[i].path)); - field_list.push_back(smithy::Document(std::move(field))); + opal::DocumentMap field; + field.emplace("message", opal::Document(failures[i].message)); + field.emplace("path", opal::Document(failures[i].path)); + field_list.push_back(opal::Document(std::move(field))); } - smithy::DocumentMap body; - body.emplace("fieldList", smithy::Document(std::move(field_list))); - smithy::http::HttpResponse response = helpers::JsonError(400, "", summary, std::move(body)); + opal::DocumentMap body; + body.emplace("fieldList", opal::Document(std::move(field_list))); + opal::http::HttpResponse response = helpers::JsonError(400, "", summary, std::move(body)); response.headers.Set("x-error-type", "ValidationException"); return response; } -smithy::Outcome ParseAddBookInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseAddBookInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; types::AddBookInput input{}; - auto body_doc = smithy::json::Decode(request.body.empty() ? "{}" : request.body); + auto body_doc = opal::json::Decode(request.body.empty() ? "{}" : request.body); if (!body_doc) return std::move(body_doc).error(); - if (!body_doc->is_map()) return smithy::Error::Serialization("AddBook: expected a JSON object body"); + if (!body_doc->is_map()) return opal::Error::Serialization("AddBook: expected a JSON object body"); { - const smithy::Document* member = body_doc->Find("isbn"); + const opal::Document* member = body_doc->Find("isbn"); if (member == nullptr || member->is_null()) { helpers::AddValidationFailure(validation_failures, "/isbn", "Value at '/isbn' failed to satisfy constraint: Member must not be null"); } else { - if (!member->is_string()) return smithy::Error::Serialization("AddBookInput.isbn: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("AddBookInput.isbn: unexpected type on the wire"); input.isbn = member->as_string(); } } { - const smithy::Document* member = body_doc->Find("title"); + const opal::Document* member = body_doc->Find("title"); if (member == nullptr || member->is_null()) { helpers::AddValidationFailure(validation_failures, "/title", "Value at '/title' failed to satisfy constraint: Member must not be null"); } else { - if (!member->is_string()) return smithy::Error::Serialization("AddBookInput.title: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("AddBookInput.title: unexpected type on the wire"); input.title = member->as_string(); } } return input; } -smithy::http::HttpResponse BuildAddBookResponse(const types::AddBookOutput& output) { +opal::http::HttpResponse BuildAddBookResponse(const types::AddBookOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 201; response.status = static_cast(output.status); if (helpers::StatusAllowsContent(response.status)) { - smithy::DocumentMap body_map; - body_map.emplace("isbn", smithy::Document(output.isbn)); + opal::DocumentMap body_map; + body_map.emplace("isbn", opal::Document(output.isbn)); response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); } return response; } -smithy::Outcome ParseGetBookInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseGetBookInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -198,18 +198,18 @@ smithy::Outcome ParseGetBookInput(const smithy::http::HttpR return input; } -smithy::http::HttpResponse BuildGetBookResponse(const types::GetBookOutput& output) { +opal::http::HttpResponse BuildGetBookResponse(const types::GetBookOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; + opal::DocumentMap body_map; if (output.price.has_value()) { - body_map.emplace("price", smithy::Document(static_cast((*output.price)))); + body_map.emplace("price", opal::Document(static_cast((*output.price)))); } - body_map.emplace("isbn", smithy::Document(output.isbn)); - body_map.emplace("title", smithy::Document(output.title)); + body_map.emplace("isbn", opal::Document(output.isbn)); + body_map.emplace("title", opal::Document(output.title)); response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } @@ -217,26 +217,26 @@ smithy::http::HttpResponse BuildGetBookResponse(const types::GetBookOutput& outp } // namespace BookstoreServer::BookstoreServer(std::shared_ptr handler) - : router_(std::make_shared()) { + : router_(std::make_shared()) { // The route table is derived from the model's @http traits; conflicts are // a modeling error surfaced by Router::Add (checked at generation time in a // later phase), so registration results are intentionally discarded. - (void)router_->Add("POST", "/books", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/books", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseAddBookInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -244,22 +244,22 @@ BookstoreServer::BookstoreServer(std::shared_ptr handler) if (!outcome) return helpers::ErrorToResponse(outcome.error()); return helpers::BuildAddBookResponse(*outcome); }, "AddBook"); - (void)router_->Add("GET", "/books/{isbn}", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/books/{isbn}", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseGetBookInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -269,9 +269,9 @@ BookstoreServer::BookstoreServer(std::shared_ptr handler) }, "GetBook"); } -smithy::http::RequestHandler BookstoreServer::Handler() const { +opal::http::RequestHandler BookstoreServer::Handler() const { auto router = router_; - return [router](const smithy::http::HttpRequest& request) { return router->Route(request); }; + return [router](const opal::http::HttpRequest& request) { return router->Route(request); }; } } // namespace example::bookstore diff --git a/examples/simplerestjson/generated/tests/integration_test.cc b/examples/simplerestjson/generated/tests/integration_test.cc index 797a4495..482b90c4 100644 --- a/examples/simplerestjson/generated/tests/integration_test.cc +++ b/examples/simplerestjson/generated/tests/integration_test.cc @@ -98,22 +98,22 @@ struct Rng { class ScriptedHandler final : public BookstoreHandler { public: - smithy::Outcome AddBook(const AddBookInput& input, const smithy::server::RequestContext&) override { + opal::Outcome AddBook(const AddBookInput& input, const opal::server::RequestContext&) override { lastAddBook = input; if (nextAddBookError.has_value()) return *nextAddBookError; return nextAddBookOutput; } std::optional lastAddBook; AddBookOutput nextAddBookOutput{}; - std::optional nextAddBookError; - smithy::Outcome GetBook(const GetBookInput& input, const smithy::server::RequestContext&) override { + std::optional nextAddBookError; + opal::Outcome GetBook(const GetBookInput& input, const opal::server::RequestContext&) override { lastGetBook = input; if (nextGetBookError.has_value()) return *nextGetBookError; return nextGetBookOutput; } std::optional lastGetBook; GetBookOutput nextGetBookOutput{}; - std::optional nextGetBookError; + std::optional nextGetBookError; }; enum class TransportKind { kLoopback, kSocket }; @@ -123,14 +123,14 @@ class BookstoreIntegrationTest : public ::testing::TestWithParam void SetUp() override { handler_ = std::make_shared(); server_ = std::make_unique(handler_); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries if (GetParam() == TransportKind::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); config.http_client = loopback; } else { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(server_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } @@ -143,7 +143,7 @@ class BookstoreIntegrationTest : public ::testing::TestWithParam std::shared_ptr handler_; std::unique_ptr server_; - std::unique_ptr socket_server_; + std::unique_ptr socket_server_; std::unique_ptr client_; }; @@ -206,13 +206,13 @@ TEST_P(BookstoreIntegrationTest, GetBookMaximalRoundTrips) { TEST_P(BookstoreIntegrationTest, GetBookBookNotFoundMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const BookNotFound detail = RandomBookNotFound(rng); - smithy::Error error = smithy::Error::Modeled("BookNotFound", "integration"); + opal::Error error = opal::Error::Modeled("BookNotFound", "integration"); error.set_detail(detail); handler_->nextGetBookError = error; const GetBookInput input = RandomGetBookInput(rng); const auto outcome = client_->GetBook(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "BookNotFound"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -221,17 +221,17 @@ TEST_P(BookstoreIntegrationTest, GetBookBookNotFoundMapsAcrossTheWire) { TEST(BookstoreIntegrationUnknownMembers, AddBookToleratesUnknownResponseMembers) { auto handler = std::make_shared(); BookstoreServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *BookstoreClient::Create(std::move(config)); @@ -248,17 +248,17 @@ TEST(BookstoreIntegrationUnknownMembers, AddBookToleratesUnknownResponseMembers) TEST(BookstoreIntegrationUnknownMembers, GetBookToleratesUnknownResponseMembers) { auto handler = std::make_shared(); BookstoreServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *BookstoreClient::Create(std::move(config)); diff --git a/examples/simplerestjson/generated/tests/smoke_test.cc b/examples/simplerestjson/generated/tests/smoke_test.cc index b205f3c2..8f95995b 100644 --- a/examples/simplerestjson/generated/tests/smoke_test.cc +++ b/examples/simplerestjson/generated/tests/smoke_test.cc @@ -37,11 +37,11 @@ GetBookOutput MinimalGetBookOutput() { class SmokeHandler : public BookstoreHandler { public: - smithy::Outcome AddBook(const AddBookInput& input, const smithy::server::RequestContext&) override { + opal::Outcome AddBook(const AddBookInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalAddBookOutput(); } - smithy::Outcome GetBook(const GetBookInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetBook(const GetBookInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalGetBookOutput(); } @@ -49,9 +49,9 @@ class SmokeHandler : public BookstoreHandler { BookstoreClient MakeClient(std::shared_ptr handler) { BookstoreServer server(std::move(handler)); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = loopback; // Create cannot fail when a transport is injected. @@ -87,9 +87,9 @@ TEST(BookstoreSmokeTest, GetBookRoundTrips) { TEST(BookstoreSmokeTest, ModeledErrorsMapAcrossTheWire) { class FailingHandler final : public SmokeHandler { public: - smithy::Outcome GetBook(const GetBookInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetBook(const GetBookInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("BookNotFound", "smoke"); + opal::Error error = opal::Error::Modeled("BookNotFound", "smoke"); auto detail = [] { BookNotFound v{}; return v; @@ -109,7 +109,7 @@ TEST(BookstoreSmokeTest, ModeledErrorsMapAcrossTheWire) { input.isbn = "smoke"; const auto outcome = client.GetBook(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "BookNotFound"); EXPECT_EQ(outcome.error().message(), "smoke"); EXPECT_NE(outcome.error().detail(), nullptr); diff --git a/examples/simplerestjson/serve_main.cc b/examples/simplerestjson/serve_main.cc index 2799d7b9..7e144139 100644 --- a/examples/simplerestjson/serve_main.cc +++ b/examples/simplerestjson/serve_main.cc @@ -34,20 +34,20 @@ using example::bookstore::GetBookOutput; // on a thread pool. class InMemoryBookstore final : public BookstoreHandler { public: - smithy::Outcome AddBook( - const AddBookInput& input, const smithy::server::RequestContext& /*context*/) override { + opal::Outcome AddBook(const AddBookInput& input, + const opal::server::RequestContext& /*context*/) override { const std::lock_guard lock(mu_); titles_[input.isbn] = input.title; return AddBookOutput{.status = 201, .isbn = input.isbn}; } - smithy::Outcome GetBook( - const GetBookInput& input, const smithy::server::RequestContext& /*context*/) override { + opal::Outcome GetBook(const GetBookInput& input, + const opal::server::RequestContext& /*context*/) override { const std::lock_guard lock(mu_); const auto it = titles_.find(input.isbn); if (it == titles_.end()) { const std::string message = "no book: " + input.isbn; - smithy::Error error = smithy::Error::Modeled("BookNotFound", message); + opal::Error error = opal::Error::Modeled("BookNotFound", message); error.set_detail(BookNotFound{.message = message, .isbn = input.isbn}); return error; // the server turns this into the modeled 404 } @@ -72,12 +72,12 @@ int main(int argc, char** argv) { pthread_sigmask(SIG_BLOCK, &shutdown_signals, nullptr); BookstoreServer server(std::make_shared()); - smithy::http::BeastServerTransport transport({ + opal::http::BeastServerTransport transport({ .address = "0.0.0.0", .port = argc > 1 ? std::atoi(argv[1]) : 8080, // 0 binds an ephemeral port .drain_timeout_seconds = 10, }); - smithy::Outcome started = transport.Start(server.Handler()); + opal::Outcome started = transport.Start(server.Handler()); if (!started.ok()) { std::fprintf(stderr, "bookstore: start failed: %s\n", started.error().message().c_str()); return 1; diff --git a/examples/weather/generated/include/example/weather/client.h b/examples/weather/generated/include/example/weather/client.h index 53c79641..2f4b4e48 100644 --- a/examples/weather/generated/include/example/weather/client.h +++ b/examples/weather/generated/include/example/weather/client.h @@ -27,34 +27,34 @@ namespace example::weather { class ListCitiesPaginator; /// simpleRestJson client for example.weather#Weather. -/// Modeled service errors surface as smithy::Error with kind kModeled, +/// Modeled service errors surface as opal::Error with kind kModeled, /// code() set to the error shape name, and the deserialized error /// structure attached. Dispatch on them through the per-operation /// Errors listings below rather than comparing code() text. class WeatherClient { public: /// Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); + static opal::Outcome Create(opal::ClientConfig config); /// Deletes a city: a 204 No Content operation (the response has no body). - smithy::Outcome DeleteCity(const DeleteCityInput& input) const; - smithy::Outcome GetCity(const GetCityInput& input) const; - smithy::Outcome GetCurrentTime(const GetCurrentTimeInput& input = {}) const; - smithy::Outcome GetForecast(const GetForecastInput& input) const; + opal::Outcome DeleteCity(const DeleteCityInput& input) const; + opal::Outcome GetCity(const GetCityInput& input) const; + opal::Outcome GetCurrentTime(const GetCurrentTimeInput& input = {}) const; + opal::Outcome GetForecast(const GetForecastInput& input) const; /// Fetches a rendered report by its slash-separated path. The greedy label /// keeps embedded slashes: GET /reports/2026/q3/summary routes here with /// reportPath = "2026/q3/summary". - smithy::Outcome GetReport(const GetReportInput& input) const; - smithy::Outcome ListCities(const ListCitiesInput& input) const; + opal::Outcome GetReport(const GetReportInput& input) const; + opal::Outcome ListCities(const ListCitiesInput& input) const; /// Pages ListCities until the service stops returning a next token (@paginated). ListCitiesPaginator PaginateListCities(ListCitiesInput input) const; private: - WeatherClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix); - smithy::Outcome Send(smithy::http::HttpRequest request) const; + WeatherClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix); + opal::Outcome Send(opal::http::HttpRequest request) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; @@ -63,12 +63,12 @@ class ListCitiesPaginator { public: /// The next page, std::nullopt once pagination is complete, or the /// first failed call's error (pagination then stops). - smithy::Outcome> Next(); + opal::Outcome> Next(); using Page = ListCitiesOutput; /// Single-pass range over pages — contract in smithy/client/pagination.h. - smithy::PageIterator begin() { return smithy::PageIterator(this); } - smithy::PageIterator end() { return {}; } + opal::PageIterator begin() { return opal::PageIterator(this); } + opal::PageIterator end() { return {}; } private: friend class WeatherClient; @@ -78,7 +78,7 @@ class ListCitiesPaginator { bool done_ = false; }; -/// The modeled errors of DeleteCity, matched from a smithy::Error so dispatch is +/// The modeled errors of DeleteCity, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -89,9 +89,9 @@ class DeleteCityErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static DeleteCityErrors FromError(const smithy::Error& error) { + static DeleteCityErrors FromError(const opal::Error& error) { DeleteCityErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "NoSuchResource") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : NoSuchResource{}); @@ -130,7 +130,7 @@ class DeleteCityErrors { switch (value_.index()) { case 1: out += "no_such_resource = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -149,14 +149,14 @@ class DeleteCityErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("DeleteCityErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("DeleteCityErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of GetCity, matched from a smithy::Error so dispatch is +/// The modeled errors of GetCity, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -167,9 +167,9 @@ class GetCityErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static GetCityErrors FromError(const smithy::Error& error) { + static GetCityErrors FromError(const opal::Error& error) { GetCityErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "NoSuchResource") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : NoSuchResource{}); @@ -208,7 +208,7 @@ class GetCityErrors { switch (value_.index()) { case 1: out += "no_such_resource = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -227,14 +227,14 @@ class GetCityErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("GetCityErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("GetCityErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of GetForecast, matched from a smithy::Error so dispatch is +/// The modeled errors of GetForecast, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -245,9 +245,9 @@ class GetForecastErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static GetForecastErrors FromError(const smithy::Error& error) { + static GetForecastErrors FromError(const opal::Error& error) { GetForecastErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "NoSuchResource") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : NoSuchResource{}); @@ -286,7 +286,7 @@ class GetForecastErrors { switch (value_.index()) { case 1: out += "no_such_resource = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -305,7 +305,7 @@ class GetForecastErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("GetForecastErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("GetForecastErrors", requested, case_name()); } } @@ -322,8 +322,8 @@ template <> struct std::hash { std::size_t operator()(const example::weather::DeleteCityErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -331,8 +331,8 @@ template <> struct std::hash { std::size_t operator()(const example::weather::GetCityErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; @@ -340,8 +340,8 @@ template <> struct std::hash { std::size_t operator()(const example::weather::GetForecastErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; diff --git a/examples/weather/generated/include/example/weather/serde.h b/examples/weather/generated/include/example/weather/serde.h index 605e665b..f5c0a8b7 100644 --- a/examples/weather/generated/include/example/weather/serde.h +++ b/examples/weather/generated/include/example/weather/serde.h @@ -12,56 +12,56 @@ namespace example::weather { // Document-pivot serde for every aggregate shape in the model closure. -// Serializers never fail; deserializers return smithy::Error on wire +// Serializers never fail; deserializers return opal::Error on wire // mismatches and enforce @required members. -smithy::Document SerializeDeleteCityInput(const DeleteCityInput& value); -smithy::Outcome DeserializeDeleteCityInput(const smithy::Document& doc); +opal::Document SerializeDeleteCityInput(const DeleteCityInput& value); +opal::Outcome DeserializeDeleteCityInput(const opal::Document& doc); -smithy::Document SerializeDeleteCityOutput(const DeleteCityOutput& value); -smithy::Outcome DeserializeDeleteCityOutput(const smithy::Document& doc); +opal::Document SerializeDeleteCityOutput(const DeleteCityOutput& value); +opal::Outcome DeserializeDeleteCityOutput(const opal::Document& doc); -smithy::Document SerializeNoSuchResource(const NoSuchResource& value); -smithy::Outcome DeserializeNoSuchResource(const smithy::Document& doc); +opal::Document SerializeNoSuchResource(const NoSuchResource& value); +opal::Outcome DeserializeNoSuchResource(const opal::Document& doc); -smithy::Document SerializeGetForecastInput(const GetForecastInput& value); -smithy::Outcome DeserializeGetForecastInput(const smithy::Document& doc); +opal::Document SerializeGetForecastInput(const GetForecastInput& value); +opal::Outcome DeserializeGetForecastInput(const opal::Document& doc); -smithy::Document SerializeGetForecastOutput(const GetForecastOutput& value); -smithy::Outcome DeserializeGetForecastOutput(const smithy::Document& doc); +opal::Document SerializeGetForecastOutput(const GetForecastOutput& value); +opal::Outcome DeserializeGetForecastOutput(const opal::Document& doc); -smithy::Document SerializeGetCityInput(const GetCityInput& value); -smithy::Outcome DeserializeGetCityInput(const smithy::Document& doc); +opal::Document SerializeGetCityInput(const GetCityInput& value); +opal::Outcome DeserializeGetCityInput(const opal::Document& doc); -smithy::Document SerializeCityCoordinates(const CityCoordinates& value); -smithy::Outcome DeserializeCityCoordinates(const smithy::Document& doc); +opal::Document SerializeCityCoordinates(const CityCoordinates& value); +opal::Outcome DeserializeCityCoordinates(const opal::Document& doc); -smithy::Document SerializeGetCityOutput(const GetCityOutput& value); -smithy::Outcome DeserializeGetCityOutput(const smithy::Document& doc); +opal::Document SerializeGetCityOutput(const GetCityOutput& value); +opal::Outcome DeserializeGetCityOutput(const opal::Document& doc); -smithy::Document SerializeListCitiesInput(const ListCitiesInput& value); -smithy::Outcome DeserializeListCitiesInput(const smithy::Document& doc); +opal::Document SerializeListCitiesInput(const ListCitiesInput& value); +opal::Outcome DeserializeListCitiesInput(const opal::Document& doc); -smithy::Document SerializeCitySummary(const CitySummary& value); -smithy::Outcome DeserializeCitySummary(const smithy::Document& doc); +opal::Document SerializeCitySummary(const CitySummary& value); +opal::Outcome DeserializeCitySummary(const opal::Document& doc); -smithy::Document SerializeCitySummaries(const std::vector& value); -smithy::Outcome> DeserializeCitySummaries(const smithy::Document& doc); +opal::Document SerializeCitySummaries(const std::vector& value); +opal::Outcome> DeserializeCitySummaries(const opal::Document& doc); -smithy::Document SerializeListCitiesOutput(const ListCitiesOutput& value); -smithy::Outcome DeserializeListCitiesOutput(const smithy::Document& doc); +opal::Document SerializeListCitiesOutput(const ListCitiesOutput& value); +opal::Outcome DeserializeListCitiesOutput(const opal::Document& doc); -smithy::Document SerializeGetCurrentTimeInput(const GetCurrentTimeInput& value); -smithy::Outcome DeserializeGetCurrentTimeInput(const smithy::Document& doc); +opal::Document SerializeGetCurrentTimeInput(const GetCurrentTimeInput& value); +opal::Outcome DeserializeGetCurrentTimeInput(const opal::Document& doc); -smithy::Document SerializeGetCurrentTimeOutput(const GetCurrentTimeOutput& value); -smithy::Outcome DeserializeGetCurrentTimeOutput(const smithy::Document& doc); +opal::Document SerializeGetCurrentTimeOutput(const GetCurrentTimeOutput& value); +opal::Outcome DeserializeGetCurrentTimeOutput(const opal::Document& doc); -smithy::Document SerializeGetReportInput(const GetReportInput& value); -smithy::Outcome DeserializeGetReportInput(const smithy::Document& doc); +opal::Document SerializeGetReportInput(const GetReportInput& value); +opal::Outcome DeserializeGetReportInput(const opal::Document& doc); -smithy::Document SerializeGetReportOutput(const GetReportOutput& value); -smithy::Outcome DeserializeGetReportOutput(const smithy::Document& doc); +opal::Document SerializeGetReportOutput(const GetReportOutput& value); +opal::Outcome DeserializeGetReportOutput(const opal::Document& doc); } // namespace example::weather diff --git a/examples/weather/generated/include/example/weather/server.h b/examples/weather/generated/include/example/weather/server.h index e2a6d8fd..9e7def15 100644 --- a/examples/weather/generated/include/example/weather/server.h +++ b/examples/weather/generated/include/example/weather/server.h @@ -13,10 +13,10 @@ namespace example::weather { /// Implement one method per operation. Return a modeled error as -/// smithy::Error::Modeled("", message), optionally with the +/// opal::Error::Modeled("", message), optionally with the /// typed error structure attached via set_detail() so it serializes fully. /// The context carries the raw request and routing captures — see -/// smithy::server::RequestContext; leave the parameter unnamed when unused. +/// opal::server::RequestContext; leave the parameter unnamed when unused. /// Implementations must be thread-safe: transports may invoke any mix of /// operations concurrently on the one handler instance. class WeatherHandler { @@ -24,28 +24,28 @@ class WeatherHandler { virtual ~WeatherHandler() = default; /// Deletes a city: a 204 No Content operation (the response has no body). - virtual smithy::Outcome DeleteCity(const DeleteCityInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome GetCity(const GetCityInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome GetCurrentTime(const GetCurrentTimeInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome GetForecast(const GetForecastInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome DeleteCity(const DeleteCityInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome GetCity(const GetCityInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome GetCurrentTime(const GetCurrentTimeInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome GetForecast(const GetForecastInput& input, const opal::server::RequestContext& context) = 0; /// Fetches a rendered report by its slash-separated path. The greedy label /// keeps embedded slashes: GET /reports/2026/q3/summary routes here with /// reportPath = "2026/q3/summary". - virtual smithy::Outcome GetReport(const GetReportInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome ListCities(const ListCitiesInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome GetReport(const GetReportInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome ListCities(const ListCitiesInput& input, const opal::server::RequestContext& context) = 0; }; /// simpleRestJson server for example.weather#Weather: routing, deserialization, handler dispatch, /// response serialization, and modeled-error mapping. Pass Handler() to any -/// smithy::http::HttpServerTransport. +/// opal::http::HttpServerTransport. class WeatherServer { public: explicit WeatherServer(std::shared_ptr handler); - smithy::http::RequestHandler Handler() const; + opal::http::RequestHandler Handler() const; private: - std::shared_ptr router_; + std::shared_ptr router_; }; } // namespace example::weather diff --git a/examples/weather/generated/include/example/weather/types.h b/examples/weather/generated/include/example/weather/types.h index b3eee3d7..5e3fe0d0 100644 --- a/examples/weather/generated/include/example/weather/types.h +++ b/examples/weather/generated/include/example/weather/types.h @@ -28,7 +28,7 @@ struct DeleteCityInput { out += sep; sep = ", "; out += ".cityId = "; - smithy::DebugAppend(out, this->cityId); + opal::DebugAppend(out, this->cityId); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -68,7 +68,7 @@ struct NoSuchResource { out += sep; sep = ", "; out += ".resourceType = "; - smithy::DebugAppend(out, this->resourceType); + opal::DebugAppend(out, this->resourceType); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -91,7 +91,7 @@ struct GetForecastInput { out += sep; sep = ", "; out += ".cityId = "; - smithy::DebugAppend(out, this->cityId); + opal::DebugAppend(out, this->cityId); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -115,7 +115,7 @@ struct GetForecastOutput { out += sep; sep = ", "; out += ".chanceOfRain = "; - smithy::DebugAppend(out, *this->chanceOfRain); + opal::DebugAppend(out, *this->chanceOfRain); } out += '}'; } @@ -139,7 +139,7 @@ struct GetCityInput { out += sep; sep = ", "; out += ".cityId = "; - smithy::DebugAppend(out, this->cityId); + opal::DebugAppend(out, this->cityId); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -163,11 +163,11 @@ struct CityCoordinates { out += sep; sep = ", "; out += ".latitude = "; - smithy::DebugAppend(out, this->latitude); + opal::DebugAppend(out, this->latitude); out += sep; sep = ", "; out += ".longitude = "; - smithy::DebugAppend(out, this->longitude); + opal::DebugAppend(out, this->longitude); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -191,11 +191,11 @@ struct GetCityOutput { out += sep; sep = ", "; out += ".name = "; - smithy::DebugAppend(out, this->name); + opal::DebugAppend(out, this->name); out += sep; sep = ", "; out += ".coordinates = "; - smithy::DebugAppend(out, this->coordinates); + opal::DebugAppend(out, this->coordinates); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -220,13 +220,13 @@ struct ListCitiesInput { out += sep; sep = ", "; out += ".nextToken = "; - smithy::DebugAppend(out, *this->nextToken); + opal::DebugAppend(out, *this->nextToken); } if (this->pageSize.has_value()) { out += sep; sep = ", "; out += ".pageSize = "; - smithy::DebugAppend(out, *this->pageSize); + opal::DebugAppend(out, *this->pageSize); } out += '}'; } @@ -251,11 +251,11 @@ struct CitySummary { out += sep; sep = ", "; out += ".cityId = "; - smithy::DebugAppend(out, this->cityId); + opal::DebugAppend(out, this->cityId); out += sep; sep = ", "; out += ".name = "; - smithy::DebugAppend(out, this->name); + opal::DebugAppend(out, this->name); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -280,12 +280,12 @@ struct ListCitiesOutput { out += sep; sep = ", "; out += ".nextToken = "; - smithy::DebugAppend(out, *this->nextToken); + opal::DebugAppend(out, *this->nextToken); } out += sep; sep = ", "; out += ".items = "; - smithy::DebugAppend(out, this->items); + opal::DebugAppend(out, this->items); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -315,7 +315,7 @@ struct GetCurrentTimeInput { struct GetCurrentTimeOutput { - smithy::Timestamp time{}; + opal::Timestamp time{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -324,7 +324,7 @@ struct GetCurrentTimeOutput { out += sep; sep = ", "; out += ".time = "; - smithy::DebugAppend(out, this->time); + opal::DebugAppend(out, this->time); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -347,7 +347,7 @@ struct GetReportInput { out += sep; sep = ", "; out += ".reportPath = "; - smithy::DebugAppend(out, this->reportPath); + opal::DebugAppend(out, this->reportPath); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -371,11 +371,11 @@ struct GetReportOutput { out += sep; sep = ", "; out += ".path = "; - smithy::DebugAppend(out, this->path); + opal::DebugAppend(out, this->path); out += sep; sep = ", "; out += ".sizeBytes = "; - smithy::DebugAppend(out, this->sizeBytes); + opal::DebugAppend(out, this->sizeBytes); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -397,7 +397,7 @@ template <> struct std::hash { std::size_t operator()(const example::weather::DeleteCityInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.cityId)); + seed = opal::HashCombine(seed, opal::HashValue(value.cityId)); return seed; } }; @@ -411,7 +411,7 @@ template <> struct std::hash { std::size_t operator()(const example::weather::NoSuchResource& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.resourceType)); + seed = opal::HashCombine(seed, opal::HashValue(value.resourceType)); return seed; } }; @@ -420,7 +420,7 @@ template <> struct std::hash { std::size_t operator()(const example::weather::GetForecastInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.cityId)); + seed = opal::HashCombine(seed, opal::HashValue(value.cityId)); return seed; } }; @@ -429,7 +429,7 @@ template <> struct std::hash { std::size_t operator()(const example::weather::GetForecastOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.chanceOfRain)); + seed = opal::HashCombine(seed, opal::HashValue(value.chanceOfRain)); return seed; } }; @@ -438,7 +438,7 @@ template <> struct std::hash { std::size_t operator()(const example::weather::GetCityInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.cityId)); + seed = opal::HashCombine(seed, opal::HashValue(value.cityId)); return seed; } }; @@ -447,8 +447,8 @@ template <> struct std::hash { std::size_t operator()(const example::weather::CityCoordinates& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.latitude)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.longitude)); + seed = opal::HashCombine(seed, opal::HashValue(value.latitude)); + seed = opal::HashCombine(seed, opal::HashValue(value.longitude)); return seed; } }; @@ -457,8 +457,8 @@ template <> struct std::hash { std::size_t operator()(const example::weather::GetCityOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.name)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.coordinates)); + seed = opal::HashCombine(seed, opal::HashValue(value.name)); + seed = opal::HashCombine(seed, opal::HashValue(value.coordinates)); return seed; } }; @@ -467,8 +467,8 @@ template <> struct std::hash { std::size_t operator()(const example::weather::ListCitiesInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.nextToken)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.pageSize)); + seed = opal::HashCombine(seed, opal::HashValue(value.nextToken)); + seed = opal::HashCombine(seed, opal::HashValue(value.pageSize)); return seed; } }; @@ -477,8 +477,8 @@ template <> struct std::hash { std::size_t operator()(const example::weather::CitySummary& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.cityId)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.name)); + seed = opal::HashCombine(seed, opal::HashValue(value.cityId)); + seed = opal::HashCombine(seed, opal::HashValue(value.name)); return seed; } }; @@ -487,8 +487,8 @@ template <> struct std::hash { std::size_t operator()(const example::weather::ListCitiesOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.nextToken)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.items)); + seed = opal::HashCombine(seed, opal::HashValue(value.nextToken)); + seed = opal::HashCombine(seed, opal::HashValue(value.items)); return seed; } }; @@ -502,7 +502,7 @@ template <> struct std::hash { std::size_t operator()(const example::weather::GetCurrentTimeOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.time)); + seed = opal::HashCombine(seed, opal::HashValue(value.time)); return seed; } }; @@ -511,7 +511,7 @@ template <> struct std::hash { std::size_t operator()(const example::weather::GetReportInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.reportPath)); + seed = opal::HashCombine(seed, opal::HashValue(value.reportPath)); return seed; } }; @@ -520,8 +520,8 @@ template <> struct std::hash { std::size_t operator()(const example::weather::GetReportOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.path)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sizeBytes)); + seed = opal::HashCombine(seed, opal::HashValue(value.path)); + seed = opal::HashCombine(seed, opal::HashValue(value.sizeBytes)); return seed; } }; diff --git a/examples/weather/generated/src/client.cc b/examples/weather/generated/src/client.cc index 74c49a37..e4d82ea5 100644 --- a/examples/weather/generated/src/client.cc +++ b/examples/weather/generated/src/client.cc @@ -38,51 +38,51 @@ struct ParsedError { int status = 0; std::string code = "UnknownError"; std::string message; - smithy::Document doc; + opal::Document doc; }; // [[maybe_unused]]: only unary response paths parse wire errors; a // service whose operations all stream never calls this. -[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) { +[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) { ParsedError parsed; parsed.status = response.status; parsed.message = "HTTP " + std::to_string(response.status); - auto doc = smithy::json::Decode(response.body); + auto doc = opal::json::Decode(response.body); if (doc.ok()) parsed.doc = *std::move(doc); const auto type_header = response.headers.Get("x-error-type"); if (type_header.has_value()) parsed.code = helpers::SanitizeErrorCode(*type_header); if (parsed.doc.is_map()) { - const smithy::Document* type = parsed.doc.Find("__type"); + const opal::Document* type = parsed.doc.Find("__type"); if (type == nullptr) type = parsed.doc.Find("code"); if (parsed.code == "UnknownError" && type != nullptr && type->is_string()) parsed.code = helpers::SanitizeErrorCode(type->as_string()); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } return parsed; } -smithy::Error GenericError(ParsedError parsed) { +opal::Error GenericError(ParsedError parsed) { const bool retryable = parsed.status >= 500; - if (parsed.code == "UnknownError") return smithy::Error(smithy::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); - return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); + if (parsed.code == "UnknownError") return opal::Error(opal::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); + return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); } // Strict text parsing for label/query/header bindings ([[maybe_unused]]: // emitted for every service; not every service binds numeric values). // Trailing text, floats-for-ints, and out-of-range values are rejected // (the malformed-request suites pin this). -[[maybe_unused]] smithy::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { +[[maybe_unused]] opal::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { std::int64_t value = 0; const char* first = text.data(); const char* last = first + text.size(); const auto result = std::from_chars(first, last, value, 10); if (text.empty() || result.ec != std::errc() || result.ptr != last || value < min_value || value > max_value) { - return smithy::Error::Serialization("invalid integer: " + text); + return opal::Error::Serialization("invalid integer: " + text); } return value; } -[[maybe_unused]] smithy::Outcome ParseDoubleText(const std::string& text) { +[[maybe_unused]] opal::Outcome ParseDoubleText(const std::string& text) { if (text == "NaN") return std::numeric_limits::quiet_NaN(); if (text == "Infinity") return std::numeric_limits::infinity(); if (text == "-Infinity") return -std::numeric_limits::infinity(); @@ -90,21 +90,21 @@ smithy::Error GenericError(ParsedError parsed) { return (c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' || c == '+' || c == '-'; }; if (text.empty() || text.front() == '+' || !std::all_of(text.begin(), text.end(), valid_char)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } char* parse_end = nullptr; const double value = std::strtod(text.c_str(), &parse_end); if (parse_end != text.c_str() + text.size() || !std::isfinite(value)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } return value; } -smithy::Error MakeNoSuchResourceError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeNoSuchResourceError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("NoSuchResource", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("NoSuchResource", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeNoSuchResource(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -112,21 +112,21 @@ smithy::Error MakeNoSuchResourceError(const smithy::http::HttpResponse& response return error; } -smithy::Error ParseDeleteCityError(const smithy::http::HttpResponse& response) { +opal::Error ParseDeleteCityError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "NoSuchResource") return helpers::MakeNoSuchResourceError(response, std::move(parsed)); if (parsed.code == "UnknownError" && parsed.status == 404) return helpers::MakeNoSuchResourceError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseGetCityError(const smithy::http::HttpResponse& response) { +opal::Error ParseGetCityError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "NoSuchResource") return helpers::MakeNoSuchResourceError(response, std::move(parsed)); if (parsed.code == "UnknownError" && parsed.status == 404) return helpers::MakeNoSuchResourceError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseGetForecastError(const smithy::http::HttpResponse& response) { +opal::Error ParseGetForecastError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "NoSuchResource") return helpers::MakeNoSuchResourceError(response, std::move(parsed)); if (parsed.code == "UnknownError" && parsed.status == 404) return helpers::MakeNoSuchResourceError(response, std::move(parsed)); @@ -136,34 +136,34 @@ smithy::Error ParseGetForecastError(const smithy::http::HttpResponse& response) } // namespace helpers } // namespace -smithy::Outcome WeatherClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome WeatherClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { // The built-in socket transport is plaintext-only; https needs a - // TLS-capable transport (e.g. smithy::http::BeastHttpClient). + // TLS-capable transport (e.g. opal::http::BeastHttpClient). if (endpoint->tls()) { - return smithy::Error::Validation("WeatherClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + return opal::Error::Validation("WeatherClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); } - transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); } } if (transport == nullptr) { - return smithy::Error::Validation("WeatherClient: config needs an endpoint or an http_client"); + return opal::Error::Validation("WeatherClient: config needs an endpoint or an http_client"); } return WeatherClient(std::move(config), std::move(transport), std::move(prefix)); } -WeatherClient::WeatherClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix) +WeatherClient::WeatherClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} -smithy::Outcome WeatherClient::Send(smithy::http::HttpRequest request) const { +opal::Outcome WeatherClient::Send(opal::http::HttpRequest request) const { // Operations with a non-document response payload set their own accept. if (!request.headers.Get("accept").has_value()) request.headers.Set("accept", "application/json"); request.headers.Set("user-agent", config_.user_agent); @@ -174,15 +174,15 @@ smithy::Outcome WeatherClient::Send(smithy::http::Ht if (!request.body.empty()) { request.headers.Set("content-length", std::to_string(request.body.size())); } - return smithy::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); + return opal::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); } -smithy::Outcome WeatherClient::DeleteCity(const DeleteCityInput& input) const { +opal::Outcome WeatherClient::DeleteCity(const DeleteCityInput& input) const { std::string target = path_prefix_; target += "/cities"; target += "/"; - target += smithy::http::EncodePathSegment(input.cityId); - smithy::http::HttpRequest request; + target += opal::http::EncodePathSegment(input.cityId); + opal::http::HttpRequest request; request.method = "DELETE"; request.target = std::move(target); auto response = Send(std::move(request)); @@ -191,75 +191,75 @@ smithy::Outcome WeatherClient::DeleteCity(const DeleteCityInpu return DeleteCityOutput{}; } -smithy::Outcome WeatherClient::GetCity(const GetCityInput& input) const { +opal::Outcome WeatherClient::GetCity(const GetCityInput& input) const { std::string target = path_prefix_; target += "/cities"; target += "/"; - target += smithy::http::EncodePathSegment(input.cityId); - smithy::http::HttpRequest request; + target += opal::http::EncodePathSegment(input.cityId); + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseGetCityError(*response); - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializeGetCityOutput(*body_doc); } -smithy::Outcome WeatherClient::GetCurrentTime(const GetCurrentTimeInput& input) const { +opal::Outcome WeatherClient::GetCurrentTime(const GetCurrentTimeInput& input) const { (void)input; std::string target = path_prefix_; target += "/current-time"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializeGetCurrentTimeOutput(*body_doc); } -smithy::Outcome WeatherClient::GetForecast(const GetForecastInput& input) const { +opal::Outcome WeatherClient::GetForecast(const GetForecastInput& input) const { std::string target = path_prefix_; target += "/cities"; target += "/"; - target += smithy::http::EncodePathSegment(input.cityId); + target += opal::http::EncodePathSegment(input.cityId); target += "/forecast"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseGetForecastError(*response); if (response->body.empty()) return GetForecastOutput{}; - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializeGetForecastOutput(*body_doc); } -smithy::Outcome WeatherClient::GetReport(const GetReportInput& input) const { +opal::Outcome WeatherClient::GetReport(const GetReportInput& input) const { std::string target = path_prefix_; target += "/reports"; target += "/"; - target += smithy::http::EncodeGreedyPathSegment(input.reportPath); - smithy::http::HttpRequest request; + target += opal::http::EncodeGreedyPathSegment(input.reportPath); + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializeGetReportOutput(*body_doc); } -smithy::Outcome WeatherClient::ListCities(const ListCitiesInput& input) const { +opal::Outcome WeatherClient::ListCities(const ListCitiesInput& input) const { std::string target = path_prefix_; target += "/cities"; - smithy::http::QueryString query; + opal::http::QueryString query; if (input.nextToken.has_value()) { query.Add("nextToken", (*input.nextToken)); } @@ -267,13 +267,13 @@ smithy::Outcome WeatherClient::ListCities(const ListCitiesInpu query.Add("pageSize", std::to_string(static_cast((*input.pageSize)))); } target += query.ToString(); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializeListCitiesOutput(*body_doc); } @@ -282,7 +282,7 @@ ListCitiesPaginator WeatherClient::PaginateListCities(ListCitiesInput input) con return ListCitiesPaginator(*this, std::move(input)); } -smithy::Outcome> ListCitiesPaginator::Next() { +opal::Outcome> ListCitiesPaginator::Next() { if (done_) return std::optional(); auto page = client_.ListCities(input_); if (!page) { diff --git a/examples/weather/generated/src/serde.cc b/examples/weather/generated/src/serde.cc index 83e027b0..01f1ec8e 100644 --- a/examples/weather/generated/src/serde.cc +++ b/examples/weather/generated/src/serde.cc @@ -8,97 +8,97 @@ namespace example::weather { -smithy::Document SerializeDeleteCityInput(const DeleteCityInput& value) { - smithy::DocumentMap map; - map.emplace("cityId", smithy::Document(value.cityId)); - return smithy::Document(std::move(map)); +opal::Document SerializeDeleteCityInput(const DeleteCityInput& value) { + opal::DocumentMap map; + map.emplace("cityId", opal::Document(value.cityId)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeDeleteCityInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("DeleteCityInput: expected a map on the wire"); +opal::Outcome DeserializeDeleteCityInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("DeleteCityInput: expected a map on the wire"); DeleteCityInput out; { - const smithy::Document* member = doc.Find("cityId"); + const opal::Document* member = doc.Find("cityId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("DeleteCityInput: missing required member: cityId"); + return opal::Error::Serialization("DeleteCityInput: missing required member: cityId"); } - if (!member->is_string()) return smithy::Error::Serialization("DeleteCityInput.cityId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("DeleteCityInput.cityId: unexpected type on the wire"); out.cityId = member->as_string(); } return out; } -smithy::Document SerializeDeleteCityOutput(const DeleteCityOutput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeDeleteCityOutput(const DeleteCityOutput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeDeleteCityOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("DeleteCityOutput: expected a map on the wire"); +opal::Outcome DeserializeDeleteCityOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("DeleteCityOutput: expected a map on the wire"); DeleteCityOutput out; return out; } -smithy::Document SerializeNoSuchResource(const NoSuchResource& value) { - smithy::DocumentMap map; - map.emplace("resourceType", smithy::Document(value.resourceType)); - return smithy::Document(std::move(map)); +opal::Document SerializeNoSuchResource(const NoSuchResource& value) { + opal::DocumentMap map; + map.emplace("resourceType", opal::Document(value.resourceType)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNoSuchResource(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("NoSuchResource: expected a map on the wire"); +opal::Outcome DeserializeNoSuchResource(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("NoSuchResource: expected a map on the wire"); NoSuchResource out; { - const smithy::Document* member = doc.Find("resourceType"); + const opal::Document* member = doc.Find("resourceType"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("NoSuchResource: missing required member: resourceType"); + return opal::Error::Serialization("NoSuchResource: missing required member: resourceType"); } - if (!member->is_string()) return smithy::Error::Serialization("NoSuchResource.resourceType: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("NoSuchResource.resourceType: unexpected type on the wire"); out.resourceType = member->as_string(); } return out; } -smithy::Document SerializeGetForecastInput(const GetForecastInput& value) { - smithy::DocumentMap map; - map.emplace("cityId", smithy::Document(value.cityId)); - return smithy::Document(std::move(map)); +opal::Document SerializeGetForecastInput(const GetForecastInput& value) { + opal::DocumentMap map; + map.emplace("cityId", opal::Document(value.cityId)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetForecastInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetForecastInput: expected a map on the wire"); +opal::Outcome DeserializeGetForecastInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetForecastInput: expected a map on the wire"); GetForecastInput out; { - const smithy::Document* member = doc.Find("cityId"); + const opal::Document* member = doc.Find("cityId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetForecastInput: missing required member: cityId"); + return opal::Error::Serialization("GetForecastInput: missing required member: cityId"); } - if (!member->is_string()) return smithy::Error::Serialization("GetForecastInput.cityId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetForecastInput.cityId: unexpected type on the wire"); out.cityId = member->as_string(); } return out; } -smithy::Document SerializeGetForecastOutput(const GetForecastOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeGetForecastOutput(const GetForecastOutput& value) { + opal::DocumentMap map; if (value.chanceOfRain.has_value()) { - map.emplace("chanceOfRain", smithy::Document(static_cast((*value.chanceOfRain)))); + map.emplace("chanceOfRain", opal::Document(static_cast((*value.chanceOfRain)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetForecastOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetForecastOutput: expected a map on the wire"); +opal::Outcome DeserializeGetForecastOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetForecastOutput: expected a map on the wire"); GetForecastOutput out; { - const smithy::Document* member = doc.Find("chanceOfRain"); + const opal::Document* member = doc.Find("chanceOfRain"); if (member != nullptr && !member->is_null()) { float parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("GetForecastOutput.chanceOfRain: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("GetForecastOutput.chanceOfRain: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("GetForecastOutput.chanceOfRain: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("GetForecastOutput.chanceOfRain: value out of range"); parsed_member = *narrowed; } out.chanceOfRain = std::move(parsed_member); @@ -107,87 +107,87 @@ smithy::Outcome DeserializeGetForecastOutput(const smithy::Do return out; } -smithy::Document SerializeGetCityInput(const GetCityInput& value) { - smithy::DocumentMap map; - map.emplace("cityId", smithy::Document(value.cityId)); - return smithy::Document(std::move(map)); +opal::Document SerializeGetCityInput(const GetCityInput& value) { + opal::DocumentMap map; + map.emplace("cityId", opal::Document(value.cityId)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetCityInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetCityInput: expected a map on the wire"); +opal::Outcome DeserializeGetCityInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetCityInput: expected a map on the wire"); GetCityInput out; { - const smithy::Document* member = doc.Find("cityId"); + const opal::Document* member = doc.Find("cityId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetCityInput: missing required member: cityId"); + return opal::Error::Serialization("GetCityInput: missing required member: cityId"); } - if (!member->is_string()) return smithy::Error::Serialization("GetCityInput.cityId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetCityInput.cityId: unexpected type on the wire"); out.cityId = member->as_string(); } return out; } -smithy::Document SerializeCityCoordinates(const CityCoordinates& value) { - smithy::DocumentMap map; - map.emplace("latitude", smithy::Document(static_cast(value.latitude))); - map.emplace("longitude", smithy::Document(static_cast(value.longitude))); - return smithy::Document(std::move(map)); +opal::Document SerializeCityCoordinates(const CityCoordinates& value) { + opal::DocumentMap map; + map.emplace("latitude", opal::Document(static_cast(value.latitude))); + map.emplace("longitude", opal::Document(static_cast(value.longitude))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeCityCoordinates(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("CityCoordinates: expected a map on the wire"); +opal::Outcome DeserializeCityCoordinates(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("CityCoordinates: expected a map on the wire"); CityCoordinates out; { - const smithy::Document* member = doc.Find("latitude"); + const opal::Document* member = doc.Find("latitude"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("CityCoordinates: missing required member: latitude"); + return opal::Error::Serialization("CityCoordinates: missing required member: latitude"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("CityCoordinates.latitude: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("CityCoordinates.latitude: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("CityCoordinates.latitude: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("CityCoordinates.latitude: value out of range"); out.latitude = *narrowed; } } { - const smithy::Document* member = doc.Find("longitude"); + const opal::Document* member = doc.Find("longitude"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("CityCoordinates: missing required member: longitude"); + return opal::Error::Serialization("CityCoordinates: missing required member: longitude"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("CityCoordinates.longitude: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("CityCoordinates.longitude: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("CityCoordinates.longitude: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("CityCoordinates.longitude: value out of range"); out.longitude = *narrowed; } } return out; } -smithy::Document SerializeGetCityOutput(const GetCityOutput& value) { - smithy::DocumentMap map; - map.emplace("name", smithy::Document(value.name)); +opal::Document SerializeGetCityOutput(const GetCityOutput& value) { + opal::DocumentMap map; + map.emplace("name", opal::Document(value.name)); map.emplace("coordinates", SerializeCityCoordinates(value.coordinates)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetCityOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetCityOutput: expected a map on the wire"); +opal::Outcome DeserializeGetCityOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetCityOutput: expected a map on the wire"); GetCityOutput out; { - const smithy::Document* member = doc.Find("name"); + const opal::Document* member = doc.Find("name"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetCityOutput: missing required member: name"); + return opal::Error::Serialization("GetCityOutput: missing required member: name"); } - if (!member->is_string()) return smithy::Error::Serialization("GetCityOutput.name: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetCityOutput.name: unexpected type on the wire"); out.name = member->as_string(); } { - const smithy::Document* member = doc.Find("coordinates"); + const opal::Document* member = doc.Find("coordinates"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetCityOutput: missing required member: coordinates"); + return opal::Error::Serialization("GetCityOutput: missing required member: coordinates"); } { auto parsed = DeserializeCityCoordinates(*member); @@ -198,35 +198,35 @@ smithy::Outcome DeserializeGetCityOutput(const smithy::Document& return out; } -smithy::Document SerializeListCitiesInput(const ListCitiesInput& value) { - smithy::DocumentMap map; +opal::Document SerializeListCitiesInput(const ListCitiesInput& value) { + opal::DocumentMap map; if (value.nextToken.has_value()) { - map.emplace("nextToken", smithy::Document((*value.nextToken))); + map.emplace("nextToken", opal::Document((*value.nextToken))); } if (value.pageSize.has_value()) { - map.emplace("pageSize", smithy::Document(static_cast((*value.pageSize)))); + map.emplace("pageSize", opal::Document(static_cast((*value.pageSize)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeListCitiesInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ListCitiesInput: expected a map on the wire"); +opal::Outcome DeserializeListCitiesInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ListCitiesInput: expected a map on the wire"); ListCitiesInput out; { - const smithy::Document* member = doc.Find("nextToken"); + const opal::Document* member = doc.Find("nextToken"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("ListCitiesInput.nextToken: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ListCitiesInput.nextToken: unexpected type on the wire"); parsed_member = member->as_string(); out.nextToken = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("pageSize"); + const opal::Document* member = doc.Find("pageSize"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("ListCitiesInput.pageSize: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("ListCitiesInput.pageSize: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("ListCitiesInput.pageSize: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("ListCitiesInput.pageSize: value out of range"); parsed_member = static_cast(member->as_int()); out.pageSize = std::move(parsed_member); } @@ -234,51 +234,51 @@ smithy::Outcome DeserializeListCitiesInput(const smithy::Docume return out; } -smithy::Document SerializeCitySummary(const CitySummary& value) { - smithy::DocumentMap map; - map.emplace("cityId", smithy::Document(value.cityId)); - map.emplace("name", smithy::Document(value.name)); - return smithy::Document(std::move(map)); +opal::Document SerializeCitySummary(const CitySummary& value) { + opal::DocumentMap map; + map.emplace("cityId", opal::Document(value.cityId)); + map.emplace("name", opal::Document(value.name)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeCitySummary(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("CitySummary: expected a map on the wire"); +opal::Outcome DeserializeCitySummary(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("CitySummary: expected a map on the wire"); CitySummary out; { - const smithy::Document* member = doc.Find("cityId"); + const opal::Document* member = doc.Find("cityId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("CitySummary: missing required member: cityId"); + return opal::Error::Serialization("CitySummary: missing required member: cityId"); } - if (!member->is_string()) return smithy::Error::Serialization("CitySummary.cityId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("CitySummary.cityId: unexpected type on the wire"); out.cityId = member->as_string(); } { - const smithy::Document* member = doc.Find("name"); + const opal::Document* member = doc.Find("name"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("CitySummary: missing required member: name"); + return opal::Error::Serialization("CitySummary: missing required member: name"); } - if (!member->is_string()) return smithy::Error::Serialization("CitySummary.name: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("CitySummary.name: unexpected type on the wire"); out.name = member->as_string(); } return out; } -smithy::Document SerializeCitySummaries(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeCitySummaries(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { list.push_back(SerializeCitySummary(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeCitySummaries(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeCitySummaries(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); CitySummary parsed_item{}; { auto parsed = DeserializeCitySummary(*item); @@ -290,31 +290,31 @@ smithy::Outcome> DeserializeCitySummaries(const smithy: return out; } -smithy::Document SerializeListCitiesOutput(const ListCitiesOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeListCitiesOutput(const ListCitiesOutput& value) { + opal::DocumentMap map; if (value.nextToken.has_value()) { - map.emplace("nextToken", smithy::Document((*value.nextToken))); + map.emplace("nextToken", opal::Document((*value.nextToken))); } map.emplace("items", SerializeCitySummaries(value.items)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeListCitiesOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ListCitiesOutput: expected a map on the wire"); +opal::Outcome DeserializeListCitiesOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ListCitiesOutput: expected a map on the wire"); ListCitiesOutput out; { - const smithy::Document* member = doc.Find("nextToken"); + const opal::Document* member = doc.Find("nextToken"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("ListCitiesOutput.nextToken: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ListCitiesOutput.nextToken: unexpected type on the wire"); parsed_member = member->as_string(); out.nextToken = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("items"); + const opal::Document* member = doc.Find("items"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("ListCitiesOutput: missing required member: items"); + return opal::Error::Serialization("ListCitiesOutput: missing required member: items"); } { auto parsed = DeserializeCitySummaries(*member); @@ -325,33 +325,33 @@ smithy::Outcome DeserializeListCitiesOutput(const smithy::Docu return out; } -smithy::Document SerializeGetCurrentTimeInput(const GetCurrentTimeInput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeGetCurrentTimeInput(const GetCurrentTimeInput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetCurrentTimeInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetCurrentTimeInput: expected a map on the wire"); +opal::Outcome DeserializeGetCurrentTimeInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetCurrentTimeInput: expected a map on the wire"); GetCurrentTimeInput out; return out; } -smithy::Document SerializeGetCurrentTimeOutput(const GetCurrentTimeOutput& value) { - smithy::DocumentMap map; - map.emplace("time", smithy::Document::FromTimestamp(value.time, smithy::TimestampFormat::kEpochSeconds)); - return smithy::Document(std::move(map)); +opal::Document SerializeGetCurrentTimeOutput(const GetCurrentTimeOutput& value) { + opal::DocumentMap map; + map.emplace("time", opal::Document::FromTimestamp(value.time, opal::TimestampFormat::kEpochSeconds)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetCurrentTimeOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetCurrentTimeOutput: expected a map on the wire"); +opal::Outcome DeserializeGetCurrentTimeOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetCurrentTimeOutput: expected a map on the wire"); GetCurrentTimeOutput out; { - const smithy::Document* member = doc.Find("time"); + const opal::Document* member = doc.Find("time"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetCurrentTimeOutput: missing required member: time"); + return opal::Error::Serialization("GetCurrentTimeOutput: missing required member: time"); } { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kEpochSeconds); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kEpochSeconds); if (!parsed) return std::move(parsed).error(); out.time = *parsed; } @@ -359,50 +359,50 @@ smithy::Outcome DeserializeGetCurrentTimeOutput(const smit return out; } -smithy::Document SerializeGetReportInput(const GetReportInput& value) { - smithy::DocumentMap map; - map.emplace("reportPath", smithy::Document(value.reportPath)); - return smithy::Document(std::move(map)); +opal::Document SerializeGetReportInput(const GetReportInput& value) { + opal::DocumentMap map; + map.emplace("reportPath", opal::Document(value.reportPath)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetReportInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetReportInput: expected a map on the wire"); +opal::Outcome DeserializeGetReportInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetReportInput: expected a map on the wire"); GetReportInput out; { - const smithy::Document* member = doc.Find("reportPath"); + const opal::Document* member = doc.Find("reportPath"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetReportInput: missing required member: reportPath"); + return opal::Error::Serialization("GetReportInput: missing required member: reportPath"); } - if (!member->is_string()) return smithy::Error::Serialization("GetReportInput.reportPath: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetReportInput.reportPath: unexpected type on the wire"); out.reportPath = member->as_string(); } return out; } -smithy::Document SerializeGetReportOutput(const GetReportOutput& value) { - smithy::DocumentMap map; - map.emplace("path", smithy::Document(value.path)); - map.emplace("sizeBytes", smithy::Document(static_cast(value.sizeBytes))); - return smithy::Document(std::move(map)); +opal::Document SerializeGetReportOutput(const GetReportOutput& value) { + opal::DocumentMap map; + map.emplace("path", opal::Document(value.path)); + map.emplace("sizeBytes", opal::Document(static_cast(value.sizeBytes))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetReportOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetReportOutput: expected a map on the wire"); +opal::Outcome DeserializeGetReportOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetReportOutput: expected a map on the wire"); GetReportOutput out; { - const smithy::Document* member = doc.Find("path"); + const opal::Document* member = doc.Find("path"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetReportOutput: missing required member: path"); + return opal::Error::Serialization("GetReportOutput: missing required member: path"); } - if (!member->is_string()) return smithy::Error::Serialization("GetReportOutput.path: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetReportOutput.path: unexpected type on the wire"); out.path = member->as_string(); } { - const smithy::Document* member = doc.Find("sizeBytes"); + const opal::Document* member = doc.Find("sizeBytes"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetReportOutput: missing required member: sizeBytes"); + return opal::Error::Serialization("GetReportOutput: missing required member: sizeBytes"); } - if (!member->is_int()) return smithy::Error::Serialization("GetReportOutput.sizeBytes: unexpected type on the wire"); + if (!member->is_int()) return opal::Error::Serialization("GetReportOutput.sizeBytes: unexpected type on the wire"); out.sizeBytes = static_cast(member->as_int()); } return out; diff --git a/examples/weather/generated/src/server.cc b/examples/weather/generated/src/server.cc index 46c770eb..f94552b7 100644 --- a/examples/weather/generated/src/server.cc +++ b/examples/weather/generated/src/server.cc @@ -35,18 +35,18 @@ namespace helpers { // emitted for every service; not every service binds numeric values). // Trailing text, floats-for-ints, and out-of-range values are rejected // (the malformed-request suites pin this). -[[maybe_unused]] smithy::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { +[[maybe_unused]] opal::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { std::int64_t value = 0; const char* first = text.data(); const char* last = first + text.size(); const auto result = std::from_chars(first, last, value, 10); if (text.empty() || result.ec != std::errc() || result.ptr != last || value < min_value || value > max_value) { - return smithy::Error::Serialization("invalid integer: " + text); + return opal::Error::Serialization("invalid integer: " + text); } return value; } -[[maybe_unused]] smithy::Outcome ParseDoubleText(const std::string& text) { +[[maybe_unused]] opal::Outcome ParseDoubleText(const std::string& text) { if (text == "NaN") return std::numeric_limits::quiet_NaN(); if (text == "Infinity") return std::numeric_limits::infinity(); if (text == "-Infinity") return -std::numeric_limits::infinity(); @@ -54,12 +54,12 @@ namespace helpers { return (c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' || c == '+' || c == '-'; }; if (text.empty() || text.front() == '+' || !std::all_of(text.begin(), text.end(), valid_char)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } char* parse_end = nullptr; const double value = std::strtod(text.c_str(), &parse_end); if (parse_end != text.c_str() + text.size() || !std::isfinite(value)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } return value; } @@ -70,31 +70,31 @@ namespace helpers { return status >= 200 && status != 204 && status != 205 && status != 304; } -smithy::http::HttpResponse JsonError(int status, const std::string& code, const std::string& message, smithy::DocumentMap body) { - if (!code.empty()) body.insert_or_assign("__type", smithy::Document(code)); - if (!message.empty()) body.insert_or_assign("message", smithy::Document(message)); - smithy::http::HttpResponse response; +opal::http::HttpResponse JsonError(int status, const std::string& code, const std::string& message, opal::DocumentMap body) { + if (!code.empty()) body.insert_or_assign("__type", opal::Document(code)); + if (!message.empty()) body.insert_or_assign("message", opal::Document(message)); + opal::http::HttpResponse response; response.status = status; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body))); + response.body = opal::json::Encode(opal::Document(std::move(body))); return response; } // [[maybe_unused]]: only unary routes map handler errors here; a service // whose operations all stream reports errors on the stream instead. -[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& error) { +[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& error) { std::vector> header_values; (void)header_values; - if (error.kind() == smithy::ErrorKind::kModeled) { + if (error.kind() == opal::ErrorKind::kModeled) { if (error.code() == "NoSuchResource") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeNoSuchResource(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } auto response = helpers::JsonError(404, "", "", std::move(body)); response.headers.Set("x-error-type", error.code()); @@ -103,7 +103,7 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const } return helpers::JsonError(400, error.code(), error.message(), {}); } - if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) { + if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) { auto response = helpers::JsonError(400, "", error.message(), {}); response.headers.Set("x-error-type", "SerializationException"); return response; @@ -114,34 +114,34 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const // Constraint validation (smithy.framework#ValidationException): messages // and '/member' paths follow the official validation conformance suite. -void AddValidationFailure(std::vector* failures, std::string path, std::string message) { +void AddValidationFailure(std::vector* failures, std::string path, std::string message) { failures->push_back({std::move(path), std::move(message)}); } -void ValidateDeleteCityInput(const types::DeleteCityInput& value, const std::string& path, std::vector* failures) { +void ValidateDeleteCityInput(const types::DeleteCityInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/cityId"; - static const smithy::Outcome kPattern0 = smithy::Regex::Compile(R"__smithy(^[A-Za-z0-9 ]+$)__smithy"); + static const opal::Outcome kPattern0 = opal::Regex::Compile(R"__smithy(^[A-Za-z0-9 ]+$)__smithy"); if (!kPattern0.ok() || !kPattern0->Search(value.cityId)) { helpers::AddValidationFailure(failures, member_path, "Value at '" + member_path + "' failed to satisfy constraint: Member must satisfy regular expression pattern: " + std::string("^[A-Za-z0-9 ]+$")); } } } -void ValidateGetForecastInput(const types::GetForecastInput& value, const std::string& path, std::vector* failures) { +void ValidateGetForecastInput(const types::GetForecastInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/cityId"; - static const smithy::Outcome kPattern1 = smithy::Regex::Compile(R"__smithy(^[A-Za-z0-9 ]+$)__smithy"); + static const opal::Outcome kPattern1 = opal::Regex::Compile(R"__smithy(^[A-Za-z0-9 ]+$)__smithy"); if (!kPattern1.ok() || !kPattern1->Search(value.cityId)) { helpers::AddValidationFailure(failures, member_path, "Value at '" + member_path + "' failed to satisfy constraint: Member must satisfy regular expression pattern: " + std::string("^[A-Za-z0-9 ]+$")); } } } -void ValidateGetCityInput(const types::GetCityInput& value, const std::string& path, std::vector* failures) { +void ValidateGetCityInput(const types::GetCityInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/cityId"; - static const smithy::Outcome kPattern2 = smithy::Regex::Compile(R"__smithy(^[A-Za-z0-9 ]+$)__smithy"); + static const opal::Outcome kPattern2 = opal::Regex::Compile(R"__smithy(^[A-Za-z0-9 ]+$)__smithy"); if (!kPattern2.ok() || !kPattern2->Search(value.cityId)) { helpers::AddValidationFailure(failures, member_path, "Value at '" + member_path + "' failed to satisfy constraint: Member must satisfy regular expression pattern: " + std::string("^[A-Za-z0-9 ]+$")); } @@ -150,25 +150,25 @@ void ValidateGetCityInput(const types::GetCityInput& value, const std::string& p // [[maybe_unused]]: only unary routes reject invalid input over HTTP; a // service whose operations all stream reports validation on the stream. -[[maybe_unused]] smithy::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { +[[maybe_unused]] opal::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { std::string summary = std::to_string(failures.size()) + " validation error" + (failures.size() == 1 ? "" : "s") + " detected. "; - smithy::DocumentList field_list; + opal::DocumentList field_list; for (std::size_t i = 0; i < failures.size(); ++i) { if (i > 0) summary += "; "; summary += failures[i].message; - smithy::DocumentMap field; - field.emplace("message", smithy::Document(failures[i].message)); - field.emplace("path", smithy::Document(failures[i].path)); - field_list.push_back(smithy::Document(std::move(field))); + opal::DocumentMap field; + field.emplace("message", opal::Document(failures[i].message)); + field.emplace("path", opal::Document(failures[i].path)); + field_list.push_back(opal::Document(std::move(field))); } - smithy::DocumentMap body; - body.emplace("fieldList", smithy::Document(std::move(field_list))); - smithy::http::HttpResponse response = helpers::JsonError(400, "", summary, std::move(body)); + opal::DocumentMap body; + body.emplace("fieldList", opal::Document(std::move(field_list))); + opal::http::HttpResponse response = helpers::JsonError(400, "", summary, std::move(body)); response.headers.Set("x-error-type", "ValidationException"); return response; } -smithy::Outcome ParseDeleteCityInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseDeleteCityInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -180,14 +180,14 @@ smithy::Outcome ParseDeleteCityInput(const smithy::http: return input; } -smithy::http::HttpResponse BuildDeleteCityResponse(const types::DeleteCityOutput& output) { +opal::http::HttpResponse BuildDeleteCityResponse(const types::DeleteCityOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 204; return response; } -smithy::Outcome ParseGetCityInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseGetCityInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -199,19 +199,19 @@ smithy::Outcome ParseGetCityInput(const smithy::http::HttpR return input; } -smithy::http::HttpResponse BuildGetCityResponse(const types::GetCityOutput& output) { +opal::http::HttpResponse BuildGetCityResponse(const types::GetCityOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; - body_map.emplace("name", smithy::Document(output.name)); + opal::DocumentMap body_map; + body_map.emplace("name", opal::Document(output.name)); body_map.emplace("coordinates", SerializeCityCoordinates(output.coordinates)); response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseGetCurrentTimeInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseGetCurrentTimeInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -219,18 +219,18 @@ smithy::Outcome ParseGetCurrentTimeInput(const smith return input; } -smithy::http::HttpResponse BuildGetCurrentTimeResponse(const types::GetCurrentTimeOutput& output) { +opal::http::HttpResponse BuildGetCurrentTimeResponse(const types::GetCurrentTimeOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; - body_map.emplace("time", smithy::Document::FromTimestamp(output.time, smithy::TimestampFormat::kEpochSeconds)); + opal::DocumentMap body_map; + body_map.emplace("time", opal::Document::FromTimestamp(output.time, opal::TimestampFormat::kEpochSeconds)); response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseGetForecastInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseGetForecastInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -242,20 +242,20 @@ smithy::Outcome ParseGetForecastInput(const smithy::htt return input; } -smithy::http::HttpResponse BuildGetForecastResponse(const types::GetForecastOutput& output) { +opal::http::HttpResponse BuildGetForecastResponse(const types::GetForecastOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; + opal::DocumentMap body_map; if (output.chanceOfRain.has_value()) { - body_map.emplace("chanceOfRain", smithy::Document(static_cast((*output.chanceOfRain)))); + body_map.emplace("chanceOfRain", opal::Document(static_cast((*output.chanceOfRain)))); } response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseGetReportInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseGetReportInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -267,19 +267,19 @@ smithy::Outcome ParseGetReportInput(const smithy::http::H return input; } -smithy::http::HttpResponse BuildGetReportResponse(const types::GetReportOutput& output) { +opal::http::HttpResponse BuildGetReportResponse(const types::GetReportOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; - body_map.emplace("path", smithy::Document(output.path)); - body_map.emplace("sizeBytes", smithy::Document(static_cast(output.sizeBytes))); + opal::DocumentMap body_map; + body_map.emplace("path", opal::Document(output.path)); + body_map.emplace("sizeBytes", opal::Document(static_cast(output.sizeBytes))); response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseListCitiesInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseListCitiesInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -299,17 +299,17 @@ smithy::Outcome ParseListCitiesInput(const smithy::http: return input; } -smithy::http::HttpResponse BuildListCitiesResponse(const types::ListCitiesOutput& output) { +opal::http::HttpResponse BuildListCitiesResponse(const types::ListCitiesOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; + opal::DocumentMap body_map; if (output.nextToken.has_value()) { - body_map.emplace("nextToken", smithy::Document((*output.nextToken))); + body_map.emplace("nextToken", opal::Document((*output.nextToken))); } body_map.emplace("items", SerializeCitySummaries(output.items)); response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } @@ -317,21 +317,21 @@ smithy::http::HttpResponse BuildListCitiesResponse(const types::ListCitiesOutput } // namespace WeatherServer::WeatherServer(std::shared_ptr handler) - : router_(std::make_shared()) { + : router_(std::make_shared()) { // The route table is derived from the model's @http traits; conflicts are // a modeling error surfaced by Router::Add (checked at generation time in a // later phase), so registration results are intentionally discarded. - (void)router_->Add("DELETE", "/cities/{cityId}", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("DELETE", "/cities/{cityId}", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseDeleteCityInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -341,22 +341,22 @@ WeatherServer::WeatherServer(std::shared_ptr handler) if (!outcome) return helpers::ErrorToResponse(outcome.error()); return helpers::BuildDeleteCityResponse(*outcome); }, "DeleteCity"); - (void)router_->Add("GET", "/cities/{cityId}", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/cities/{cityId}", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseGetCityInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -366,7 +366,7 @@ WeatherServer::WeatherServer(std::shared_ptr handler) if (!outcome) return helpers::ErrorToResponse(outcome.error()); return helpers::BuildGetCityResponse(*outcome); }, "GetCity"); - (void)router_->Add("GET", "/current-time", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/current-time", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept @@ -376,12 +376,12 @@ WeatherServer::WeatherServer(std::shared_ptr handler) error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseGetCurrentTimeInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -389,22 +389,22 @@ WeatherServer::WeatherServer(std::shared_ptr handler) if (!outcome) return helpers::ErrorToResponse(outcome.error()); return helpers::BuildGetCurrentTimeResponse(*outcome); }, "GetCurrentTime"); - (void)router_->Add("GET", "/cities/{cityId}/forecast", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/cities/{cityId}/forecast", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseGetForecastInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -414,22 +414,22 @@ WeatherServer::WeatherServer(std::shared_ptr handler) if (!outcome) return helpers::ErrorToResponse(outcome.error()); return helpers::BuildGetForecastResponse(*outcome); }, "GetForecast"); - (void)router_->Add("GET", "/reports/{reportPath+}", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/reports/{reportPath+}", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseGetReportInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -437,22 +437,22 @@ WeatherServer::WeatherServer(std::shared_ptr handler) if (!outcome) return helpers::ErrorToResponse(outcome.error()); return helpers::BuildGetReportResponse(*outcome); }, "GetReport"); - (void)router_->Add("GET", "/cities", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/cities", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseListCitiesInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -462,9 +462,9 @@ WeatherServer::WeatherServer(std::shared_ptr handler) }, "ListCities"); } -smithy::http::RequestHandler WeatherServer::Handler() const { +opal::http::RequestHandler WeatherServer::Handler() const { auto router = router_; - return [router](const smithy::http::HttpRequest& request) { return router->Route(request); }; + return [router](const opal::http::HttpRequest& request) { return router->Route(request); }; } } // namespace example::weather diff --git a/examples/weather/generated/tests/integration_test.cc b/examples/weather/generated/tests/integration_test.cc index ed2e1b6a..8f4ae557 100644 --- a/examples/weather/generated/tests/integration_test.cc +++ b/examples/weather/generated/tests/integration_test.cc @@ -146,7 +146,7 @@ struct Rng { [[maybe_unused]] GetCurrentTimeOutput RandomGetCurrentTimeOutput([[maybe_unused]] Rng& rng) { GetCurrentTimeOutput v{}; - v.time = smithy::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); + v.time = opal::Timestamp::FromEpochMilliseconds(rng.Int(0, 4102444799LL) * 1000); return v; } @@ -165,54 +165,54 @@ struct Rng { class ScriptedHandler final : public WeatherHandler { public: - smithy::Outcome DeleteCity(const DeleteCityInput& input, const smithy::server::RequestContext&) override { + opal::Outcome DeleteCity(const DeleteCityInput& input, const opal::server::RequestContext&) override { lastDeleteCity = input; if (nextDeleteCityError.has_value()) return *nextDeleteCityError; return nextDeleteCityOutput; } std::optional lastDeleteCity; DeleteCityOutput nextDeleteCityOutput{}; - std::optional nextDeleteCityError; - smithy::Outcome GetCity(const GetCityInput& input, const smithy::server::RequestContext&) override { + std::optional nextDeleteCityError; + opal::Outcome GetCity(const GetCityInput& input, const opal::server::RequestContext&) override { lastGetCity = input; if (nextGetCityError.has_value()) return *nextGetCityError; return nextGetCityOutput; } std::optional lastGetCity; GetCityOutput nextGetCityOutput{}; - std::optional nextGetCityError; - smithy::Outcome GetCurrentTime(const GetCurrentTimeInput& input, const smithy::server::RequestContext&) override { + std::optional nextGetCityError; + opal::Outcome GetCurrentTime(const GetCurrentTimeInput& input, const opal::server::RequestContext&) override { lastGetCurrentTime = input; if (nextGetCurrentTimeError.has_value()) return *nextGetCurrentTimeError; return nextGetCurrentTimeOutput; } std::optional lastGetCurrentTime; GetCurrentTimeOutput nextGetCurrentTimeOutput{}; - std::optional nextGetCurrentTimeError; - smithy::Outcome GetForecast(const GetForecastInput& input, const smithy::server::RequestContext&) override { + std::optional nextGetCurrentTimeError; + opal::Outcome GetForecast(const GetForecastInput& input, const opal::server::RequestContext&) override { lastGetForecast = input; if (nextGetForecastError.has_value()) return *nextGetForecastError; return nextGetForecastOutput; } std::optional lastGetForecast; GetForecastOutput nextGetForecastOutput{}; - std::optional nextGetForecastError; - smithy::Outcome GetReport(const GetReportInput& input, const smithy::server::RequestContext&) override { + std::optional nextGetForecastError; + opal::Outcome GetReport(const GetReportInput& input, const opal::server::RequestContext&) override { lastGetReport = input; if (nextGetReportError.has_value()) return *nextGetReportError; return nextGetReportOutput; } std::optional lastGetReport; GetReportOutput nextGetReportOutput{}; - std::optional nextGetReportError; - smithy::Outcome ListCities(const ListCitiesInput& input, const smithy::server::RequestContext&) override { + std::optional nextGetReportError; + opal::Outcome ListCities(const ListCitiesInput& input, const opal::server::RequestContext&) override { lastListCities = input; if (nextListCitiesError.has_value()) return *nextListCitiesError; return nextListCitiesOutput; } std::optional lastListCities; ListCitiesOutput nextListCitiesOutput{}; - std::optional nextListCitiesError; + std::optional nextListCitiesError; }; enum class TransportKind { kLoopback, kSocket }; @@ -222,14 +222,14 @@ class WeatherIntegrationTest : public ::testing::TestWithParam { void SetUp() override { handler_ = std::make_shared(); server_ = std::make_unique(handler_); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries if (GetParam() == TransportKind::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); config.http_client = loopback; } else { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(server_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } @@ -242,7 +242,7 @@ class WeatherIntegrationTest : public ::testing::TestWithParam { std::shared_ptr handler_; std::unique_ptr server_; - std::unique_ptr socket_server_; + std::unique_ptr socket_server_; std::unique_ptr client_; }; @@ -405,13 +405,13 @@ TEST_P(WeatherIntegrationTest, ListCitiesMaximalRoundTrips) { TEST_P(WeatherIntegrationTest, DeleteCityNoSuchResourceMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const NoSuchResource detail = RandomNoSuchResource(rng); - smithy::Error error = smithy::Error::Modeled("NoSuchResource", "integration"); + opal::Error error = opal::Error::Modeled("NoSuchResource", "integration"); error.set_detail(detail); handler_->nextDeleteCityError = error; const DeleteCityInput input = RandomDeleteCityInput(rng); const auto outcome = client_->DeleteCity(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "NoSuchResource"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -420,13 +420,13 @@ TEST_P(WeatherIntegrationTest, DeleteCityNoSuchResourceMapsAcrossTheWire) { TEST_P(WeatherIntegrationTest, GetCityNoSuchResourceMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const NoSuchResource detail = RandomNoSuchResource(rng); - smithy::Error error = smithy::Error::Modeled("NoSuchResource", "integration"); + opal::Error error = opal::Error::Modeled("NoSuchResource", "integration"); error.set_detail(detail); handler_->nextGetCityError = error; const GetCityInput input = RandomGetCityInput(rng); const auto outcome = client_->GetCity(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "NoSuchResource"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -435,13 +435,13 @@ TEST_P(WeatherIntegrationTest, GetCityNoSuchResourceMapsAcrossTheWire) { TEST_P(WeatherIntegrationTest, GetForecastNoSuchResourceMapsAcrossTheWire) { Rng rng{std::mt19937{42U}, /*fill_all=*/true}; const NoSuchResource detail = RandomNoSuchResource(rng); - smithy::Error error = smithy::Error::Modeled("NoSuchResource", "integration"); + opal::Error error = opal::Error::Modeled("NoSuchResource", "integration"); error.set_detail(detail); handler_->nextGetForecastError = error; const GetForecastInput input = RandomGetForecastInput(rng); const auto outcome = client_->GetForecast(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "NoSuchResource"); ASSERT_NE(outcome.error().detail(), nullptr); EXPECT_EQ(*outcome.error().detail(), detail); @@ -450,17 +450,17 @@ TEST_P(WeatherIntegrationTest, GetForecastNoSuchResourceMapsAcrossTheWire) { TEST(WeatherIntegrationUnknownMembers, GetCityToleratesUnknownResponseMembers) { auto handler = std::make_shared(); WeatherServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *WeatherClient::Create(std::move(config)); @@ -476,17 +476,17 @@ TEST(WeatherIntegrationUnknownMembers, GetCityToleratesUnknownResponseMembers) { TEST(WeatherIntegrationUnknownMembers, GetCurrentTimeToleratesUnknownResponseMembers) { auto handler = std::make_shared(); WeatherServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *WeatherClient::Create(std::move(config)); @@ -502,17 +502,17 @@ TEST(WeatherIntegrationUnknownMembers, GetCurrentTimeToleratesUnknownResponseMem TEST(WeatherIntegrationUnknownMembers, GetForecastToleratesUnknownResponseMembers) { auto handler = std::make_shared(); WeatherServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *WeatherClient::Create(std::move(config)); @@ -528,17 +528,17 @@ TEST(WeatherIntegrationUnknownMembers, GetForecastToleratesUnknownResponseMember TEST(WeatherIntegrationUnknownMembers, GetReportToleratesUnknownResponseMembers) { auto handler = std::make_shared(); WeatherServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *WeatherClient::Create(std::move(config)); @@ -554,17 +554,17 @@ TEST(WeatherIntegrationUnknownMembers, GetReportToleratesUnknownResponseMembers) TEST(WeatherIntegrationUnknownMembers, ListCitiesToleratesUnknownResponseMembers) { auto handler = std::make_shared(); WeatherServer server(handler); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - auto inject = [](smithy::http::HttpResponse& response) { - auto doc = smithy::json::Decode(response.body); + auto inject = [](opal::http::HttpResponse& response) { + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return; auto map = doc->as_map(); - map.insert_or_assign("smithy_cpp_unknown_member", smithy::Document(42)); - response.body = smithy::json::Encode(smithy::Document(std::move(map))); + map.insert_or_assign("smithy_cpp_unknown_member", opal::Document(42)); + response.body = opal::json::Encode(opal::Document(std::move(map))); }; - auto transport = std::make_shared(loopback, inject); - smithy::ClientConfig config; + auto transport = std::make_shared(loopback, inject); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *WeatherClient::Create(std::move(config)); diff --git a/examples/weather/generated/tests/smoke_test.cc b/examples/weather/generated/tests/smoke_test.cc index ef1a00e4..179cf7a4 100644 --- a/examples/weather/generated/tests/smoke_test.cc +++ b/examples/weather/generated/tests/smoke_test.cc @@ -62,27 +62,27 @@ ListCitiesOutput MinimalListCitiesOutput() { class SmokeHandler : public WeatherHandler { public: - smithy::Outcome DeleteCity(const DeleteCityInput& input, const smithy::server::RequestContext&) override { + opal::Outcome DeleteCity(const DeleteCityInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalDeleteCityOutput(); } - smithy::Outcome GetCity(const GetCityInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetCity(const GetCityInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalGetCityOutput(); } - smithy::Outcome GetCurrentTime(const GetCurrentTimeInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetCurrentTime(const GetCurrentTimeInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalGetCurrentTimeOutput(); } - smithy::Outcome GetForecast(const GetForecastInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetForecast(const GetForecastInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalGetForecastOutput(); } - smithy::Outcome GetReport(const GetReportInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetReport(const GetReportInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalGetReportOutput(); } - smithy::Outcome ListCities(const ListCitiesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome ListCities(const ListCitiesInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalListCitiesOutput(); } @@ -90,9 +90,9 @@ class SmokeHandler : public WeatherHandler { WeatherClient MakeClient(std::shared_ptr handler) { WeatherServer server(std::move(handler)); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = loopback; // Create cannot fail when a transport is injected. @@ -178,9 +178,9 @@ TEST(WeatherSmokeTest, ListCitiesRoundTrips) { TEST(WeatherSmokeTest, ModeledErrorsMapAcrossTheWire) { class FailingHandler final : public SmokeHandler { public: - smithy::Outcome DeleteCity(const DeleteCityInput& input, const smithy::server::RequestContext&) override { + opal::Outcome DeleteCity(const DeleteCityInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("NoSuchResource", "smoke"); + opal::Error error = opal::Error::Modeled("NoSuchResource", "smoke"); auto detail = [] { NoSuchResource v{}; return v; @@ -199,7 +199,7 @@ TEST(WeatherSmokeTest, ModeledErrorsMapAcrossTheWire) { input.cityId = "smoke"; const auto outcome = client.DeleteCity(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "NoSuchResource"); EXPECT_EQ(outcome.error().message(), "smoke"); EXPECT_NE(outcome.error().detail(), nullptr); diff --git a/examples/weather/generated_client_e2e_test.cc b/examples/weather/generated_client_e2e_test.cc index 053525bd..148fe04a 100644 --- a/examples/weather/generated_client_e2e_test.cc +++ b/examples/weather/generated_client_e2e_test.cc @@ -18,17 +18,17 @@ namespace hw = example::weather::handwritten; class ReferenceHandler final : public hw::WeatherHandler { public: - smithy::Outcome GetCity(const hw::GetCityInput& input) override { + opal::Outcome GetCity(const hw::GetCityInput& input) override { if (input.cityId == "seattle") { return hw::GetCityOutput{"Seattle", hw::CityCoordinates{47.6062, -122.3321}}; } if (input.cityId == "rain city") { return hw::GetCityOutput{"Rain City", hw::CityCoordinates{45.0, -120.0}}; } - return smithy::Error::Modeled(hw::kNoSuchResourceCode, "no city: " + input.cityId); + return opal::Error::Modeled(hw::kNoSuchResourceCode, "no city: " + input.cityId); } - smithy::Outcome ListCities(const hw::ListCitiesInput& input) override { + opal::Outcome ListCities(const hw::ListCitiesInput& input) override { hw::ListCitiesOutput out; if (!input.nextToken.has_value()) { out.items.push_back(hw::CitySummary{"seattle", "Seattle"}); @@ -41,15 +41,15 @@ class ReferenceHandler final : public hw::WeatherHandler { return out; } - smithy::Outcome GetForecast(const hw::GetForecastInput& input) override { + opal::Outcome GetForecast(const hw::GetForecastInput& input) override { if (input.cityId != "seattle") { - return smithy::Error::Modeled(hw::kNoSuchResourceCode, "no city: " + input.cityId); + return opal::Error::Modeled(hw::kNoSuchResourceCode, "no city: " + input.cityId); } return hw::GetForecastOutput{0.75}; } - smithy::Outcome GetCurrentTime() override { - return hw::GetCurrentTimeOutput{smithy::Timestamp::FromEpochMilliseconds(1398796238500)}; + opal::Outcome GetCurrentTime() override { + return hw::GetCurrentTimeOutput{opal::Timestamp::FromEpochMilliseconds(1398796238500)}; } }; @@ -59,13 +59,13 @@ class GeneratedClientEndToEndTest : public testing::TestWithParam { protected: void SetUp() override { service_ = std::make_unique(std::make_shared()); - smithy::ClientConfig config; + opal::ClientConfig config; if (GetParam() == Transport::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(service_->Handler()).ok()); config.http_client = loopback; } else { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(service_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } @@ -79,7 +79,7 @@ class GeneratedClientEndToEndTest : public testing::TestWithParam { } std::unique_ptr service_; - std::unique_ptr socket_server_; + std::unique_ptr socket_server_; std::unique_ptr client_; }; @@ -101,7 +101,7 @@ TEST_P(GeneratedClientEndToEndTest, PercentEncodedLabels) { TEST_P(GeneratedClientEndToEndTest, ModeledErrorsSurfaceTyped) { const auto city = client_->GetCity(GetCityInput{.cityId = "atlantis"}); ASSERT_FALSE(city.ok()); - EXPECT_EQ(city.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(city.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(city.error().code(), "NoSuchResource"); EXPECT_EQ(city.error().message(), "no city: atlantis"); } diff --git a/examples/weather/generated_server_e2e_test.cc b/examples/weather/generated_server_e2e_test.cc index 369423b0..9da95ede 100644 --- a/examples/weather/generated_server_e2e_test.cc +++ b/examples/weather/generated_server_e2e_test.cc @@ -31,10 +31,10 @@ namespace hw = example::weather::handwritten; // Reference implementation of the GENERATED handler interface. class ReferenceHandler : public WeatherHandler { public: - smithy::Outcome GetCity(const GetCityInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome GetCity(const GetCityInput& input, + const opal::server::RequestContext&) override { if (input.cityId != "seattle") { - smithy::Error error = smithy::Error::Modeled("NoSuchResource", "no city: " + input.cityId); + opal::Error error = opal::Error::Modeled("NoSuchResource", "no city: " + input.cityId); error.set_detail(NoSuchResource{.resourceType = "City"}); return error; } @@ -43,18 +43,18 @@ class ReferenceHandler : public WeatherHandler { .coordinates = CityCoordinates{.latitude = 47.6062F, .longitude = -122.3321F}}; } - smithy::Outcome DeleteCity(const DeleteCityInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome DeleteCity(const DeleteCityInput& input, + const opal::server::RequestContext&) override { if (input.cityId != "seattle") { - smithy::Error error = smithy::Error::Modeled("NoSuchResource", "no city: " + input.cityId); + opal::Error error = opal::Error::Modeled("NoSuchResource", "no city: " + input.cityId); error.set_detail(NoSuchResource{.resourceType = "City"}); return error; } return DeleteCityOutput{}; } - smithy::Outcome ListCities(const ListCitiesInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome ListCities(const ListCitiesInput& input, + const opal::server::RequestContext&) override { ListCitiesOutput out; if (!input.nextToken.has_value()) { out.items.push_back(CitySummary{.cityId = "seattle", .name = "Seattle"}); @@ -67,20 +67,20 @@ class ReferenceHandler : public WeatherHandler { return out; } - smithy::Outcome GetForecast(const GetForecastInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome GetForecast(const GetForecastInput& input, + const opal::server::RequestContext&) override { (void)input; return GetForecastOutput{.chanceOfRain = 0.75F}; } - smithy::Outcome GetCurrentTime( - const GetCurrentTimeInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetCurrentTime(const GetCurrentTimeInput& input, + const opal::server::RequestContext&) override { (void)input; - return GetCurrentTimeOutput{.time = smithy::Timestamp::FromEpochMilliseconds(1398796238500)}; + return GetCurrentTimeOutput{.time = opal::Timestamp::FromEpochMilliseconds(1398796238500)}; } - smithy::Outcome GetReport(const GetReportInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome GetReport(const GetReportInput& input, + const opal::server::RequestContext&) override { // Echo the decoded path so tests can assert label-decoding fidelity. return GetReportOutput{.path = input.reportPath, .sizeBytes = static_cast(input.reportPath.size())}; @@ -91,9 +91,9 @@ class GeneratedServerEndToEndTest : public testing::Test { protected: void SetUp() override { server_ = std::make_unique(std::make_shared()); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; auto client = hw::WeatherClient::Create(std::move(config)); ASSERT_TRUE(client.ok()) << client.error().message(); @@ -119,8 +119,8 @@ TEST_F(GeneratedServerEndToEndTest, GetCityRoundTrips) { // assert the status and correlation-id header the client abstraction hides. class ThrowingHandler : public ReferenceHandler { public: - smithy::Outcome GetCity(const GetCityInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome GetCity(const GetCityInput& input, + const opal::server::RequestContext&) override { (void)input; throw std::runtime_error("handler blew up mid-request"); } @@ -128,10 +128,10 @@ class ThrowingHandler : public ReferenceHandler { TEST(GeneratedServerFaultTest, ThrowingHandlerBecomesA500ThroughGeneratedDispatch) { WeatherServer server(std::make_shared()); - smithy::http::Loopback loopback; + opal::http::Loopback loopback; ASSERT_TRUE(loopback.Start(server.Handler()).ok()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/cities/seattle"; // valid route → reaches GetCity const auto response = loopback.Send(request); @@ -142,7 +142,7 @@ TEST(GeneratedServerFaultTest, ThrowingHandlerBecomesA500ThroughGeneratedDispatc // The server instance is still usable afterward: a well-behaved route works. WeatherServer healthy(std::make_shared()); - smithy::http::Loopback ok_loopback; + opal::http::Loopback ok_loopback; ASSERT_TRUE(ok_loopback.Start(healthy.Handler()).ok()); const auto ok = ok_loopback.Send(request); ASSERT_TRUE(ok.ok()) << ok.error().message(); @@ -151,26 +151,25 @@ TEST(GeneratedServerFaultTest, ThrowingHandlerBecomesA500ThroughGeneratedDispatc // A transport that fails transiently proves the generated client's retry // path end to end (Phase 7): the third attempt reaches the server. -class FlakyTransport final : public smithy::http::HttpClient { +class FlakyTransport final : public opal::http::HttpClient { public: - explicit FlakyTransport(std::shared_ptr inner) + explicit FlakyTransport(std::shared_ptr inner) : inner_(std::move(inner)) {} - smithy::Outcome Send( - const smithy::http::HttpRequest& request) override { - if (++calls_ <= 2) return smithy::Error::Transport("transient outage"); + opal::Outcome Send(const opal::http::HttpRequest& request) override { + if (++calls_ <= 2) return opal::Error::Transport("transient outage"); return inner_->Send(request); } private: - std::shared_ptr inner_; + std::shared_ptr inner_; int calls_ = 0; }; TEST_F(GeneratedServerEndToEndTest, GeneratedClientRetriesTransientFailures) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = std::make_shared(loopback); config.retry.sleep = [](std::chrono::milliseconds) {}; // instant for tests auto client = example::weather::WeatherClient::Create(std::move(config)); @@ -185,36 +184,36 @@ TEST_F(GeneratedServerEndToEndTest, GeneratedClientRetriesTransientFailures) { // rejects requests without it before the router runs, and Observe reports the // served request. TEST_F(GeneratedServerEndToEndTest, InterceptorAndMiddlewareCarryAuthAcrossTheWire) { - class BearerAuth final : public smithy::Interceptor { + class BearerAuth final : public opal::Interceptor { public: - void ModifyBeforeTransmit(smithy::http::HttpRequest& request, int) override { + void ModifyBeforeTransmit(opal::http::HttpRequest& request, int) override { request.headers.Set("authorization", "Bearer smoke-token"); } }; - std::vector observations; - auto require_auth = [](smithy::http::RequestHandler next) { - return [next = std::move(next)](const smithy::http::HttpRequest& request) { + std::vector observations; + auto require_auth = [](opal::http::RequestHandler next) { + return [next = std::move(next)](const opal::http::HttpRequest& request) { if (request.headers.Get("authorization") != "Bearer smoke-token") { - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 401; return response; } return next(request); }; }; - auto handler = smithy::server::Chain( - {require_auth, smithy::server::Observe([&](const smithy::server::RequestObservation& o) { + auto handler = opal::server::Chain( + {require_auth, opal::server::Observe([&](const opal::server::RequestObservation& o) { observations.push_back(o); })}, server_->Handler()); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(handler).ok()); // Without the interceptor the middleware rejects the call outright. { - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; config.retry.max_attempts = 1; auto client = example::weather::WeatherClient::Create(std::move(config)); @@ -223,7 +222,7 @@ TEST_F(GeneratedServerEndToEndTest, InterceptorAndMiddlewareCarryAuthAcrossTheWi ASSERT_FALSE(city.ok()); } - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; config.interceptors.push_back(std::make_shared()); auto client = example::weather::WeatherClient::Create(std::move(config)); @@ -242,15 +241,15 @@ TEST_F(GeneratedServerEndToEndTest, InterceptorAndMiddlewareCarryAuthAcrossTheWi // @httpBearerAuth end to end (Phase 7c): config.bearer_token feeds the // generated client; RequireBearerAuth guards the generated server. TEST_F(GeneratedServerEndToEndTest, BearerTokenFlowsFromConfigThroughAuthMiddleware) { - auto handler = - smithy::server::Chain({smithy::server::RequireBearerAuth( - [](const std::string& token) { return token == "weather-token"; })}, - server_->Handler()); - auto loopback = std::make_shared(); + auto handler = opal::server::Chain({opal::server::RequireBearerAuth([](const std::string& token) { + return token == "weather-token"; + })}, + server_->Handler()); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(handler).ok()); { - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; config.retry.max_attempts = 1; auto anonymous = example::weather::WeatherClient::Create(std::move(config)); @@ -258,7 +257,7 @@ TEST_F(GeneratedServerEndToEndTest, BearerTokenFlowsFromConfigThroughAuthMiddlew EXPECT_FALSE(anonymous->GetCity(example::weather::GetCityInput{.cityId = "seattle"}).ok()); } - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; config.bearer_token = [] { return std::string("weather-token"); }; auto client = example::weather::WeatherClient::Create(std::move(config)); @@ -271,9 +270,9 @@ TEST_F(GeneratedServerEndToEndTest, BearerTokenFlowsFromConfigThroughAuthMiddlew // The generated @paginated paginator walks pages until the server stops // returning a next token (ReferenceHandler pages when pageSize < 2). TEST_F(GeneratedServerEndToEndTest, PaginatorWalksAllPages) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; auto client = example::weather::WeatherClient::Create(std::move(config)); ASSERT_TRUE(client.ok()); @@ -303,10 +302,10 @@ TEST_F(GeneratedServerEndToEndTest, PaginatorWalksAllPages) { // Loopback-backed generated client over `handler`; the client's config keeps // the loopback transport alive. -example::weather::WeatherClient MakeGeneratedClient(const smithy::http::RequestHandler& handler) { - auto loopback = std::make_shared(); +example::weather::WeatherClient MakeGeneratedClient(const opal::http::RequestHandler& handler) { + auto loopback = std::make_shared(); loopback->Start(handler).value_or_die("starting loopback"); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = std::move(loopback); return example::weather::WeatherClient::Create(std::move(config)) .value_or_die("creating generated weather client"); @@ -327,10 +326,10 @@ TEST_F(GeneratedServerEndToEndTest, PaginatorRangeForWalksAllPages) { TEST_F(GeneratedServerEndToEndTest, PaginatorRangeForYieldsTheErrorOnceThenEnds) { class FailsOnSecondPage final : public ReferenceHandler { public: - smithy::Outcome ListCities(const ListCitiesInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome ListCities(const ListCitiesInput& input, + const opal::server::RequestContext&) override { if (input.nextToken.has_value()) { - return smithy::Error::Modeled("NoSuchResource", "page evaporated"); + return opal::Error::Modeled("NoSuchResource", "page evaporated"); } ListCitiesOutput out; out.items.push_back(CitySummary{.cityId = "page1", .name = "Page One"}); @@ -342,7 +341,7 @@ TEST_F(GeneratedServerEndToEndTest, PaginatorRangeForYieldsTheErrorOnceThenEnds) auto client = MakeGeneratedClient(server.Handler()); std::vector pages_seen; - std::optional failure; + std::optional failure; for (auto& page : client.PaginateListCities(ListCitiesInput{})) { if (!page.ok()) { failure = page.error(); @@ -359,20 +358,21 @@ TEST_F(GeneratedServerEndToEndTest, PaginatorRangeForYieldsTheErrorOnceThenEnds) // context and observes its attempts; the server's Observe middleware reports // the matched operation and the incoming traceparent for correlation. TEST_F(GeneratedServerEndToEndTest, TraceContextAndOperationFlowThroughObservability) { - std::vector served; - auto handler = smithy::server::Chain( - {smithy::server::Observe( - [&](const smithy::server::RequestObservation& o) { served.push_back(o); })}, - server_->Handler()); - auto loopback = std::make_shared(); + std::vector served; + auto handler = + opal::server::Chain({opal::server::Observe([&](const opal::server::RequestObservation& o) { + served.push_back(o); + })}, + server_->Handler()); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(handler).ok()); - std::vector attempts; - smithy::ClientConfig config; + std::vector attempts; + opal::ClientConfig config; config.http_client = loopback; - config.interceptors.push_back(smithy::PropagateTraceContext()); + config.interceptors.push_back(opal::PropagateTraceContext()); config.interceptors.push_back( - smithy::ObserveAttempts([&](const smithy::AttemptObservation& a) { attempts.push_back(a); })); + opal::ObserveAttempts([&](const opal::AttemptObservation& a) { attempts.push_back(a); })); auto client = example::weather::WeatherClient::Create(std::move(config)); ASSERT_TRUE(client.ok()); @@ -381,7 +381,7 @@ TEST_F(GeneratedServerEndToEndTest, TraceContextAndOperationFlowThroughObservabi ASSERT_EQ(served.size(), 1u); EXPECT_EQ(served[0].operation, "GetCity"); - const auto trace = smithy::http::ParseTraceparent(served[0].trace_parent); + const auto trace = opal::http::ParseTraceparent(served[0].trace_parent); ASSERT_TRUE(trace.has_value()) << served[0].trace_parent; EXPECT_TRUE(trace->sampled); @@ -391,7 +391,7 @@ TEST_F(GeneratedServerEndToEndTest, TraceContextAndOperationFlowThroughObservabi EXPECT_EQ(attempts[0].method, "GET"); // Dispatch failures report an empty operation. - smithy::http::HttpRequest unrouted; + opal::http::HttpRequest unrouted; unrouted.method = "GET"; unrouted.target = "/no/such/route"; (void)handler(unrouted); @@ -403,9 +403,9 @@ TEST_F(GeneratedServerEndToEndTest, TraceContextAndOperationFlowThroughObservabi // Greedy labels ({reportPath+}) keep their embedded slashes and decode // percent-encoded characters segment by segment. TEST_F(GeneratedServerEndToEndTest, GreedyLabelKeepsSlashesAndDecodes) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; auto client = example::weather::WeatherClient::Create(std::move(config)); ASSERT_TRUE(client.ok()); @@ -430,9 +430,9 @@ TEST_F(GeneratedServerEndToEndTest, GreedyLabelKeepsSlashesAndDecodes) { // URI-hostile values outside it are rejected by generated validation with a // clean 400 ValidationException, never a crash, mis-route, or mangled echo. TEST_F(GeneratedServerEndToEndTest, HostileLabelValuesSurviveTheRoundTrip) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server_->Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; auto client = example::weather::WeatherClient::Create(std::move(config)); ASSERT_TRUE(client.ok()); @@ -470,8 +470,8 @@ TEST_F(GeneratedServerEndToEndTest, PaginatorRoundTripsHostileTokens) { static const std::string kNastyToken = "a b&c=d?e+f/g%h#i"; class PagingHandler final : public ReferenceHandler { public: - smithy::Outcome ListCities(const ListCitiesInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome ListCities(const ListCitiesInput& input, + const opal::server::RequestContext&) override { ListCitiesOutput out; if (!input.nextToken.has_value()) { out.items.push_back(CitySummary{.cityId = "page1", .name = "Page One"}); @@ -480,7 +480,7 @@ TEST_F(GeneratedServerEndToEndTest, PaginatorRoundTripsHostileTokens) { } // The token must arrive exactly as issued, through the query string. if (*input.nextToken != kNastyToken) { - return smithy::Error::Modeled("NoSuchResource", "token corrupted: " + *input.nextToken); + return opal::Error::Modeled("NoSuchResource", "token corrupted: " + *input.nextToken); } out.items.push_back(CitySummary{.cityId = "page2", .name = "Page Two"}); return out; @@ -488,9 +488,9 @@ TEST_F(GeneratedServerEndToEndTest, PaginatorRoundTripsHostileTokens) { }; WeatherServer server(std::make_shared()); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(server.Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.http_client = loopback; auto client = example::weather::WeatherClient::Create(std::move(config)); ASSERT_TRUE(client.ok()); @@ -516,24 +516,25 @@ TEST_F(GeneratedServerEndToEndTest, PaginatorRoundTripsHostileTokens) { // auth + observation middleware on the server. Client-side hooks see every // attempt; the server sees exactly one authorized request. TEST_F(GeneratedServerEndToEndTest, FullStackLayeringSurvivesRetries) { - std::vector served; - auto handler = smithy::server::Chain( - {smithy::server::RequireBearerAuth( - [](const std::string& token) { return token == "stack-token"; }), - smithy::server::Observe( - [&](const smithy::server::RequestObservation& o) { served.push_back(o); })}, - server_->Handler()); - auto loopback = std::make_shared(); + std::vector served; + auto handler = + opal::server::Chain({opal::server::RequireBearerAuth( + [](const std::string& token) { return token == "stack-token"; }), + opal::server::Observe([&](const opal::server::RequestObservation& o) { + served.push_back(o); + })}, + server_->Handler()); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(handler).ok()); - std::vector attempts; - smithy::ClientConfig config; + std::vector attempts; + opal::ClientConfig config; config.http_client = std::make_shared(loopback); // 2 failures first config.retry.sleep = [](std::chrono::milliseconds) {}; config.bearer_token = [] { return std::string("stack-token"); }; - config.interceptors.push_back(smithy::PropagateTraceContext()); + config.interceptors.push_back(opal::PropagateTraceContext()); config.interceptors.push_back( - smithy::ObserveAttempts([&](const smithy::AttemptObservation& a) { attempts.push_back(a); })); + opal::ObserveAttempts([&](const opal::AttemptObservation& a) { attempts.push_back(a); })); auto client = example::weather::WeatherClient::Create(std::move(config)); ASSERT_TRUE(client.ok()); @@ -549,14 +550,14 @@ TEST_F(GeneratedServerEndToEndTest, FullStackLayeringSurvivesRetries) { // Only the successful attempt reached the server, authorized and traced. ASSERT_EQ(served.size(), 1u); EXPECT_EQ(served[0].operation, "GetCity"); - EXPECT_TRUE(smithy::http::ParseTraceparent(served[0].trace_parent).has_value()); + EXPECT_TRUE(opal::http::ParseTraceparent(served[0].trace_parent).has_value()); } TEST_F(GeneratedServerEndToEndTest, DeleteCityIs204WithNoBody) { - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "DELETE"; request.target = "/cities/seattle"; - const smithy::http::HttpResponse response = server_->Handler()(request); + const opal::http::HttpResponse response = server_->Handler()(request); EXPECT_EQ(response.status, 204); EXPECT_TRUE(response.body.empty()) << response.body; EXPECT_FALSE(response.headers.Get("content-type").has_value()); @@ -565,7 +566,7 @@ TEST_F(GeneratedServerEndToEndTest, DeleteCityIs204WithNoBody) { TEST_F(GeneratedServerEndToEndTest, ModeledErrorsGetTheirHttpStatusAndCode) { const auto city = client_->GetCity(hw::GetCityInput{.cityId = "atlantis"}); ASSERT_FALSE(city.ok()); - EXPECT_EQ(city.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(city.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(city.error().code(), "NoSuchResource"); // @httpError(404) on the wire EXPECT_EQ(city.error().message(), "no city: atlantis"); } diff --git a/examples/weather/generated_types_test.cc b/examples/weather/generated_types_test.cc index 83d9c64e..639927ca 100644 --- a/examples/weather/generated_types_test.cc +++ b/examples/weather/generated_types_test.cc @@ -41,7 +41,7 @@ TEST(WeatherGeneratedTypesTest, ErrorShapesAreGenerated) { TEST(WeatherGeneratedTypesTest, TimestampMembersUseRuntimeType) { GetCurrentTimeOutput output; - output.time = smithy::Timestamp::FromEpochMilliseconds(1000); + output.time = opal::Timestamp::FromEpochMilliseconds(1000); EXPECT_EQ(output.time.epoch_milliseconds(), 1000); } diff --git a/examples/weather/handwritten/weather_client.cc b/examples/weather/handwritten/weather_client.cc index 595cfb71..963d955b 100644 --- a/examples/weather/handwritten/weather_client.cc +++ b/examples/weather/handwritten/weather_client.cc @@ -8,20 +8,20 @@ namespace example::weather::handwritten { namespace { -using smithy::Document; -using smithy::Error; -using smithy::Outcome; +using opal::Document; +using opal::Error; +using opal::Outcome; // restJson1 error deserialization (prototype): code from the // x-error-type header (how generated servers send it), else the "__type" // or "code" body field; message from "message". -Error DeserializeError(const smithy::http::HttpResponse& response) { +Error DeserializeError(const opal::http::HttpResponse& response) { std::string code = "UnknownError"; std::string message = "HTTP " + std::to_string(response.status); if (const auto header = response.headers.Get("x-error-type"); header.has_value()) { code = *header; } - if (const auto doc = smithy::json::Decode(response.body); doc.ok() && doc->is_map()) { + if (const auto doc = opal::json::Decode(response.body); doc.ok() && doc->is_map()) { const Document* type = doc->Find("__type"); if (type == nullptr) type = doc->Find("code"); if (code == "UnknownError" && type != nullptr && type->is_string()) code = type->as_string(); @@ -30,30 +30,30 @@ Error DeserializeError(const smithy::http::HttpResponse& response) { } } const bool retryable = response.status >= 500; - if (code == "UnknownError") return Error(smithy::ErrorKind::kUnknown, code, message, retryable); + if (code == "UnknownError") return Error(opal::ErrorKind::kUnknown, code, message, retryable); return Error::Modeled(code, message, retryable); } template -Outcome ParseBody(const smithy::http::HttpResponse& response, +Outcome ParseBody(const opal::http::HttpResponse& response, Outcome (*deserialize)(const Document&)) { - auto doc = smithy::json::Decode(response.body); + auto doc = opal::json::Decode(response.body); if (!doc) return std::move(doc).error(); return deserialize(*doc); } } // namespace -smithy::Outcome WeatherClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome WeatherClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { - transport = std::make_shared(endpoint->host, endpoint->port, - config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, + config.request_timeout_ms); } } if (transport == nullptr) { @@ -62,9 +62,9 @@ smithy::Outcome WeatherClient::Create(smithy::ClientConfig config return WeatherClient(std::move(config), std::move(transport), std::move(prefix)); } -smithy::Outcome WeatherClient::Send(const std::string& method, - const std::string& target) const { - smithy::http::HttpRequest request; +opal::Outcome WeatherClient::Send(const std::string& method, + const std::string& target) const { + opal::http::HttpRequest request; request.method = method; request.target = path_prefix_ + target; request.headers.Set("accept", "application/json"); @@ -72,15 +72,15 @@ smithy::Outcome WeatherClient::Send(const std::strin return transport_->Send(request); } -smithy::Outcome WeatherClient::GetCity(const GetCityInput& input) const { - auto response = Send("GET", "/cities/" + smithy::http::EncodePathSegment(input.cityId)); +opal::Outcome WeatherClient::GetCity(const GetCityInput& input) const { + auto response = Send("GET", "/cities/" + opal::http::EncodePathSegment(input.cityId)); if (!response) return std::move(response).error(); if (response->status != 200) return DeserializeError(*response); return ParseBody(*response, &DeserializeGetCityOutput); } -smithy::Outcome WeatherClient::ListCities(const ListCitiesInput& input) const { - smithy::http::QueryString query; +opal::Outcome WeatherClient::ListCities(const ListCitiesInput& input) const { + opal::http::QueryString query; if (input.nextToken.has_value()) query.Add("nextToken", *input.nextToken); if (input.pageSize.has_value()) query.Add("pageSize", std::to_string(*input.pageSize)); auto response = Send("GET", "/cities" + query.ToString()); @@ -89,15 +89,15 @@ smithy::Outcome WeatherClient::ListCities(const ListCitiesInpu return ParseBody(*response, &DeserializeListCitiesOutput); } -smithy::Outcome WeatherClient::GetForecast(const GetForecastInput& input) const { +opal::Outcome WeatherClient::GetForecast(const GetForecastInput& input) const { auto response = - Send("GET", "/cities/" + smithy::http::EncodePathSegment(input.cityId) + "/forecast"); + Send("GET", "/cities/" + opal::http::EncodePathSegment(input.cityId) + "/forecast"); if (!response) return std::move(response).error(); if (response->status != 200) return DeserializeError(*response); return ParseBody(*response, &DeserializeGetForecastOutput); } -smithy::Outcome WeatherClient::GetCurrentTime() const { +opal::Outcome WeatherClient::GetCurrentTime() const { auto response = Send("GET", "/current-time"); if (!response) return std::move(response).error(); if (response->status != 200) return DeserializeError(*response); diff --git a/examples/weather/handwritten/weather_client.h b/examples/weather/handwritten/weather_client.h index 5bbe254d..8e24ff25 100644 --- a/examples/weather/handwritten/weather_client.h +++ b/examples/weather/handwritten/weather_client.h @@ -17,25 +17,25 @@ namespace example::weather::handwritten { class WeatherClient { public: // Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); + static opal::Outcome Create(opal::ClientConfig config); - smithy::Outcome GetCity(const GetCityInput& input) const; - smithy::Outcome ListCities(const ListCitiesInput& input) const; - smithy::Outcome GetForecast(const GetForecastInput& input) const; - smithy::Outcome GetCurrentTime() const; + opal::Outcome GetCity(const GetCityInput& input) const; + opal::Outcome ListCities(const ListCitiesInput& input) const; + opal::Outcome GetForecast(const GetForecastInput& input) const; + opal::Outcome GetCurrentTime() const; private: - WeatherClient(smithy::ClientConfig config, std::shared_ptr transport, + WeatherClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} - smithy::Outcome Send(const std::string& method, - const std::string& target) const; + opal::Outcome Send(const std::string& method, + const std::string& target) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; diff --git a/examples/weather/handwritten/weather_e2e_test.cc b/examples/weather/handwritten/weather_e2e_test.cc index bc274fbb..73165f37 100644 --- a/examples/weather/handwritten/weather_e2e_test.cc +++ b/examples/weather/handwritten/weather_e2e_test.cc @@ -21,17 +21,17 @@ namespace { // Reference handler: two cities, deterministic time. class ReferenceHandler final : public WeatherHandler { public: - smithy::Outcome GetCity(const GetCityInput& input) override { + opal::Outcome GetCity(const GetCityInput& input) override { if (input.cityId == "seattle") { return GetCityOutput{"Seattle", CityCoordinates{47.6062, -122.3321}}; } if (input.cityId == "rain city") { // exercises percent-encoded labels return GetCityOutput{"Rain City", CityCoordinates{45.0, -120.0}}; } - return smithy::Error::Modeled(kNoSuchResourceCode, "no city: " + input.cityId); + return opal::Error::Modeled(kNoSuchResourceCode, "no city: " + input.cityId); } - smithy::Outcome ListCities(const ListCitiesInput& input) override { + opal::Outcome ListCities(const ListCitiesInput& input) override { ListCitiesOutput out; if (!input.nextToken.has_value()) { out.items.push_back(CitySummary{"seattle", "Seattle"}); @@ -44,15 +44,15 @@ class ReferenceHandler final : public WeatherHandler { return out; } - smithy::Outcome GetForecast(const GetForecastInput& input) override { + opal::Outcome GetForecast(const GetForecastInput& input) override { if (input.cityId != "seattle") { - return smithy::Error::Modeled(kNoSuchResourceCode, "no city: " + input.cityId); + return opal::Error::Modeled(kNoSuchResourceCode, "no city: " + input.cityId); } return GetForecastOutput{0.75}; } - smithy::Outcome GetCurrentTime() override { - return GetCurrentTimeOutput{smithy::Timestamp::FromEpochMilliseconds(1398796238500)}; + opal::Outcome GetCurrentTime() override { + return GetCurrentTimeOutput{opal::Timestamp::FromEpochMilliseconds(1398796238500)}; } }; @@ -62,19 +62,19 @@ class WeatherEndToEndTest : public testing::TestWithParam { protected: void SetUp() override { service_ = std::make_unique(std::make_shared()); - smithy::ClientConfig config; + opal::ClientConfig config; if (GetParam() == Transport::kLoopback) { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); ASSERT_TRUE(loopback->Start(service_->Handler()).ok()); transport_holder_ = loopback; config.http_client = loopback; } else if (GetParam() == Transport::kSocket) { - socket_server_ = std::make_unique(); + socket_server_ = std::make_unique(); ASSERT_TRUE(socket_server_->Start(service_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(socket_server_->port()); } else { #ifdef SMITHY_E2E_HAVE_BEAST - beast_server_ = std::make_unique(); + beast_server_ = std::make_unique(); ASSERT_TRUE(beast_server_->Start(service_->Handler()).ok()); config.endpoint = "http://127.0.0.1:" + std::to_string(beast_server_->port()); #else @@ -94,10 +94,10 @@ class WeatherEndToEndTest : public testing::TestWithParam { } std::unique_ptr service_; - std::shared_ptr transport_holder_; - std::unique_ptr socket_server_; + std::shared_ptr transport_holder_; + std::unique_ptr socket_server_; #ifdef SMITHY_E2E_HAVE_BEAST - std::unique_ptr beast_server_; + std::unique_ptr beast_server_; #endif std::unique_ptr client_; }; @@ -117,7 +117,7 @@ TEST_P(WeatherEndToEndTest, LabelsWithSpacesAreEncodedCorrectly) { TEST_P(WeatherEndToEndTest, ModeledErrorsSurfaceWithCodeAndStatus) { const auto city = client_->GetCity(GetCityInput{"atlantis"}); ASSERT_FALSE(city.ok()); - EXPECT_EQ(city.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(city.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(city.error().code(), kNoSuchResourceCode); EXPECT_EQ(city.error().message(), "no city: atlantis"); } diff --git a/examples/weather/handwritten/weather_server.cc b/examples/weather/handwritten/weather_server.cc index b9b1e2d8..a90376d5 100644 --- a/examples/weather/handwritten/weather_server.cc +++ b/examples/weather/handwritten/weather_server.cc @@ -9,23 +9,23 @@ namespace example::weather::handwritten { namespace { -using smithy::Document; -using smithy::Error; -using smithy::ErrorKind; -using smithy::http::HttpRequest; -using smithy::http::HttpResponse; -using smithy::server::MakeErrorResponse; -using smithy::server::RequestContext; +using opal::Document; +using opal::Error; +using opal::ErrorKind; +using opal::http::HttpRequest; +using opal::http::HttpResponse; +using opal::server::MakeErrorResponse; +using opal::server::RequestContext; HttpResponse ErrorToResponse(const Error& error) { if (error.kind() == ErrorKind::kModeled && error.code() == kNoSuchResourceCode) { HttpResponse response; response.status = 404; // @httpError(404) on NoSuchResource response.headers.Set("content-type", "application/json"); - smithy::DocumentMap body; + opal::DocumentMap body; body.emplace("__type", Document(error.code())); body.emplace("message", Document(error.message())); - response.body = smithy::json::Encode(Document(std::move(body))); + response.body = opal::json::Encode(Document(std::move(body))); return response; } if (error.kind() == ErrorKind::kValidation || error.kind() == ErrorKind::kSerialization) { @@ -38,14 +38,14 @@ HttpResponse ErrorToResponse(const Error& error) { HttpResponse JsonResponse(const Document& doc) { HttpResponse response; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(doc); + response.body = opal::json::Encode(doc); return response; } } // namespace WeatherService::WeatherService(const std::shared_ptr& handler) - : router_(std::make_shared()) { + : router_(std::make_shared()) { // The route table below is conflict-free by construction, so Add cannot // fail; the generator emits the same table from the @http traits. (void)router_->Add("GET", "/cities/{cityId}", @@ -82,7 +82,7 @@ WeatherService::WeatherService(const std::shared_ptr& handler) }); } -smithy::http::RequestHandler WeatherService::Handler() const { +opal::http::RequestHandler WeatherService::Handler() const { auto router = router_; return [router](const HttpRequest& request) { return router->Route(request); }; } diff --git a/examples/weather/handwritten/weather_server.h b/examples/weather/handwritten/weather_server.h index 57bfee10..9cb87046 100644 --- a/examples/weather/handwritten/weather_server.h +++ b/examples/weather/handwritten/weather_server.h @@ -16,10 +16,10 @@ class WeatherHandler { public: virtual ~WeatherHandler() = default; - virtual smithy::Outcome GetCity(const GetCityInput& input) = 0; - virtual smithy::Outcome ListCities(const ListCitiesInput& input) = 0; - virtual smithy::Outcome GetForecast(const GetForecastInput& input) = 0; - virtual smithy::Outcome GetCurrentTime() = 0; + virtual opal::Outcome GetCity(const GetCityInput& input) = 0; + virtual opal::Outcome ListCities(const ListCitiesInput& input) = 0; + virtual opal::Outcome GetForecast(const GetForecastInput& input) = 0; + virtual opal::Outcome GetCurrentTime() = 0; }; // Binds a WeatherHandler to the runtime router. Transport-agnostic: pass @@ -29,10 +29,10 @@ class WeatherService { // Route registration cannot fail for this fixed, conflict-free route table. explicit WeatherService(const std::shared_ptr& handler); - smithy::http::RequestHandler Handler() const; + opal::http::RequestHandler Handler() const; private: - std::shared_ptr router_; + std::shared_ptr router_; }; } // namespace example::weather::handwritten diff --git a/examples/weather/handwritten/weather_types.cc b/examples/weather/handwritten/weather_types.cc index 89167703..349a70de 100644 --- a/examples/weather/handwritten/weather_types.cc +++ b/examples/weather/handwritten/weather_types.cc @@ -3,11 +3,11 @@ namespace example::weather::handwritten { namespace { -using smithy::Document; -using smithy::DocumentList; -using smithy::DocumentMap; -using smithy::Error; -using smithy::Outcome; +using opal::Document; +using opal::DocumentList; +using opal::DocumentMap; +using opal::Error; +using opal::Outcome; Error MissingMember(const char* name) { return Error::Serialization(std::string("weather: missing required member: ") + name); @@ -106,7 +106,7 @@ Outcome DeserializeGetForecastOutput(const Document& doc) { Document SerializeGetCurrentTimeOutput(const GetCurrentTimeOutput& value) { DocumentMap map; // restJson1 serializes body timestamps as epoch-seconds by default. - map.emplace("time", Document::FromTimestamp(value.time, smithy::TimestampFormat::kEpochSeconds)); + map.emplace("time", Document::FromTimestamp(value.time, opal::TimestampFormat::kEpochSeconds)); return Document(std::move(map)); } @@ -116,7 +116,7 @@ Outcome DeserializeGetCurrentTimeOutput(const Document& do if (time == nullptr) return MissingMember("time"); GetCurrentTimeOutput out; if (time->is_int() || time->is_double()) { - out.time = smithy::Timestamp::FromEpochSeconds(time->AsNumber()); + out.time = opal::Timestamp::FromEpochSeconds(time->AsNumber()); } else if (time->is_timestamp()) { out.time = time->as_timestamp().value; } else { diff --git a/examples/weather/handwritten/weather_types.h b/examples/weather/handwritten/weather_types.h index 7dea7d6a..f6f91019 100644 --- a/examples/weather/handwritten/weather_types.h +++ b/examples/weather/handwritten/weather_types.h @@ -62,24 +62,24 @@ struct GetForecastOutput { }; struct GetCurrentTimeOutput { - smithy::Timestamp time; + opal::Timestamp time; friend bool operator==(const GetCurrentTimeOutput&, const GetCurrentTimeOutput&) = default; }; // Document serde, one pair per structure — the shape of code the generator // will emit. Deserializers reject missing @required members. -smithy::Document SerializeGetCityOutput(const GetCityOutput& value); -smithy::Outcome DeserializeGetCityOutput(const smithy::Document& doc); +opal::Document SerializeGetCityOutput(const GetCityOutput& value); +opal::Outcome DeserializeGetCityOutput(const opal::Document& doc); -smithy::Document SerializeListCitiesOutput(const ListCitiesOutput& value); -smithy::Outcome DeserializeListCitiesOutput(const smithy::Document& doc); +opal::Document SerializeListCitiesOutput(const ListCitiesOutput& value); +opal::Outcome DeserializeListCitiesOutput(const opal::Document& doc); -smithy::Document SerializeGetForecastOutput(const GetForecastOutput& value); -smithy::Outcome DeserializeGetForecastOutput(const smithy::Document& doc); +opal::Document SerializeGetForecastOutput(const GetForecastOutput& value); +opal::Outcome DeserializeGetForecastOutput(const opal::Document& doc); -smithy::Document SerializeGetCurrentTimeOutput(const GetCurrentTimeOutput& value); -smithy::Outcome DeserializeGetCurrentTimeOutput(const smithy::Document& doc); +opal::Document SerializeGetCurrentTimeOutput(const GetCurrentTimeOutput& value); +opal::Outcome DeserializeGetCurrentTimeOutput(const opal::Document& doc); // Modeled error code shared by client and server ("NoSuchResource" per model). inline constexpr char kNoSuchResourceCode[] = "NoSuchResource"; diff --git a/fuzz/access_log_fuzz.cc b/fuzz/access_log_fuzz.cc index 52bb0d66..f9aaa509 100644 --- a/fuzz/access_log_fuzz.cc +++ b/fuzz/access_log_fuzz.cc @@ -34,7 +34,7 @@ bool IsValidUtf8(const std::string& text) { extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) { // Layout: method '\n' target '\n' operation '\n' extra-value '\n' traceparent. const std::string all(reinterpret_cast(data), size); - smithy::server::RequestObservation o; + opal::server::RequestObservation o; std::string extra_value; std::string* fields[] = {&o.method, &o.target, &o.operation, &extra_value, &o.trace_parent}; std::size_t start = 0; @@ -46,10 +46,10 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size } o.status = size == 0 ? 0 : 100 + data[0] % 500; o.client.address = "203.0.113.7"; - o.client.source = smithy::http::DerivedClient::Source::kForwarded; + o.client.source = opal::http::DerivedClient::Source::kForwarded; const std::string line = - smithy::server::FormatAccessLog(o, {{"service_name", "svc"}, {"tenant", extra_value}}); + opal::server::FormatAccessLog(o, {{"service_name", "svc"}, {"tenant", extra_value}}); // One object, strictly parsed, no trailing bytes. accept() is the strict // parser a collector would be: it rejects unescaped control characters and diff --git a/fuzz/cbor_decode_fuzz.cc b/fuzz/cbor_decode_fuzz.cc index 24c14949..539c95a4 100644 --- a/fuzz/cbor_decode_fuzz.cc +++ b/fuzz/cbor_decode_fuzz.cc @@ -8,11 +8,10 @@ #include "smithy/core/blob.h" extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) { - const auto blob = - smithy::Blob::FromString(std::string(reinterpret_cast(data), size)); - auto doc = smithy::cbor::Decode(blob); + const auto blob = opal::Blob::FromString(std::string(reinterpret_cast(data), size)); + auto doc = opal::cbor::Decode(blob); if (doc.ok()) { - (void)smithy::cbor::Encode(*doc); + (void)opal::cbor::Encode(*doc); } return 0; } diff --git a/fuzz/eventstream_frame_fuzz.cc b/fuzz/eventstream_frame_fuzz.cc index a72680d8..fadfdcc9 100644 --- a/fuzz/eventstream_frame_fuzz.cc +++ b/fuzz/eventstream_frame_fuzz.cc @@ -13,12 +13,12 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) { const std::string_view text(reinterpret_cast(data), size); - const auto decoded = smithy::eventstream::DecodeMessage(text); + const auto decoded = opal::eventstream::DecodeMessage(text); if (!decoded.ok() || !decoded->has_value()) { return 0; } const auto& frame = **decoded; - const auto reencoded = smithy::eventstream::EncodeMessage(frame.message); + const auto reencoded = opal::eventstream::EncodeMessage(frame.message); if (!reencoded.ok()) std::abort(); // decoded but not re-encodable: bounds asymmetry if (*reencoded != text.substr(0, frame.bytes_consumed)) std::abort(); // not byte-identical // Every strict prefix must ask for more bytes. Prefixes have only two @@ -30,7 +30,7 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size // file alone. The exhaustive sweep lives in the unit suite. const std::size_t n = frame.bytes_consumed; // always >= 16 const auto expect_more = [&](std::size_t length) { - const auto prefix = smithy::eventstream::DecodeMessage(text.substr(0, length)); + const auto prefix = opal::eventstream::DecodeMessage(text.substr(0, length)); if (!prefix.ok() || prefix->has_value()) std::abort(); // prefix must ask for more }; const std::size_t stride = n <= 4096 ? 1 : n / 64; diff --git a/fuzz/eventstream_json_frame_fuzz.cc b/fuzz/eventstream_json_frame_fuzz.cc index 82d7b17d..b4ef6b93 100644 --- a/fuzz/eventstream_json_frame_fuzz.cc +++ b/fuzz/eventstream_json_frame_fuzz.cc @@ -17,13 +17,13 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) { const std::string_view text(reinterpret_cast(data), size); - const auto message = smithy::eventstream::DecodeJsonFrame(text); + const auto message = opal::eventstream::DecodeJsonFrame(text); if (!message.ok()) { return 0; } - const auto reencoded = smithy::eventstream::EncodeJsonFrame(*message); + const auto reencoded = opal::eventstream::EncodeJsonFrame(*message); if (!reencoded.ok()) std::abort(); // decoded but not re-encodable: bounds asymmetry - const auto again = smithy::eventstream::DecodeJsonFrame(*reencoded); + const auto again = opal::eventstream::DecodeJsonFrame(*reencoded); if (!again.ok()) std::abort(); // the canonical form must decode if (*again != *message) std::abort(); // and be a fixed point return 0; diff --git a/fuzz/eventstream_jsonrpc_frame_fuzz.cc b/fuzz/eventstream_jsonrpc_frame_fuzz.cc index bc1004b9..89c63b1c 100644 --- a/fuzz/eventstream_jsonrpc_frame_fuzz.cc +++ b/fuzz/eventstream_jsonrpc_frame_fuzz.cc @@ -19,26 +19,26 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) { const std::string_view text(reinterpret_cast(data), size); - const smithy::Document id(1); - const auto frame = smithy::eventstream::DecodeJsonRpcStreamFrame(text, id); - using Kind = smithy::eventstream::JsonRpcStreamFrame::Kind; + const opal::Document id(1); + const auto frame = opal::eventstream::DecodeJsonRpcStreamFrame(text, id); + using Kind = opal::eventstream::JsonRpcStreamFrame::Kind; if (frame.kind == Kind::kViolation) { if (frame.code != -32700 && frame.code != -32600) std::abort(); // reserved codes only if (frame.reason.empty()) std::abort(); // the terminal's message member const auto terminal = - smithy::eventstream::EncodeJsonRpcViolationResponse(frame.code, frame.reason, id); + opal::eventstream::EncodeJsonRpcViolationResponse(frame.code, frame.reason, id); // The server answers this text on the wire; the codec itself must // classify it (as a response envelope, never a violation of its own). - const auto answered = smithy::eventstream::DecodeJsonRpcStreamFrame(terminal, id); + const auto answered = opal::eventstream::DecodeJsonRpcStreamFrame(terminal, id); if (answered.kind != Kind::kException) std::abort(); return 0; } if (frame.kind != Kind::kEvent) { return 0; // kResult/kException carry no notification to re-encode } - const auto reencoded = smithy::eventstream::EncodeJsonRpcNotification(frame.message, id); + const auto reencoded = opal::eventstream::EncodeJsonRpcNotification(frame.message, id); if (!reencoded.ok()) std::abort(); // classified kEvent but not representable: asymmetry - const auto again = smithy::eventstream::DecodeJsonRpcStreamFrame(*reencoded, id); + const auto again = opal::eventstream::DecodeJsonRpcStreamFrame(*reencoded, id); if (again.kind != Kind::kEvent) std::abort(); // the canonical form must classify back if (again.message != frame.message) std::abort(); // and be a fixed point return 0; diff --git a/fuzz/forwarded_fuzz.cc b/fuzz/forwarded_fuzz.cc index d6deda1a..a51f3bc0 100644 --- a/fuzz/forwarded_fuzz.cc +++ b/fuzz/forwarded_fuzz.cc @@ -16,7 +16,7 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size if (size == 0) { return 0; } - static const smithy::http::TrustedProxies trusted = *smithy::http::TrustedProxies::Parse( + static const opal::http::TrustedProxies trusted = *opal::http::TrustedProxies::Parse( {"10.0.0.0/8", "192.0.2.1", "2001:db8::/32", "::ffff:172.16.0.0/108"}); // data[0] picks the peer so every run anchors a walk — trusted and @@ -26,7 +26,7 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size static constexpr std::array kPeers = { "10.0.0.1:443", "203.0.113.9:52814", "[2001:db8::1]:443", "[::ffff:172.16.0.1]:1", "", "garbage"}; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.peer_address = std::string(kPeers[data[0] % kPeers.size()]); std::string_view rest(reinterpret_cast(data + 1), size - 1); while (!rest.empty()) { @@ -38,9 +38,9 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size // Source/address consistency invariants (issue #104): the label must // always agree with what the walk actually did. - const auto derived = smithy::http::DeriveClient(request, trusted); - using Source = smithy::http::DerivedClient::Source; - if (smithy::http::ClientAddress(request, trusted) != derived.address) std::abort(); + const auto derived = opal::http::DeriveClient(request, trusted); + using Source = opal::http::DerivedClient::Source; + if (opal::http::ClientAddress(request, trusted) != derived.address) std::abort(); if ((derived.source == Source::kUnknown) != derived.address.empty()) std::abort(); const bool header_present = request.headers.Has("x-forwarded-for"); if (derived.source == Source::kDirectPeer && header_present) std::abort(); @@ -56,11 +56,11 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size // Canonical output is a fixed point: a derived key is a valid // host-route trust entry (Parse must accept it), and re-deriving from it // changes nothing. - const auto echo = smithy::http::TrustedProxies::Parse({client}); + const auto echo = opal::http::TrustedProxies::Parse({client}); if (!echo.ok() || !echo->Contains(client)) std::abort(); - smithy::http::HttpRequest again; + opal::http::HttpRequest again; again.peer_address = client; - if (smithy::http::ClientAddress(again, smithy::http::TrustedProxies::None()) != client) { + if (opal::http::ClientAddress(again, opal::http::TrustedProxies::None()) != client) { std::abort(); } } @@ -70,7 +70,7 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size // and Parse returns a valid boundary or an Error — never a crash. When it // parses, exercise Contains on the result; the parser is fuzzed either way. (void)trusted.Contains(text); - const auto probe = smithy::http::TrustedProxies::Parse({std::string(text)}); + const auto probe = opal::http::TrustedProxies::Parse({std::string(text)}); if (probe.ok()) { (void)probe->Contains("10.0.0.1"); } diff --git a/fuzz/gzip_fuzz.cc b/fuzz/gzip_fuzz.cc index 18008b5b..23f6590c 100644 --- a/fuzz/gzip_fuzz.cc +++ b/fuzz/gzip_fuzz.cc @@ -24,18 +24,18 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size constexpr std::size_t kOutputCap = std::size_t{1} << 20; // Differential decompress: slicing must not change the verdict or bytes. - const auto whole = smithy::GzipDecompress(payload, kOutputCap); - const auto sliced = smithy::internal::GzipDecompressChunked(payload, kOutputCap, max_feed); + const auto whole = opal::GzipDecompress(payload, kOutputCap); + const auto sliced = opal::internal::GzipDecompressChunked(payload, kOutputCap, max_feed); if (whole.ok() != sliced.ok()) std::abort(); // slicing changed the verdict if (whole.ok() && *whole != *sliced) std::abort(); // slicing changed the bytes // Round trip: compress under the fuzzed slicing, read back both ways. - const auto packed = smithy::internal::GzipCompressChunked(payload, max_feed); + const auto packed = opal::internal::GzipCompressChunked(payload, max_feed); if (!packed.ok()) std::abort(); // compress accepts any bytes - const auto restored = smithy::GzipDecompress(*packed, kOutputCap); + const auto restored = opal::GzipDecompress(*packed, kOutputCap); if (!restored.ok()) std::abort(); // own output must decompress if (*restored != payload) std::abort(); // and round-trip exactly - const auto re_sliced = smithy::internal::GzipDecompressChunked(*packed, kOutputCap, max_feed); + const auto re_sliced = opal::internal::GzipDecompressChunked(*packed, kOutputCap, max_feed); if (!re_sliced.ok() || *re_sliced != payload) std::abort(); return 0; } diff --git a/fuzz/http1_fuzz.cc b/fuzz/http1_fuzz.cc index cc936e4e..027a0467 100644 --- a/fuzz/http1_fuzz.cc +++ b/fuzz/http1_fuzz.cc @@ -44,7 +44,7 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size return static_cast(take); }; - auto message = smithy::http::ReadHttp1Message(read, body_until_eof); + auto message = opal::http::ReadHttp1Message(read, body_until_eof); if (message.ok()) { if (message->body.size() > kMaxBodyBytes) std::abort(); // Whatever parsed must be internally consistent enough to iterate. @@ -54,8 +54,8 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size } std::string method; std::string target; - (void)smithy::http::ParseRequestLine(message->start_line, &method, &target); - (void)smithy::http::ParseStatusLine(message->start_line); + (void)opal::http::ParseRequestLine(message->start_line, &method, &target); + (void)opal::http::ParseStatusLine(message->start_line); } return 0; } diff --git a/fuzz/json_decode_fuzz.cc b/fuzz/json_decode_fuzz.cc index 15024895..08c5fb19 100644 --- a/fuzz/json_decode_fuzz.cc +++ b/fuzz/json_decode_fuzz.cc @@ -8,9 +8,9 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) { const std::string_view text(reinterpret_cast(data), size); - auto doc = smithy::json::Decode(text); + auto doc = opal::json::Decode(text); if (doc.ok()) { - (void)smithy::json::Encode(*doc); + (void)opal::json::Encode(*doc); } return 0; } diff --git a/fuzz/regex_fuzz.cc b/fuzz/regex_fuzz.cc index 4e949045..39c7911e 100644 --- a/fuzz/regex_fuzz.cc +++ b/fuzz/regex_fuzz.cc @@ -15,7 +15,7 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size const std::string_view pattern = split == std::string_view::npos ? record : record.substr(0, split); const std::string_view text = split == std::string_view::npos ? "" : record.substr(split + 1); - auto re = smithy::Regex::Compile(pattern); + auto re = opal::Regex::Compile(pattern); if (re.ok()) { (void)re->Search(text); (void)re->Search(pattern); diff --git a/fuzz/server_dispatch_fuzz.cc b/fuzz/server_dispatch_fuzz.cc index 476575e3..01181cac 100644 --- a/fuzz/server_dispatch_fuzz.cc +++ b/fuzz/server_dispatch_fuzz.cc @@ -14,37 +14,35 @@ namespace { class NullHandler final : public example::weather::WeatherHandler { public: - smithy::Outcome GetCity( - const example::weather::GetCityInput&, const smithy::server::RequestContext&) override { + opal::Outcome GetCity( + const example::weather::GetCityInput&, const opal::server::RequestContext&) override { return example::weather::GetCityOutput{.name = "x"}; } - smithy::Outcome DeleteCity( - const example::weather::DeleteCityInput&, const smithy::server::RequestContext&) override { + opal::Outcome DeleteCity( + const example::weather::DeleteCityInput&, const opal::server::RequestContext&) override { return example::weather::DeleteCityOutput{}; } - smithy::Outcome ListCities( - const example::weather::ListCitiesInput&, const smithy::server::RequestContext&) override { + opal::Outcome ListCities( + const example::weather::ListCitiesInput&, const opal::server::RequestContext&) override { return example::weather::ListCitiesOutput{}; } - smithy::Outcome GetForecast( - const example::weather::GetForecastInput&, const smithy::server::RequestContext&) override { + opal::Outcome GetForecast( + const example::weather::GetForecastInput&, const opal::server::RequestContext&) override { return example::weather::GetForecastOutput{}; } - smithy::Outcome GetCurrentTime( - const example::weather::GetCurrentTimeInput&, - const smithy::server::RequestContext&) override { + opal::Outcome GetCurrentTime( + const example::weather::GetCurrentTimeInput&, const opal::server::RequestContext&) override { return example::weather::GetCurrentTimeOutput{}; } - smithy::Outcome GetReport( - const example::weather::GetReportInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome GetReport( + const example::weather::GetReportInput& input, const opal::server::RequestContext&) override { return example::weather::GetReportOutput{.path = input.reportPath, .sizeBytes = 0}; } }; -smithy::http::RequestHandler& Handler() { +opal::http::RequestHandler& Handler() { static auto* server = new example::weather::WeatherServer(std::make_shared()); - static auto* handler = new smithy::http::RequestHandler(server->Handler()); + static auto* handler = new opal::http::RequestHandler(server->Handler()); return *handler; } @@ -53,7 +51,7 @@ smithy::http::RequestHandler& Handler() { extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) { // Layout: method '\n' target '\n' header-value '\n' body. const std::string all(reinterpret_cast(data), size); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; std::size_t start = 0; std::string* fields[] = {&request.method, &request.target}; for (std::string* field : fields) { diff --git a/fuzz/timestamp_fuzz.cc b/fuzz/timestamp_fuzz.cc index 5b7ee06e..8a9f243d 100644 --- a/fuzz/timestamp_fuzz.cc +++ b/fuzz/timestamp_fuzz.cc @@ -17,13 +17,12 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) { const std::string_view text(reinterpret_cast(data), size); - for (const auto format : - {smithy::TimestampFormat::kEpochSeconds, smithy::TimestampFormat::kDateTime, - smithy::TimestampFormat::kHttpDate}) { - const auto parsed = smithy::Timestamp::Parse(text, format); + for (const auto format : {opal::TimestampFormat::kEpochSeconds, opal::TimestampFormat::kDateTime, + opal::TimestampFormat::kHttpDate}) { + const auto parsed = opal::Timestamp::Parse(text, format); if (!parsed.ok()) continue; const std::string canonical = parsed->Format(format); - const auto again = smithy::Timestamp::Parse(canonical, format); + const auto again = opal::Timestamp::Parse(canonical, format); if (!again.ok()) std::abort(); // own output must parse if (*again != *parsed) std::abort(); // and be a fixed point } @@ -34,12 +33,12 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size // Total over the unchecked domain: must not crash or trip UBSan even // at the int64 extremes (the civil decomposition is not involved). const std::string rendered = - smithy::Timestamp::FromEpochMilliseconds(ms).Format(smithy::TimestampFormat::kEpochSeconds); + opal::Timestamp::FromEpochMilliseconds(ms).Format(opal::TimestampFormat::kEpochSeconds); // Inside the checked window the text must read back exactly; outside // it the checked parser refuses by design. constexpr std::int64_t kMinRepresentableMs = -62167219200000; constexpr std::int64_t kMaxRepresentableMs = 253402300799999; - const auto read = smithy::Timestamp::Parse(rendered, smithy::TimestampFormat::kEpochSeconds); + const auto read = opal::Timestamp::Parse(rendered, opal::TimestampFormat::kEpochSeconds); if (ms >= kMinRepresentableMs && ms <= kMaxRepresentableMs) { if (!read.ok()) std::abort(); // in-window text must parse if (read->epoch_milliseconds() != ms) std::abort(); // exactly diff --git a/fuzz/uri_fuzz.cc b/fuzz/uri_fuzz.cc index 5c07a126..eba2845b 100644 --- a/fuzz/uri_fuzz.cc +++ b/fuzz/uri_fuzz.cc @@ -10,13 +10,13 @@ extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) { const std::string_view text(reinterpret_cast(data), size); - auto decoded = smithy::http::PercentDecode(text); + auto decoded = opal::http::PercentDecode(text); if (decoded.ok()) { - auto reencoded = smithy::http::EncodeQueryComponent(*decoded); - auto redecoded = smithy::http::PercentDecode(reencoded); + auto reencoded = opal::http::EncodeQueryComponent(*decoded); + auto redecoded = opal::http::PercentDecode(reencoded); if (!redecoded.ok() || *redecoded != *decoded) std::abort(); } - (void)smithy::http::EncodePathSegment(text); - (void)smithy::http::EncodeGreedyPathSegment(text); + (void)opal::http::EncodePathSegment(text); + (void)opal::http::EncodeGreedyPathSegment(text); return 0; } diff --git a/protocol-tests/jsonrpc2/generated/BUILD.bazel b/protocol-tests/jsonrpc2/generated/BUILD.bazel index efeb6b8e..4bfbf9f3 100644 --- a/protocol-tests/jsonrpc2/generated/BUILD.bazel +++ b/protocol-tests/jsonrpc2/generated/BUILD.bazel @@ -6,7 +6,7 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "types", - hdrs = ["include/smithy/protocoltests/jsonrpc2/types.h"], + hdrs = ["include/opal/protocoltests/jsonrpc2/types.h"], copts = [ "-Wall", "-Wextra", @@ -18,7 +18,7 @@ cc_library( cc_library( name = "serde", srcs = ["src/serde.cc"], - hdrs = ["include/smithy/protocoltests/jsonrpc2/serde.h"], + hdrs = ["include/opal/protocoltests/jsonrpc2/serde.h"], copts = [ "-Wall", "-Wextra", @@ -33,7 +33,7 @@ cc_library( cc_library( name = "client", srcs = ["src/client.cc"], - hdrs = ["include/smithy/protocoltests/jsonrpc2/client.h"], + hdrs = ["include/opal/protocoltests/jsonrpc2/client.h"], copts = [ "-Wall", "-Wextra", @@ -55,7 +55,7 @@ cc_library( cc_library( name = "server", srcs = ["src/server.cc"], - hdrs = ["include/smithy/protocoltests/jsonrpc2/server.h"], + hdrs = ["include/opal/protocoltests/jsonrpc2/server.h"], copts = [ "-Wall", "-Wextra", diff --git a/protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/client.h b/protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/client.h similarity index 75% rename from protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/client.h rename to protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/client.h index 67198cdc..d09467c1 100644 --- a/protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/client.h +++ b/protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/client.h @@ -1,7 +1,7 @@ // Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. -#ifndef SMITHY_PROTOCOLTESTS_JSONRPC2_CLIENT_H_ -#define SMITHY_PROTOCOLTESTS_JSONRPC2_CLIENT_H_ +#ifndef OPAL_PROTOCOLTESTS_JSONRPC2_CLIENT_H_ +#define OPAL_PROTOCOLTESTS_JSONRPC2_CLIENT_H_ #include #include @@ -12,6 +12,7 @@ #include #include +#include "opal/protocoltests/jsonrpc2/types.h" #include "smithy/client/config.h" #include "smithy/core/fatal.h" #include "smithy/core/hash.h" @@ -19,25 +20,24 @@ #include "smithy/core/print.h" #include "smithy/eventstream/event_stream.h" #include "smithy/http/transport.h" -#include "smithy/protocoltests/jsonrpc2/types.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { /// The typed session EchoStream returns (ADR-0016): Tx = what this client /// sends, Rx = what the server sends. -using EchoStreamClientStream = smithy::eventstream::EventStream; +using EchoStreamClientStream = opal::eventstream::EventStream; /// jsonRpc2 client for smithy.cpp.protocoltests.jsonrpc2#JsonRpc2Protocol. -/// Modeled service errors surface as smithy::Error with kind kModeled, +/// Modeled service errors surface as opal::Error with kind kModeled, /// code() set to the error shape name, and the deserialized error /// structure attached. Dispatch on them through the per-operation /// Errors listings below rather than comparing code() text. class JsonRpc2ProtocolClient { public: /// Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); + static opal::Outcome Create(opal::ClientConfig config); - smithy::Outcome EchoPayload(const EchoPayloadInput& input) const; + opal::Outcome EchoPayload(const EchoPayloadInput& input) const; /// The stream wire's conformance surface (ADR-0023). The smithy test traits /// are request/response-shaped and cannot express a stream, so the stream /// cases are authored as C++ in ../stream_conformance_test.cc — normative @@ -49,20 +49,20 @@ class JsonRpc2ProtocolClient { /// (ADR-0016). Send carries input events, Receive yields output events /// (nullopt on the peer's clean close), and a received exception /// surfaces through Receive() as a modeled error, the unary shape. - smithy::Outcome EchoStream(const EchoStreamInput& input) const; - smithy::Outcome NoArgs(const NoArgsInput& input = {}) const; - smithy::Outcome PutConstrained(const PutConstrainedInput& input) const; + opal::Outcome EchoStream(const EchoStreamInput& input) const; + opal::Outcome NoArgs(const NoArgsInput& input = {}) const; + opal::Outcome PutConstrained(const PutConstrainedInput& input) const; private: - JsonRpc2ProtocolClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix); - smithy::Outcome Send(smithy::http::HttpRequest request) const; + JsonRpc2ProtocolClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix); + opal::Outcome Send(opal::http::HttpRequest request) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; -/// The modeled errors of EchoPayload, matched from a smithy::Error so dispatch is +/// The modeled errors of EchoPayload, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -73,9 +73,9 @@ class EchoPayloadErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static EchoPayloadErrors FromError(const smithy::Error& error) { + static EchoPayloadErrors FromError(const opal::Error& error) { EchoPayloadErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "NotFoundError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : NotFoundError{}); @@ -127,11 +127,11 @@ class EchoPayloadErrors { switch (value_.index()) { case 1: out += "not_found_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "throttled_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -150,14 +150,14 @@ class EchoPayloadErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("EchoPayloadErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("EchoPayloadErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of EchoStream, matched from a smithy::Error so dispatch is +/// The modeled errors of EchoStream, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -168,9 +168,9 @@ class EchoStreamErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static EchoStreamErrors FromError(const smithy::Error& error) { + static EchoStreamErrors FromError(const opal::Error& error) { EchoStreamErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "StreamAbort") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : StreamAbort{}); @@ -209,7 +209,7 @@ class EchoStreamErrors { switch (value_.index()) { case 1: out += "stream_abort = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -228,35 +228,35 @@ class EchoStreamErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("EchoStreamErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("EchoStreamErrors", requested, case_name()); } } std::variant value_; }; -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 // std::hash so generated types key std::unordered_map/std::unordered_set — // emitted exactly for the types that get operator<=> (issue #49). Hash // values are process-local: never persist or compare them across runs. template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::EchoPayloadErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::EchoPayloadErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::EchoStreamErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::EchoStreamErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; -#endif // SMITHY_PROTOCOLTESTS_JSONRPC2_CLIENT_H_ +#endif // OPAL_PROTOCOLTESTS_JSONRPC2_CLIENT_H_ diff --git a/protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/serde.h b/protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/serde.h new file mode 100644 index 00000000..6bb94add --- /dev/null +++ b/protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/serde.h @@ -0,0 +1,76 @@ +// Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. + +#ifndef OPAL_PROTOCOLTESTS_JSONRPC2_SERDE_H_ +#define OPAL_PROTOCOLTESTS_JSONRPC2_SERDE_H_ + +#include +#include +#include + +#include "opal/protocoltests/jsonrpc2/types.h" +#include "smithy/core/document.h" +#include "smithy/core/outcome.h" + +namespace opal::protocoltests::jsonrpc2 { + +// Document-pivot serde for every aggregate shape in the model closure. +// Serializers never fail; deserializers return opal::Error on wire +// mismatches and enforce @required members. + +opal::Document SerializeEchoedNote(const EchoedNote& value); +opal::Outcome DeserializeEchoedNote(const opal::Document& doc); + +opal::Document SerializeDownEvents(const DownEvents& value); +opal::Outcome DeserializeDownEvents(const opal::Document& doc); + +opal::Document SerializeStringMap(const std::map& value); +opal::Outcome> DeserializeStringMap(const opal::Document& doc); + +opal::Document SerializeStringList(const std::vector& value); +opal::Outcome> DeserializeStringList(const opal::Document& doc); + +opal::Document SerializeNested(const Nested& value); +opal::Outcome DeserializeNested(const opal::Document& doc); + +opal::Document SerializeEchoPayloadInput(const EchoPayloadInput& value); +opal::Outcome DeserializeEchoPayloadInput(const opal::Document& doc); + +opal::Document SerializeEchoPayloadOutput(const EchoPayloadOutput& value); +opal::Outcome DeserializeEchoPayloadOutput(const opal::Document& doc); + +opal::Document SerializeNotFoundError(const NotFoundError& value); +opal::Outcome DeserializeNotFoundError(const opal::Document& doc); + +opal::Document SerializeThrottledError(const ThrottledError& value); +opal::Outcome DeserializeThrottledError(const opal::Document& doc); + +opal::Document SerializeNote(const Note& value); +opal::Outcome DeserializeNote(const opal::Document& doc); + +opal::Document SerializeUpEvents(const UpEvents& value); +opal::Outcome DeserializeUpEvents(const opal::Document& doc); + +opal::Document SerializeEchoStreamInput(const EchoStreamInput& value); +opal::Outcome DeserializeEchoStreamInput(const opal::Document& doc); + +opal::Document SerializeEchoStreamOutput(const EchoStreamOutput& value); +opal::Outcome DeserializeEchoStreamOutput(const opal::Document& doc); + +opal::Document SerializeStreamAbort(const StreamAbort& value); +opal::Outcome DeserializeStreamAbort(const opal::Document& doc); + +opal::Document SerializeNoArgsInput(const NoArgsInput& value); +opal::Outcome DeserializeNoArgsInput(const opal::Document& doc); + +opal::Document SerializeNoArgsOutput(const NoArgsOutput& value); +opal::Outcome DeserializeNoArgsOutput(const opal::Document& doc); + +opal::Document SerializePutConstrainedInput(const PutConstrainedInput& value); +opal::Outcome DeserializePutConstrainedInput(const opal::Document& doc); + +opal::Document SerializePutConstrainedOutput(const PutConstrainedOutput& value); +opal::Outcome DeserializePutConstrainedOutput(const opal::Document& doc); + +} // namespace opal::protocoltests::jsonrpc2 + +#endif // OPAL_PROTOCOLTESTS_JSONRPC2_SERDE_H_ diff --git a/protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/server.h b/protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/server.h similarity index 69% rename from protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/server.h rename to protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/server.h index 965708a9..693e2c07 100644 --- a/protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/server.h +++ b/protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/server.h @@ -1,39 +1,39 @@ // Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. -#ifndef SMITHY_PROTOCOLTESTS_JSONRPC2_SERVER_H_ -#define SMITHY_PROTOCOLTESTS_JSONRPC2_SERVER_H_ +#ifndef OPAL_PROTOCOLTESTS_JSONRPC2_SERVER_H_ +#define OPAL_PROTOCOLTESTS_JSONRPC2_SERVER_H_ #include +#include "opal/protocoltests/jsonrpc2/types.h" #include "smithy/core/outcome.h" #include "smithy/eventstream/async_event_stream.h" #include "smithy/eventstream/event_stream.h" #include "smithy/http/transport.h" -#include "smithy/protocoltests/jsonrpc2/types.h" #include "smithy/server/router.h" #include "smithy/server/websocket_router.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { /// The typed session a EchoStream handler borrows (ADR-0016): Tx = what this /// server sends, Rx = what the client sends. -using EchoStreamServerStream = smithy::eventstream::EventStream; +using EchoStreamServerStream = opal::eventstream::EventStream; /// The same session for an async handler (ADR-0021): co_await where the /// blocking sibling parks a thread; identical directions and Share(). -using EchoStreamAsyncServerStream = smithy::eventstream::AsyncEventStream; +using EchoStreamAsyncServerStream = opal::eventstream::AsyncEventStream; /// Implement one method per operation. Return a modeled error as -/// smithy::Error::Modeled("", message), optionally with the +/// opal::Error::Modeled("", message), optionally with the /// typed error structure attached via set_detail() so it serializes fully. /// The context carries the raw request and routing captures — see -/// smithy::server::RequestContext; leave the parameter unnamed when unused. +/// opal::server::RequestContext; leave the parameter unnamed when unused. /// Implementations must be thread-safe: transports may invoke any mix of /// operations concurrently on the one handler instance. class JsonRpc2ProtocolHandler { public: virtual ~JsonRpc2ProtocolHandler() = default; - virtual smithy::Outcome EchoPayload(const EchoPayloadInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome EchoPayload(const EchoPayloadInput& input, const opal::server::RequestContext& context) = 0; /// The stream wire's conformance surface (ADR-0023). The smithy test traits /// are request/response-shaped and cannot express a stream, so the stream /// cases are authored as C++ in ../stream_conformance_test.cc — normative @@ -49,9 +49,9 @@ class JsonRpc2ProtocolHandler { /// `stream` is valid only until this method returns; join any helper /// thread still using it. Blocks the transport's handler thread for /// the session's lifetime. - virtual smithy::Outcome EchoStream(const EchoStreamInput& input, EchoStreamServerStream& stream, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome NoArgs(const NoArgsInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome PutConstrained(const PutConstrainedInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome EchoStream(const EchoStreamInput& input, EchoStreamServerStream& stream, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome NoArgs(const NoArgsInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome PutConstrained(const PutConstrainedInput& input, const opal::server::RequestContext& context) = 0; }; /// JsonRpc2ProtocolHandler's zero-thread sibling (ADR-0021): implement this and construct @@ -63,7 +63,7 @@ class JsonRpc2ProtocolAsyncHandler { public: virtual ~JsonRpc2ProtocolAsyncHandler() = default; - virtual smithy::Outcome EchoPayload(const EchoPayloadInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::Outcome EchoPayload(const EchoPayloadInput& input, const opal::server::RequestContext& context) = 0; /// The stream wire's conformance surface (ADR-0023). The smithy test traits /// are request/response-shaped and cannot express a stream, so the stream /// cases are authored as C++ in ../stream_conformance_test.cc — normative @@ -73,8 +73,8 @@ class JsonRpc2ProtocolAsyncHandler { /// /// Async streaming operation (ADR-0021): a coroutine serving the whole /// session — co_await stream.Receive()/Send() until done. - /// co_return smithy::Unit{} for a clean close, or an error — modeled as - /// smithy::Error::Modeled("", message) + set_detail(), + /// co_return opal::Unit{} for a clean close, or an error — modeled as + /// opal::Error::Modeled("", message) + set_detail(), /// like a blocking handler — which ends the stream with one best-effort /// exception message before the close. `input` is the coroutine's own /// copy: the upgrade request (and its RequestContext) is gone by the @@ -83,14 +83,14 @@ class JsonRpc2ProtocolAsyncHandler { /// task completes. Code before the first co_await runs on the launching /// handler thread (brief blocking is fine there); every later resumption /// is a transport completion context — never block those. - virtual smithy::eventstream::StreamTask EchoStream(EchoStreamInput input, EchoStreamAsyncServerStream& stream) = 0; - virtual smithy::Outcome NoArgs(const NoArgsInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome PutConstrained(const PutConstrainedInput& input, const smithy::server::RequestContext& context) = 0; + virtual opal::eventstream::StreamTask EchoStream(EchoStreamInput input, EchoStreamAsyncServerStream& stream) = 0; + virtual opal::Outcome NoArgs(const NoArgsInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome PutConstrained(const PutConstrainedInput& input, const opal::server::RequestContext& context) = 0; }; /// jsonRpc2 server for smithy.cpp.protocoltests.jsonrpc2#JsonRpc2Protocol: routing, deserialization, handler dispatch, /// response serialization, and modeled-error mapping. Pass Handler() to any -/// smithy::http::HttpServerTransport. +/// opal::http::HttpServerTransport. class JsonRpc2ProtocolServer { public: explicit JsonRpc2ProtocolServer(std::shared_ptr handler); @@ -100,7 +100,7 @@ class JsonRpc2ProtocolServer { /// constructor chosen decides which two-line mount applies (StreamRouter). explicit JsonRpc2ProtocolServer(std::shared_ptr handler); - smithy::http::RequestHandler Handler() const; + opal::http::RequestHandler Handler() const; /// The WebSocket router carrying every streaming route (ADR-0016), ready /// to mount on the transport in two lines — the serve line keyed to the @@ -109,13 +109,13 @@ class JsonRpc2ProtocolServer { /// options.on_websocket = server.StreamRouter()->Serve(); // blocking handler /// options.on_websocket_session = /// server.StreamRouter()->ServeSession(); // async handler (ADR-0021) - std::shared_ptr StreamRouter() const; + std::shared_ptr StreamRouter() const; private: - std::shared_ptr router_; - std::shared_ptr stream_router_; + std::shared_ptr router_; + std::shared_ptr stream_router_; }; -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 -#endif // SMITHY_PROTOCOLTESTS_JSONRPC2_SERVER_H_ +#endif // OPAL_PROTOCOLTESTS_JSONRPC2_SERVER_H_ diff --git a/protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/types.h b/protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/types.h similarity index 71% rename from protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/types.h rename to protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/types.h index 3eec12e0..fc7ad462 100644 --- a/protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/types.h +++ b/protocol-tests/jsonrpc2/generated/include/opal/protocoltests/jsonrpc2/types.h @@ -1,7 +1,7 @@ // Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. -#ifndef SMITHY_PROTOCOLTESTS_JSONRPC2_TYPES_H_ -#define SMITHY_PROTOCOLTESTS_JSONRPC2_TYPES_H_ +#ifndef OPAL_PROTOCOLTESTS_JSONRPC2_TYPES_H_ +#define OPAL_PROTOCOLTESTS_JSONRPC2_TYPES_H_ #include #include @@ -20,7 +20,7 @@ #include "smithy/core/print.h" #include "smithy/core/timestamp.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { struct EchoedNote { std::string text{}; @@ -32,7 +32,7 @@ struct EchoedNote { out += sep; sep = ", "; out += ".text = "; - smithy::DebugAppend(out, this->text); + opal::DebugAppend(out, this->text); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -84,7 +84,7 @@ class DownEvents { switch (value_.index()) { case 1: out += "echo = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -103,7 +103,7 @@ class DownEvents { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("DownEvents", requested, case_name()); + opal::internal::FatalWrongUnionAccess("DownEvents", requested, case_name()); } } @@ -122,12 +122,12 @@ struct Nested { out += sep; sep = ", "; out += ".label = "; - smithy::DebugAppend(out, this->label); + opal::DebugAppend(out, this->label); if (this->depth.has_value()) { out += sep; sep = ", "; out += ".depth = "; - smithy::DebugAppend(out, *this->depth); + opal::DebugAppend(out, *this->depth); } out += '}'; } @@ -147,8 +147,8 @@ struct EchoPayloadInput { std::optional integer{}; std::optional boolean{}; std::optional double_{}; - std::optional timestamp{}; - std::optional dateTime{}; + std::optional timestamp{}; + std::optional dateTime{}; std::optional> names{}; std::optional> attributes{}; std::optional nested{}; @@ -161,61 +161,61 @@ struct EchoPayloadInput { out += sep; sep = ", "; out += ".string = "; - smithy::DebugAppend(out, *this->string); + opal::DebugAppend(out, *this->string); } if (this->aliased.has_value()) { out += sep; sep = ", "; out += ".aliased = "; - smithy::DebugAppend(out, *this->aliased); + opal::DebugAppend(out, *this->aliased); } if (this->integer.has_value()) { out += sep; sep = ", "; out += ".integer = "; - smithy::DebugAppend(out, *this->integer); + opal::DebugAppend(out, *this->integer); } if (this->boolean.has_value()) { out += sep; sep = ", "; out += ".boolean = "; - smithy::DebugAppend(out, *this->boolean); + opal::DebugAppend(out, *this->boolean); } if (this->double_.has_value()) { out += sep; sep = ", "; out += ".double_ = "; - smithy::DebugAppend(out, *this->double_); + opal::DebugAppend(out, *this->double_); } if (this->timestamp.has_value()) { out += sep; sep = ", "; out += ".timestamp = "; - smithy::DebugAppend(out, *this->timestamp); + opal::DebugAppend(out, *this->timestamp); } if (this->dateTime.has_value()) { out += sep; sep = ", "; out += ".dateTime = "; - smithy::DebugAppend(out, *this->dateTime); + opal::DebugAppend(out, *this->dateTime); } if (this->names.has_value()) { out += sep; sep = ", "; out += ".names = "; - smithy::DebugAppend(out, *this->names); + opal::DebugAppend(out, *this->names); } if (this->attributes.has_value()) { out += sep; sep = ", "; out += ".attributes = "; - smithy::DebugAppend(out, *this->attributes); + opal::DebugAppend(out, *this->attributes); } if (this->nested.has_value()) { out += sep; sep = ", "; out += ".nested = "; - smithy::DebugAppend(out, *this->nested); + opal::DebugAppend(out, *this->nested); } out += '}'; } @@ -242,19 +242,19 @@ struct EchoPayloadOutput { out += sep; sep = ", "; out += ".echo = "; - smithy::DebugAppend(out, *this->echo); + opal::DebugAppend(out, *this->echo); } if (this->count.has_value()) { out += sep; sep = ", "; out += ".count = "; - smithy::DebugAppend(out, *this->count); + opal::DebugAppend(out, *this->count); } if (this->nested.has_value()) { out += sep; sep = ", "; out += ".nested = "; - smithy::DebugAppend(out, *this->nested); + opal::DebugAppend(out, *this->nested); } out += '}'; } @@ -279,12 +279,12 @@ struct NotFoundError { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); if (this->resourceType.has_value()) { out += sep; sep = ", "; out += ".resourceType = "; - smithy::DebugAppend(out, *this->resourceType); + opal::DebugAppend(out, *this->resourceType); } out += '}'; } @@ -309,7 +309,7 @@ struct ThrottledError { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, *this->message); + opal::DebugAppend(out, *this->message); } out += '}'; } @@ -333,7 +333,7 @@ struct Note { out += sep; sep = ", "; out += ".text = "; - smithy::DebugAppend(out, this->text); + opal::DebugAppend(out, this->text); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -385,7 +385,7 @@ class UpEvents { switch (value_.index()) { case 1: out += "note = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -404,7 +404,7 @@ class UpEvents { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("UpEvents", requested, case_name()); + opal::internal::FatalWrongUnionAccess("UpEvents", requested, case_name()); } } @@ -424,13 +424,13 @@ struct EchoStreamInput { out += sep; sep = ", "; out += ".prefix = "; - smithy::DebugAppend(out, *this->prefix); + opal::DebugAppend(out, *this->prefix); } if (this->events.has_value()) { out += sep; sep = ", "; out += ".events = "; - smithy::DebugAppend(out, *this->events); + opal::DebugAppend(out, *this->events); } out += '}'; } @@ -455,7 +455,7 @@ struct EchoStreamOutput { out += sep; sep = ", "; out += ".events = "; - smithy::DebugAppend(out, *this->events); + opal::DebugAppend(out, *this->events); } out += '}'; } @@ -479,7 +479,7 @@ struct StreamAbort { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -537,24 +537,24 @@ struct PutConstrainedInput { out += sep; sep = ", "; out += ".name = "; - smithy::DebugAppend(out, this->name); + opal::DebugAppend(out, this->name); if (this->limit.has_value()) { out += sep; sep = ", "; out += ".limit = "; - smithy::DebugAppend(out, *this->limit); + opal::DebugAppend(out, *this->limit); } if (this->slug.has_value()) { out += sep; sep = ", "; out += ".slug = "; - smithy::DebugAppend(out, *this->slug); + opal::DebugAppend(out, *this->slug); } if (this->evilDigits.has_value()) { out += sep; sep = ", "; out += ".evilDigits = "; - smithy::DebugAppend(out, *this->evilDigits); + opal::DebugAppend(out, *this->evilDigits); } out += '}'; } @@ -578,7 +578,7 @@ struct PutConstrainedOutput { out += sep; sep = ", "; out += ".accepted = "; - smithy::DebugAppend(out, this->accepted); + opal::DebugAppend(out, this->accepted); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -590,163 +590,163 @@ struct PutConstrainedOutput { friend auto operator<=>(const PutConstrainedOutput&, const PutConstrainedOutput&) = default; }; -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 // std::hash so generated types key std::unordered_map/std::unordered_set — // emitted exactly for the types that get operator<=> (issue #49). Hash // values are process-local: never persist or compare them across runs. template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::EchoedNote& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::EchoedNote& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.text)); + seed = opal::HashCombine(seed, opal::HashValue(value.text)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::DownEvents& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::DownEvents& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::Nested& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::Nested& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.label)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.depth)); + seed = opal::HashCombine(seed, opal::HashValue(value.label)); + seed = opal::HashCombine(seed, opal::HashValue(value.depth)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::EchoPayloadInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::EchoPayloadInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.string)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.aliased)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.integer)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.boolean)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.double_)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.timestamp)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.dateTime)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.names)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.attributes)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.nested)); + seed = opal::HashCombine(seed, opal::HashValue(value.string)); + seed = opal::HashCombine(seed, opal::HashValue(value.aliased)); + seed = opal::HashCombine(seed, opal::HashValue(value.integer)); + seed = opal::HashCombine(seed, opal::HashValue(value.boolean)); + seed = opal::HashCombine(seed, opal::HashValue(value.double_)); + seed = opal::HashCombine(seed, opal::HashValue(value.timestamp)); + seed = opal::HashCombine(seed, opal::HashValue(value.dateTime)); + seed = opal::HashCombine(seed, opal::HashValue(value.names)); + seed = opal::HashCombine(seed, opal::HashValue(value.attributes)); + seed = opal::HashCombine(seed, opal::HashValue(value.nested)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::EchoPayloadOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::EchoPayloadOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.echo)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.count)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.nested)); + seed = opal::HashCombine(seed, opal::HashValue(value.echo)); + seed = opal::HashCombine(seed, opal::HashValue(value.count)); + seed = opal::HashCombine(seed, opal::HashValue(value.nested)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::NotFoundError& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::NotFoundError& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.resourceType)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.resourceType)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::ThrottledError& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::ThrottledError& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::Note& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::Note& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.text)); + seed = opal::HashCombine(seed, opal::HashValue(value.text)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::UpEvents& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::UpEvents& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::EchoStreamInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::EchoStreamInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.prefix)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.events)); + seed = opal::HashCombine(seed, opal::HashValue(value.prefix)); + seed = opal::HashCombine(seed, opal::HashValue(value.events)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::EchoStreamOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::EchoStreamOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.events)); + seed = opal::HashCombine(seed, opal::HashValue(value.events)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::StreamAbort& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::StreamAbort& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::NoArgsInput& /*value*/) const noexcept { return 0; } +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::NoArgsInput& /*value*/) const noexcept { return 0; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::NoArgsOutput& /*value*/) const noexcept { return 0; } +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::NoArgsOutput& /*value*/) const noexcept { return 0; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::PutConstrainedInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::PutConstrainedInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.name)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.limit)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.slug)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.evilDigits)); + seed = opal::HashCombine(seed, opal::HashValue(value.name)); + seed = opal::HashCombine(seed, opal::HashValue(value.limit)); + seed = opal::HashCombine(seed, opal::HashValue(value.slug)); + seed = opal::HashCombine(seed, opal::HashValue(value.evilDigits)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::jsonrpc2::PutConstrainedOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::jsonrpc2::PutConstrainedOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.accepted)); + seed = opal::HashCombine(seed, opal::HashValue(value.accepted)); return seed; } }; -#endif // SMITHY_PROTOCOLTESTS_JSONRPC2_TYPES_H_ +#endif // OPAL_PROTOCOLTESTS_JSONRPC2_TYPES_H_ diff --git a/protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/serde.h b/protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/serde.h deleted file mode 100644 index beaa2e84..00000000 --- a/protocol-tests/jsonrpc2/generated/include/smithy/protocoltests/jsonrpc2/serde.h +++ /dev/null @@ -1,76 +0,0 @@ -// Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. - -#ifndef SMITHY_PROTOCOLTESTS_JSONRPC2_SERDE_H_ -#define SMITHY_PROTOCOLTESTS_JSONRPC2_SERDE_H_ - -#include -#include -#include - -#include "smithy/core/document.h" -#include "smithy/core/outcome.h" -#include "smithy/protocoltests/jsonrpc2/types.h" - -namespace smithy::protocoltests::jsonrpc2 { - -// Document-pivot serde for every aggregate shape in the model closure. -// Serializers never fail; deserializers return smithy::Error on wire -// mismatches and enforce @required members. - -smithy::Document SerializeEchoedNote(const EchoedNote& value); -smithy::Outcome DeserializeEchoedNote(const smithy::Document& doc); - -smithy::Document SerializeDownEvents(const DownEvents& value); -smithy::Outcome DeserializeDownEvents(const smithy::Document& doc); - -smithy::Document SerializeStringMap(const std::map& value); -smithy::Outcome> DeserializeStringMap(const smithy::Document& doc); - -smithy::Document SerializeStringList(const std::vector& value); -smithy::Outcome> DeserializeStringList(const smithy::Document& doc); - -smithy::Document SerializeNested(const Nested& value); -smithy::Outcome DeserializeNested(const smithy::Document& doc); - -smithy::Document SerializeEchoPayloadInput(const EchoPayloadInput& value); -smithy::Outcome DeserializeEchoPayloadInput(const smithy::Document& doc); - -smithy::Document SerializeEchoPayloadOutput(const EchoPayloadOutput& value); -smithy::Outcome DeserializeEchoPayloadOutput(const smithy::Document& doc); - -smithy::Document SerializeNotFoundError(const NotFoundError& value); -smithy::Outcome DeserializeNotFoundError(const smithy::Document& doc); - -smithy::Document SerializeThrottledError(const ThrottledError& value); -smithy::Outcome DeserializeThrottledError(const smithy::Document& doc); - -smithy::Document SerializeNote(const Note& value); -smithy::Outcome DeserializeNote(const smithy::Document& doc); - -smithy::Document SerializeUpEvents(const UpEvents& value); -smithy::Outcome DeserializeUpEvents(const smithy::Document& doc); - -smithy::Document SerializeEchoStreamInput(const EchoStreamInput& value); -smithy::Outcome DeserializeEchoStreamInput(const smithy::Document& doc); - -smithy::Document SerializeEchoStreamOutput(const EchoStreamOutput& value); -smithy::Outcome DeserializeEchoStreamOutput(const smithy::Document& doc); - -smithy::Document SerializeStreamAbort(const StreamAbort& value); -smithy::Outcome DeserializeStreamAbort(const smithy::Document& doc); - -smithy::Document SerializeNoArgsInput(const NoArgsInput& value); -smithy::Outcome DeserializeNoArgsInput(const smithy::Document& doc); - -smithy::Document SerializeNoArgsOutput(const NoArgsOutput& value); -smithy::Outcome DeserializeNoArgsOutput(const smithy::Document& doc); - -smithy::Document SerializePutConstrainedInput(const PutConstrainedInput& value); -smithy::Outcome DeserializePutConstrainedInput(const smithy::Document& doc); - -smithy::Document SerializePutConstrainedOutput(const PutConstrainedOutput& value); -smithy::Outcome DeserializePutConstrainedOutput(const smithy::Document& doc); - -} // namespace smithy::protocoltests::jsonrpc2 - -#endif // SMITHY_PROTOCOLTESTS_JSONRPC2_SERDE_H_ diff --git a/protocol-tests/jsonrpc2/generated/src/client.cc b/protocol-tests/jsonrpc2/generated/src/client.cc index ae77bcc2..fd1efeb5 100644 --- a/protocol-tests/jsonrpc2/generated/src/client.cc +++ b/protocol-tests/jsonrpc2/generated/src/client.cc @@ -6,6 +6,8 @@ #include #include +#include "opal/protocoltests/jsonrpc2/client.h" +#include "opal/protocoltests/jsonrpc2/serde.h" #include "smithy/core/blob.h" #include "smithy/core/document.h" #include "smithy/core/document_serde.h" @@ -17,12 +19,10 @@ #include "smithy/http/uri.h" #include "smithy/http/websocket.h" #include "smithy/json/json.h" -#include "smithy/protocoltests/jsonrpc2/client.h" -#include "smithy/protocoltests/jsonrpc2/serde.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { -namespace types = ::smithy::protocoltests::jsonrpc2; +namespace types = ::opal::protocoltests::jsonrpc2; namespace { namespace helpers { @@ -39,43 +39,43 @@ struct ParsedError { int status = 0; std::string code = "UnknownError"; std::string message; - smithy::Document doc; + opal::Document doc; }; // [[maybe_unused]]: only unary response paths parse wire errors; a // service whose operations all stream never calls this. -[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) { +[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) { ParsedError parsed; parsed.status = response.status; parsed.message = "HTTP " + std::to_string(response.status); - auto doc = smithy::json::Decode(response.body); + auto doc = opal::json::Decode(response.body); if (!doc.ok() || !doc->is_map()) return parsed; - const smithy::Document* error = doc->Find("error"); + const opal::Document* error = doc->Find("error"); if (error == nullptr || !error->is_map()) return parsed; - if (const smithy::Document* code = error->Find("code"); code != nullptr && code->is_int()) { + if (const opal::Document* code = error->Find("code"); code != nullptr && code->is_int()) { const std::int64_t rpc_code = code->as_int(); parsed.status = rpc_code >= 100 && rpc_code < 600 ? static_cast(rpc_code) : (rpc_code == -32603 ? 500 : 400); } - if (const smithy::Document* message = error->Find("message"); message != nullptr && message->is_string()) parsed.message = message->as_string(); - if (const smithy::Document* data = error->Find("data"); data != nullptr) parsed.doc = *data; + if (const opal::Document* message = error->Find("message"); message != nullptr && message->is_string()) parsed.message = message->as_string(); + if (const opal::Document* data = error->Find("data"); data != nullptr) parsed.doc = *data; if (parsed.doc.is_map()) { - const smithy::Document* type = parsed.doc.Find("__type"); + const opal::Document* type = parsed.doc.Find("__type"); if (type != nullptr && type->is_string()) parsed.code = helpers::SanitizeErrorCode(type->as_string()); } return parsed; } -smithy::Error GenericError(ParsedError parsed) { +opal::Error GenericError(ParsedError parsed) { const bool retryable = parsed.status >= 500; - if (parsed.code == "UnknownError") return smithy::Error(smithy::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); - return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); + if (parsed.code == "UnknownError") return opal::Error(opal::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); + return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); } -smithy::Error MakeNotFoundErrorError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeNotFoundErrorError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("NotFoundError", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("NotFoundError", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeNotFoundError(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -83,11 +83,11 @@ smithy::Error MakeNotFoundErrorError(const smithy::http::HttpResponse& response, return error; } -smithy::Error MakeStreamAbortError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeStreamAbortError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("StreamAbort", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("StreamAbort", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeStreamAbort(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -95,11 +95,11 @@ smithy::Error MakeStreamAbortError(const smithy::http::HttpResponse& response, P return error; } -smithy::Error MakeThrottledErrorError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeThrottledErrorError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = true; // @retryable - smithy::Error error = smithy::Error::Modeled("ThrottledError", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("ThrottledError", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeThrottledError(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -107,7 +107,7 @@ smithy::Error MakeThrottledErrorError(const smithy::http::HttpResponse& response return error; } -smithy::Error ParseEchoPayloadError(const smithy::http::HttpResponse& response) { +opal::Error ParseEchoPayloadError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "NotFoundError") return helpers::MakeNotFoundErrorError(response, std::move(parsed)); if (parsed.code == "ThrottledError") return helpers::MakeThrottledErrorError(response, std::move(parsed)); @@ -118,9 +118,9 @@ smithy::Error ParseEchoPayloadError(const smithy::http::HttpResponse& response) // TLS come from the same endpoint the unary transport uses (nothing is // configured twice); config.websocket_dialer overrides the Beast dialer the // way http_client overrides the unary transport. -smithy::Outcome> DialStream(const smithy::ClientConfig& config, smithy::http::WebSocketDialRequest request) { +opal::Outcome> DialStream(const opal::ClientConfig& config, opal::http::WebSocketDialRequest request) { if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); request.host = endpoint->host; request.port = endpoint->port; @@ -129,114 +129,114 @@ smithy::Outcome> DialStream(const smith } if (config.websocket_dialer) return config.websocket_dialer(request); if (request.host.empty()) { - return smithy::Error::Validation("JsonRpc2ProtocolClient: config needs an endpoint or a websocket_dialer"); + return opal::Error::Validation("JsonRpc2ProtocolClient: config needs an endpoint or a websocket_dialer"); } - return smithy::http::BeastWebSocketClient::Dialer()(request); + return opal::http::BeastWebSocketClient::Dialer()(request); } // One event per message (ADR-0016): the engaged member's structure is the // payload, its member name the :event-type. -smithy::Outcome EncodeEchoStreamEvent(const types::UpEvents& event) { +opal::Outcome EncodeEchoStreamEvent(const types::UpEvents& event) { if (event.is_note()) { - return smithy::eventstream::MakeEventMessage("note", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeNote(event.as_note())))); + return opal::eventstream::MakeEventMessage("note", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeNote(event.as_note())))); } - return smithy::Error::Validation("UpEvents: no event member engaged"); + return opal::Error::Validation("UpEvents: no event member engaged"); } -smithy::Outcome DecodeEchoStreamEvent(const smithy::eventstream::Message& message) { - auto envelope = smithy::eventstream::ParseEnvelope(message); +opal::Outcome DecodeEchoStreamEvent(const opal::eventstream::Message& message) { + auto envelope = opal::eventstream::ParseEnvelope(message); if (!envelope) return std::move(envelope).error(); - if (envelope->kind == smithy::eventstream::EventEnvelope::Kind::kException) { + if (envelope->kind == opal::eventstream::EventEnvelope::Kind::kException) { // A received exception is terminal (ADR-0016): the EventStream closes the // session and surfaces this error, exactly the unary shape. ParsedError parsed; parsed.code = helpers::SanitizeErrorCode(envelope->type); - auto exception_doc = smithy::json::Decode(envelope->payload.ToString()); + auto exception_doc = opal::json::Decode(envelope->payload.ToString()); if (exception_doc.ok() && exception_doc->is_map()) { parsed.doc = *std::move(exception_doc); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } // MakeError's header-patch source; exception messages carry none. - smithy::http::HttpResponse response; + opal::http::HttpResponse response; if (parsed.code == "StreamAbort") return helpers::MakeStreamAbortError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); } if (envelope->type == "echo") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeEchoedNote(*doc); if (!event) return std::move(event).error(); return types::DownEvents::FromEcho(*std::move(event)); } - return smithy::Error::Serialization("EchoStream: unknown event type: " + envelope->type); + return opal::Error::Serialization("EchoStream: unknown event type: " + envelope->type); } } // namespace helpers } // namespace -smithy::Outcome JsonRpc2ProtocolClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome JsonRpc2ProtocolClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { // The built-in socket transport is plaintext-only; https needs a - // TLS-capable transport (e.g. smithy::http::BeastHttpClient). + // TLS-capable transport (e.g. opal::http::BeastHttpClient). if (endpoint->tls()) { - return smithy::Error::Validation("JsonRpc2ProtocolClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + return opal::Error::Validation("JsonRpc2ProtocolClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); } - transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); } } if (transport == nullptr) { - return smithy::Error::Validation("JsonRpc2ProtocolClient: config needs an endpoint or an http_client"); + return opal::Error::Validation("JsonRpc2ProtocolClient: config needs an endpoint or an http_client"); } return JsonRpc2ProtocolClient(std::move(config), std::move(transport), std::move(prefix)); } -JsonRpc2ProtocolClient::JsonRpc2ProtocolClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix) +JsonRpc2ProtocolClient::JsonRpc2ProtocolClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} -smithy::Outcome JsonRpc2ProtocolClient::Send(smithy::http::HttpRequest request) const { +opal::Outcome JsonRpc2ProtocolClient::Send(opal::http::HttpRequest request) const { // Operations with a non-document response payload set their own accept. if (!request.headers.Get("accept").has_value()) request.headers.Set("accept", "application/json"); request.headers.Set("user-agent", config_.user_agent); if (!request.body.empty()) { request.headers.Set("content-length", std::to_string(request.body.size())); } - return smithy::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); + return opal::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); } -smithy::Outcome JsonRpc2ProtocolClient::EchoPayload(const EchoPayloadInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome JsonRpc2ProtocolClient::EchoPayload(const EchoPayloadInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/"; request.headers.Set("content-type", "application/json"); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("method", smithy::Document("EchoPayload")); - envelope.emplace("id", smithy::Document(1)); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("method", opal::Document("EchoPayload")); + envelope.emplace("id", opal::Document(1)); envelope.emplace("params", SerializeEchoPayloadInput(input)); - request.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + request.body = opal::json::Encode(opal::Document(std::move(envelope))); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); - auto envelope_doc = smithy::json::Decode(response->body); + auto envelope_doc = opal::json::Decode(response->body); // Errors are JSON-RPC envelopes on HTTP 200; non-200 means the request // never reached the protocol layer (router 404, proxy) and parses generically. const bool is_error = !envelope_doc.ok() || !envelope_doc->is_map() || envelope_doc->Find("error") != nullptr; if (response->status != 200 || is_error) return helpers::ParseEchoPayloadError(*response); - const smithy::Document* result = envelope_doc->Find("result"); + const opal::Document* result = envelope_doc->Find("result"); if (result == nullptr) return EchoPayloadOutput{}; return DeserializeEchoPayloadOutput(*result); } -smithy::Outcome JsonRpc2ProtocolClient::EchoStream(const EchoStreamInput& input) const { - smithy::http::WebSocketDialRequest request; +opal::Outcome JsonRpc2ProtocolClient::EchoStream(const EchoStreamInput& input) const { + opal::http::WebSocketDialRequest request; // The shared endpoint (ADR-0023): the same target the unary POST uses — // the operation rides the opening envelope, and every frame is text. request.target = path_prefix_ + "/"; @@ -246,37 +246,37 @@ smithy::Outcome JsonRpc2ProtocolClient::EchoStream(const if (!socket) return std::move(socket).error(); // The opening request envelope: selects the operation and carries the // initial-request members (the :initial-request seam, realized). - smithy::DocumentMap params = SerializeEchoStreamInput(input).as_map(); + opal::DocumentMap params = SerializeEchoStreamInput(input).as_map(); // The union is the session, never a params member. params.erase("events"); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("method", smithy::Document("EchoStream")); - envelope.emplace("id", smithy::Document(1)); - envelope.emplace("params", smithy::Document(std::move(params))); - smithy::eventstream::Message opening; - opening.payload = smithy::Blob::FromString(smithy::json::Encode(smithy::Document(std::move(envelope)))); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("method", opal::Document("EchoStream")); + envelope.emplace("id", opal::Document(1)); + envelope.emplace("params", opal::Document(std::move(params))); + opal::eventstream::Message opening; + opening.payload = opal::Blob::FromString(opal::json::Encode(opal::Document(std::move(envelope)))); auto sent = (*socket)->Send(opening); if (!sent) return std::move(sent).error(); return EchoStreamClientStream( - std::make_shared(*std::move(socket), smithy::Document(1), smithy::eventstream::JsonRpcStreamSocket::Role::kClient), + std::make_shared(*std::move(socket), opal::Document(1), opal::eventstream::JsonRpcStreamSocket::Role::kClient), helpers::EncodeEchoStreamEvent, helpers::DecodeEchoStreamEvent); } -smithy::Outcome JsonRpc2ProtocolClient::NoArgs(const NoArgsInput& input) const { +opal::Outcome JsonRpc2ProtocolClient::NoArgs(const NoArgsInput& input) const { (void)input; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/"; request.headers.Set("content-type", "application/json"); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("method", smithy::Document("NoArgs")); - envelope.emplace("id", smithy::Document(1)); - request.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("method", opal::Document("NoArgs")); + envelope.emplace("id", opal::Document(1)); + request.body = opal::json::Encode(opal::Document(std::move(envelope))); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); - auto envelope_doc = smithy::json::Decode(response->body); + auto envelope_doc = opal::json::Decode(response->body); // Errors are JSON-RPC envelopes on HTTP 200; non-200 means the request // never reached the protocol layer (router 404, proxy) and parses generically. const bool is_error = !envelope_doc.ok() || !envelope_doc->is_map() || envelope_doc->Find("error") != nullptr; @@ -284,27 +284,27 @@ smithy::Outcome JsonRpc2ProtocolClient::NoArgs(const NoArgsInput& return NoArgsOutput{}; } -smithy::Outcome JsonRpc2ProtocolClient::PutConstrained(const PutConstrainedInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome JsonRpc2ProtocolClient::PutConstrained(const PutConstrainedInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/"; request.headers.Set("content-type", "application/json"); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("method", smithy::Document("PutConstrained")); - envelope.emplace("id", smithy::Document(1)); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("method", opal::Document("PutConstrained")); + envelope.emplace("id", opal::Document(1)); envelope.emplace("params", SerializePutConstrainedInput(input)); - request.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + request.body = opal::json::Encode(opal::Document(std::move(envelope))); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); - auto envelope_doc = smithy::json::Decode(response->body); + auto envelope_doc = opal::json::Decode(response->body); // Errors are JSON-RPC envelopes on HTTP 200; non-200 means the request // never reached the protocol layer (router 404, proxy) and parses generically. const bool is_error = !envelope_doc.ok() || !envelope_doc->is_map() || envelope_doc->Find("error") != nullptr; if (response->status != 200 || is_error) return helpers::GenericError(helpers::ParseError(*response)); - const smithy::Document* result = envelope_doc->Find("result"); - if (result == nullptr) return smithy::Error::Serialization("jsonRpc2: response has no result member"); + const opal::Document* result = envelope_doc->Find("result"); + if (result == nullptr) return opal::Error::Serialization("jsonRpc2: response has no result member"); return DeserializePutConstrainedOutput(*result); } -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 diff --git a/protocol-tests/jsonrpc2/generated/src/serde.cc b/protocol-tests/jsonrpc2/generated/src/serde.cc index 4c48cbaa..539df7fc 100644 --- a/protocol-tests/jsonrpc2/generated/src/serde.cc +++ b/protocol-tests/jsonrpc2/generated/src/serde.cc @@ -3,45 +3,45 @@ #include #include +#include "opal/protocoltests/jsonrpc2/serde.h" #include "smithy/core/document_serde.h" -#include "smithy/protocoltests/jsonrpc2/serde.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { -namespace types = ::smithy::protocoltests::jsonrpc2; +namespace types = ::opal::protocoltests::jsonrpc2; -smithy::Document SerializeEchoedNote(const EchoedNote& value) { - smithy::DocumentMap map; - map.emplace("text", smithy::Document(value.text)); - return smithy::Document(std::move(map)); +opal::Document SerializeEchoedNote(const EchoedNote& value) { + opal::DocumentMap map; + map.emplace("text", opal::Document(value.text)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeEchoedNote(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("EchoedNote: expected a map on the wire"); +opal::Outcome DeserializeEchoedNote(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("EchoedNote: expected a map on the wire"); EchoedNote out; { - const smithy::Document* member = doc.Find("text"); + const opal::Document* member = doc.Find("text"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("EchoedNote: missing required member: text"); + return opal::Error::Serialization("EchoedNote: missing required member: text"); } - if (!member->is_string()) return smithy::Error::Serialization("EchoedNote.text: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("EchoedNote.text: unexpected type on the wire"); out.text = member->as_string(); } return out; } -smithy::Document SerializeDownEvents(const DownEvents& value) { - smithy::DocumentMap map; +opal::Document SerializeDownEvents(const DownEvents& value) { + opal::DocumentMap map; if (value.is_echo()) { map.emplace("echo", SerializeEchoedNote(value.as_echo())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeDownEvents(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("DownEvents: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("DownEvents: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("echo"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeDownEvents(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("DownEvents: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("DownEvents: expected exactly one union member"); + if (const opal::Document* member = doc.Find("echo"); member != nullptr && !member->is_null()) { EchoedNote parsed_member{}; { auto parsed = DeserializeEchoedNote(*member); @@ -50,82 +50,82 @@ smithy::Outcome DeserializeDownEvents(const smithy::Document& doc) { } return DownEvents::FromEcho(std::move(parsed_member)); } - return smithy::Error::Serialization("DownEvents: unknown or missing union member"); + return opal::Error::Serialization("DownEvents: unknown or missing union member"); } -smithy::Document SerializeStringMap(const std::map& value) { - smithy::DocumentMap map; +opal::Document SerializeStringMap(const std::map& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { - map.emplace(key, smithy::Document(item)); + map.emplace(key, opal::Document(item)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome> DeserializeStringMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map: expected a map on the wire"); +opal::Outcome> DeserializeStringMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map: expected a map on the wire"); std::map out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::map{}: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::map{}: unexpected type on the wire"); parsed_item = item->as_string(); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeStringList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeStringList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeStringList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeStringList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = item->as_string(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeNested(const Nested& value) { - smithy::DocumentMap map; - map.emplace("label", smithy::Document(value.label)); +opal::Document SerializeNested(const Nested& value) { + opal::DocumentMap map; + map.emplace("label", opal::Document(value.label)); if (value.depth.has_value()) { - map.emplace("depth", smithy::Document(static_cast((*value.depth)))); + map.emplace("depth", opal::Document(static_cast((*value.depth)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNested(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Nested: expected a map on the wire"); +opal::Outcome DeserializeNested(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Nested: expected a map on the wire"); Nested out; { - const smithy::Document* member = doc.Find("label"); + const opal::Document* member = doc.Find("label"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Nested: missing required member: label"); + return opal::Error::Serialization("Nested: missing required member: label"); } - if (!member->is_string()) return smithy::Error::Serialization("Nested.label: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Nested.label: unexpected type on the wire"); out.label = member->as_string(); } { - const smithy::Document* member = doc.Find("depth"); + const opal::Document* member = doc.Find("depth"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("Nested.depth: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("Nested.depth: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("Nested.depth: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("Nested.depth: value out of range"); parsed_member = static_cast(member->as_int()); out.depth = std::move(parsed_member); } @@ -133,28 +133,28 @@ smithy::Outcome DeserializeNested(const smithy::Document& doc) { return out; } -smithy::Document SerializeEchoPayloadInput(const EchoPayloadInput& value) { - smithy::DocumentMap map; +opal::Document SerializeEchoPayloadInput(const EchoPayloadInput& value) { + opal::DocumentMap map; if (value.string.has_value()) { - map.emplace("string", smithy::Document((*value.string))); + map.emplace("string", opal::Document((*value.string))); } if (value.aliased.has_value()) { - map.emplace("renamed", smithy::Document((*value.aliased))); + map.emplace("renamed", opal::Document((*value.aliased))); } if (value.integer.has_value()) { - map.emplace("integer", smithy::Document(static_cast((*value.integer)))); + map.emplace("integer", opal::Document(static_cast((*value.integer)))); } if (value.boolean.has_value()) { - map.emplace("boolean", smithy::Document((*value.boolean))); + map.emplace("boolean", opal::Document((*value.boolean))); } if (value.double_.has_value()) { - map.emplace("double", smithy::Document(static_cast((*value.double_)))); + map.emplace("double", opal::Document(static_cast((*value.double_)))); } if (value.timestamp.has_value()) { - map.emplace("timestamp", smithy::Document::FromTimestamp((*value.timestamp), smithy::TimestampFormat::kEpochSeconds)); + map.emplace("timestamp", opal::Document::FromTimestamp((*value.timestamp), opal::TimestampFormat::kEpochSeconds)); } if (value.dateTime.has_value()) { - map.emplace("dateTime", smithy::Document::FromTimestamp((*value.dateTime), smithy::TimestampFormat::kDateTime)); + map.emplace("dateTime", opal::Document::FromTimestamp((*value.dateTime), opal::TimestampFormat::kDateTime)); } if (value.names.has_value()) { map.emplace("names", SerializeStringList((*value.names))); @@ -165,67 +165,67 @@ smithy::Document SerializeEchoPayloadInput(const EchoPayloadInput& value) { if (value.nested.has_value()) { map.emplace("nested", SerializeNested((*value.nested))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeEchoPayloadInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("EchoPayloadInput: expected a map on the wire"); +opal::Outcome DeserializeEchoPayloadInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("EchoPayloadInput: expected a map on the wire"); EchoPayloadInput out; { - const smithy::Document* member = doc.Find("string"); + const opal::Document* member = doc.Find("string"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("EchoPayloadInput.string: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("EchoPayloadInput.string: unexpected type on the wire"); parsed_member = member->as_string(); out.string = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("renamed"); + const opal::Document* member = doc.Find("renamed"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("EchoPayloadInput.aliased: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("EchoPayloadInput.aliased: unexpected type on the wire"); parsed_member = member->as_string(); out.aliased = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("integer"); + const opal::Document* member = doc.Find("integer"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("EchoPayloadInput.integer: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("EchoPayloadInput.integer: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("EchoPayloadInput.integer: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("EchoPayloadInput.integer: value out of range"); parsed_member = static_cast(member->as_int()); out.integer = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("boolean"); + const opal::Document* member = doc.Find("boolean"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("EchoPayloadInput.boolean: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("EchoPayloadInput.boolean: unexpected type on the wire"); parsed_member = member->as_bool(); out.boolean = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("double"); + const opal::Document* member = doc.Find("double"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("EchoPayloadInput.double: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("EchoPayloadInput.double: expected a number"); parsed_member = static_cast(*parsed); } out.double_ = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("timestamp"); + const opal::Document* member = doc.Find("timestamp"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kEpochSeconds); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kEpochSeconds); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -233,11 +233,11 @@ smithy::Outcome DeserializeEchoPayloadInput(const smithy::Docu } } { - const smithy::Document* member = doc.Find("dateTime"); + const opal::Document* member = doc.Find("dateTime"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kDateTime); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kDateTime); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -245,7 +245,7 @@ smithy::Outcome DeserializeEchoPayloadInput(const smithy::Docu } } { - const smithy::Document* member = doc.Find("names"); + const opal::Document* member = doc.Find("names"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -257,7 +257,7 @@ smithy::Outcome DeserializeEchoPayloadInput(const smithy::Docu } } { - const smithy::Document* member = doc.Find("attributes"); + const opal::Document* member = doc.Find("attributes"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -269,7 +269,7 @@ smithy::Outcome DeserializeEchoPayloadInput(const smithy::Docu } } { - const smithy::Document* member = doc.Find("nested"); + const opal::Document* member = doc.Find("nested"); if (member != nullptr && !member->is_null()) { types::Nested parsed_member{}; { @@ -283,44 +283,44 @@ smithy::Outcome DeserializeEchoPayloadInput(const smithy::Docu return out; } -smithy::Document SerializeEchoPayloadOutput(const EchoPayloadOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeEchoPayloadOutput(const EchoPayloadOutput& value) { + opal::DocumentMap map; if (value.echo.has_value()) { - map.emplace("echo", smithy::Document((*value.echo))); + map.emplace("echo", opal::Document((*value.echo))); } if (value.count.has_value()) { - map.emplace("count", smithy::Document(static_cast((*value.count)))); + map.emplace("count", opal::Document(static_cast((*value.count)))); } if (value.nested.has_value()) { map.emplace("nested", SerializeNested((*value.nested))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeEchoPayloadOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("EchoPayloadOutput: expected a map on the wire"); +opal::Outcome DeserializeEchoPayloadOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("EchoPayloadOutput: expected a map on the wire"); EchoPayloadOutput out; { - const smithy::Document* member = doc.Find("echo"); + const opal::Document* member = doc.Find("echo"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("EchoPayloadOutput.echo: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("EchoPayloadOutput.echo: unexpected type on the wire"); parsed_member = member->as_string(); out.echo = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("count"); + const opal::Document* member = doc.Find("count"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("EchoPayloadOutput.count: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("EchoPayloadOutput.count: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("EchoPayloadOutput.count: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("EchoPayloadOutput.count: value out of range"); parsed_member = static_cast(member->as_int()); out.count = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("nested"); + const opal::Document* member = doc.Find("nested"); if (member != nullptr && !member->is_null()) { types::Nested parsed_member{}; { @@ -334,31 +334,31 @@ smithy::Outcome DeserializeEchoPayloadOutput(const smithy::Do return out; } -smithy::Document SerializeNotFoundError(const NotFoundError& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); +opal::Document SerializeNotFoundError(const NotFoundError& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); if (value.resourceType.has_value()) { - map.emplace("resourceType", smithy::Document((*value.resourceType))); + map.emplace("resourceType", opal::Document((*value.resourceType))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNotFoundError(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("NotFoundError: expected a map on the wire"); +opal::Outcome DeserializeNotFoundError(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("NotFoundError: expected a map on the wire"); NotFoundError out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("NotFoundError: missing required member: message"); + return opal::Error::Serialization("NotFoundError: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("NotFoundError.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("NotFoundError.message: unexpected type on the wire"); out.message = member->as_string(); } { - const smithy::Document* member = doc.Find("resourceType"); + const opal::Document* member = doc.Find("resourceType"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("NotFoundError.resourceType: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("NotFoundError.resourceType: unexpected type on the wire"); parsed_member = member->as_string(); out.resourceType = std::move(parsed_member); } @@ -366,22 +366,22 @@ smithy::Outcome DeserializeNotFoundError(const smithy::Document& return out; } -smithy::Document SerializeThrottledError(const ThrottledError& value) { - smithy::DocumentMap map; +opal::Document SerializeThrottledError(const ThrottledError& value) { + opal::DocumentMap map; if (value.message.has_value()) { - map.emplace("message", smithy::Document((*value.message))); + map.emplace("message", opal::Document((*value.message))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeThrottledError(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ThrottledError: expected a map on the wire"); +opal::Outcome DeserializeThrottledError(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ThrottledError: expected a map on the wire"); ThrottledError out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("ThrottledError.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ThrottledError.message: unexpected type on the wire"); parsed_member = member->as_string(); out.message = std::move(parsed_member); } @@ -389,38 +389,38 @@ smithy::Outcome DeserializeThrottledError(const smithy::Document return out; } -smithy::Document SerializeNote(const Note& value) { - smithy::DocumentMap map; - map.emplace("text", smithy::Document(value.text)); - return smithy::Document(std::move(map)); +opal::Document SerializeNote(const Note& value) { + opal::DocumentMap map; + map.emplace("text", opal::Document(value.text)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNote(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Note: expected a map on the wire"); +opal::Outcome DeserializeNote(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Note: expected a map on the wire"); Note out; { - const smithy::Document* member = doc.Find("text"); + const opal::Document* member = doc.Find("text"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Note: missing required member: text"); + return opal::Error::Serialization("Note: missing required member: text"); } - if (!member->is_string()) return smithy::Error::Serialization("Note.text: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Note.text: unexpected type on the wire"); out.text = member->as_string(); } return out; } -smithy::Document SerializeUpEvents(const UpEvents& value) { - smithy::DocumentMap map; +opal::Document SerializeUpEvents(const UpEvents& value) { + opal::DocumentMap map; if (value.is_note()) { map.emplace("note", SerializeNote(value.as_note())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeUpEvents(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("UpEvents: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("UpEvents: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("note"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeUpEvents(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("UpEvents: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("UpEvents: expected exactly one union member"); + if (const opal::Document* member = doc.Find("note"); member != nullptr && !member->is_null()) { Note parsed_member{}; { auto parsed = DeserializeNote(*member); @@ -429,34 +429,34 @@ smithy::Outcome DeserializeUpEvents(const smithy::Document& doc) { } return UpEvents::FromNote(std::move(parsed_member)); } - return smithy::Error::Serialization("UpEvents: unknown or missing union member"); + return opal::Error::Serialization("UpEvents: unknown or missing union member"); } -smithy::Document SerializeEchoStreamInput(const EchoStreamInput& value) { - smithy::DocumentMap map; +opal::Document SerializeEchoStreamInput(const EchoStreamInput& value) { + opal::DocumentMap map; if (value.prefix.has_value()) { - map.emplace("prefix", smithy::Document((*value.prefix))); + map.emplace("prefix", opal::Document((*value.prefix))); } if (value.events.has_value()) { map.emplace("events", SerializeUpEvents((*value.events))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeEchoStreamInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("EchoStreamInput: expected a map on the wire"); +opal::Outcome DeserializeEchoStreamInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("EchoStreamInput: expected a map on the wire"); EchoStreamInput out; { - const smithy::Document* member = doc.Find("prefix"); + const opal::Document* member = doc.Find("prefix"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("EchoStreamInput.prefix: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("EchoStreamInput.prefix: unexpected type on the wire"); parsed_member = member->as_string(); out.prefix = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("events"); + const opal::Document* member = doc.Find("events"); if (member != nullptr && !member->is_null()) { types::UpEvents parsed_member{}; { @@ -470,19 +470,19 @@ smithy::Outcome DeserializeEchoStreamInput(const smithy::Docume return out; } -smithy::Document SerializeEchoStreamOutput(const EchoStreamOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeEchoStreamOutput(const EchoStreamOutput& value) { + opal::DocumentMap map; if (value.events.has_value()) { map.emplace("events", SerializeDownEvents((*value.events))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeEchoStreamOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("EchoStreamOutput: expected a map on the wire"); +opal::Outcome DeserializeEchoStreamOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("EchoStreamOutput: expected a map on the wire"); EchoStreamOutput out; { - const smithy::Document* member = doc.Find("events"); + const opal::Document* member = doc.Find("events"); if (member != nullptr && !member->is_null()) { types::DownEvents parsed_member{}; { @@ -496,98 +496,98 @@ smithy::Outcome DeserializeEchoStreamOutput(const smithy::Docu return out; } -smithy::Document SerializeStreamAbort(const StreamAbort& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); - return smithy::Document(std::move(map)); +opal::Document SerializeStreamAbort(const StreamAbort& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeStreamAbort(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("StreamAbort: expected a map on the wire"); +opal::Outcome DeserializeStreamAbort(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("StreamAbort: expected a map on the wire"); StreamAbort out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("StreamAbort: missing required member: message"); + return opal::Error::Serialization("StreamAbort: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("StreamAbort.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("StreamAbort.message: unexpected type on the wire"); out.message = member->as_string(); } return out; } -smithy::Document SerializeNoArgsInput(const NoArgsInput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeNoArgsInput(const NoArgsInput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNoArgsInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("NoArgsInput: expected a map on the wire"); +opal::Outcome DeserializeNoArgsInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("NoArgsInput: expected a map on the wire"); NoArgsInput out; return out; } -smithy::Document SerializeNoArgsOutput(const NoArgsOutput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeNoArgsOutput(const NoArgsOutput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNoArgsOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("NoArgsOutput: expected a map on the wire"); +opal::Outcome DeserializeNoArgsOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("NoArgsOutput: expected a map on the wire"); NoArgsOutput out; return out; } -smithy::Document SerializePutConstrainedInput(const PutConstrainedInput& value) { - smithy::DocumentMap map; - map.emplace("name", smithy::Document(value.name)); +opal::Document SerializePutConstrainedInput(const PutConstrainedInput& value) { + opal::DocumentMap map; + map.emplace("name", opal::Document(value.name)); if (value.limit.has_value()) { - map.emplace("limit", smithy::Document(static_cast((*value.limit)))); + map.emplace("limit", opal::Document(static_cast((*value.limit)))); } if (value.slug.has_value()) { - map.emplace("slug", smithy::Document((*value.slug))); + map.emplace("slug", opal::Document((*value.slug))); } if (value.evilDigits.has_value()) { - map.emplace("evilDigits", smithy::Document((*value.evilDigits))); + map.emplace("evilDigits", opal::Document((*value.evilDigits))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePutConstrainedInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PutConstrainedInput: expected a map on the wire"); +opal::Outcome DeserializePutConstrainedInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PutConstrainedInput: expected a map on the wire"); PutConstrainedInput out; { - const smithy::Document* member = doc.Find("name"); + const opal::Document* member = doc.Find("name"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PutConstrainedInput: missing required member: name"); + return opal::Error::Serialization("PutConstrainedInput: missing required member: name"); } - if (!member->is_string()) return smithy::Error::Serialization("PutConstrainedInput.name: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutConstrainedInput.name: unexpected type on the wire"); out.name = member->as_string(); } { - const smithy::Document* member = doc.Find("limit"); + const opal::Document* member = doc.Find("limit"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("PutConstrainedInput.limit: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("PutConstrainedInput.limit: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("PutConstrainedInput.limit: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("PutConstrainedInput.limit: value out of range"); parsed_member = static_cast(member->as_int()); out.limit = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("slug"); + const opal::Document* member = doc.Find("slug"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("PutConstrainedInput.slug: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutConstrainedInput.slug: unexpected type on the wire"); parsed_member = member->as_string(); out.slug = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("evilDigits"); + const opal::Document* member = doc.Find("evilDigits"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("PutConstrainedInput.evilDigits: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PutConstrainedInput.evilDigits: unexpected type on the wire"); parsed_member = member->as_string(); out.evilDigits = std::move(parsed_member); } @@ -595,24 +595,24 @@ smithy::Outcome DeserializePutConstrainedInput(const smithy return out; } -smithy::Document SerializePutConstrainedOutput(const PutConstrainedOutput& value) { - smithy::DocumentMap map; - map.emplace("accepted", smithy::Document(value.accepted)); - return smithy::Document(std::move(map)); +opal::Document SerializePutConstrainedOutput(const PutConstrainedOutput& value) { + opal::DocumentMap map; + map.emplace("accepted", opal::Document(value.accepted)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePutConstrainedOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PutConstrainedOutput: expected a map on the wire"); +opal::Outcome DeserializePutConstrainedOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PutConstrainedOutput: expected a map on the wire"); PutConstrainedOutput out; { - const smithy::Document* member = doc.Find("accepted"); + const opal::Document* member = doc.Find("accepted"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PutConstrainedOutput: missing required member: accepted"); + return opal::Error::Serialization("PutConstrainedOutput: missing required member: accepted"); } - if (!member->is_bool()) return smithy::Error::Serialization("PutConstrainedOutput.accepted: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("PutConstrainedOutput.accepted: unexpected type on the wire"); out.accepted = member->as_bool(); } return out; } -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 diff --git a/protocol-tests/jsonrpc2/generated/src/server.cc b/protocol-tests/jsonrpc2/generated/src/server.cc index 216cd71f..2995bc6c 100644 --- a/protocol-tests/jsonrpc2/generated/src/server.cc +++ b/protocol-tests/jsonrpc2/generated/src/server.cc @@ -7,6 +7,8 @@ #include #include +#include "opal/protocoltests/jsonrpc2/serde.h" +#include "opal/protocoltests/jsonrpc2/server.h" #include "smithy/core/document.h" #include "smithy/core/regex.h" #include "smithy/core/text.h" @@ -16,97 +18,95 @@ #include "smithy/http/headers.h" #include "smithy/http/websocket.h" #include "smithy/json/json.h" -#include "smithy/protocoltests/jsonrpc2/serde.h" -#include "smithy/protocoltests/jsonrpc2/server.h" #include "smithy/server/router.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { -namespace types = ::smithy::protocoltests::jsonrpc2; +namespace types = ::opal::protocoltests::jsonrpc2; namespace { namespace helpers { -smithy::http::HttpResponse JsonRpcError(int code, const std::string& type, const std::string& message, smithy::DocumentMap data, const smithy::Document& id) { - if (!type.empty()) data.insert_or_assign("__type", smithy::Document(type)); +opal::http::HttpResponse JsonRpcError(int code, const std::string& type, const std::string& message, opal::DocumentMap data, const opal::Document& id) { + if (!type.empty()) data.insert_or_assign("__type", opal::Document(type)); std::string text = message; if (text.empty()) { const auto it = data.find("message"); if (it != data.end() && it->second.is_string()) text = it->second.as_string(); } - smithy::DocumentMap error; - error.emplace("code", smithy::Document(code)); - error.emplace("message", smithy::Document(std::move(text))); - if (!data.empty()) error.emplace("data", smithy::Document(std::move(data))); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("error", smithy::Document(std::move(error))); + opal::DocumentMap error; + error.emplace("code", opal::Document(code)); + error.emplace("message", opal::Document(std::move(text))); + if (!data.empty()) error.emplace("data", opal::Document(std::move(data))); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("error", opal::Document(std::move(error))); envelope.emplace("id", id); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + response.body = opal::json::Encode(opal::Document(std::move(envelope))); return response; } // [[maybe_unused]]: only unary routes map handler errors here; a service // whose operations all stream reports errors on the stream instead. -[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& error, const smithy::Document& id) { - if (error.kind() == smithy::ErrorKind::kModeled) { +[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& error, const opal::Document& id) { + if (error.kind() == opal::ErrorKind::kModeled) { if (error.code() == "NotFoundError") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeNotFoundError(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::JsonRpcError(404, "smithy.cpp.protocoltests.jsonrpc2#NotFoundError", "", std::move(body), id); } if (error.code() == "StreamAbort") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeStreamAbort(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::JsonRpcError(409, "smithy.cpp.protocoltests.jsonrpc2#StreamAbort", "", std::move(body), id); } if (error.code() == "ThrottledError") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeThrottledError(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::JsonRpcError(503, "smithy.cpp.protocoltests.jsonrpc2#ThrottledError", "", std::move(body), id); } return helpers::JsonRpcError(400, error.code(), error.message(), {}, id); } - if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) return helpers::JsonRpcError(400, "SerializationException", error.message(), {}, id); + if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) return helpers::JsonRpcError(400, "SerializationException", error.message(), {}, id); // Never leak internal detail on unexpected failures. return helpers::JsonRpcError(500, "InternalFailure", "internal failure", {}, id); } // Constraint validation (smithy.framework#ValidationException): messages // and '/member' paths follow the official validation conformance suite. -void AddValidationFailure(std::vector* failures, std::string path, std::string message) { +void AddValidationFailure(std::vector* failures, std::string path, std::string message) { failures->push_back({std::move(path), std::move(message)}); } -void ValidatePutConstrainedInput(const types::PutConstrainedInput& value, const std::string& path, std::vector* failures) { +void ValidatePutConstrainedInput(const types::PutConstrainedInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/name"; { - const std::size_t member_length = smithy::Utf8CodePointCount(value.name); + const std::size_t member_length = opal::Utf8CodePointCount(value.name); if (member_length < 1ULL || member_length > 8ULL) { helpers::AddValidationFailure(failures, member_path, "Value with length " + std::to_string(member_length) + " at '" + member_path + "' failed to satisfy constraint: Member must have length between 1 and 8, inclusive"); } @@ -120,14 +120,14 @@ void ValidatePutConstrainedInput(const types::PutConstrainedInput& value, const } if (value.slug.has_value()) { const std::string member_path = path + "/slug"; - static const smithy::Outcome kPattern0 = smithy::Regex::Compile(R"__smithy(^[a-z0-9-]+$)__smithy"); + static const opal::Outcome kPattern0 = opal::Regex::Compile(R"__smithy(^[a-z0-9-]+$)__smithy"); if (!kPattern0.ok() || !kPattern0->Search((*value.slug))) { helpers::AddValidationFailure(failures, member_path, "Value at '" + member_path + "' failed to satisfy constraint: Member must satisfy regular expression pattern: " + std::string("^[a-z0-9-]+$")); } } if (value.evilDigits.has_value()) { const std::string member_path = path + "/evilDigits"; - static const smithy::Outcome kPattern1 = smithy::Regex::Compile(R"__smithy(^([0-9]+)+$)__smithy"); + static const opal::Outcome kPattern1 = opal::Regex::Compile(R"__smithy(^([0-9]+)+$)__smithy"); if (!kPattern1.ok() || !kPattern1->Search((*value.evilDigits))) { helpers::AddValidationFailure(failures, member_path, "Value at '" + member_path + "' failed to satisfy constraint: Member must satisfy regular expression pattern: " + std::string("^([0-9]+)+$")); } @@ -136,25 +136,25 @@ void ValidatePutConstrainedInput(const types::PutConstrainedInput& value, const // [[maybe_unused]]: only unary routes reject invalid input over HTTP; a // service whose operations all stream reports validation on the stream. -[[maybe_unused]] smithy::http::HttpResponse ValidationErrorResponse(const std::vector& failures, const smithy::Document& id) { +[[maybe_unused]] opal::http::HttpResponse ValidationErrorResponse(const std::vector& failures, const opal::Document& id) { std::string summary = std::to_string(failures.size()) + " validation error" + (failures.size() == 1 ? "" : "s") + " detected. "; - smithy::DocumentList field_list; + opal::DocumentList field_list; for (std::size_t i = 0; i < failures.size(); ++i) { if (i > 0) summary += "; "; summary += failures[i].message; - smithy::DocumentMap field; - field.emplace("message", smithy::Document(failures[i].message)); - field.emplace("path", smithy::Document(failures[i].path)); - field_list.push_back(smithy::Document(std::move(field))); + opal::DocumentMap field; + field.emplace("message", opal::Document(failures[i].message)); + field.emplace("path", opal::Document(failures[i].path)); + field_list.push_back(opal::Document(std::move(field))); } - smithy::DocumentMap body; - body.emplace("fieldList", smithy::Document(std::move(field_list))); - smithy::http::HttpResponse response = helpers::JsonRpcError(400, "smithy.framework#ValidationException", summary, std::move(body), id); + opal::DocumentMap body; + body.emplace("fieldList", opal::Document(std::move(field_list))); + opal::http::HttpResponse response = helpers::JsonRpcError(400, "smithy.framework#ValidationException", summary, std::move(body), id); return response; } template -smithy::http::HttpResponse HandleEchoPayload(Handler& handler, const smithy::Document& params, const smithy::Document& id, const smithy::server::RequestContext& context) { +opal::http::HttpResponse HandleEchoPayload(Handler& handler, const opal::Document& params, const opal::Document& id, const opal::server::RequestContext& context) { types::EchoPayloadInput input{}; if (!params.is_map()) return helpers::JsonRpcError(-32602, "SerializationException", "params must be an object", {}, id); auto parsed = DeserializeEchoPayloadInput(params); @@ -162,75 +162,75 @@ smithy::http::HttpResponse HandleEchoPayload(Handler& handler, const smithy::Doc input = *std::move(parsed); auto outcome = handler.EchoPayload(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error(), id); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); envelope.emplace("result", SerializeEchoPayloadOutput(*outcome)); envelope.emplace("id", id); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + response.body = opal::json::Encode(opal::Document(std::move(envelope))); return response; } template -smithy::http::HttpResponse HandleNoArgs(Handler& handler, const smithy::Document& params, const smithy::Document& id, const smithy::server::RequestContext& context) { +opal::http::HttpResponse HandleNoArgs(Handler& handler, const opal::Document& params, const opal::Document& id, const opal::server::RequestContext& context) { types::NoArgsInput input{}; (void)params; auto outcome = handler.NoArgs(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error(), id); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); envelope.emplace("result", SerializeNoArgsOutput(*outcome)); envelope.emplace("id", id); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + response.body = opal::json::Encode(opal::Document(std::move(envelope))); return response; } template -smithy::http::HttpResponse HandlePutConstrained(Handler& handler, const smithy::Document& params, const smithy::Document& id, const smithy::server::RequestContext& context) { +opal::http::HttpResponse HandlePutConstrained(Handler& handler, const opal::Document& params, const opal::Document& id, const opal::server::RequestContext& context) { types::PutConstrainedInput input{}; if (!params.is_map()) return helpers::JsonRpcError(-32602, "SerializationException", "params must be an object", {}, id); auto parsed = DeserializePutConstrainedInput(params); if (!parsed) return helpers::JsonRpcError(-32602, "SerializationException", parsed.error().message(), {}, id); input = *std::move(parsed); - std::vector validation_failures; + std::vector validation_failures; helpers::ValidatePutConstrainedInput(input, "", &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures, id); auto outcome = handler.PutConstrained(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error(), id); - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); envelope.emplace("result", SerializePutConstrainedOutput(*outcome)); envelope.emplace("id", id); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + response.body = opal::json::Encode(opal::Document(std::move(envelope))); return response; } // One JSON-RPC envelope as the raw-text message the stream wire carries // (ADR-0023): the unary emitters build the envelope, streams reuse their // bodies verbatim — one error identity, one spelling. -smithy::eventstream::Message JsonRpcStreamText(const smithy::http::HttpResponse& response) { - smithy::eventstream::Message message; - message.payload = smithy::Blob::FromString(response.body); +opal::eventstream::Message JsonRpcStreamText(const opal::http::HttpResponse& response) { + opal::eventstream::Message message; + message.payload = opal::Blob::FromString(response.body); return message; } // The terminal result envelope that ends a clean stream: result stays {} // while initial-response members remain deferred (ADR-0016/0023). -smithy::eventstream::Message BuildJsonRpcTerminalResult(const smithy::Document& id) { - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("result", smithy::Document(smithy::DocumentMap{})); +opal::eventstream::Message BuildJsonRpcTerminalResult(const opal::Document& id) { + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("result", opal::Document(opal::DocumentMap{})); envelope.emplace("id", id); - smithy::eventstream::Message message; - message.payload = smithy::Blob::FromString(smithy::json::Encode(smithy::Document(std::move(envelope)))); + opal::eventstream::Message message; + message.payload = opal::Blob::FromString(opal::json::Encode(opal::Document(std::move(envelope)))); return message; } @@ -239,13 +239,13 @@ smithy::eventstream::Message BuildJsonRpcTerminalResult(const smithy::Document& // compares bodies, so no decoder detail leaks into the wire. struct JsonRpcOpening { bool ok = false; - smithy::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) + opal::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) std::string method; - smithy::Document params{smithy::DocumentMap{}}; - smithy::eventstream::Message refusal; // when !ok: send, then close + opal::Document params{opal::DocumentMap{}}; + opal::eventstream::Message refusal; // when !ok: send, then close }; -JsonRpcOpening ParseJsonRpcOpening(const smithy::eventstream::Message& message) { +JsonRpcOpening ParseJsonRpcOpening(const opal::eventstream::Message& message) { JsonRpcOpening opening; if (!message.headers.empty()) { // Only the raw-text wire reaches this route; a framed message means a @@ -253,7 +253,7 @@ JsonRpcOpening ParseJsonRpcOpening(const smithy::eventstream::Message& message) opening.refusal = helpers::JsonRpcStreamText(helpers::JsonRpcError(-32600, "SerializationException", "the opening message must be one JSON-RPC request envelope", {}, opening.id)); return opening; } - auto decoded = smithy::json::Decode(message.payload.ToString()); + auto decoded = opal::json::Decode(message.payload.ToString()); if (!decoded) { opening.refusal = helpers::JsonRpcStreamText(helpers::JsonRpcError(-32700, "SerializationException", "request body is not valid JSON", {}, opening.id)); return opening; @@ -262,13 +262,13 @@ JsonRpcOpening ParseJsonRpcOpening(const smithy::eventstream::Message& message) opening.refusal = helpers::JsonRpcStreamText(helpers::JsonRpcError(-32600, "SerializationException", "request is not a JSON-RPC 2.0 call", {}, opening.id)); return opening; } - if (const smithy::Document* id_doc = decoded->Find("id"); id_doc != nullptr) opening.id = *id_doc; - const smithy::Document* version = decoded->Find("jsonrpc"); + if (const opal::Document* id_doc = decoded->Find("id"); id_doc != nullptr) opening.id = *id_doc; + const opal::Document* version = decoded->Find("jsonrpc"); if (version == nullptr || !version->is_string() || version->as_string() != "2.0") { opening.refusal = helpers::JsonRpcStreamText(helpers::JsonRpcError(-32600, "SerializationException", "expected jsonrpc: \"2.0\"", {}, opening.id)); return opening; } - const smithy::Document* method = decoded->Find("method"); + const opal::Document* method = decoded->Find("method"); if (method == nullptr || !method->is_string()) { opening.refusal = helpers::JsonRpcStreamText(helpers::JsonRpcError(-32600, "SerializationException", "expected a string method member", {}, opening.id)); return opening; @@ -280,7 +280,7 @@ JsonRpcOpening ParseJsonRpcOpening(const smithy::eventstream::Message& message) return opening; } // Absent/null params deserialize like an empty object. - const smithy::Document* params = decoded->Find("params"); + const opal::Document* params = decoded->Find("params"); if (params != nullptr && !params->is_null()) opening.params = *params; opening.method = method->as_string(); opening.ok = true; @@ -289,29 +289,29 @@ JsonRpcOpening ParseJsonRpcOpening(const smithy::eventstream::Message& message) // One event per message (ADR-0016): the engaged member's structure is the // payload, its member name the :event-type. -smithy::Outcome EncodeEchoStreamEvent(const types::DownEvents& event) { +opal::Outcome EncodeEchoStreamEvent(const types::DownEvents& event) { if (event.is_echo()) { - return smithy::eventstream::MakeEventMessage("echo", "application/json", smithy::Blob::FromString(smithy::json::Encode(SerializeEchoedNote(event.as_echo())))); + return opal::eventstream::MakeEventMessage("echo", "application/json", opal::Blob::FromString(opal::json::Encode(SerializeEchoedNote(event.as_echo())))); } - return smithy::Error::Validation("DownEvents: no event member engaged"); + return opal::Error::Validation("DownEvents: no event member engaged"); } -smithy::Outcome DecodeEchoStreamEvent(const smithy::eventstream::Message& message) { - auto envelope = smithy::eventstream::ParseEnvelope(message); +opal::Outcome DecodeEchoStreamEvent(const opal::eventstream::Message& message) { + auto envelope = opal::eventstream::ParseEnvelope(message); if (!envelope) return std::move(envelope).error(); - if (envelope->kind == smithy::eventstream::EventEnvelope::Kind::kException) { + if (envelope->kind == opal::eventstream::EventEnvelope::Kind::kException) { // Clients send events, never exceptions; treat one as a terminal protocol // violation carrying the peer's claimed identity. - return smithy::Error::Modeled(envelope->type, "peer sent an exception message"); + return opal::Error::Modeled(envelope->type, "peer sent an exception message"); } if (envelope->type == "note") { - auto doc = smithy::json::Decode(envelope->payload.ToString()); + auto doc = opal::json::Decode(envelope->payload.ToString()); if (!doc) return std::move(doc).error(); auto event = DeserializeNote(*doc); if (!event) return std::move(event).error(); return types::UpEvents::FromNote(*std::move(event)); } - return smithy::Error::Serialization("EchoStream: unknown event type: " + envelope->type); + return opal::Error::Serialization("EchoStream: unknown event type: " + envelope->type); } // The async route's launch wrapper (ADR-0021), on the JSON-RPC wire @@ -320,22 +320,22 @@ smithy::Outcome DecodeEchoStreamEvent(const smithy::eventstream // completion, the unary error identity otherwise — is AWAITED so this // frame (and the stream it owns) outlives the write. Best-effort, like // every terminal send: a send the dead session refuses is discarded. -smithy::eventstream::Detached ServeEchoStreamAsync(std::shared_ptr handler, types::EchoStreamInput input, std::shared_ptr socket, smithy::Document id) { - auto wrapped = std::make_shared(socket, id, smithy::eventstream::JsonRpcStreamSocket::Role::kServer); +opal::eventstream::Detached ServeEchoStreamAsync(std::shared_ptr handler, types::EchoStreamInput input, std::shared_ptr socket, opal::Document id) { + auto wrapped = std::make_shared(socket, id, opal::eventstream::JsonRpcStreamSocket::Role::kServer); types::EchoStreamAsyncServerStream stream(wrapped, helpers::EncodeEchoStreamEvent, helpers::DecodeEchoStreamEvent); auto outcome = co_await handler->EchoStream(std::move(input), stream); // Built OUTSIDE the co_await expression on purpose: a conditional // operator inside a co_await full expression miscompiles on GCC (the // branch temporaries become frame slots and the wrong branch runs). - smithy::eventstream::Message terminal = + opal::eventstream::Message terminal = outcome.ok() ? BuildJsonRpcTerminalResult(id) : helpers::JsonRpcStreamText(helpers::ErrorToResponse(outcome.error(), id)); - (void)co_await smithy::eventstream::SendMessage(socket, std::move(terminal)); + (void)co_await opal::eventstream::SendMessage(socket, std::move(terminal)); stream.Close(); } // The blocking seam's shared-endpoint driver (ADR-0023). -void ServeJsonRpcStream(types::JsonRpc2ProtocolHandler& handler, const smithy::server::RequestContext& context, smithy::http::WebSocket& socket) { +void ServeJsonRpcStream(types::JsonRpc2ProtocolHandler& handler, const opal::server::RequestContext& context, opal::http::WebSocket& socket) { auto first = socket.Receive(); // A wire that failed or closed before the opening call is a non-event. if (!first.ok() || !first->has_value()) return; @@ -356,7 +356,7 @@ void ServeJsonRpcStream(types::JsonRpc2ProtocolHandler& handler, const smithy::s input = *std::move(parsed); // The union is the session, never an opening member (ADR-0023). input.events.reset(); - smithy::eventstream::JsonRpcStreamSocket wrapped(socket, opening.id, smithy::eventstream::JsonRpcStreamSocket::Role::kServer); + opal::eventstream::JsonRpcStreamSocket wrapped(socket, opening.id, opal::eventstream::JsonRpcStreamSocket::Role::kServer); types::EchoStreamServerStream stream(wrapped, helpers::EncodeEchoStreamEvent, helpers::DecodeEchoStreamEvent); auto outcome = handler.EchoStream(input, stream, context); // The terminal response rides the raw socket: the wrapper only speaks @@ -374,12 +374,12 @@ void ServeJsonRpcStream(types::JsonRpc2ProtocolHandler& handler, const smithy::s // The session seam's shared-endpoint driver (ADR-0021/0023): the opening // envelope is read inside this Detached frame — a client that upgrades // and never calls costs no parked thread. -smithy::eventstream::Detached ServeJsonRpcSession(std::shared_ptr handler, std::shared_ptr socket) { - auto first = co_await smithy::eventstream::ReceiveMessage(socket); +opal::eventstream::Detached ServeJsonRpcSession(std::shared_ptr handler, std::shared_ptr socket) { + auto first = co_await opal::eventstream::ReceiveMessage(socket); if (!first.ok() || !first->has_value()) co_return; const JsonRpcOpening opening = helpers::ParseJsonRpcOpening(**first); if (!opening.ok) { - (void)co_await smithy::eventstream::SendMessage(socket, opening.refusal); + (void)co_await opal::eventstream::SendMessage(socket, opening.refusal); socket->Close(); co_return; } @@ -387,7 +387,7 @@ smithy::eventstream::Detached ServeJsonRpcSession(std::shared_ptrClose(); co_return; } @@ -397,7 +397,7 @@ smithy::eventstream::Detached ServeJsonRpcSession(std::shared_ptrClose(); co_return; } @@ -406,34 +406,34 @@ smithy::eventstream::Detached ServeJsonRpcSession(std::shared_ptr handler) - : router_(std::make_shared()), - stream_router_(std::make_shared()) { + : router_(std::make_shared()), + stream_router_(std::make_shared()) { // The route table is derived from the model's @http traits; conflicts are // a modeling error surfaced by Router::Add (checked at generation time in a // later phase), so registration results are intentionally discarded. - (void)router_->Add("POST", "/", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { - smithy::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) + (void)router_->Add("POST", "/", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { + opal::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) // A present Content-Type must carry application/json (parameters ignored). - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { return helpers::JsonRpcError(-32600, "UnsupportedMediaTypeException", "expected content-type: application/json", {}, id); } - auto decoded = smithy::json::Decode(request.body); + auto decoded = opal::json::Decode(request.body); // Envelope failure messages are fixed strings: the conformance suite // compares bodies exactly, so no decoder detail leaks into the wire. if (!decoded) return helpers::JsonRpcError(-32700, "SerializationException", "request body is not valid JSON", {}, id); if (!decoded->is_map()) return helpers::JsonRpcError(-32600, "SerializationException", "request is not a JSON-RPC 2.0 call", {}, id); - if (const smithy::Document* id_doc = decoded->Find("id"); id_doc != nullptr) id = *id_doc; - const smithy::Document* version = decoded->Find("jsonrpc"); + if (const opal::Document* id_doc = decoded->Find("id"); id_doc != nullptr) id = *id_doc; + const opal::Document* version = decoded->Find("jsonrpc"); if (version == nullptr || !version->is_string() || version->as_string() != "2.0") { return helpers::JsonRpcError(-32600, "SerializationException", "expected jsonrpc: \"2.0\"", {}, id); } - const smithy::Document* method = decoded->Find("method"); + const opal::Document* method = decoded->Find("method"); if (method == nullptr || !method->is_string()) { return helpers::JsonRpcError(-32600, "SerializationException", "expected a string method member", {}, id); } // Absent/null params deserialize like an empty object. - const smithy::Document empty_params{smithy::DocumentMap{}}; - const smithy::Document* params = decoded->Find("params"); + const opal::Document empty_params{opal::DocumentMap{}}; + const opal::Document* params = decoded->Find("params"); if (params == nullptr || params->is_null()) params = &empty_params; const std::string& method_name = method->as_string(); if (method_name == "EchoPayload") { @@ -458,41 +458,41 @@ JsonRpc2ProtocolServer::JsonRpc2ProtocolServer(std::shared_ptrAdd("GET", "/", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, smithy::http::WebSocket& socket) { + (void)stream_router_->Add("GET", "/", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context, opal::http::WebSocket& socket) { (void)request; helpers::ServeJsonRpcStream(*handler, context, socket); }, "JsonRpc2Protocol"); } JsonRpc2ProtocolServer::JsonRpc2ProtocolServer(std::shared_ptr handler) - : router_(std::make_shared()), - stream_router_(std::make_shared()) { + : router_(std::make_shared()), + stream_router_(std::make_shared()) { // The same unary table; every streaming route rides the shared-session // seam (ADR-0021) — an AddSession launch point per operation, so serving // a stream parks no handler thread. - (void)router_->Add("POST", "/", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { - smithy::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) + (void)router_->Add("POST", "/", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { + opal::Document id; // null until the envelope yields one (JSON-RPC 2.0 §5) // A present Content-Type must carry application/json (parameters ignored). - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { return helpers::JsonRpcError(-32600, "UnsupportedMediaTypeException", "expected content-type: application/json", {}, id); } - auto decoded = smithy::json::Decode(request.body); + auto decoded = opal::json::Decode(request.body); // Envelope failure messages are fixed strings: the conformance suite // compares bodies exactly, so no decoder detail leaks into the wire. if (!decoded) return helpers::JsonRpcError(-32700, "SerializationException", "request body is not valid JSON", {}, id); if (!decoded->is_map()) return helpers::JsonRpcError(-32600, "SerializationException", "request is not a JSON-RPC 2.0 call", {}, id); - if (const smithy::Document* id_doc = decoded->Find("id"); id_doc != nullptr) id = *id_doc; - const smithy::Document* version = decoded->Find("jsonrpc"); + if (const opal::Document* id_doc = decoded->Find("id"); id_doc != nullptr) id = *id_doc; + const opal::Document* version = decoded->Find("jsonrpc"); if (version == nullptr || !version->is_string() || version->as_string() != "2.0") { return helpers::JsonRpcError(-32600, "SerializationException", "expected jsonrpc: \"2.0\"", {}, id); } - const smithy::Document* method = decoded->Find("method"); + const opal::Document* method = decoded->Find("method"); if (method == nullptr || !method->is_string()) { return helpers::JsonRpcError(-32600, "SerializationException", "expected a string method member", {}, id); } // Absent/null params deserialize like an empty object. - const smithy::Document empty_params{smithy::DocumentMap{}}; - const smithy::Document* params = decoded->Find("params"); + const opal::Document empty_params{opal::DocumentMap{}}; + const opal::Document* params = decoded->Find("params"); if (params == nullptr || params->is_null()) params = &empty_params; const std::string& method_name = method->as_string(); if (method_name == "EchoPayload") { @@ -512,20 +512,20 @@ JsonRpc2ProtocolServer::JsonRpc2ProtocolServer(std::shared_ptrAddSession("GET", "/", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::shared_ptr socket) { + (void)stream_router_->AddSession("GET", "/", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::shared_ptr socket) { (void)request; (void)context; helpers::ServeJsonRpcSession(handler, std::move(socket)); }, "JsonRpc2Protocol"); } -smithy::http::RequestHandler JsonRpc2ProtocolServer::Handler() const { +opal::http::RequestHandler JsonRpc2ProtocolServer::Handler() const { auto router = router_; - return [router](const smithy::http::HttpRequest& request) { return router->Route(request); }; + return [router](const opal::http::HttpRequest& request) { return router->Route(request); }; } -std::shared_ptr JsonRpc2ProtocolServer::StreamRouter() const { +std::shared_ptr JsonRpc2ProtocolServer::StreamRouter() const { return stream_router_; } -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 diff --git a/protocol-tests/jsonrpc2/generated/tests/request_tests.cc b/protocol-tests/jsonrpc2/generated/tests/request_tests.cc index b6e688f1..5ac297fd 100644 --- a/protocol-tests/jsonrpc2/generated/tests/request_tests.cc +++ b/protocol-tests/jsonrpc2/generated/tests/request_tests.cc @@ -8,22 +8,22 @@ #include #include -#include "smithy/protocoltests/jsonrpc2/client.h" +#include "opal/protocoltests/jsonrpc2/client.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { // Generated from smithy.test#httpRequestTests (client cases). namespace { struct Fixture { - std::shared_ptr transport; + std::shared_ptr transport; JsonRpc2ProtocolClient client; }; Fixture MakeFixture(const std::string& endpoint = "") { - auto transport = std::make_shared(); - smithy::ClientConfig config; + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; config.endpoint = endpoint; @@ -47,12 +47,12 @@ TEST(JsonRpc2ProtocolRequestTest, JsonRpc2BasicRequest) { return v; }(); (void)fixture.client.EchoPayload(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/"); EXPECT_EQ(request.headers.Get("accept").value_or(""), "application/json"); EXPECT_EQ(request.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"method\":\"EchoPayload\",\"id\":1,\"params\":{\"string\":\"hello\",\"renamed\":\"other\",\"integer\":42,\"boolean\":true,\"double\":3.5}}", request.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"method\":\"EchoPayload\",\"id\":1,\"params\":{\"string\":\"hello\",\"renamed\":\"other\",\"integer\":42,\"boolean\":true,\"double\":3.5}}", request.body)); } // Lists, maps, and nested structures ride the shared JSON document pivot. @@ -71,10 +71,10 @@ TEST(JsonRpc2ProtocolRequestTest, JsonRpc2AggregatesRequest) { return v; }(); (void)fixture.client.EchoPayload(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"method\":\"EchoPayload\",\"id\":1,\"params\":{\"names\":[\"a\",\"b\"],\"attributes\":{\"k\":\"v\"},\"nested\":{\"label\":\"n\",\"depth\":2}}}", request.body)); + EXPECT_EQ(opal::testing::UriPath(request.target), "/"); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"method\":\"EchoPayload\",\"id\":1,\"params\":{\"names\":[\"a\",\"b\"],\"attributes\":{\"k\":\"v\"},\"nested\":{\"label\":\"n\",\"depth\":2}}}", request.body)); } // Timestamps default to epoch-seconds; @timestampFormat(date-time) renders RFC3339. @@ -82,15 +82,15 @@ TEST(JsonRpc2ProtocolRequestTest, JsonRpc2TimestampsRequest) { Fixture fixture = MakeFixture(); const EchoPayloadInput input = [] { EchoPayloadInput v{}; - v.timestamp = smithy::Timestamp::FromEpochMilliseconds(1515531081000LL); - v.dateTime = smithy::Timestamp::FromEpochMilliseconds(1515531081000LL); + v.timestamp = opal::Timestamp::FromEpochMilliseconds(1515531081000LL); + v.dateTime = opal::Timestamp::FromEpochMilliseconds(1515531081000LL); return v; }(); (void)fixture.client.EchoPayload(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"method\":\"EchoPayload\",\"id\":1,\"params\":{\"timestamp\":1515531081,\"dateTime\":\"2018-01-09T20:51:21Z\"}}", request.body)); + EXPECT_EQ(opal::testing::UriPath(request.target), "/"); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"method\":\"EchoPayload\",\"id\":1,\"params\":{\"timestamp\":1515531081,\"dateTime\":\"2018-01-09T20:51:21Z\"}}", request.body)); } // Operations with no modeled input omit the params member entirely. @@ -101,12 +101,12 @@ TEST(JsonRpc2ProtocolRequestTest, JsonRpc2NoParamsRequest) { return v; }(); (void)fixture.client.NoArgs(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/"); EXPECT_EQ(request.headers.Get("accept").value_or(""), "application/json"); EXPECT_EQ(request.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"method\":\"NoArgs\",\"id\":1}", request.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"method\":\"NoArgs\",\"id\":1}", request.body)); } // A valid constrained input passes validation and reaches the handler. @@ -119,10 +119,10 @@ TEST(JsonRpc2ProtocolRequestTest, JsonRpc2ConstrainedRequest) { return v; }(); (void)fixture.client.PutConstrained(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"method\":\"PutConstrained\",\"id\":1,\"params\":{\"name\":\"ok\",\"limit\":10}}", request.body)); + EXPECT_EQ(opal::testing::UriPath(request.target), "/"); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"method\":\"PutConstrained\",\"id\":1,\"params\":{\"name\":\"ok\",\"limit\":10}}", request.body)); } -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 diff --git a/protocol-tests/jsonrpc2/generated/tests/response_tests.cc b/protocol-tests/jsonrpc2/generated/tests/response_tests.cc index c5d2fcd7..d8f82e7b 100644 --- a/protocol-tests/jsonrpc2/generated/tests/response_tests.cc +++ b/protocol-tests/jsonrpc2/generated/tests/response_tests.cc @@ -8,23 +8,23 @@ #include #include -#include "smithy/protocoltests/jsonrpc2/client.h" +#include "opal/protocoltests/jsonrpc2/client.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { // Generated from smithy.test#httpResponseTests (client cases), // including the cases attached to modeled error shapes. namespace { struct Fixture { - std::shared_ptr transport; + std::shared_ptr transport; JsonRpc2ProtocolClient client; }; Fixture MakeFixture(const std::string& endpoint = "") { - auto transport = std::make_shared(); - smithy::ClientConfig config; + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; config.endpoint = endpoint; @@ -112,4 +112,4 @@ TEST(JsonRpc2ProtocolErrorTest, JsonRpc2ThrottledError) { EXPECT_EQ(*detail, expected); } -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 diff --git a/protocol-tests/jsonrpc2/generated/tests/server_malformed_tests.cc b/protocol-tests/jsonrpc2/generated/tests/server_malformed_tests.cc index 33b9c29a..a3b18b2b 100644 --- a/protocol-tests/jsonrpc2/generated/tests/server_malformed_tests.cc +++ b/protocol-tests/jsonrpc2/generated/tests/server_malformed_tests.cc @@ -8,11 +8,11 @@ #include #include -#include "smithy/protocoltests/jsonrpc2/client.h" -#include "smithy/protocoltests/jsonrpc2/server.h" +#include "opal/protocoltests/jsonrpc2/client.h" +#include "opal/protocoltests/jsonrpc2/server.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { // Generated from smithy.test#httpMalformedRequestTests: each malformed // wire request is routed into the generated server, which must reject @@ -42,24 +42,24 @@ PutConstrainedOutput MinimalPutConstrainedOutput() { class RecordingHandler : public JsonRpc2ProtocolHandler { public: - smithy::Outcome EchoPayload(const EchoPayloadInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EchoPayload(const EchoPayloadInput& input, const opal::server::RequestContext&) override { lastEchoPayload = input; return MinimalEchoPayloadOutput(); } std::optional lastEchoPayload; // Streaming operation (ADR-0016): no generated unary-shaped test drives // this; the stub closes the stream so the interface stays implemented. - smithy::Outcome EchoStream(const EchoStreamInput& input, EchoStreamServerStream& stream, const smithy::server::RequestContext&) override { + opal::Outcome EchoStream(const EchoStreamInput& input, EchoStreamServerStream& stream, const opal::server::RequestContext&) override { (void)input; stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } - smithy::Outcome NoArgs(const NoArgsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome NoArgs(const NoArgsInput& input, const opal::server::RequestContext&) override { lastNoArgs = input; return MinimalNoArgsOutput(); } std::optional lastNoArgs; - smithy::Outcome PutConstrained(const PutConstrainedInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PutConstrained(const PutConstrainedInput& input, const opal::server::RequestContext&) override { lastPutConstrained = input; return MinimalPutConstrainedOutput(); } @@ -71,141 +71,141 @@ class RecordingHandler : public JsonRpc2ProtocolHandler { // An unparseable body answers the reserved -32700 Parse error with a null id. TEST(JsonRpc2ProtocolServerMalformedTest, JsonRpc2RejectsInvalidJson) { JsonRpc2ProtocolServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); request.body = "{"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); EXPECT_EQ(response.status, 200) << response.body; EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32700,\"message\":\"request body is not valid JSON\",\"data\":{\"__type\":\"SerializationException\"}},\"id\":null}", response.body)) << response.body; + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32700,\"message\":\"request body is not valid JSON\",\"data\":{\"__type\":\"SerializationException\"}},\"id\":null}", response.body)) << response.body; } // A JSON body that is not an object is an invalid request (-32600). TEST(JsonRpc2ProtocolServerMalformedTest, JsonRpc2RejectsNonObjectEnvelope) { JsonRpc2ProtocolServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); request.body = "[1,2,3]"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); EXPECT_EQ(response.status, 200) << response.body; EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32600,\"message\":\"request is not a JSON-RPC 2.0 call\",\"data\":{\"__type\":\"SerializationException\"}},\"id\":null}", response.body)) << response.body; + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32600,\"message\":\"request is not a JSON-RPC 2.0 call\",\"data\":{\"__type\":\"SerializationException\"}},\"id\":null}", response.body)) << response.body; } // jsonrpc must be the string "2.0"; the id is still echoed once parsed. TEST(JsonRpc2ProtocolServerMalformedTest, JsonRpc2RejectsWrongVersion) { JsonRpc2ProtocolServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); request.body = "{\"jsonrpc\":\"1.0\",\"method\":\"EchoPayload\",\"id\":7}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); EXPECT_EQ(response.status, 200) << response.body; EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32600,\"message\":\"expected jsonrpc: \\\"2.0\\\"\",\"data\":{\"__type\":\"SerializationException\"}},\"id\":7}", response.body)) << response.body; + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32600,\"message\":\"expected jsonrpc: \\\"2.0\\\"\",\"data\":{\"__type\":\"SerializationException\"}},\"id\":7}", response.body)) << response.body; } // A call without a string method member is an invalid request (-32600). TEST(JsonRpc2ProtocolServerMalformedTest, JsonRpc2RejectsMissingMethod) { JsonRpc2ProtocolServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); request.body = "{\"jsonrpc\":\"2.0\",\"id\":3}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); EXPECT_EQ(response.status, 200) << response.body; EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32600,\"message\":\"expected a string method member\",\"data\":{\"__type\":\"SerializationException\"}},\"id\":3}", response.body)) << response.body; + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32600,\"message\":\"expected a string method member\",\"data\":{\"__type\":\"SerializationException\"}},\"id\":3}", response.body)) << response.body; } // A method naming no operation answers -32601 Method not found. TEST(JsonRpc2ProtocolServerMalformedTest, JsonRpc2RejectsUnknownMethod) { JsonRpc2ProtocolServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"DoesNotExist\",\"id\":4}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); EXPECT_EQ(response.status, 200) << response.body; EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32601,\"message\":\"unknown method: DoesNotExist\",\"data\":{\"__type\":\"UnknownOperationException\"}},\"id\":4}", response.body)) << response.body; + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32601,\"message\":\"unknown method: DoesNotExist\",\"data\":{\"__type\":\"UnknownOperationException\"}},\"id\":4}", response.body)) << response.body; } // params must be an object when present (-32602 Invalid params). TEST(JsonRpc2ProtocolServerMalformedTest, JsonRpc2RejectsNonObjectParams) { JsonRpc2ProtocolServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"EchoPayload\",\"params\":5,\"id\":6}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); EXPECT_EQ(response.status, 200) << response.body; EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32602,\"message\":\"params must be an object\",\"data\":{\"__type\":\"SerializationException\"}},\"id\":6}", response.body)) << response.body; + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32602,\"message\":\"params must be an object\",\"data\":{\"__type\":\"SerializationException\"}},\"id\":6}", response.body)) << response.body; } // A present Content-Type must carry application/json. TEST(JsonRpc2ProtocolServerMalformedTest, JsonRpc2RejectsWrongContentType) { JsonRpc2ProtocolServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "text/plain"); request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"EchoPayload\",\"id\":1}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); EXPECT_EQ(response.status, 200) << response.body; EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32600,\"message\":\"expected content-type: application/json\",\"data\":{\"__type\":\"UnsupportedMediaTypeException\"}},\"id\":null}", response.body)) << response.body; + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32600,\"message\":\"expected content-type: application/json\",\"data\":{\"__type\":\"UnsupportedMediaTypeException\"}},\"id\":null}", response.body)) << response.body; } // Constraint violations answer a 400-coded error envelope carrying smithy.framework#ValidationException identity and the fieldList. TEST(JsonRpc2ProtocolServerMalformedTest, JsonRpc2ValidationFailure) { JsonRpc2ProtocolServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"PutConstrained\",\"params\":{\"name\":\"\"},\"id\":9}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); EXPECT_EQ(response.status, 200) << response.body; EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":400,\"message\":\"1 validation error detected. Value with length 0 at '/name' failed to satisfy constraint: Member must have length between 1 and 8, inclusive\",\"data\":{\"__type\":\"smithy.framework#ValidationException\",\"fieldList\":[{\"message\":\"Value with length 0 at '/name' failed to satisfy constraint: Member must have length between 1 and 8, inclusive\",\"path\":\"/name\"}]}},\"id\":9}", response.body)) << response.body; + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":400,\"message\":\"1 validation error detected. Value with length 0 at '/name' failed to satisfy constraint: Member must have length between 1 and 8, inclusive\",\"data\":{\"__type\":\"smithy.framework#ValidationException\",\"fieldList\":[{\"message\":\"Value with length 0 at '/name' failed to satisfy constraint: Member must have length between 1 and 8, inclusive\",\"path\":\"/name\"}]}},\"id\":9}", response.body)) << response.body; } // @pattern violations report the suite-exact message with the pattern text. TEST(JsonRpc2ProtocolServerMalformedTest, JsonRpc2PatternMismatch) { JsonRpc2ProtocolServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"PutConstrained\",\"params\":{\"name\":\"ok\",\"slug\":\"Not Valid!\"},\"id\":10}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); EXPECT_EQ(response.status, 200) << response.body; EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":400,\"message\":\"1 validation error detected. Value at '/slug' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-z0-9-]+$\",\"data\":{\"__type\":\"smithy.framework#ValidationException\",\"fieldList\":[{\"message\":\"Value at '/slug' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-z0-9-]+$\",\"path\":\"/slug\"}]}},\"id\":10}", response.body)) << response.body; + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":400,\"message\":\"1 validation error detected. Value at '/slug' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-z0-9-]+$\",\"data\":{\"__type\":\"smithy.framework#ValidationException\",\"fieldList\":[{\"message\":\"Value at '/slug' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-z0-9-]+$\",\"path\":\"/slug\"}]}},\"id\":10}", response.body)) << response.body; } // When the pattern is susceptible to catastrophic backtracking, the server answers promptly instead of hanging while evaluating it (linear-time engine). TEST(JsonRpc2ProtocolServerMalformedTest, JsonRpc2PatternReDoSInput) { JsonRpc2ProtocolServer server(std::make_shared()); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"PutConstrained\",\"params\":{\"name\":\"ok\",\"evilDigits\":\"00000000000000000000000000000000000000000000000000!\"},\"id\":11}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); EXPECT_EQ(response.status, 200) << response.body; EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":400,\"message\":\"1 validation error detected. Value at '/evilDigits' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$\",\"data\":{\"__type\":\"smithy.framework#ValidationException\",\"fieldList\":[{\"message\":\"Value at '/evilDigits' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$\",\"path\":\"/evilDigits\"}]}},\"id\":11}", response.body)) << response.body; + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":400,\"message\":\"1 validation error detected. Value at '/evilDigits' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$\",\"data\":{\"__type\":\"smithy.framework#ValidationException\",\"fieldList\":[{\"message\":\"Value at '/evilDigits' failed to satisfy constraint: Member must satisfy regular expression pattern: ^([0-9]+)+$\",\"path\":\"/evilDigits\"}]}},\"id\":11}", response.body)) << response.body; } -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 diff --git a/protocol-tests/jsonrpc2/generated/tests/server_request_tests.cc b/protocol-tests/jsonrpc2/generated/tests/server_request_tests.cc index a3f8ff16..3fd38d44 100644 --- a/protocol-tests/jsonrpc2/generated/tests/server_request_tests.cc +++ b/protocol-tests/jsonrpc2/generated/tests/server_request_tests.cc @@ -8,11 +8,11 @@ #include #include -#include "smithy/protocoltests/jsonrpc2/client.h" -#include "smithy/protocoltests/jsonrpc2/server.h" +#include "opal/protocoltests/jsonrpc2/client.h" +#include "opal/protocoltests/jsonrpc2/server.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { // Generated from smithy.test#httpRequestTests (server cases): the wire // request is routed into the generated server and the parsed input is @@ -42,24 +42,24 @@ PutConstrainedOutput MinimalPutConstrainedOutput() { class RecordingHandler : public JsonRpc2ProtocolHandler { public: - smithy::Outcome EchoPayload(const EchoPayloadInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EchoPayload(const EchoPayloadInput& input, const opal::server::RequestContext&) override { lastEchoPayload = input; return MinimalEchoPayloadOutput(); } std::optional lastEchoPayload; // Streaming operation (ADR-0016): no generated unary-shaped test drives // this; the stub closes the stream so the interface stays implemented. - smithy::Outcome EchoStream(const EchoStreamInput& input, EchoStreamServerStream& stream, const smithy::server::RequestContext&) override { + opal::Outcome EchoStream(const EchoStreamInput& input, EchoStreamServerStream& stream, const opal::server::RequestContext&) override { (void)input; stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } - smithy::Outcome NoArgs(const NoArgsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome NoArgs(const NoArgsInput& input, const opal::server::RequestContext&) override { lastNoArgs = input; return MinimalNoArgsOutput(); } std::optional lastNoArgs; - smithy::Outcome PutConstrained(const PutConstrainedInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PutConstrained(const PutConstrainedInput& input, const opal::server::RequestContext&) override { lastPutConstrained = input; return MinimalPutConstrainedOutput(); } @@ -72,13 +72,13 @@ class RecordingHandler : public JsonRpc2ProtocolHandler { TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2BasicRequest) { auto handler = std::make_shared(); JsonRpc2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("accept", "application/json"); request.headers.Set("content-type", "application/json"); request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"EchoPayload\",\"id\":1,\"params\":{\"string\":\"hello\",\"renamed\":\"other\",\"integer\":42,\"boolean\":true,\"double\":3.5}}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastEchoPayload.has_value()) << response.status << " " << response.body; const EchoPayloadInput expected = [] { EchoPayloadInput v{}; @@ -96,11 +96,11 @@ TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2BasicRequest) { TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2AggregatesRequest) { auto handler = std::make_shared(); JsonRpc2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"EchoPayload\",\"id\":1,\"params\":{\"names\":[\"a\",\"b\"],\"attributes\":{\"k\":\"v\"},\"nested\":{\"label\":\"n\",\"depth\":2}}}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastEchoPayload.has_value()) << response.status << " " << response.body; const EchoPayloadInput expected = [] { EchoPayloadInput v{}; @@ -121,16 +121,16 @@ TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2AggregatesRequest) { TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2TimestampsRequest) { auto handler = std::make_shared(); JsonRpc2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"EchoPayload\",\"id\":1,\"params\":{\"timestamp\":1515531081,\"dateTime\":\"2018-01-09T20:51:21Z\"}}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastEchoPayload.has_value()) << response.status << " " << response.body; const EchoPayloadInput expected = [] { EchoPayloadInput v{}; - v.timestamp = smithy::Timestamp::FromEpochMilliseconds(1515531081000LL); - v.dateTime = smithy::Timestamp::FromEpochMilliseconds(1515531081000LL); + v.timestamp = opal::Timestamp::FromEpochMilliseconds(1515531081000LL); + v.dateTime = opal::Timestamp::FromEpochMilliseconds(1515531081000LL); return v; }(); EXPECT_EQ(*handler->lastEchoPayload, expected); @@ -140,13 +140,13 @@ TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2TimestampsRequest) { TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2NoParamsRequest) { auto handler = std::make_shared(); JsonRpc2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("accept", "application/json"); request.headers.Set("content-type", "application/json"); request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"NoArgs\",\"id\":1}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastNoArgs.has_value()) << response.status << " " << response.body; const NoArgsInput expected = [] { NoArgsInput v{}; @@ -159,12 +159,12 @@ TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2NoParamsRequest) { TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2ServerIgnoresParamsForNoArgs) { auto handler = std::make_shared(); JsonRpc2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"NoArgs\",\"id\":1,\"params\":{\"unexpected\":true}}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastNoArgs.has_value()) << response.status << " " << response.body; const NoArgsInput expected = [] { NoArgsInput v{}; @@ -177,11 +177,11 @@ TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2ServerIgnoresParamsForNoArgs) { TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2ConstrainedRequest) { auto handler = std::make_shared(); JsonRpc2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"PutConstrained\",\"id\":1,\"params\":{\"name\":\"ok\",\"limit\":10}}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastPutConstrained.has_value()) << response.status << " " << response.body; const PutConstrainedInput expected = [] { PutConstrainedInput v{}; @@ -192,4 +192,4 @@ TEST(JsonRpc2ProtocolServerRequestTest, JsonRpc2ConstrainedRequest) { EXPECT_EQ(*handler->lastPutConstrained, expected); } -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 diff --git a/protocol-tests/jsonrpc2/generated/tests/server_response_tests.cc b/protocol-tests/jsonrpc2/generated/tests/server_response_tests.cc index 87188c34..9d0bea0d 100644 --- a/protocol-tests/jsonrpc2/generated/tests/server_response_tests.cc +++ b/protocol-tests/jsonrpc2/generated/tests/server_response_tests.cc @@ -8,11 +8,11 @@ #include #include -#include "smithy/protocoltests/jsonrpc2/client.h" -#include "smithy/protocoltests/jsonrpc2/server.h" +#include "opal/protocoltests/jsonrpc2/client.h" +#include "opal/protocoltests/jsonrpc2/server.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { // Generated from smithy.test#httpResponseTests (server cases): a stub // handler returns the expected params and the wire response the server @@ -42,33 +42,33 @@ PutConstrainedOutput MinimalPutConstrainedOutput() { class RecordingHandler : public JsonRpc2ProtocolHandler { public: - smithy::Outcome EchoPayload(const EchoPayloadInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EchoPayload(const EchoPayloadInput& input, const opal::server::RequestContext&) override { lastEchoPayload = input; return MinimalEchoPayloadOutput(); } std::optional lastEchoPayload; // Streaming operation (ADR-0016): no generated unary-shaped test drives // this; the stub closes the stream so the interface stays implemented. - smithy::Outcome EchoStream(const EchoStreamInput& input, EchoStreamServerStream& stream, const smithy::server::RequestContext&) override { + opal::Outcome EchoStream(const EchoStreamInput& input, EchoStreamServerStream& stream, const opal::server::RequestContext&) override { (void)input; stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } - smithy::Outcome NoArgs(const NoArgsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome NoArgs(const NoArgsInput& input, const opal::server::RequestContext&) override { lastNoArgs = input; return MinimalNoArgsOutput(); } std::optional lastNoArgs; - smithy::Outcome PutConstrained(const PutConstrainedInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PutConstrained(const PutConstrainedInput& input, const opal::server::RequestContext&) override { lastPutConstrained = input; return MinimalPutConstrainedOutput(); } std::optional lastPutConstrained; }; -smithy::http::HttpRequest MinimalRequestForEchoPayload() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForEchoPayload() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *JsonRpc2ProtocolClient::Create(std::move(config)); @@ -80,9 +80,9 @@ smithy::http::HttpRequest MinimalRequestForEchoPayload() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForNoArgs() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForNoArgs() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *JsonRpc2ProtocolClient::Create(std::move(config)); @@ -100,7 +100,7 @@ smithy::http::HttpRequest MinimalRequestForNoArgs() { TEST(JsonRpc2ProtocolServerResponseTest, JsonRpc2BasicResponse) { class Handler final : public RecordingHandler { public: - smithy::Outcome EchoPayload(const EchoPayloadInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EchoPayload(const EchoPayloadInput& input, const opal::server::RequestContext&) override { (void)input; return [] { EchoPayloadOutput v{}; @@ -117,17 +117,17 @@ TEST(JsonRpc2ProtocolServerResponseTest, JsonRpc2BasicResponse) { } }; JsonRpc2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForEchoPayload()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForEchoPayload()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"result\":{\"echo\":\"hello\",\"count\":3,\"nested\":{\"label\":\"n\",\"depth\":2}},\"id\":1}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"result\":{\"echo\":\"hello\",\"count\":3,\"nested\":{\"label\":\"n\",\"depth\":2}},\"id\":1}", response.body)); } // An operation with no modeled output answers an empty result object. TEST(JsonRpc2ProtocolServerResponseTest, JsonRpc2EmptyResponse) { class Handler final : public RecordingHandler { public: - smithy::Outcome NoArgs(const NoArgsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome NoArgs(const NoArgsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { NoArgsOutput v{}; @@ -136,19 +136,19 @@ TEST(JsonRpc2ProtocolServerResponseTest, JsonRpc2EmptyResponse) { } }; JsonRpc2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForNoArgs()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForNoArgs()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"result\":{},\"id\":1}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"result\":{},\"id\":1}", response.body)); } // Modeled errors ride the JSON-RPC error object: code from @httpError, data carries the members plus the fully qualified shape id in __type, message mirrors the detail's message. TEST(JsonRpc2ProtocolServerErrorTest, JsonRpc2NotFoundError) { class Handler final : public RecordingHandler { public: - smithy::Outcome EchoPayload(const EchoPayloadInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EchoPayload(const EchoPayloadInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("NotFoundError", ""); + opal::Error error = opal::Error::Modeled("NotFoundError", ""); error.set_detail([] { NotFoundError v{}; v.message = "no such sink"; @@ -159,19 +159,19 @@ TEST(JsonRpc2ProtocolServerErrorTest, JsonRpc2NotFoundError) { } }; JsonRpc2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForEchoPayload()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForEchoPayload()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":404,\"message\":\"no such sink\",\"data\":{\"__type\":\"smithy.cpp.protocoltests.jsonrpc2#NotFoundError\",\"message\":\"no such sink\",\"resourceType\":\"Sink\"}},\"id\":1}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":404,\"message\":\"no such sink\",\"data\":{\"__type\":\"smithy.cpp.protocoltests.jsonrpc2#NotFoundError\",\"message\":\"no such sink\",\"resourceType\":\"Sink\"}},\"id\":1}", response.body)); } // Server-class errors carry their 5xx @httpError status as the JSON-RPC code, marking them retryable client-side. TEST(JsonRpc2ProtocolServerErrorTest, JsonRpc2ThrottledError) { class Handler final : public RecordingHandler { public: - smithy::Outcome EchoPayload(const EchoPayloadInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EchoPayload(const EchoPayloadInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("ThrottledError", ""); + opal::Error error = opal::Error::Modeled("ThrottledError", ""); error.set_detail([] { ThrottledError v{}; v.message = "slow down"; @@ -181,10 +181,10 @@ TEST(JsonRpc2ProtocolServerErrorTest, JsonRpc2ThrottledError) { } }; JsonRpc2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForEchoPayload()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForEchoPayload()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":503,\"message\":\"slow down\",\"data\":{\"__type\":\"smithy.cpp.protocoltests.jsonrpc2#ThrottledError\",\"message\":\"slow down\"}},\"id\":1}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"jsonrpc\":\"2.0\",\"error\":{\"code\":503,\"message\":\"slow down\",\"data\":{\"__type\":\"smithy.cpp.protocoltests.jsonrpc2#ThrottledError\",\"message\":\"slow down\"}},\"id\":1}", response.body)); } -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 diff --git a/protocol-tests/jsonrpc2/generated/tests/smoke_test.cc b/protocol-tests/jsonrpc2/generated/tests/smoke_test.cc index 5105758a..d4c9aad9 100644 --- a/protocol-tests/jsonrpc2/generated/tests/smoke_test.cc +++ b/protocol-tests/jsonrpc2/generated/tests/smoke_test.cc @@ -4,12 +4,12 @@ #include #include +#include "opal/protocoltests/jsonrpc2/client.h" +#include "opal/protocoltests/jsonrpc2/server.h" #include "smithy/client/config.h" #include "smithy/http/loopback.h" -#include "smithy/protocoltests/jsonrpc2/client.h" -#include "smithy/protocoltests/jsonrpc2/server.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { // Smoke tests for the generated JsonRpc2Protocol service: the generated client calls the // generated server over the in-memory loopback transport. A passing suite @@ -41,22 +41,22 @@ PutConstrainedOutput MinimalPutConstrainedOutput() { class SmokeHandler : public JsonRpc2ProtocolHandler { public: - smithy::Outcome EchoPayload(const EchoPayloadInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EchoPayload(const EchoPayloadInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalEchoPayloadOutput(); } // Streaming operation (ADR-0016): no generated unary-shaped test drives // this; the stub closes the stream so the interface stays implemented. - smithy::Outcome EchoStream(const EchoStreamInput& input, EchoStreamServerStream& stream, const smithy::server::RequestContext&) override { + opal::Outcome EchoStream(const EchoStreamInput& input, EchoStreamServerStream& stream, const opal::server::RequestContext&) override { (void)input; stream.Close(); - return smithy::Unit{}; + return opal::Unit{}; } - smithy::Outcome NoArgs(const NoArgsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome NoArgs(const NoArgsInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalNoArgsOutput(); } - smithy::Outcome PutConstrained(const PutConstrainedInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PutConstrained(const PutConstrainedInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalPutConstrainedOutput(); } @@ -64,9 +64,9 @@ class SmokeHandler : public JsonRpc2ProtocolHandler { JsonRpc2ProtocolClient MakeClient(std::shared_ptr handler) { JsonRpc2ProtocolServer server(std::move(handler)); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = loopback; // Create cannot fail when a transport is injected. @@ -112,9 +112,9 @@ TEST(JsonRpc2ProtocolSmokeTest, PutConstrainedRoundTrips) { TEST(JsonRpc2ProtocolSmokeTest, ModeledErrorsMapAcrossTheWire) { class FailingHandler final : public SmokeHandler { public: - smithy::Outcome EchoPayload(const EchoPayloadInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EchoPayload(const EchoPayloadInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("NotFoundError", "smoke"); + opal::Error error = opal::Error::Modeled("NotFoundError", "smoke"); auto detail = [] { NotFoundError v{}; return v; @@ -132,10 +132,10 @@ TEST(JsonRpc2ProtocolSmokeTest, ModeledErrorsMapAcrossTheWire) { }(); const auto outcome = client.EchoPayload(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "NotFoundError"); EXPECT_EQ(outcome.error().message(), "smoke"); EXPECT_NE(outcome.error().detail(), nullptr); } -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 diff --git a/protocol-tests/jsonrpc2/stream_conformance_test.cc b/protocol-tests/jsonrpc2/stream_conformance_test.cc index f213fc70..cc7fcf1c 100644 --- a/protocol-tests/jsonrpc2/stream_conformance_test.cc +++ b/protocol-tests/jsonrpc2/stream_conformance_test.cc @@ -25,6 +25,8 @@ #include #include +#include "opal/protocoltests/jsonrpc2/client.h" +#include "opal/protocoltests/jsonrpc2/server.h" #include "smithy/client/config.h" #include "smithy/core/error.h" #include "smithy/core/outcome.h" @@ -33,10 +35,8 @@ #include "smithy/http/message.h" #include "smithy/http/websocket.h" #include "smithy/http/websocket_pair.h" -#include "smithy/protocoltests/jsonrpc2/client.h" -#include "smithy/protocoltests/jsonrpc2/server.h" -namespace smithy::protocoltests::jsonrpc2 { +namespace opal::protocoltests::jsonrpc2 { namespace { // One raw wire frame: a headerless message whose payload is the envelope @@ -54,69 +54,68 @@ eventstream::Message RawText(std::string text) { // single-threaded and deterministic; one blocking-seam case pins parity. class AsyncEchoHandler final : public JsonRpc2ProtocolAsyncHandler { public: - smithy::Outcome EchoPayload(const EchoPayloadInput&, - const smithy::server::RequestContext&) override { + opal::Outcome EchoPayload(const EchoPayloadInput&, + const opal::server::RequestContext&) override { return EchoPayloadOutput{}; } - smithy::Outcome NoArgs(const NoArgsInput&, - const smithy::server::RequestContext&) override { + opal::Outcome NoArgs(const NoArgsInput&, + const opal::server::RequestContext&) override { return NoArgsOutput{}; } - smithy::Outcome PutConstrained( - const PutConstrainedInput&, const smithy::server::RequestContext&) override { + opal::Outcome PutConstrained(const PutConstrainedInput&, + const opal::server::RequestContext&) override { return PutConstrainedOutput{}; } - smithy::eventstream::StreamTask EchoStream(EchoStreamInput input, - EchoStreamAsyncServerStream& stream) override { + opal::eventstream::StreamTask EchoStream(EchoStreamInput input, + EchoStreamAsyncServerStream& stream) override { const std::string prefix = input.prefix.value_or(""); while (true) { auto note = co_await stream.Receive(); - if (!note.ok() || !note->has_value()) co_return smithy::Unit{}; + if (!note.ok() || !note->has_value()) co_return opal::Unit{}; const std::string& text = (**note).as_note().text; - if (text == "done") co_return smithy::Unit{}; + if (text == "done") co_return opal::Unit{}; if (text == "abort") { - smithy::Error error = smithy::Error::Modeled("StreamAbort", "aborted by note"); + opal::Error error = opal::Error::Modeled("StreamAbort", "aborted by note"); error.set_detail(StreamAbort{.message = "aborted by note"}); co_return error; } auto sent = co_await stream.Send(DownEvents::FromEcho(EchoedNote{.text = prefix + text})); - if (!sent.ok()) co_return smithy::Unit{}; + if (!sent.ok()) co_return opal::Unit{}; } } }; class BlockingEchoHandler final : public JsonRpc2ProtocolHandler { public: - smithy::Outcome EchoPayload(const EchoPayloadInput&, - const smithy::server::RequestContext&) override { + opal::Outcome EchoPayload(const EchoPayloadInput&, + const opal::server::RequestContext&) override { return EchoPayloadOutput{}; } - smithy::Outcome NoArgs(const NoArgsInput&, - const smithy::server::RequestContext&) override { + opal::Outcome NoArgs(const NoArgsInput&, + const opal::server::RequestContext&) override { return NoArgsOutput{}; } - smithy::Outcome PutConstrained( - const PutConstrainedInput&, const smithy::server::RequestContext&) override { + opal::Outcome PutConstrained(const PutConstrainedInput&, + const opal::server::RequestContext&) override { return PutConstrainedOutput{}; } - smithy::Outcome EchoStream(const EchoStreamInput& input, - EchoStreamServerStream& stream, - const smithy::server::RequestContext&) override { + opal::Outcome EchoStream(const EchoStreamInput& input, EchoStreamServerStream& stream, + const opal::server::RequestContext&) override { const std::string prefix = input.prefix.value_or(""); while (true) { auto note = stream.Receive(); - if (!note.ok() || !note->has_value()) return smithy::Unit{}; + if (!note.ok() || !note->has_value()) return opal::Unit{}; const std::string& text = (**note).as_note().text; - if (text == "done") return smithy::Unit{}; + if (text == "done") return opal::Unit{}; if (text == "abort") { - smithy::Error error = smithy::Error::Modeled("StreamAbort", "aborted by note"); + opal::Error error = opal::Error::Modeled("StreamAbort", "aborted by note"); error.set_detail(StreamAbort{.message = "aborted by note"}); return error; } if (!stream.Send(DownEvents::FromEcho(EchoedNote{.text = prefix + text})).ok()) { - return smithy::Unit{}; + return opal::Unit{}; } } } @@ -276,8 +275,8 @@ TEST_F(StreamConformanceTest, AHeaderedOpeningMessageIsRefusedWithMinus32600) { // messages by construction): a peer speaking the eventstream envelope // wire into the JSON-RPC endpoint. auto peer = OpenSession(); - EXPECT_TRUE(peer->Send(smithy::eventstream::MakeEventMessage("note", "application/json", - Blob::FromString("{}"))) + EXPECT_TRUE(peer->Send(opal::eventstream::MakeEventMessage("note", "application/json", + Blob::FromString("{}"))) .ok()); auto answer = peer->Receive(); ASSERT_TRUE(answer.ok() && answer->has_value()); @@ -441,13 +440,13 @@ class ClientStreamConformanceTest : public testing::Test { // A generated client whose dialer yields one pair end; the far end stays // raw — the test IS the server. JsonRpc2ProtocolClient MakeClient() { - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // Never dialed: the injected websocket_dialer intercepts the stream, // and no unary call is made — Create just requires a transport story. config.endpoint = "http://127.0.0.1:1"; config.websocket_dialer = [this](const http::WebSocketDialRequest& request) - -> smithy::Outcome> { + -> opal::Outcome> { EXPECT_EQ(request.target, "/"); EXPECT_TRUE(request.raw_text_frames); auto [near, far] = http::InMemoryWebSocketPair::Create(); @@ -524,7 +523,7 @@ TEST_F(ClientStreamConformanceTest, TheTerminalErrorArrivesTypedThroughTheUnaryI .ok()); auto outcome = stream->Receive(); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "StreamAbort"); const StreamAbort* detail = outcome.error().detail(); ASSERT_NE(detail, nullptr); @@ -550,4 +549,4 @@ TEST_F(ClientStreamConformanceTest, AReservedCodeErrorSurfacesAsTheGenericTermin } } // namespace -} // namespace smithy::protocoltests::jsonrpc2 +} // namespace opal::protocoltests::jsonrpc2 diff --git a/protocol-tests/rpcv2cbor/generated/BUILD.bazel b/protocol-tests/rpcv2cbor/generated/BUILD.bazel index d77946e4..5f8acabe 100644 --- a/protocol-tests/rpcv2cbor/generated/BUILD.bazel +++ b/protocol-tests/rpcv2cbor/generated/BUILD.bazel @@ -6,7 +6,7 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "types", - hdrs = ["include/smithy/protocoltests/rpcv2cbor/types.h"], + hdrs = ["include/opal/protocoltests/rpcv2cbor/types.h"], copts = [ "-Wall", "-Wextra", @@ -18,7 +18,7 @@ cc_library( cc_library( name = "serde", srcs = ["src/serde.cc"], - hdrs = ["include/smithy/protocoltests/rpcv2cbor/serde.h"], + hdrs = ["include/opal/protocoltests/rpcv2cbor/serde.h"], copts = [ "-Wall", "-Wextra", @@ -33,7 +33,7 @@ cc_library( cc_library( name = "client", srcs = ["src/client.cc"], - hdrs = ["include/smithy/protocoltests/rpcv2cbor/client.h"], + hdrs = ["include/opal/protocoltests/rpcv2cbor/client.h"], copts = [ "-Wall", "-Wextra", @@ -52,7 +52,7 @@ cc_library( cc_library( name = "server", srcs = ["src/server.cc"], - hdrs = ["include/smithy/protocoltests/rpcv2cbor/server.h"], + hdrs = ["include/opal/protocoltests/rpcv2cbor/server.h"], copts = [ "-Wall", "-Wextra", diff --git a/protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/client.h b/protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/client.h similarity index 74% rename from protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/client.h rename to protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/client.h index b9d6a6cf..5c2ce5b4 100644 --- a/protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/client.h +++ b/protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/client.h @@ -1,7 +1,7 @@ // Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. -#ifndef SMITHY_PROTOCOLTESTS_RPCV2CBOR_CLIENT_H_ -#define SMITHY_PROTOCOLTESTS_RPCV2CBOR_CLIENT_H_ +#ifndef OPAL_PROTOCOLTESTS_RPCV2CBOR_CLIENT_H_ +#define OPAL_PROTOCOLTESTS_RPCV2CBOR_CLIENT_H_ #include #include @@ -12,29 +12,29 @@ #include #include +#include "opal/protocoltests/rpcv2cbor/types.h" #include "smithy/client/config.h" #include "smithy/core/fatal.h" #include "smithy/core/hash.h" #include "smithy/core/outcome.h" #include "smithy/core/print.h" #include "smithy/http/transport.h" -#include "smithy/protocoltests/rpcv2cbor/types.h" -namespace smithy::protocoltests::rpcv2cbor { +namespace opal::protocoltests::rpcv2cbor { /// rpcv2Cbor client for smithy.protocoltests.rpcv2Cbor#RpcV2Protocol. -/// Modeled service errors surface as smithy::Error with kind kModeled, +/// Modeled service errors surface as opal::Error with kind kModeled, /// code() set to the error shape name, and the deserialized error /// structure attached. Dispatch on them through the per-operation /// Errors listings below rather than comparing code() text. class RpcV2ProtocolClient { public: /// Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); + static opal::Outcome Create(opal::ClientConfig config); - smithy::Outcome EmptyInputOutput(const EmptyInputOutputInput& input = {}) const; - smithy::Outcome Float16(const Float16Input& input = {}) const; - smithy::Outcome FractionalSeconds(const FractionalSecondsInput& input = {}) const; + opal::Outcome EmptyInputOutput(const EmptyInputOutputInput& input = {}) const; + opal::Outcome Float16(const Float16Input& input = {}) const; + opal::Outcome FractionalSeconds(const FractionalSecondsInput& input = {}) const; /// This operation has three possible return values: /// /// 1. A successful response in the form of GreetingWithErrorsOutput @@ -43,13 +43,13 @@ class RpcV2ProtocolClient { /// /// Implementations must be able to successfully take a response and /// properly deserialize successful and error responses. - smithy::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input = {}) const; - smithy::Outcome NoInputOutput(const NoInputOutputInput& input = {}) const; - smithy::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input) const; - smithy::Outcome OptionalInputOutput(const OptionalInputOutputInput& input) const; - smithy::Outcome RecursiveShapes(const RecursiveShapesInput& input) const; + opal::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input = {}) const; + opal::Outcome NoInputOutput(const NoInputOutputInput& input = {}) const; + opal::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input) const; + opal::Outcome OptionalInputOutput(const OptionalInputOutputInput& input) const; + opal::Outcome RecursiveShapes(const RecursiveShapesInput& input) const; /// The example tests basic map serialization. - smithy::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input) const; + opal::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input) const; /// This test case serializes JSON lists for the following cases for both /// input and output: /// @@ -57,23 +57,23 @@ class RpcV2ProtocolClient { /// 2. Normal sets. /// 3. Lists of lists. /// 4. Lists of structures. - smithy::Outcome RpcV2CborLists(const RpcV2CborListsInput& input) const; - smithy::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input) const; + opal::Outcome RpcV2CborLists(const RpcV2CborListsInput& input) const; + opal::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input) const; /// This operation uses unions for inputs and outputs. - smithy::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input) const; - smithy::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input) const; - smithy::Outcome SparseNullsOperation(const SparseNullsOperationInput& input) const; + opal::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input) const; + opal::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input) const; + opal::Outcome SparseNullsOperation(const SparseNullsOperationInput& input) const; private: - RpcV2ProtocolClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix); - smithy::Outcome Send(smithy::http::HttpRequest request) const; + RpcV2ProtocolClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix); + opal::Outcome Send(opal::http::HttpRequest request) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; -/// The modeled errors of GreetingWithErrors, matched from a smithy::Error so dispatch is +/// The modeled errors of GreetingWithErrors, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -84,9 +84,9 @@ class GreetingWithErrorsErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static GreetingWithErrorsErrors FromError(const smithy::Error& error) { + static GreetingWithErrorsErrors FromError(const opal::Error& error) { GreetingWithErrorsErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "InvalidGreeting") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : InvalidGreeting{}); @@ -138,11 +138,11 @@ class GreetingWithErrorsErrors { switch (value_.index()) { case 1: out += "invalid_greeting = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "complex_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -161,14 +161,14 @@ class GreetingWithErrorsErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("GreetingWithErrorsErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("GreetingWithErrorsErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of OperationWithDefaults, matched from a smithy::Error so dispatch is +/// The modeled errors of OperationWithDefaults, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -179,9 +179,9 @@ class OperationWithDefaultsErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static OperationWithDefaultsErrors FromError(const smithy::Error& error) { + static OperationWithDefaultsErrors FromError(const opal::Error& error) { OperationWithDefaultsErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "ValidationException") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : ValidationException{}); @@ -220,7 +220,7 @@ class OperationWithDefaultsErrors { switch (value_.index()) { case 1: out += "validation_exception = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -239,14 +239,14 @@ class OperationWithDefaultsErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("OperationWithDefaultsErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("OperationWithDefaultsErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of RpcV2CborDenseMaps, matched from a smithy::Error so dispatch is +/// The modeled errors of RpcV2CborDenseMaps, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -257,9 +257,9 @@ class RpcV2CborDenseMapsErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static RpcV2CborDenseMapsErrors FromError(const smithy::Error& error) { + static RpcV2CborDenseMapsErrors FromError(const opal::Error& error) { RpcV2CborDenseMapsErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "ValidationException") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : ValidationException{}); @@ -298,7 +298,7 @@ class RpcV2CborDenseMapsErrors { switch (value_.index()) { case 1: out += "validation_exception = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -317,14 +317,14 @@ class RpcV2CborDenseMapsErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("RpcV2CborDenseMapsErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("RpcV2CborDenseMapsErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of RpcV2CborLists, matched from a smithy::Error so dispatch is +/// The modeled errors of RpcV2CborLists, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -335,9 +335,9 @@ class RpcV2CborListsErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static RpcV2CborListsErrors FromError(const smithy::Error& error) { + static RpcV2CborListsErrors FromError(const opal::Error& error) { RpcV2CborListsErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "ValidationException") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : ValidationException{}); @@ -376,7 +376,7 @@ class RpcV2CborListsErrors { switch (value_.index()) { case 1: out += "validation_exception = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -395,14 +395,14 @@ class RpcV2CborListsErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("RpcV2CborListsErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("RpcV2CborListsErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of RpcV2CborSparseMaps, matched from a smithy::Error so dispatch is +/// The modeled errors of RpcV2CborSparseMaps, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -413,9 +413,9 @@ class RpcV2CborSparseMapsErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static RpcV2CborSparseMapsErrors FromError(const smithy::Error& error) { + static RpcV2CborSparseMapsErrors FromError(const opal::Error& error) { RpcV2CborSparseMapsErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "ValidationException") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : ValidationException{}); @@ -454,7 +454,7 @@ class RpcV2CborSparseMapsErrors { switch (value_.index()) { case 1: out += "validation_exception = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -473,62 +473,62 @@ class RpcV2CborSparseMapsErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("RpcV2CborSparseMapsErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("RpcV2CborSparseMapsErrors", requested, case_name()); } } std::variant value_; }; -} // namespace smithy::protocoltests::rpcv2cbor +} // namespace opal::protocoltests::rpcv2cbor // std::hash so generated types key std::unordered_map/std::unordered_set — // emitted exactly for the types that get operator<=> (issue #49). Hash // values are process-local: never persist or compare them across runs. template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::GreetingWithErrorsErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::GreetingWithErrorsErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::OperationWithDefaultsErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::OperationWithDefaultsErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborDenseMapsErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborDenseMapsErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborListsErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborListsErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborSparseMapsErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborSparseMapsErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; -#endif // SMITHY_PROTOCOLTESTS_RPCV2CBOR_CLIENT_H_ +#endif // OPAL_PROTOCOLTESTS_RPCV2CBOR_CLIENT_H_ diff --git a/protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/serde.h b/protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/serde.h new file mode 100644 index 00000000..3d715e01 --- /dev/null +++ b/protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/serde.h @@ -0,0 +1,221 @@ +// Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. + +#ifndef OPAL_PROTOCOLTESTS_RPCV2CBOR_SERDE_H_ +#define OPAL_PROTOCOLTESTS_RPCV2CBOR_SERDE_H_ + +#include +#include +#include +#include +#include + +#include "opal/protocoltests/rpcv2cbor/types.h" +#include "smithy/core/blob.h" +#include "smithy/core/document.h" +#include "smithy/core/outcome.h" +#include "smithy/core/timestamp.h" + +namespace opal::protocoltests::rpcv2cbor { + +// Document-pivot serde for every aggregate shape in the model closure. +// Serializers never fail; deserializers return opal::Error on wire +// mismatches and enforce @required members. + +opal::Document SerializeValidationExceptionField(const ValidationExceptionField& value); +opal::Outcome DeserializeValidationExceptionField(const opal::Document& doc); + +opal::Document SerializeValidationExceptionFieldList(const std::vector& value); +opal::Outcome> DeserializeValidationExceptionFieldList(const opal::Document& doc); + +opal::Document SerializeValidationException(const ValidationException& value); +opal::Outcome DeserializeValidationException(const opal::Document& doc); + +opal::Document SerializeClientOptionalDefaults(const ClientOptionalDefaults& value); +opal::Outcome DeserializeClientOptionalDefaults(const opal::Document& doc); + +opal::Document SerializeComplexNestedErrorData(const ComplexNestedErrorData& value); +opal::Outcome DeserializeComplexNestedErrorData(const opal::Document& doc); + +opal::Document SerializeComplexError(const ComplexError& value); +opal::Outcome DeserializeComplexError(const opal::Document& doc); + +opal::Document SerializeTestStringList(const std::vector& value); +opal::Outcome> DeserializeTestStringList(const opal::Document& doc); + +opal::Document SerializeTestStringMap(const std::map& value); +opal::Outcome> DeserializeTestStringMap(const opal::Document& doc); + +opal::Document SerializeDefaults(const Defaults& value); +opal::Outcome DeserializeDefaults(const opal::Document& doc); + +opal::Document SerializeDenseBooleanMap(const std::map& value); +opal::Outcome> DeserializeDenseBooleanMap(const opal::Document& doc); + +opal::Document SerializeDenseNumberMap(const std::map& value); +opal::Outcome> DeserializeDenseNumberMap(const opal::Document& doc); + +opal::Document SerializeStringSet(const std::vector& value); +opal::Outcome> DeserializeStringSet(const opal::Document& doc); + +opal::Document SerializeDenseSetMap(const std::map>& value); +opal::Outcome>> DeserializeDenseSetMap(const opal::Document& doc); + +opal::Document SerializeDenseStringMap(const std::map& value); +opal::Outcome> DeserializeDenseStringMap(const opal::Document& doc); + +opal::Document SerializeGreetingStruct(const GreetingStruct& value); +opal::Outcome DeserializeGreetingStruct(const opal::Document& doc); + +opal::Document SerializeDenseStructMap(const std::map& value); +opal::Outcome> DeserializeDenseStructMap(const opal::Document& doc); + +opal::Document SerializeEmptyInputOutputInput(const EmptyInputOutputInput& value); +opal::Outcome DeserializeEmptyInputOutputInput(const opal::Document& doc); + +opal::Document SerializeEmptyInputOutputOutput(const EmptyInputOutputOutput& value); +opal::Outcome DeserializeEmptyInputOutputOutput(const opal::Document& doc); + +opal::Document SerializeFloat16Input(const Float16Input& value); +opal::Outcome DeserializeFloat16Input(const opal::Document& doc); + +opal::Document SerializeFloat16Output(const Float16Output& value); +opal::Outcome DeserializeFloat16Output(const opal::Document& doc); + +opal::Document SerializeFractionalSecondsInput(const FractionalSecondsInput& value); +opal::Outcome DeserializeFractionalSecondsInput(const opal::Document& doc); + +opal::Document SerializeFractionalSecondsOutput(const FractionalSecondsOutput& value); +opal::Outcome DeserializeFractionalSecondsOutput(const opal::Document& doc); + +opal::Document SerializeGreetingWithErrorsInput(const GreetingWithErrorsInput& value); +opal::Outcome DeserializeGreetingWithErrorsInput(const opal::Document& doc); + +opal::Document SerializeGreetingWithErrorsOutput(const GreetingWithErrorsOutput& value); +opal::Outcome DeserializeGreetingWithErrorsOutput(const opal::Document& doc); + +opal::Document SerializeInvalidGreeting(const InvalidGreeting& value); +opal::Outcome DeserializeInvalidGreeting(const opal::Document& doc); + +opal::Document SerializeNoInputOutputInput(const NoInputOutputInput& value); +opal::Outcome DeserializeNoInputOutputInput(const opal::Document& doc); + +opal::Document SerializeNoInputOutputOutput(const NoInputOutputOutput& value); +opal::Outcome DeserializeNoInputOutputOutput(const opal::Document& doc); + +opal::Document SerializeOperationWithDefaultsInput(const OperationWithDefaultsInput& value); +opal::Outcome DeserializeOperationWithDefaultsInput(const opal::Document& doc); + +opal::Document SerializeOperationWithDefaultsOutput(const OperationWithDefaultsOutput& value); +opal::Outcome DeserializeOperationWithDefaultsOutput(const opal::Document& doc); + +opal::Document SerializeOptionalInputOutputInput(const OptionalInputOutputInput& value); +opal::Outcome DeserializeOptionalInputOutputInput(const opal::Document& doc); + +opal::Document SerializeOptionalInputOutputOutput(const OptionalInputOutputOutput& value); +opal::Outcome DeserializeOptionalInputOutputOutput(const opal::Document& doc); + +opal::Document SerializeRpcV2CborDenseMapsInput(const RpcV2CborDenseMapsInput& value); +opal::Outcome DeserializeRpcV2CborDenseMapsInput(const opal::Document& doc); + +opal::Document SerializeRpcV2CborDenseMapsOutput(const RpcV2CborDenseMapsOutput& value); +opal::Outcome DeserializeRpcV2CborDenseMapsOutput(const opal::Document& doc); + +opal::Document SerializeBlobList(const std::vector& value); +opal::Outcome> DeserializeBlobList(const opal::Document& doc); + +opal::Document SerializeBooleanList(const std::vector& value); +opal::Outcome> DeserializeBooleanList(const opal::Document& doc); + +opal::Document SerializeFooEnumList(const std::vector& value); +opal::Outcome> DeserializeFooEnumList(const opal::Document& doc); + +opal::Document SerializeIntegerList(const std::vector& value); +opal::Outcome> DeserializeIntegerList(const opal::Document& doc); + +opal::Document SerializeIntegerEnumList(const std::vector& value); +opal::Outcome> DeserializeIntegerEnumList(const opal::Document& doc); + +opal::Document SerializeStringList(const std::vector& value); +opal::Outcome> DeserializeStringList(const opal::Document& doc); + +opal::Document SerializeNestedStringList(const std::vector>& value); +opal::Outcome>> DeserializeNestedStringList(const opal::Document& doc); + +opal::Document SerializeStructureListMember(const StructureListMember& value); +opal::Outcome DeserializeStructureListMember(const opal::Document& doc); + +opal::Document SerializeStructureList(const std::vector& value); +opal::Outcome> DeserializeStructureList(const opal::Document& doc); + +opal::Document SerializeTimestampList(const std::vector& value); +opal::Outcome> DeserializeTimestampList(const opal::Document& doc); + +opal::Document SerializeRpcV2CborListsInput(const RpcV2CborListsInput& value); +opal::Outcome DeserializeRpcV2CborListsInput(const opal::Document& doc); + +opal::Document SerializeRpcV2CborListsOutput(const RpcV2CborListsOutput& value); +opal::Outcome DeserializeRpcV2CborListsOutput(const opal::Document& doc); + +opal::Document SerializeRpcV2CborNestedUnion(const RpcV2CborNestedUnion& value); +opal::Outcome DeserializeRpcV2CborNestedUnion(const opal::Document& doc); + +opal::Document SerializeSparseBooleanMap(const std::map>& value); +opal::Outcome>> DeserializeSparseBooleanMap(const opal::Document& doc); + +opal::Document SerializeSparseNumberMap(const std::map>& value); +opal::Outcome>> DeserializeSparseNumberMap(const opal::Document& doc); + +opal::Document SerializeSparseSetMap(const std::map>>& value); +opal::Outcome>>> DeserializeSparseSetMap(const opal::Document& doc); + +opal::Document SerializeSparseStringMap(const std::map>& value); +opal::Outcome>> DeserializeSparseStringMap(const opal::Document& doc); + +opal::Document SerializeSparseStructMap(const std::map>& value); +opal::Outcome>> DeserializeSparseStructMap(const opal::Document& doc); + +opal::Document SerializeRpcV2CborSparseMapsInput(const RpcV2CborSparseMapsInput& value); +opal::Outcome DeserializeRpcV2CborSparseMapsInput(const opal::Document& doc); + +opal::Document SerializeRpcV2CborSparseMapsOutput(const RpcV2CborSparseMapsOutput& value); +opal::Outcome DeserializeRpcV2CborSparseMapsOutput(const opal::Document& doc); + +opal::Document SerializeRpcV2CborUnion(const RpcV2CborUnion& value); +opal::Outcome DeserializeRpcV2CborUnion(const opal::Document& doc); + +opal::Document SerializeRpcV2CborUnionsInput(const RpcV2CborUnionsInput& value); +opal::Outcome DeserializeRpcV2CborUnionsInput(const opal::Document& doc); + +opal::Document SerializeRpcV2CborUnionsOutput(const RpcV2CborUnionsOutput& value); +opal::Outcome DeserializeRpcV2CborUnionsOutput(const opal::Document& doc); + +opal::Document SerializeSimpleScalarPropertiesInput(const SimpleScalarPropertiesInput& value); +opal::Outcome DeserializeSimpleScalarPropertiesInput(const opal::Document& doc); + +opal::Document SerializeSimpleScalarPropertiesOutput(const SimpleScalarPropertiesOutput& value); +opal::Outcome DeserializeSimpleScalarPropertiesOutput(const opal::Document& doc); + +opal::Document SerializeSparseStringList(const std::vector>& value); +opal::Outcome>> DeserializeSparseStringList(const opal::Document& doc); + +opal::Document SerializeSparseNullsOperationInput(const SparseNullsOperationInput& value); +opal::Outcome DeserializeSparseNullsOperationInput(const opal::Document& doc); + +opal::Document SerializeSparseNullsOperationOutput(const SparseNullsOperationOutput& value); +opal::Outcome DeserializeSparseNullsOperationOutput(const opal::Document& doc); + +opal::Document SerializeRecursiveShapesInput(const RecursiveShapesInput& value); +opal::Outcome DeserializeRecursiveShapesInput(const opal::Document& doc); + +opal::Document SerializeRecursiveShapesInputOutputNested1(const RecursiveShapesInputOutputNested1& value); +opal::Outcome DeserializeRecursiveShapesInputOutputNested1(const opal::Document& doc); + +opal::Document SerializeRecursiveShapesInputOutputNested2(const RecursiveShapesInputOutputNested2& value); +opal::Outcome DeserializeRecursiveShapesInputOutputNested2(const opal::Document& doc); + +opal::Document SerializeRecursiveShapesOutput(const RecursiveShapesOutput& value); +opal::Outcome DeserializeRecursiveShapesOutput(const opal::Document& doc); + +} // namespace opal::protocoltests::rpcv2cbor + +#endif // OPAL_PROTOCOLTESTS_RPCV2CBOR_SERDE_H_ diff --git a/protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/server.h b/protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/server.h new file mode 100644 index 00000000..0c6c19b5 --- /dev/null +++ b/protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/server.h @@ -0,0 +1,74 @@ +// Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. + +#ifndef OPAL_PROTOCOLTESTS_RPCV2CBOR_SERVER_H_ +#define OPAL_PROTOCOLTESTS_RPCV2CBOR_SERVER_H_ + +#include + +#include "opal/protocoltests/rpcv2cbor/types.h" +#include "smithy/core/outcome.h" +#include "smithy/http/transport.h" +#include "smithy/server/router.h" + +namespace opal::protocoltests::rpcv2cbor { + +/// Implement one method per operation. Return a modeled error as +/// opal::Error::Modeled("", message), optionally with the +/// typed error structure attached via set_detail() so it serializes fully. +/// The context carries the raw request and routing captures — see +/// opal::server::RequestContext; leave the parameter unnamed when unused. +/// Implementations must be thread-safe: transports may invoke any mix of +/// operations concurrently on the one handler instance. +class RpcV2ProtocolHandler { + public: + virtual ~RpcV2ProtocolHandler() = default; + + virtual opal::Outcome EmptyInputOutput(const EmptyInputOutputInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome Float16(const Float16Input& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome FractionalSeconds(const FractionalSecondsInput& input, const opal::server::RequestContext& context) = 0; + /// This operation has three possible return values: + /// + /// 1. A successful response in the form of GreetingWithErrorsOutput + /// 2. An InvalidGreeting error. + /// 3. A ComplexError error. + /// + /// Implementations must be able to successfully take a response and + /// properly deserialize successful and error responses. + virtual opal::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome NoInputOutput(const NoInputOutputInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome OptionalInputOutput(const OptionalInputOutputInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome RecursiveShapes(const RecursiveShapesInput& input, const opal::server::RequestContext& context) = 0; + /// The example tests basic map serialization. + virtual opal::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const opal::server::RequestContext& context) = 0; + /// This test case serializes JSON lists for the following cases for both + /// input and output: + /// + /// 1. Normal lists. + /// 2. Normal sets. + /// 3. Lists of lists. + /// 4. Lists of structures. + virtual opal::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const opal::server::RequestContext& context) = 0; + /// This operation uses unions for inputs and outputs. + virtual opal::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const opal::server::RequestContext& context) = 0; +}; + +/// rpcv2Cbor server for smithy.protocoltests.rpcv2Cbor#RpcV2Protocol: routing, deserialization, handler dispatch, +/// response serialization, and modeled-error mapping. Pass Handler() to any +/// opal::http::HttpServerTransport. +class RpcV2ProtocolServer { + public: + explicit RpcV2ProtocolServer(std::shared_ptr handler); + + opal::http::RequestHandler Handler() const; + + private: + std::shared_ptr router_; +}; + +} // namespace opal::protocoltests::rpcv2cbor + +#endif // OPAL_PROTOCOLTESTS_RPCV2CBOR_SERVER_H_ diff --git a/protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/types.h b/protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/types.h similarity index 67% rename from protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/types.h rename to protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/types.h index d23ce3e8..f1c9ebc0 100644 --- a/protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/types.h +++ b/protocol-tests/rpcv2cbor/generated/include/opal/protocoltests/rpcv2cbor/types.h @@ -1,7 +1,7 @@ // Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. -#ifndef SMITHY_PROTOCOLTESTS_RPCV2CBOR_TYPES_H_ -#define SMITHY_PROTOCOLTESTS_RPCV2CBOR_TYPES_H_ +#ifndef OPAL_PROTOCOLTESTS_RPCV2CBOR_TYPES_H_ +#define OPAL_PROTOCOLTESTS_RPCV2CBOR_TYPES_H_ #include #include @@ -23,7 +23,7 @@ #include "smithy/core/print.h" #include "smithy/core/timestamp.h" -namespace smithy::protocoltests::rpcv2cbor { +namespace opal::protocoltests::rpcv2cbor { /// Describes one specific validation failure for an input member. struct ValidationExceptionField { @@ -37,11 +37,11 @@ struct ValidationExceptionField { out += sep; sep = ", "; out += ".path = "; - smithy::DebugAppend(out, this->path); + opal::DebugAppend(out, this->path); out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -68,12 +68,12 @@ struct ValidationException { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); if (this->fieldList.has_value()) { out += sep; sep = ", "; out += ".fieldList = "; - smithy::DebugAppend(out, *this->fieldList); + opal::DebugAppend(out, *this->fieldList); } out += '}'; } @@ -98,7 +98,7 @@ struct ClientOptionalDefaults { out += sep; sep = ", "; out += ".member = "; - smithy::DebugAppend(out, *this->member); + opal::DebugAppend(out, *this->member); } out += '}'; } @@ -123,7 +123,7 @@ struct ComplexNestedErrorData { out += sep; sep = ", "; out += ".Foo = "; - smithy::DebugAppend(out, *this->Foo); + opal::DebugAppend(out, *this->Foo); } out += '}'; } @@ -150,13 +150,13 @@ struct ComplexError { out += sep; sep = ", "; out += ".TopLevel = "; - smithy::DebugAppend(out, *this->TopLevel); + opal::DebugAppend(out, *this->TopLevel); } if (this->Nested.has_value()) { out += sep; sep = ", "; out += ".Nested = "; - smithy::DebugAppend(out, *this->Nested); + opal::DebugAppend(out, *this->Nested); } out += '}'; } @@ -241,8 +241,8 @@ struct Defaults { std::string defaultString = "hi"; bool defaultBoolean = true; std::vector defaultList{}; - smithy::Timestamp defaultTimestamp = smithy::Timestamp::FromEpochMilliseconds(0LL); - smithy::Blob defaultBlob = smithy::Blob::FromString("abc"); + opal::Timestamp defaultTimestamp = opal::Timestamp::FromEpochMilliseconds(0LL); + opal::Blob defaultBlob = opal::Blob::FromString("abc"); std::int8_t defaultByte = 1; std::int16_t defaultShort = 1; std::int32_t defaultInteger = 10; @@ -254,7 +254,7 @@ struct Defaults { TestIntEnum defaultIntEnum = static_cast(1); std::string emptyString = ""; bool falseBoolean = false; - smithy::Blob emptyBlob = smithy::Blob::FromString(""); + opal::Blob emptyBlob = opal::Blob::FromString(""); std::int8_t zeroByte = 0; std::int16_t zeroShort = 0; std::int32_t zeroInteger = 0; @@ -269,95 +269,95 @@ struct Defaults { out += sep; sep = ", "; out += ".defaultString = "; - smithy::DebugAppend(out, this->defaultString); + opal::DebugAppend(out, this->defaultString); out += sep; sep = ", "; out += ".defaultBoolean = "; - smithy::DebugAppend(out, this->defaultBoolean); + opal::DebugAppend(out, this->defaultBoolean); out += sep; sep = ", "; out += ".defaultList = "; - smithy::DebugAppend(out, this->defaultList); + opal::DebugAppend(out, this->defaultList); out += sep; sep = ", "; out += ".defaultTimestamp = "; - smithy::DebugAppend(out, this->defaultTimestamp); + opal::DebugAppend(out, this->defaultTimestamp); out += sep; sep = ", "; out += ".defaultBlob = "; - smithy::DebugAppend(out, this->defaultBlob); + opal::DebugAppend(out, this->defaultBlob); out += sep; sep = ", "; out += ".defaultByte = "; - smithy::DebugAppend(out, this->defaultByte); + opal::DebugAppend(out, this->defaultByte); out += sep; sep = ", "; out += ".defaultShort = "; - smithy::DebugAppend(out, this->defaultShort); + opal::DebugAppend(out, this->defaultShort); out += sep; sep = ", "; out += ".defaultInteger = "; - smithy::DebugAppend(out, this->defaultInteger); + opal::DebugAppend(out, this->defaultInteger); out += sep; sep = ", "; out += ".defaultLong = "; - smithy::DebugAppend(out, this->defaultLong); + opal::DebugAppend(out, this->defaultLong); out += sep; sep = ", "; out += ".defaultFloat = "; - smithy::DebugAppend(out, this->defaultFloat); + opal::DebugAppend(out, this->defaultFloat); out += sep; sep = ", "; out += ".defaultDouble = "; - smithy::DebugAppend(out, this->defaultDouble); + opal::DebugAppend(out, this->defaultDouble); out += sep; sep = ", "; out += ".defaultMap = "; - smithy::DebugAppend(out, this->defaultMap); + opal::DebugAppend(out, this->defaultMap); out += sep; sep = ", "; out += ".defaultEnum = "; - smithy::DebugAppend(out, this->defaultEnum); + opal::DebugAppend(out, this->defaultEnum); out += sep; sep = ", "; out += ".defaultIntEnum = "; - smithy::DebugAppend(out, this->defaultIntEnum); + opal::DebugAppend(out, this->defaultIntEnum); out += sep; sep = ", "; out += ".emptyString = "; - smithy::DebugAppend(out, this->emptyString); + opal::DebugAppend(out, this->emptyString); out += sep; sep = ", "; out += ".falseBoolean = "; - smithy::DebugAppend(out, this->falseBoolean); + opal::DebugAppend(out, this->falseBoolean); out += sep; sep = ", "; out += ".emptyBlob = "; - smithy::DebugAppend(out, this->emptyBlob); + opal::DebugAppend(out, this->emptyBlob); out += sep; sep = ", "; out += ".zeroByte = "; - smithy::DebugAppend(out, this->zeroByte); + opal::DebugAppend(out, this->zeroByte); out += sep; sep = ", "; out += ".zeroShort = "; - smithy::DebugAppend(out, this->zeroShort); + opal::DebugAppend(out, this->zeroShort); out += sep; sep = ", "; out += ".zeroInteger = "; - smithy::DebugAppend(out, this->zeroInteger); + opal::DebugAppend(out, this->zeroInteger); out += sep; sep = ", "; out += ".zeroLong = "; - smithy::DebugAppend(out, this->zeroLong); + opal::DebugAppend(out, this->zeroLong); out += sep; sep = ", "; out += ".zeroFloat = "; - smithy::DebugAppend(out, this->zeroFloat); + opal::DebugAppend(out, this->zeroFloat); out += sep; sep = ", "; out += ".zeroDouble = "; - smithy::DebugAppend(out, this->zeroDouble); + opal::DebugAppend(out, this->zeroDouble); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -381,7 +381,7 @@ struct GreetingStruct { out += sep; sep = ", "; out += ".hi = "; - smithy::DebugAppend(out, *this->hi); + opal::DebugAppend(out, *this->hi); } out += '}'; } @@ -454,7 +454,7 @@ struct Float16Output { out += sep; sep = ", "; out += ".value = "; - smithy::DebugAppend(out, *this->value); + opal::DebugAppend(out, *this->value); } out += '}'; } @@ -485,7 +485,7 @@ struct FractionalSecondsInput { struct FractionalSecondsOutput { - std::optional datetime{}; + std::optional datetime{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -495,7 +495,7 @@ struct FractionalSecondsOutput { out += sep; sep = ", "; out += ".datetime = "; - smithy::DebugAppend(out, *this->datetime); + opal::DebugAppend(out, *this->datetime); } out += '}'; } @@ -536,7 +536,7 @@ struct GreetingWithErrorsOutput { out += sep; sep = ", "; out += ".greeting = "; - smithy::DebugAppend(out, *this->greeting); + opal::DebugAppend(out, *this->greeting); } out += '}'; } @@ -562,7 +562,7 @@ struct InvalidGreeting { out += sep; sep = ", "; out += ".Message = "; - smithy::DebugAppend(out, *this->Message); + opal::DebugAppend(out, *this->Message); } out += '}'; } @@ -622,25 +622,25 @@ struct OperationWithDefaultsInput { out += sep; sep = ", "; out += ".defaults = "; - smithy::DebugAppend(out, *this->defaults); + opal::DebugAppend(out, *this->defaults); } if (this->clientOptionalDefaults.has_value()) { out += sep; sep = ", "; out += ".clientOptionalDefaults = "; - smithy::DebugAppend(out, *this->clientOptionalDefaults); + opal::DebugAppend(out, *this->clientOptionalDefaults); } if (this->topLevelDefault.has_value()) { out += sep; sep = ", "; out += ".topLevelDefault = "; - smithy::DebugAppend(out, *this->topLevelDefault); + opal::DebugAppend(out, *this->topLevelDefault); } if (this->otherTopLevelDefault.has_value()) { out += sep; sep = ", "; out += ".otherTopLevelDefault = "; - smithy::DebugAppend(out, *this->otherTopLevelDefault); + opal::DebugAppend(out, *this->otherTopLevelDefault); } out += '}'; } @@ -658,8 +658,8 @@ struct OperationWithDefaultsOutput { std::string defaultString = "hi"; bool defaultBoolean = true; std::vector defaultList{}; - smithy::Timestamp defaultTimestamp = smithy::Timestamp::FromEpochMilliseconds(0LL); - smithy::Blob defaultBlob = smithy::Blob::FromString("abc"); + opal::Timestamp defaultTimestamp = opal::Timestamp::FromEpochMilliseconds(0LL); + opal::Blob defaultBlob = opal::Blob::FromString("abc"); std::int8_t defaultByte = 1; std::int16_t defaultShort = 1; std::int32_t defaultInteger = 10; @@ -671,7 +671,7 @@ struct OperationWithDefaultsOutput { TestIntEnum defaultIntEnum = static_cast(1); std::string emptyString = ""; bool falseBoolean = false; - smithy::Blob emptyBlob = smithy::Blob::FromString(""); + opal::Blob emptyBlob = opal::Blob::FromString(""); std::int8_t zeroByte = 0; std::int16_t zeroShort = 0; std::int32_t zeroInteger = 0; @@ -686,95 +686,95 @@ struct OperationWithDefaultsOutput { out += sep; sep = ", "; out += ".defaultString = "; - smithy::DebugAppend(out, this->defaultString); + opal::DebugAppend(out, this->defaultString); out += sep; sep = ", "; out += ".defaultBoolean = "; - smithy::DebugAppend(out, this->defaultBoolean); + opal::DebugAppend(out, this->defaultBoolean); out += sep; sep = ", "; out += ".defaultList = "; - smithy::DebugAppend(out, this->defaultList); + opal::DebugAppend(out, this->defaultList); out += sep; sep = ", "; out += ".defaultTimestamp = "; - smithy::DebugAppend(out, this->defaultTimestamp); + opal::DebugAppend(out, this->defaultTimestamp); out += sep; sep = ", "; out += ".defaultBlob = "; - smithy::DebugAppend(out, this->defaultBlob); + opal::DebugAppend(out, this->defaultBlob); out += sep; sep = ", "; out += ".defaultByte = "; - smithy::DebugAppend(out, this->defaultByte); + opal::DebugAppend(out, this->defaultByte); out += sep; sep = ", "; out += ".defaultShort = "; - smithy::DebugAppend(out, this->defaultShort); + opal::DebugAppend(out, this->defaultShort); out += sep; sep = ", "; out += ".defaultInteger = "; - smithy::DebugAppend(out, this->defaultInteger); + opal::DebugAppend(out, this->defaultInteger); out += sep; sep = ", "; out += ".defaultLong = "; - smithy::DebugAppend(out, this->defaultLong); + opal::DebugAppend(out, this->defaultLong); out += sep; sep = ", "; out += ".defaultFloat = "; - smithy::DebugAppend(out, this->defaultFloat); + opal::DebugAppend(out, this->defaultFloat); out += sep; sep = ", "; out += ".defaultDouble = "; - smithy::DebugAppend(out, this->defaultDouble); + opal::DebugAppend(out, this->defaultDouble); out += sep; sep = ", "; out += ".defaultMap = "; - smithy::DebugAppend(out, this->defaultMap); + opal::DebugAppend(out, this->defaultMap); out += sep; sep = ", "; out += ".defaultEnum = "; - smithy::DebugAppend(out, this->defaultEnum); + opal::DebugAppend(out, this->defaultEnum); out += sep; sep = ", "; out += ".defaultIntEnum = "; - smithy::DebugAppend(out, this->defaultIntEnum); + opal::DebugAppend(out, this->defaultIntEnum); out += sep; sep = ", "; out += ".emptyString = "; - smithy::DebugAppend(out, this->emptyString); + opal::DebugAppend(out, this->emptyString); out += sep; sep = ", "; out += ".falseBoolean = "; - smithy::DebugAppend(out, this->falseBoolean); + opal::DebugAppend(out, this->falseBoolean); out += sep; sep = ", "; out += ".emptyBlob = "; - smithy::DebugAppend(out, this->emptyBlob); + opal::DebugAppend(out, this->emptyBlob); out += sep; sep = ", "; out += ".zeroByte = "; - smithy::DebugAppend(out, this->zeroByte); + opal::DebugAppend(out, this->zeroByte); out += sep; sep = ", "; out += ".zeroShort = "; - smithy::DebugAppend(out, this->zeroShort); + opal::DebugAppend(out, this->zeroShort); out += sep; sep = ", "; out += ".zeroInteger = "; - smithy::DebugAppend(out, this->zeroInteger); + opal::DebugAppend(out, this->zeroInteger); out += sep; sep = ", "; out += ".zeroLong = "; - smithy::DebugAppend(out, this->zeroLong); + opal::DebugAppend(out, this->zeroLong); out += sep; sep = ", "; out += ".zeroFloat = "; - smithy::DebugAppend(out, this->zeroFloat); + opal::DebugAppend(out, this->zeroFloat); out += sep; sep = ", "; out += ".zeroDouble = "; - smithy::DebugAppend(out, this->zeroDouble); + opal::DebugAppend(out, this->zeroDouble); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -798,7 +798,7 @@ struct OptionalInputOutputInput { out += sep; sep = ", "; out += ".value = "; - smithy::DebugAppend(out, *this->value); + opal::DebugAppend(out, *this->value); } out += '}'; } @@ -823,7 +823,7 @@ struct OptionalInputOutputOutput { out += sep; sep = ", "; out += ".value = "; - smithy::DebugAppend(out, *this->value); + opal::DebugAppend(out, *this->value); } out += '}'; } @@ -852,31 +852,31 @@ struct RpcV2CborDenseMapsInput { out += sep; sep = ", "; out += ".denseStructMap = "; - smithy::DebugAppend(out, *this->denseStructMap); + opal::DebugAppend(out, *this->denseStructMap); } if (this->denseNumberMap.has_value()) { out += sep; sep = ", "; out += ".denseNumberMap = "; - smithy::DebugAppend(out, *this->denseNumberMap); + opal::DebugAppend(out, *this->denseNumberMap); } if (this->denseBooleanMap.has_value()) { out += sep; sep = ", "; out += ".denseBooleanMap = "; - smithy::DebugAppend(out, *this->denseBooleanMap); + opal::DebugAppend(out, *this->denseBooleanMap); } if (this->denseStringMap.has_value()) { out += sep; sep = ", "; out += ".denseStringMap = "; - smithy::DebugAppend(out, *this->denseStringMap); + opal::DebugAppend(out, *this->denseStringMap); } if (this->denseSetMap.has_value()) { out += sep; sep = ", "; out += ".denseSetMap = "; - smithy::DebugAppend(out, *this->denseSetMap); + opal::DebugAppend(out, *this->denseSetMap); } out += '}'; } @@ -905,31 +905,31 @@ struct RpcV2CborDenseMapsOutput { out += sep; sep = ", "; out += ".denseStructMap = "; - smithy::DebugAppend(out, *this->denseStructMap); + opal::DebugAppend(out, *this->denseStructMap); } if (this->denseNumberMap.has_value()) { out += sep; sep = ", "; out += ".denseNumberMap = "; - smithy::DebugAppend(out, *this->denseNumberMap); + opal::DebugAppend(out, *this->denseNumberMap); } if (this->denseBooleanMap.has_value()) { out += sep; sep = ", "; out += ".denseBooleanMap = "; - smithy::DebugAppend(out, *this->denseBooleanMap); + opal::DebugAppend(out, *this->denseBooleanMap); } if (this->denseStringMap.has_value()) { out += sep; sep = ", "; out += ".denseStringMap = "; - smithy::DebugAppend(out, *this->denseStringMap); + opal::DebugAppend(out, *this->denseStringMap); } if (this->denseSetMap.has_value()) { out += sep; sep = ", "; out += ".denseSetMap = "; - smithy::DebugAppend(out, *this->denseSetMap); + opal::DebugAppend(out, *this->denseSetMap); } out += '}'; } @@ -1029,13 +1029,13 @@ struct StructureListMember { out += sep; sep = ", "; out += ".a = "; - smithy::DebugAppend(out, *this->a); + opal::DebugAppend(out, *this->a); } if (this->b.has_value()) { out += sep; sep = ", "; out += ".b = "; - smithy::DebugAppend(out, *this->b); + opal::DebugAppend(out, *this->b); } out += '}'; } @@ -1054,12 +1054,12 @@ struct RpcV2CborListsInput { std::optional> stringSet{}; std::optional> integerList{}; std::optional> booleanList{}; - std::optional> timestampList{}; + std::optional> timestampList{}; std::optional> enumList{}; std::optional> intEnumList{}; std::optional>> nestedStringList{}; std::optional> structureList{}; - std::optional> blobList{}; + std::optional> blobList{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -1069,61 +1069,61 @@ struct RpcV2CborListsInput { out += sep; sep = ", "; out += ".stringList = "; - smithy::DebugAppend(out, *this->stringList); + opal::DebugAppend(out, *this->stringList); } if (this->stringSet.has_value()) { out += sep; sep = ", "; out += ".stringSet = "; - smithy::DebugAppend(out, *this->stringSet); + opal::DebugAppend(out, *this->stringSet); } if (this->integerList.has_value()) { out += sep; sep = ", "; out += ".integerList = "; - smithy::DebugAppend(out, *this->integerList); + opal::DebugAppend(out, *this->integerList); } if (this->booleanList.has_value()) { out += sep; sep = ", "; out += ".booleanList = "; - smithy::DebugAppend(out, *this->booleanList); + opal::DebugAppend(out, *this->booleanList); } if (this->timestampList.has_value()) { out += sep; sep = ", "; out += ".timestampList = "; - smithy::DebugAppend(out, *this->timestampList); + opal::DebugAppend(out, *this->timestampList); } if (this->enumList.has_value()) { out += sep; sep = ", "; out += ".enumList = "; - smithy::DebugAppend(out, *this->enumList); + opal::DebugAppend(out, *this->enumList); } if (this->intEnumList.has_value()) { out += sep; sep = ", "; out += ".intEnumList = "; - smithy::DebugAppend(out, *this->intEnumList); + opal::DebugAppend(out, *this->intEnumList); } if (this->nestedStringList.has_value()) { out += sep; sep = ", "; out += ".nestedStringList = "; - smithy::DebugAppend(out, *this->nestedStringList); + opal::DebugAppend(out, *this->nestedStringList); } if (this->structureList.has_value()) { out += sep; sep = ", "; out += ".structureList = "; - smithy::DebugAppend(out, *this->structureList); + opal::DebugAppend(out, *this->structureList); } if (this->blobList.has_value()) { out += sep; sep = ", "; out += ".blobList = "; - smithy::DebugAppend(out, *this->blobList); + opal::DebugAppend(out, *this->blobList); } out += '}'; } @@ -1142,12 +1142,12 @@ struct RpcV2CborListsOutput { std::optional> stringSet{}; std::optional> integerList{}; std::optional> booleanList{}; - std::optional> timestampList{}; + std::optional> timestampList{}; std::optional> enumList{}; std::optional> intEnumList{}; std::optional>> nestedStringList{}; std::optional> structureList{}; - std::optional> blobList{}; + std::optional> blobList{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -1157,61 +1157,61 @@ struct RpcV2CborListsOutput { out += sep; sep = ", "; out += ".stringList = "; - smithy::DebugAppend(out, *this->stringList); + opal::DebugAppend(out, *this->stringList); } if (this->stringSet.has_value()) { out += sep; sep = ", "; out += ".stringSet = "; - smithy::DebugAppend(out, *this->stringSet); + opal::DebugAppend(out, *this->stringSet); } if (this->integerList.has_value()) { out += sep; sep = ", "; out += ".integerList = "; - smithy::DebugAppend(out, *this->integerList); + opal::DebugAppend(out, *this->integerList); } if (this->booleanList.has_value()) { out += sep; sep = ", "; out += ".booleanList = "; - smithy::DebugAppend(out, *this->booleanList); + opal::DebugAppend(out, *this->booleanList); } if (this->timestampList.has_value()) { out += sep; sep = ", "; out += ".timestampList = "; - smithy::DebugAppend(out, *this->timestampList); + opal::DebugAppend(out, *this->timestampList); } if (this->enumList.has_value()) { out += sep; sep = ", "; out += ".enumList = "; - smithy::DebugAppend(out, *this->enumList); + opal::DebugAppend(out, *this->enumList); } if (this->intEnumList.has_value()) { out += sep; sep = ", "; out += ".intEnumList = "; - smithy::DebugAppend(out, *this->intEnumList); + opal::DebugAppend(out, *this->intEnumList); } if (this->nestedStringList.has_value()) { out += sep; sep = ", "; out += ".nestedStringList = "; - smithy::DebugAppend(out, *this->nestedStringList); + opal::DebugAppend(out, *this->nestedStringList); } if (this->structureList.has_value()) { out += sep; sep = ", "; out += ".structureList = "; - smithy::DebugAppend(out, *this->structureList); + opal::DebugAppend(out, *this->structureList); } if (this->blobList.has_value()) { out += sep; sep = ", "; out += ".blobList = "; - smithy::DebugAppend(out, *this->blobList); + opal::DebugAppend(out, *this->blobList); } out += '}'; } @@ -1264,7 +1264,7 @@ class RpcV2CborNestedUnion { switch (value_.index()) { case 1: out += "stringValue = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; default: break; @@ -1283,7 +1283,7 @@ class RpcV2CborNestedUnion { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("RpcV2CborNestedUnion", requested, case_name()); + opal::internal::FatalWrongUnionAccess("RpcV2CborNestedUnion", requested, case_name()); } } @@ -1306,31 +1306,31 @@ struct RpcV2CborSparseMapsInput { out += sep; sep = ", "; out += ".sparseStructMap = "; - smithy::DebugAppend(out, *this->sparseStructMap); + opal::DebugAppend(out, *this->sparseStructMap); } if (this->sparseNumberMap.has_value()) { out += sep; sep = ", "; out += ".sparseNumberMap = "; - smithy::DebugAppend(out, *this->sparseNumberMap); + opal::DebugAppend(out, *this->sparseNumberMap); } if (this->sparseBooleanMap.has_value()) { out += sep; sep = ", "; out += ".sparseBooleanMap = "; - smithy::DebugAppend(out, *this->sparseBooleanMap); + opal::DebugAppend(out, *this->sparseBooleanMap); } if (this->sparseStringMap.has_value()) { out += sep; sep = ", "; out += ".sparseStringMap = "; - smithy::DebugAppend(out, *this->sparseStringMap); + opal::DebugAppend(out, *this->sparseStringMap); } if (this->sparseSetMap.has_value()) { out += sep; sep = ", "; out += ".sparseSetMap = "; - smithy::DebugAppend(out, *this->sparseSetMap); + opal::DebugAppend(out, *this->sparseSetMap); } out += '}'; } @@ -1359,31 +1359,31 @@ struct RpcV2CborSparseMapsOutput { out += sep; sep = ", "; out += ".sparseStructMap = "; - smithy::DebugAppend(out, *this->sparseStructMap); + opal::DebugAppend(out, *this->sparseStructMap); } if (this->sparseNumberMap.has_value()) { out += sep; sep = ", "; out += ".sparseNumberMap = "; - smithy::DebugAppend(out, *this->sparseNumberMap); + opal::DebugAppend(out, *this->sparseNumberMap); } if (this->sparseBooleanMap.has_value()) { out += sep; sep = ", "; out += ".sparseBooleanMap = "; - smithy::DebugAppend(out, *this->sparseBooleanMap); + opal::DebugAppend(out, *this->sparseBooleanMap); } if (this->sparseStringMap.has_value()) { out += sep; sep = ", "; out += ".sparseStringMap = "; - smithy::DebugAppend(out, *this->sparseStringMap); + opal::DebugAppend(out, *this->sparseStringMap); } if (this->sparseSetMap.has_value()) { out += sep; sep = ", "; out += ".sparseSetMap = "; - smithy::DebugAppend(out, *this->sparseSetMap); + opal::DebugAppend(out, *this->sparseSetMap); } out += '}'; } @@ -1449,11 +1449,11 @@ class RpcV2CborUnion { switch (value_.index()) { case 1: out += "stringValue = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "unionValue = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -1472,7 +1472,7 @@ class RpcV2CborUnion { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("RpcV2CborUnion", requested, case_name()); + opal::internal::FatalWrongUnionAccess("RpcV2CborUnion", requested, case_name()); } } @@ -1492,13 +1492,13 @@ struct RpcV2CborUnionsInput { out += sep; sep = ", "; out += ".contents = "; - smithy::DebugAppend(out, *this->contents); + opal::DebugAppend(out, *this->contents); } if (this->otherValue.has_value()) { out += sep; sep = ", "; out += ".otherValue = "; - smithy::DebugAppend(out, *this->otherValue); + opal::DebugAppend(out, *this->otherValue); } out += '}'; } @@ -1524,13 +1524,13 @@ struct RpcV2CborUnionsOutput { out += sep; sep = ", "; out += ".contents = "; - smithy::DebugAppend(out, *this->contents); + opal::DebugAppend(out, *this->contents); } if (this->otherValue.has_value()) { out += sep; sep = ", "; out += ".otherValue = "; - smithy::DebugAppend(out, *this->otherValue); + opal::DebugAppend(out, *this->otherValue); } out += '}'; } @@ -1554,7 +1554,7 @@ struct SimpleScalarPropertiesInput { std::optional longValue{}; std::optional shortValue{}; std::optional stringValue{}; - std::optional blobValue{}; + std::optional blobValue{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -1564,61 +1564,61 @@ struct SimpleScalarPropertiesInput { out += sep; sep = ", "; out += ".trueBooleanValue = "; - smithy::DebugAppend(out, *this->trueBooleanValue); + opal::DebugAppend(out, *this->trueBooleanValue); } if (this->falseBooleanValue.has_value()) { out += sep; sep = ", "; out += ".falseBooleanValue = "; - smithy::DebugAppend(out, *this->falseBooleanValue); + opal::DebugAppend(out, *this->falseBooleanValue); } if (this->byteValue.has_value()) { out += sep; sep = ", "; out += ".byteValue = "; - smithy::DebugAppend(out, *this->byteValue); + opal::DebugAppend(out, *this->byteValue); } if (this->doubleValue.has_value()) { out += sep; sep = ", "; out += ".doubleValue = "; - smithy::DebugAppend(out, *this->doubleValue); + opal::DebugAppend(out, *this->doubleValue); } if (this->floatValue.has_value()) { out += sep; sep = ", "; out += ".floatValue = "; - smithy::DebugAppend(out, *this->floatValue); + opal::DebugAppend(out, *this->floatValue); } if (this->integerValue.has_value()) { out += sep; sep = ", "; out += ".integerValue = "; - smithy::DebugAppend(out, *this->integerValue); + opal::DebugAppend(out, *this->integerValue); } if (this->longValue.has_value()) { out += sep; sep = ", "; out += ".longValue = "; - smithy::DebugAppend(out, *this->longValue); + opal::DebugAppend(out, *this->longValue); } if (this->shortValue.has_value()) { out += sep; sep = ", "; out += ".shortValue = "; - smithy::DebugAppend(out, *this->shortValue); + opal::DebugAppend(out, *this->shortValue); } if (this->stringValue.has_value()) { out += sep; sep = ", "; out += ".stringValue = "; - smithy::DebugAppend(out, *this->stringValue); + opal::DebugAppend(out, *this->stringValue); } if (this->blobValue.has_value()) { out += sep; sep = ", "; out += ".blobValue = "; - smithy::DebugAppend(out, *this->blobValue); + opal::DebugAppend(out, *this->blobValue); } out += '}'; } @@ -1642,7 +1642,7 @@ struct SimpleScalarPropertiesOutput { std::optional longValue{}; std::optional shortValue{}; std::optional stringValue{}; - std::optional blobValue{}; + std::optional blobValue{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -1652,61 +1652,61 @@ struct SimpleScalarPropertiesOutput { out += sep; sep = ", "; out += ".trueBooleanValue = "; - smithy::DebugAppend(out, *this->trueBooleanValue); + opal::DebugAppend(out, *this->trueBooleanValue); } if (this->falseBooleanValue.has_value()) { out += sep; sep = ", "; out += ".falseBooleanValue = "; - smithy::DebugAppend(out, *this->falseBooleanValue); + opal::DebugAppend(out, *this->falseBooleanValue); } if (this->byteValue.has_value()) { out += sep; sep = ", "; out += ".byteValue = "; - smithy::DebugAppend(out, *this->byteValue); + opal::DebugAppend(out, *this->byteValue); } if (this->doubleValue.has_value()) { out += sep; sep = ", "; out += ".doubleValue = "; - smithy::DebugAppend(out, *this->doubleValue); + opal::DebugAppend(out, *this->doubleValue); } if (this->floatValue.has_value()) { out += sep; sep = ", "; out += ".floatValue = "; - smithy::DebugAppend(out, *this->floatValue); + opal::DebugAppend(out, *this->floatValue); } if (this->integerValue.has_value()) { out += sep; sep = ", "; out += ".integerValue = "; - smithy::DebugAppend(out, *this->integerValue); + opal::DebugAppend(out, *this->integerValue); } if (this->longValue.has_value()) { out += sep; sep = ", "; out += ".longValue = "; - smithy::DebugAppend(out, *this->longValue); + opal::DebugAppend(out, *this->longValue); } if (this->shortValue.has_value()) { out += sep; sep = ", "; out += ".shortValue = "; - smithy::DebugAppend(out, *this->shortValue); + opal::DebugAppend(out, *this->shortValue); } if (this->stringValue.has_value()) { out += sep; sep = ", "; out += ".stringValue = "; - smithy::DebugAppend(out, *this->stringValue); + opal::DebugAppend(out, *this->stringValue); } if (this->blobValue.has_value()) { out += sep; sep = ", "; out += ".blobValue = "; - smithy::DebugAppend(out, *this->blobValue); + opal::DebugAppend(out, *this->blobValue); } out += '}'; } @@ -1732,13 +1732,13 @@ struct SparseNullsOperationInput { out += sep; sep = ", "; out += ".sparseStringList = "; - smithy::DebugAppend(out, *this->sparseStringList); + opal::DebugAppend(out, *this->sparseStringList); } if (this->sparseStringMap.has_value()) { out += sep; sep = ", "; out += ".sparseStringMap = "; - smithy::DebugAppend(out, *this->sparseStringMap); + opal::DebugAppend(out, *this->sparseStringMap); } out += '}'; } @@ -1764,13 +1764,13 @@ struct SparseNullsOperationOutput { out += sep; sep = ", "; out += ".sparseStringList = "; - smithy::DebugAppend(out, *this->sparseStringList); + opal::DebugAppend(out, *this->sparseStringList); } if (this->sparseStringMap.has_value()) { out += sep; sep = ", "; out += ".sparseStringMap = "; - smithy::DebugAppend(out, *this->sparseStringMap); + opal::DebugAppend(out, *this->sparseStringMap); } out += '}'; } @@ -1788,7 +1788,7 @@ struct RecursiveShapesInputOutputNested2; struct RecursiveShapesInputOutputNested1 { std::optional foo{}; - std::optional> nested{}; + std::optional> nested{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -1798,13 +1798,13 @@ struct RecursiveShapesInputOutputNested1 { out += sep; sep = ", "; out += ".foo = "; - smithy::DebugAppend(out, *this->foo); + opal::DebugAppend(out, *this->foo); } if (this->nested.has_value()) { out += sep; sep = ", "; out += ".nested = "; - smithy::DebugAppend(out, *this->nested); + opal::DebugAppend(out, *this->nested); } out += '}'; } @@ -1814,8 +1814,8 @@ struct RecursiveShapesInputOutputNested1 { } friend bool operator==(const RecursiveShapesInputOutputNested1&, const RecursiveShapesInputOutputNested1&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. }; @@ -1823,7 +1823,7 @@ struct RecursiveShapesInputOutputNested1; struct RecursiveShapesInputOutputNested2 { std::optional bar{}; - std::optional> recursiveMember{}; + std::optional> recursiveMember{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -1833,13 +1833,13 @@ struct RecursiveShapesInputOutputNested2 { out += sep; sep = ", "; out += ".bar = "; - smithy::DebugAppend(out, *this->bar); + opal::DebugAppend(out, *this->bar); } if (this->recursiveMember.has_value()) { out += sep; sep = ", "; out += ".recursiveMember = "; - smithy::DebugAppend(out, *this->recursiveMember); + opal::DebugAppend(out, *this->recursiveMember); } out += '}'; } @@ -1849,8 +1849,8 @@ struct RecursiveShapesInputOutputNested2 { } friend bool operator==(const RecursiveShapesInputOutputNested2&, const RecursiveShapesInputOutputNested2&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. }; @@ -1865,7 +1865,7 @@ struct RecursiveShapesInput { out += sep; sep = ", "; out += ".nested = "; - smithy::DebugAppend(out, *this->nested); + opal::DebugAppend(out, *this->nested); } out += '}'; } @@ -1875,8 +1875,8 @@ struct RecursiveShapesInput { } friend bool operator==(const RecursiveShapesInput&, const RecursiveShapesInput&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. }; @@ -1891,7 +1891,7 @@ struct RecursiveShapesOutput { out += sep; sep = ", "; out += ".nested = "; - smithy::DebugAppend(out, *this->nested); + opal::DebugAppend(out, *this->nested); } out += '}'; } @@ -1901,442 +1901,442 @@ struct RecursiveShapesOutput { } friend bool operator==(const RecursiveShapesOutput&, const RecursiveShapesOutput&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. }; -} // namespace smithy::protocoltests::rpcv2cbor +} // namespace opal::protocoltests::rpcv2cbor // std::hash so generated types key std::unordered_map/std::unordered_set — // emitted exactly for the types that get operator<=> (issue #49). Hash // values are process-local: never persist or compare them across runs. template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::ValidationExceptionField& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::ValidationExceptionField& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.path)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.path)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::ValidationException& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::ValidationException& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.fieldList)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.fieldList)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::ClientOptionalDefaults& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::ClientOptionalDefaults& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.member)); + seed = opal::HashCombine(seed, opal::HashValue(value.member)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::ComplexNestedErrorData& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::ComplexNestedErrorData& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.Foo)); + seed = opal::HashCombine(seed, opal::HashValue(value.Foo)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::ComplexError& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::ComplexError& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.TopLevel)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.Nested)); + seed = opal::HashCombine(seed, opal::HashValue(value.TopLevel)); + seed = opal::HashCombine(seed, opal::HashValue(value.Nested)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::TestEnum& value) const noexcept { - return smithy::HashCombine(static_cast(value.value_), - smithy::HashValue(value.unknown_)); +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::TestEnum& value) const noexcept { + return opal::HashCombine(static_cast(value.value_), + opal::HashValue(value.unknown_)); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::Defaults& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::Defaults& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultString)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultBoolean)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultTimestamp)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultBlob)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultByte)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultShort)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultInteger)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultLong)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultFloat)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultDouble)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultEnum)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultIntEnum)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.emptyString)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.falseBoolean)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.emptyBlob)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroByte)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroShort)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroInteger)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroLong)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroFloat)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroDouble)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultString)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultBoolean)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultList)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultTimestamp)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultBlob)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultByte)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultShort)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultInteger)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultLong)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultFloat)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultDouble)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultEnum)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultIntEnum)); + seed = opal::HashCombine(seed, opal::HashValue(value.emptyString)); + seed = opal::HashCombine(seed, opal::HashValue(value.falseBoolean)); + seed = opal::HashCombine(seed, opal::HashValue(value.emptyBlob)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroByte)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroShort)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroInteger)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroLong)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroFloat)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroDouble)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::GreetingStruct& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::GreetingStruct& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.hi)); + seed = opal::HashCombine(seed, opal::HashValue(value.hi)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::EmptyInputOutputInput& /*value*/) const noexcept { return 0; } +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::EmptyInputOutputInput& /*value*/) const noexcept { return 0; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::EmptyInputOutputOutput& /*value*/) const noexcept { return 0; } +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::EmptyInputOutputOutput& /*value*/) const noexcept { return 0; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::Float16Input& /*value*/) const noexcept { return 0; } +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::Float16Input& /*value*/) const noexcept { return 0; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::Float16Output& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::Float16Output& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.value)); + seed = opal::HashCombine(seed, opal::HashValue(value.value)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::FractionalSecondsInput& /*value*/) const noexcept { return 0; } +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::FractionalSecondsInput& /*value*/) const noexcept { return 0; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::FractionalSecondsOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::FractionalSecondsOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.datetime)); + seed = opal::HashCombine(seed, opal::HashValue(value.datetime)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::GreetingWithErrorsInput& /*value*/) const noexcept { return 0; } +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::GreetingWithErrorsInput& /*value*/) const noexcept { return 0; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::GreetingWithErrorsOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::GreetingWithErrorsOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.greeting)); + seed = opal::HashCombine(seed, opal::HashValue(value.greeting)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::InvalidGreeting& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::InvalidGreeting& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.Message)); + seed = opal::HashCombine(seed, opal::HashValue(value.Message)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::NoInputOutputInput& /*value*/) const noexcept { return 0; } +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::NoInputOutputInput& /*value*/) const noexcept { return 0; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::NoInputOutputOutput& /*value*/) const noexcept { return 0; } +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::NoInputOutputOutput& /*value*/) const noexcept { return 0; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::OperationWithDefaultsInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::OperationWithDefaultsInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaults)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.clientOptionalDefaults)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.topLevelDefault)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.otherTopLevelDefault)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaults)); + seed = opal::HashCombine(seed, opal::HashValue(value.clientOptionalDefaults)); + seed = opal::HashCombine(seed, opal::HashValue(value.topLevelDefault)); + seed = opal::HashCombine(seed, opal::HashValue(value.otherTopLevelDefault)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::OperationWithDefaultsOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::OperationWithDefaultsOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultString)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultBoolean)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultTimestamp)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultBlob)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultByte)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultShort)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultInteger)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultLong)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultFloat)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultDouble)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultEnum)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.defaultIntEnum)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.emptyString)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.falseBoolean)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.emptyBlob)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroByte)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroShort)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroInteger)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroLong)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroFloat)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.zeroDouble)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultString)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultBoolean)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultList)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultTimestamp)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultBlob)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultByte)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultShort)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultInteger)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultLong)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultFloat)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultDouble)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultEnum)); + seed = opal::HashCombine(seed, opal::HashValue(value.defaultIntEnum)); + seed = opal::HashCombine(seed, opal::HashValue(value.emptyString)); + seed = opal::HashCombine(seed, opal::HashValue(value.falseBoolean)); + seed = opal::HashCombine(seed, opal::HashValue(value.emptyBlob)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroByte)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroShort)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroInteger)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroLong)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroFloat)); + seed = opal::HashCombine(seed, opal::HashValue(value.zeroDouble)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::OptionalInputOutputInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::OptionalInputOutputInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.value)); + seed = opal::HashCombine(seed, opal::HashValue(value.value)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::OptionalInputOutputOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::OptionalInputOutputOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.value)); + seed = opal::HashCombine(seed, opal::HashValue(value.value)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborDenseMapsInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborDenseMapsInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.denseStructMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.denseNumberMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.denseBooleanMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.denseStringMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.denseSetMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.denseStructMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.denseNumberMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.denseBooleanMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.denseStringMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.denseSetMap)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborDenseMapsOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborDenseMapsOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.denseStructMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.denseNumberMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.denseBooleanMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.denseStringMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.denseSetMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.denseStructMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.denseNumberMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.denseBooleanMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.denseStringMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.denseSetMap)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::FooEnum& value) const noexcept { - return smithy::HashCombine(static_cast(value.value_), - smithy::HashValue(value.unknown_)); +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::FooEnum& value) const noexcept { + return opal::HashCombine(static_cast(value.value_), + opal::HashValue(value.unknown_)); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::StructureListMember& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::StructureListMember& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.a)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.b)); + seed = opal::HashCombine(seed, opal::HashValue(value.a)); + seed = opal::HashCombine(seed, opal::HashValue(value.b)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborListsInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborListsInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.stringList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.stringSet)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.integerList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.booleanList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.timestampList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.enumList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.intEnumList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.nestedStringList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.structureList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.blobList)); + seed = opal::HashCombine(seed, opal::HashValue(value.stringList)); + seed = opal::HashCombine(seed, opal::HashValue(value.stringSet)); + seed = opal::HashCombine(seed, opal::HashValue(value.integerList)); + seed = opal::HashCombine(seed, opal::HashValue(value.booleanList)); + seed = opal::HashCombine(seed, opal::HashValue(value.timestampList)); + seed = opal::HashCombine(seed, opal::HashValue(value.enumList)); + seed = opal::HashCombine(seed, opal::HashValue(value.intEnumList)); + seed = opal::HashCombine(seed, opal::HashValue(value.nestedStringList)); + seed = opal::HashCombine(seed, opal::HashValue(value.structureList)); + seed = opal::HashCombine(seed, opal::HashValue(value.blobList)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborListsOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborListsOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.stringList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.stringSet)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.integerList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.booleanList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.timestampList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.enumList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.intEnumList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.nestedStringList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.structureList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.blobList)); + seed = opal::HashCombine(seed, opal::HashValue(value.stringList)); + seed = opal::HashCombine(seed, opal::HashValue(value.stringSet)); + seed = opal::HashCombine(seed, opal::HashValue(value.integerList)); + seed = opal::HashCombine(seed, opal::HashValue(value.booleanList)); + seed = opal::HashCombine(seed, opal::HashValue(value.timestampList)); + seed = opal::HashCombine(seed, opal::HashValue(value.enumList)); + seed = opal::HashCombine(seed, opal::HashValue(value.intEnumList)); + seed = opal::HashCombine(seed, opal::HashValue(value.nestedStringList)); + seed = opal::HashCombine(seed, opal::HashValue(value.structureList)); + seed = opal::HashCombine(seed, opal::HashValue(value.blobList)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborNestedUnion& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborNestedUnion& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborSparseMapsInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborSparseMapsInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseStructMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseNumberMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseBooleanMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseStringMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseSetMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseStructMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseNumberMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseBooleanMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseStringMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseSetMap)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborSparseMapsOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborSparseMapsOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseStructMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseNumberMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseBooleanMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseStringMap)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseSetMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseStructMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseNumberMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseBooleanMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseStringMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseSetMap)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborUnion& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborUnion& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborUnionsInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborUnionsInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.contents)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.otherValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.contents)); + seed = opal::HashCombine(seed, opal::HashValue(value.otherValue)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::RpcV2CborUnionsOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::RpcV2CborUnionsOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.contents)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.otherValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.contents)); + seed = opal::HashCombine(seed, opal::HashValue(value.otherValue)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::SimpleScalarPropertiesInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::SimpleScalarPropertiesInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.trueBooleanValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.falseBooleanValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.byteValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.doubleValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.floatValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.integerValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.longValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.shortValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.stringValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.blobValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.trueBooleanValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.falseBooleanValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.byteValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.doubleValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.floatValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.integerValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.longValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.shortValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.stringValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.blobValue)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::SimpleScalarPropertiesOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::SimpleScalarPropertiesOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.trueBooleanValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.falseBooleanValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.byteValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.doubleValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.floatValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.integerValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.longValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.shortValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.stringValue)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.blobValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.trueBooleanValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.falseBooleanValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.byteValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.doubleValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.floatValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.integerValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.longValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.shortValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.stringValue)); + seed = opal::HashCombine(seed, opal::HashValue(value.blobValue)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::SparseNullsOperationInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::SparseNullsOperationInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseStringList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseStringMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseStringList)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseStringMap)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::rpcv2cbor::SparseNullsOperationOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::rpcv2cbor::SparseNullsOperationOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseStringList)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.sparseStringMap)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseStringList)); + seed = opal::HashCombine(seed, opal::HashValue(value.sparseStringMap)); return seed; } }; -#endif // SMITHY_PROTOCOLTESTS_RPCV2CBOR_TYPES_H_ +#endif // OPAL_PROTOCOLTESTS_RPCV2CBOR_TYPES_H_ diff --git a/protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/serde.h b/protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/serde.h deleted file mode 100644 index 6eef834c..00000000 --- a/protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/serde.h +++ /dev/null @@ -1,221 +0,0 @@ -// Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. - -#ifndef SMITHY_PROTOCOLTESTS_RPCV2CBOR_SERDE_H_ -#define SMITHY_PROTOCOLTESTS_RPCV2CBOR_SERDE_H_ - -#include -#include -#include -#include -#include - -#include "smithy/core/blob.h" -#include "smithy/core/document.h" -#include "smithy/core/outcome.h" -#include "smithy/core/timestamp.h" -#include "smithy/protocoltests/rpcv2cbor/types.h" - -namespace smithy::protocoltests::rpcv2cbor { - -// Document-pivot serde for every aggregate shape in the model closure. -// Serializers never fail; deserializers return smithy::Error on wire -// mismatches and enforce @required members. - -smithy::Document SerializeValidationExceptionField(const ValidationExceptionField& value); -smithy::Outcome DeserializeValidationExceptionField(const smithy::Document& doc); - -smithy::Document SerializeValidationExceptionFieldList(const std::vector& value); -smithy::Outcome> DeserializeValidationExceptionFieldList(const smithy::Document& doc); - -smithy::Document SerializeValidationException(const ValidationException& value); -smithy::Outcome DeserializeValidationException(const smithy::Document& doc); - -smithy::Document SerializeClientOptionalDefaults(const ClientOptionalDefaults& value); -smithy::Outcome DeserializeClientOptionalDefaults(const smithy::Document& doc); - -smithy::Document SerializeComplexNestedErrorData(const ComplexNestedErrorData& value); -smithy::Outcome DeserializeComplexNestedErrorData(const smithy::Document& doc); - -smithy::Document SerializeComplexError(const ComplexError& value); -smithy::Outcome DeserializeComplexError(const smithy::Document& doc); - -smithy::Document SerializeTestStringList(const std::vector& value); -smithy::Outcome> DeserializeTestStringList(const smithy::Document& doc); - -smithy::Document SerializeTestStringMap(const std::map& value); -smithy::Outcome> DeserializeTestStringMap(const smithy::Document& doc); - -smithy::Document SerializeDefaults(const Defaults& value); -smithy::Outcome DeserializeDefaults(const smithy::Document& doc); - -smithy::Document SerializeDenseBooleanMap(const std::map& value); -smithy::Outcome> DeserializeDenseBooleanMap(const smithy::Document& doc); - -smithy::Document SerializeDenseNumberMap(const std::map& value); -smithy::Outcome> DeserializeDenseNumberMap(const smithy::Document& doc); - -smithy::Document SerializeStringSet(const std::vector& value); -smithy::Outcome> DeserializeStringSet(const smithy::Document& doc); - -smithy::Document SerializeDenseSetMap(const std::map>& value); -smithy::Outcome>> DeserializeDenseSetMap(const smithy::Document& doc); - -smithy::Document SerializeDenseStringMap(const std::map& value); -smithy::Outcome> DeserializeDenseStringMap(const smithy::Document& doc); - -smithy::Document SerializeGreetingStruct(const GreetingStruct& value); -smithy::Outcome DeserializeGreetingStruct(const smithy::Document& doc); - -smithy::Document SerializeDenseStructMap(const std::map& value); -smithy::Outcome> DeserializeDenseStructMap(const smithy::Document& doc); - -smithy::Document SerializeEmptyInputOutputInput(const EmptyInputOutputInput& value); -smithy::Outcome DeserializeEmptyInputOutputInput(const smithy::Document& doc); - -smithy::Document SerializeEmptyInputOutputOutput(const EmptyInputOutputOutput& value); -smithy::Outcome DeserializeEmptyInputOutputOutput(const smithy::Document& doc); - -smithy::Document SerializeFloat16Input(const Float16Input& value); -smithy::Outcome DeserializeFloat16Input(const smithy::Document& doc); - -smithy::Document SerializeFloat16Output(const Float16Output& value); -smithy::Outcome DeserializeFloat16Output(const smithy::Document& doc); - -smithy::Document SerializeFractionalSecondsInput(const FractionalSecondsInput& value); -smithy::Outcome DeserializeFractionalSecondsInput(const smithy::Document& doc); - -smithy::Document SerializeFractionalSecondsOutput(const FractionalSecondsOutput& value); -smithy::Outcome DeserializeFractionalSecondsOutput(const smithy::Document& doc); - -smithy::Document SerializeGreetingWithErrorsInput(const GreetingWithErrorsInput& value); -smithy::Outcome DeserializeGreetingWithErrorsInput(const smithy::Document& doc); - -smithy::Document SerializeGreetingWithErrorsOutput(const GreetingWithErrorsOutput& value); -smithy::Outcome DeserializeGreetingWithErrorsOutput(const smithy::Document& doc); - -smithy::Document SerializeInvalidGreeting(const InvalidGreeting& value); -smithy::Outcome DeserializeInvalidGreeting(const smithy::Document& doc); - -smithy::Document SerializeNoInputOutputInput(const NoInputOutputInput& value); -smithy::Outcome DeserializeNoInputOutputInput(const smithy::Document& doc); - -smithy::Document SerializeNoInputOutputOutput(const NoInputOutputOutput& value); -smithy::Outcome DeserializeNoInputOutputOutput(const smithy::Document& doc); - -smithy::Document SerializeOperationWithDefaultsInput(const OperationWithDefaultsInput& value); -smithy::Outcome DeserializeOperationWithDefaultsInput(const smithy::Document& doc); - -smithy::Document SerializeOperationWithDefaultsOutput(const OperationWithDefaultsOutput& value); -smithy::Outcome DeserializeOperationWithDefaultsOutput(const smithy::Document& doc); - -smithy::Document SerializeOptionalInputOutputInput(const OptionalInputOutputInput& value); -smithy::Outcome DeserializeOptionalInputOutputInput(const smithy::Document& doc); - -smithy::Document SerializeOptionalInputOutputOutput(const OptionalInputOutputOutput& value); -smithy::Outcome DeserializeOptionalInputOutputOutput(const smithy::Document& doc); - -smithy::Document SerializeRpcV2CborDenseMapsInput(const RpcV2CborDenseMapsInput& value); -smithy::Outcome DeserializeRpcV2CborDenseMapsInput(const smithy::Document& doc); - -smithy::Document SerializeRpcV2CborDenseMapsOutput(const RpcV2CborDenseMapsOutput& value); -smithy::Outcome DeserializeRpcV2CborDenseMapsOutput(const smithy::Document& doc); - -smithy::Document SerializeBlobList(const std::vector& value); -smithy::Outcome> DeserializeBlobList(const smithy::Document& doc); - -smithy::Document SerializeBooleanList(const std::vector& value); -smithy::Outcome> DeserializeBooleanList(const smithy::Document& doc); - -smithy::Document SerializeFooEnumList(const std::vector& value); -smithy::Outcome> DeserializeFooEnumList(const smithy::Document& doc); - -smithy::Document SerializeIntegerList(const std::vector& value); -smithy::Outcome> DeserializeIntegerList(const smithy::Document& doc); - -smithy::Document SerializeIntegerEnumList(const std::vector& value); -smithy::Outcome> DeserializeIntegerEnumList(const smithy::Document& doc); - -smithy::Document SerializeStringList(const std::vector& value); -smithy::Outcome> DeserializeStringList(const smithy::Document& doc); - -smithy::Document SerializeNestedStringList(const std::vector>& value); -smithy::Outcome>> DeserializeNestedStringList(const smithy::Document& doc); - -smithy::Document SerializeStructureListMember(const StructureListMember& value); -smithy::Outcome DeserializeStructureListMember(const smithy::Document& doc); - -smithy::Document SerializeStructureList(const std::vector& value); -smithy::Outcome> DeserializeStructureList(const smithy::Document& doc); - -smithy::Document SerializeTimestampList(const std::vector& value); -smithy::Outcome> DeserializeTimestampList(const smithy::Document& doc); - -smithy::Document SerializeRpcV2CborListsInput(const RpcV2CborListsInput& value); -smithy::Outcome DeserializeRpcV2CborListsInput(const smithy::Document& doc); - -smithy::Document SerializeRpcV2CborListsOutput(const RpcV2CborListsOutput& value); -smithy::Outcome DeserializeRpcV2CborListsOutput(const smithy::Document& doc); - -smithy::Document SerializeRpcV2CborNestedUnion(const RpcV2CborNestedUnion& value); -smithy::Outcome DeserializeRpcV2CborNestedUnion(const smithy::Document& doc); - -smithy::Document SerializeSparseBooleanMap(const std::map>& value); -smithy::Outcome>> DeserializeSparseBooleanMap(const smithy::Document& doc); - -smithy::Document SerializeSparseNumberMap(const std::map>& value); -smithy::Outcome>> DeserializeSparseNumberMap(const smithy::Document& doc); - -smithy::Document SerializeSparseSetMap(const std::map>>& value); -smithy::Outcome>>> DeserializeSparseSetMap(const smithy::Document& doc); - -smithy::Document SerializeSparseStringMap(const std::map>& value); -smithy::Outcome>> DeserializeSparseStringMap(const smithy::Document& doc); - -smithy::Document SerializeSparseStructMap(const std::map>& value); -smithy::Outcome>> DeserializeSparseStructMap(const smithy::Document& doc); - -smithy::Document SerializeRpcV2CborSparseMapsInput(const RpcV2CborSparseMapsInput& value); -smithy::Outcome DeserializeRpcV2CborSparseMapsInput(const smithy::Document& doc); - -smithy::Document SerializeRpcV2CborSparseMapsOutput(const RpcV2CborSparseMapsOutput& value); -smithy::Outcome DeserializeRpcV2CborSparseMapsOutput(const smithy::Document& doc); - -smithy::Document SerializeRpcV2CborUnion(const RpcV2CborUnion& value); -smithy::Outcome DeserializeRpcV2CborUnion(const smithy::Document& doc); - -smithy::Document SerializeRpcV2CborUnionsInput(const RpcV2CborUnionsInput& value); -smithy::Outcome DeserializeRpcV2CborUnionsInput(const smithy::Document& doc); - -smithy::Document SerializeRpcV2CborUnionsOutput(const RpcV2CborUnionsOutput& value); -smithy::Outcome DeserializeRpcV2CborUnionsOutput(const smithy::Document& doc); - -smithy::Document SerializeSimpleScalarPropertiesInput(const SimpleScalarPropertiesInput& value); -smithy::Outcome DeserializeSimpleScalarPropertiesInput(const smithy::Document& doc); - -smithy::Document SerializeSimpleScalarPropertiesOutput(const SimpleScalarPropertiesOutput& value); -smithy::Outcome DeserializeSimpleScalarPropertiesOutput(const smithy::Document& doc); - -smithy::Document SerializeSparseStringList(const std::vector>& value); -smithy::Outcome>> DeserializeSparseStringList(const smithy::Document& doc); - -smithy::Document SerializeSparseNullsOperationInput(const SparseNullsOperationInput& value); -smithy::Outcome DeserializeSparseNullsOperationInput(const smithy::Document& doc); - -smithy::Document SerializeSparseNullsOperationOutput(const SparseNullsOperationOutput& value); -smithy::Outcome DeserializeSparseNullsOperationOutput(const smithy::Document& doc); - -smithy::Document SerializeRecursiveShapesInput(const RecursiveShapesInput& value); -smithy::Outcome DeserializeRecursiveShapesInput(const smithy::Document& doc); - -smithy::Document SerializeRecursiveShapesInputOutputNested1(const RecursiveShapesInputOutputNested1& value); -smithy::Outcome DeserializeRecursiveShapesInputOutputNested1(const smithy::Document& doc); - -smithy::Document SerializeRecursiveShapesInputOutputNested2(const RecursiveShapesInputOutputNested2& value); -smithy::Outcome DeserializeRecursiveShapesInputOutputNested2(const smithy::Document& doc); - -smithy::Document SerializeRecursiveShapesOutput(const RecursiveShapesOutput& value); -smithy::Outcome DeserializeRecursiveShapesOutput(const smithy::Document& doc); - -} // namespace smithy::protocoltests::rpcv2cbor - -#endif // SMITHY_PROTOCOLTESTS_RPCV2CBOR_SERDE_H_ diff --git a/protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/server.h b/protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/server.h deleted file mode 100644 index 193a9665..00000000 --- a/protocol-tests/rpcv2cbor/generated/include/smithy/protocoltests/rpcv2cbor/server.h +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. - -#ifndef SMITHY_PROTOCOLTESTS_RPCV2CBOR_SERVER_H_ -#define SMITHY_PROTOCOLTESTS_RPCV2CBOR_SERVER_H_ - -#include - -#include "smithy/core/outcome.h" -#include "smithy/http/transport.h" -#include "smithy/protocoltests/rpcv2cbor/types.h" -#include "smithy/server/router.h" - -namespace smithy::protocoltests::rpcv2cbor { - -/// Implement one method per operation. Return a modeled error as -/// smithy::Error::Modeled("", message), optionally with the -/// typed error structure attached via set_detail() so it serializes fully. -/// The context carries the raw request and routing captures — see -/// smithy::server::RequestContext; leave the parameter unnamed when unused. -/// Implementations must be thread-safe: transports may invoke any mix of -/// operations concurrently on the one handler instance. -class RpcV2ProtocolHandler { - public: - virtual ~RpcV2ProtocolHandler() = default; - - virtual smithy::Outcome EmptyInputOutput(const EmptyInputOutputInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome Float16(const Float16Input& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome FractionalSeconds(const FractionalSecondsInput& input, const smithy::server::RequestContext& context) = 0; - /// This operation has three possible return values: - /// - /// 1. A successful response in the form of GreetingWithErrorsOutput - /// 2. An InvalidGreeting error. - /// 3. A ComplexError error. - /// - /// Implementations must be able to successfully take a response and - /// properly deserialize successful and error responses. - virtual smithy::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome NoInputOutput(const NoInputOutputInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome OptionalInputOutput(const OptionalInputOutputInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome RecursiveShapes(const RecursiveShapesInput& input, const smithy::server::RequestContext& context) = 0; - /// The example tests basic map serialization. - virtual smithy::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const smithy::server::RequestContext& context) = 0; - /// This test case serializes JSON lists for the following cases for both - /// input and output: - /// - /// 1. Normal lists. - /// 2. Normal sets. - /// 3. Lists of lists. - /// 4. Lists of structures. - virtual smithy::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const smithy::server::RequestContext& context) = 0; - /// This operation uses unions for inputs and outputs. - virtual smithy::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const smithy::server::RequestContext& context) = 0; -}; - -/// rpcv2Cbor server for smithy.protocoltests.rpcv2Cbor#RpcV2Protocol: routing, deserialization, handler dispatch, -/// response serialization, and modeled-error mapping. Pass Handler() to any -/// smithy::http::HttpServerTransport. -class RpcV2ProtocolServer { - public: - explicit RpcV2ProtocolServer(std::shared_ptr handler); - - smithy::http::RequestHandler Handler() const; - - private: - std::shared_ptr router_; -}; - -} // namespace smithy::protocoltests::rpcv2cbor - -#endif // SMITHY_PROTOCOLTESTS_RPCV2CBOR_SERVER_H_ diff --git a/protocol-tests/rpcv2cbor/generated/src/client.cc b/protocol-tests/rpcv2cbor/generated/src/client.cc index b0b19147..9ed8cfcd 100644 --- a/protocol-tests/rpcv2cbor/generated/src/client.cc +++ b/protocol-tests/rpcv2cbor/generated/src/client.cc @@ -4,16 +4,16 @@ #include #include +#include "opal/protocoltests/rpcv2cbor/client.h" +#include "opal/protocoltests/rpcv2cbor/serde.h" #include "smithy/cbor/cbor.h" #include "smithy/core/blob.h" #include "smithy/core/document_serde.h" #include "smithy/core/uuid.h" #include "smithy/http/socket_transport.h" #include "smithy/http/uri.h" -#include "smithy/protocoltests/rpcv2cbor/client.h" -#include "smithy/protocoltests/rpcv2cbor/serde.h" -namespace smithy::protocoltests::rpcv2cbor { +namespace opal::protocoltests::rpcv2cbor { namespace { namespace helpers { @@ -30,38 +30,38 @@ struct ParsedError { int status = 0; std::string code = "UnknownError"; std::string message; - smithy::Document doc; + opal::Document doc; }; // [[maybe_unused]]: only unary response paths parse wire errors; a // service whose operations all stream never calls this. -[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) { +[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) { ParsedError parsed; parsed.status = response.status; parsed.message = "HTTP " + std::to_string(response.status); - auto doc = smithy::cbor::Decode(smithy::Blob::FromString(response.body)); + auto doc = opal::cbor::Decode(opal::Blob::FromString(response.body)); if (doc.ok()) parsed.doc = *std::move(doc); if (parsed.doc.is_map()) { - const smithy::Document* type = parsed.doc.Find("__type"); + const opal::Document* type = parsed.doc.Find("__type"); if (type == nullptr) type = parsed.doc.Find("code"); if (parsed.code == "UnknownError" && type != nullptr && type->is_string()) parsed.code = helpers::SanitizeErrorCode(type->as_string()); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } return parsed; } -smithy::Error GenericError(ParsedError parsed) { +opal::Error GenericError(ParsedError parsed) { const bool retryable = parsed.status >= 500; - if (parsed.code == "UnknownError") return smithy::Error(smithy::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); - return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); + if (parsed.code == "UnknownError") return opal::Error(opal::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); + return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); } -smithy::Error MakeComplexErrorError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeComplexErrorError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("ComplexError", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("ComplexError", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeComplexError(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -69,11 +69,11 @@ smithy::Error MakeComplexErrorError(const smithy::http::HttpResponse& response, return error; } -smithy::Error MakeInvalidGreetingError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeInvalidGreetingError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("InvalidGreeting", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("InvalidGreeting", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeInvalidGreeting(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -81,11 +81,11 @@ smithy::Error MakeInvalidGreetingError(const smithy::http::HttpResponse& respons return error; } -smithy::Error MakeValidationExceptionError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeValidationExceptionError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("ValidationException", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("ValidationException", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeValidationException(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -93,32 +93,32 @@ smithy::Error MakeValidationExceptionError(const smithy::http::HttpResponse& res return error; } -smithy::Error ParseGreetingWithErrorsError(const smithy::http::HttpResponse& response) { +opal::Error ParseGreetingWithErrorsError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "ComplexError") return helpers::MakeComplexErrorError(response, std::move(parsed)); if (parsed.code == "InvalidGreeting") return helpers::MakeInvalidGreetingError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseOperationWithDefaultsError(const smithy::http::HttpResponse& response) { +opal::Error ParseOperationWithDefaultsError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "ValidationException") return helpers::MakeValidationExceptionError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseRpcV2CborDenseMapsError(const smithy::http::HttpResponse& response) { +opal::Error ParseRpcV2CborDenseMapsError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "ValidationException") return helpers::MakeValidationExceptionError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseRpcV2CborListsError(const smithy::http::HttpResponse& response) { +opal::Error ParseRpcV2CborListsError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "ValidationException") return helpers::MakeValidationExceptionError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseRpcV2CborSparseMapsError(const smithy::http::HttpResponse& response) { +opal::Error ParseRpcV2CborSparseMapsError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "ValidationException") return helpers::MakeValidationExceptionError(response, std::move(parsed)); return helpers::GenericError(std::move(parsed)); @@ -127,60 +127,60 @@ smithy::Error ParseRpcV2CborSparseMapsError(const smithy::http::HttpResponse& re } // namespace helpers } // namespace -smithy::Outcome RpcV2ProtocolClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome RpcV2ProtocolClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { // The built-in socket transport is plaintext-only; https needs a - // TLS-capable transport (e.g. smithy::http::BeastHttpClient). + // TLS-capable transport (e.g. opal::http::BeastHttpClient). if (endpoint->tls()) { - return smithy::Error::Validation("RpcV2ProtocolClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + return opal::Error::Validation("RpcV2ProtocolClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); } - transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); } } if (transport == nullptr) { - return smithy::Error::Validation("RpcV2ProtocolClient: config needs an endpoint or an http_client"); + return opal::Error::Validation("RpcV2ProtocolClient: config needs an endpoint or an http_client"); } return RpcV2ProtocolClient(std::move(config), std::move(transport), std::move(prefix)); } -RpcV2ProtocolClient::RpcV2ProtocolClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix) +RpcV2ProtocolClient::RpcV2ProtocolClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} -smithy::Outcome RpcV2ProtocolClient::Send(smithy::http::HttpRequest request) const { +opal::Outcome RpcV2ProtocolClient::Send(opal::http::HttpRequest request) const { // Operations with a non-document response payload set their own accept. if (!request.headers.Get("accept").has_value()) request.headers.Set("accept", "application/cbor"); request.headers.Set("user-agent", config_.user_agent); if (!request.body.empty()) { request.headers.Set("content-length", std::to_string(request.body.size())); } - return smithy::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); + return opal::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); } -smithy::Outcome RpcV2ProtocolClient::EmptyInputOutput(const EmptyInputOutputInput& input) const { +opal::Outcome RpcV2ProtocolClient::EmptyInputOutput(const EmptyInputOutputInput& input) const { (void)input; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/EmptyInputOutput"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeEmptyInputOutputInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializeEmptyInputOutputInput(input)).ToString(); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); return EmptyInputOutputOutput{}; } -smithy::Outcome RpcV2ProtocolClient::Float16(const Float16Input& input) const { +opal::Outcome RpcV2ProtocolClient::Float16(const Float16Input& input) const { (void)input; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/Float16"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); @@ -188,14 +188,14 @@ smithy::Outcome RpcV2ProtocolClient::Float16(const Float16Input& if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); if (response->body.empty()) return Float16Output{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeFloat16Output(*body_doc); } -smithy::Outcome RpcV2ProtocolClient::FractionalSeconds(const FractionalSecondsInput& input) const { +opal::Outcome RpcV2ProtocolClient::FractionalSeconds(const FractionalSecondsInput& input) const { (void)input; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/FractionalSeconds"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); @@ -203,14 +203,14 @@ smithy::Outcome RpcV2ProtocolClient::FractionalSeconds( if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); if (response->body.empty()) return FractionalSecondsOutput{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeFractionalSecondsOutput(*body_doc); } -smithy::Outcome RpcV2ProtocolClient::GreetingWithErrors(const GreetingWithErrorsInput& input) const { +opal::Outcome RpcV2ProtocolClient::GreetingWithErrors(const GreetingWithErrorsInput& input) const { (void)input; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/GreetingWithErrors"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); @@ -218,14 +218,14 @@ smithy::Outcome RpcV2ProtocolClient::GreetingWithError if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseGreetingWithErrorsError(*response); if (response->body.empty()) return GreetingWithErrorsOutput{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeGreetingWithErrorsOutput(*body_doc); } -smithy::Outcome RpcV2ProtocolClient::NoInputOutput(const NoInputOutputInput& input) const { +opal::Outcome RpcV2ProtocolClient::NoInputOutput(const NoInputOutputInput& input) const { (void)input; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/NoInputOutput"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); @@ -235,148 +235,148 @@ smithy::Outcome RpcV2ProtocolClient::NoInputOutput(const No return NoInputOutputOutput{}; } -smithy::Outcome RpcV2ProtocolClient::OperationWithDefaults(const OperationWithDefaultsInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome RpcV2ProtocolClient::OperationWithDefaults(const OperationWithDefaultsInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/OperationWithDefaults"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeOperationWithDefaultsInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializeOperationWithDefaultsInput(input)).ToString(); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseOperationWithDefaultsError(*response); if (response->body.empty()) return OperationWithDefaultsOutput{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeOperationWithDefaultsOutput(*body_doc); } -smithy::Outcome RpcV2ProtocolClient::OptionalInputOutput(const OptionalInputOutputInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome RpcV2ProtocolClient::OptionalInputOutput(const OptionalInputOutputInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/OptionalInputOutput"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeOptionalInputOutputInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializeOptionalInputOutputInput(input)).ToString(); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); if (response->body.empty()) return OptionalInputOutputOutput{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeOptionalInputOutputOutput(*body_doc); } -smithy::Outcome RpcV2ProtocolClient::RecursiveShapes(const RecursiveShapesInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome RpcV2ProtocolClient::RecursiveShapes(const RecursiveShapesInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/RecursiveShapes"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeRecursiveShapesInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializeRecursiveShapesInput(input)).ToString(); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); if (response->body.empty()) return RecursiveShapesOutput{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeRecursiveShapesOutput(*body_doc); } -smithy::Outcome RpcV2ProtocolClient::RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome RpcV2ProtocolClient::RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeRpcV2CborDenseMapsInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializeRpcV2CborDenseMapsInput(input)).ToString(); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseRpcV2CborDenseMapsError(*response); if (response->body.empty()) return RpcV2CborDenseMapsOutput{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeRpcV2CborDenseMapsOutput(*body_doc); } -smithy::Outcome RpcV2ProtocolClient::RpcV2CborLists(const RpcV2CborListsInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome RpcV2ProtocolClient::RpcV2CborLists(const RpcV2CborListsInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/RpcV2CborLists"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeRpcV2CborListsInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializeRpcV2CborListsInput(input)).ToString(); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseRpcV2CborListsError(*response); if (response->body.empty()) return RpcV2CborListsOutput{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeRpcV2CborListsOutput(*body_doc); } -smithy::Outcome RpcV2ProtocolClient::RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome RpcV2ProtocolClient::RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeRpcV2CborSparseMapsInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializeRpcV2CborSparseMapsInput(input)).ToString(); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseRpcV2CborSparseMapsError(*response); if (response->body.empty()) return RpcV2CborSparseMapsOutput{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeRpcV2CborSparseMapsOutput(*body_doc); } -smithy::Outcome RpcV2ProtocolClient::RpcV2CborUnions(const RpcV2CborUnionsInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome RpcV2ProtocolClient::RpcV2CborUnions(const RpcV2CborUnionsInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/RpcV2CborUnions"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeRpcV2CborUnionsInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializeRpcV2CborUnionsInput(input)).ToString(); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); if (response->body.empty()) return RpcV2CborUnionsOutput{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeRpcV2CborUnionsOutput(*body_doc); } -smithy::Outcome RpcV2ProtocolClient::SimpleScalarProperties(const SimpleScalarPropertiesInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome RpcV2ProtocolClient::SimpleScalarProperties(const SimpleScalarPropertiesInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/SimpleScalarProperties"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeSimpleScalarPropertiesInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializeSimpleScalarPropertiesInput(input)).ToString(); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); if (response->body.empty()) return SimpleScalarPropertiesOutput{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeSimpleScalarPropertiesOutput(*body_doc); } -smithy::Outcome RpcV2ProtocolClient::SparseNullsOperation(const SparseNullsOperationInput& input) const { - smithy::http::HttpRequest request; +opal::Outcome RpcV2ProtocolClient::SparseNullsOperation(const SparseNullsOperationInput& input) const { + opal::http::HttpRequest request; request.method = "POST"; request.target = path_prefix_ + "/service/RpcV2Protocol/operation/SparseNullsOperation"; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); request.headers.Set("content-type", "application/cbor"); - request.body = smithy::cbor::Encode(SerializeSparseNullsOperationInput(input)).ToString(); + request.body = opal::cbor::Encode(SerializeSparseNullsOperationInput(input)).ToString(); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::GenericError(helpers::ParseError(*response)); if (response->body.empty()) return SparseNullsOperationOutput{}; - auto body_doc = smithy::cbor::Decode(smithy::Blob::FromString(response->body)); + auto body_doc = opal::cbor::Decode(opal::Blob::FromString(response->body)); if (!body_doc) return std::move(body_doc).error(); return DeserializeSparseNullsOperationOutput(*body_doc); } -} // namespace smithy::protocoltests::rpcv2cbor +} // namespace opal::protocoltests::rpcv2cbor diff --git a/protocol-tests/rpcv2cbor/generated/src/serde.cc b/protocol-tests/rpcv2cbor/generated/src/serde.cc index f53a3b7a..8251ed5b 100644 --- a/protocol-tests/rpcv2cbor/generated/src/serde.cc +++ b/protocol-tests/rpcv2cbor/generated/src/serde.cc @@ -3,58 +3,58 @@ #include #include +#include "opal/protocoltests/rpcv2cbor/serde.h" #include "smithy/core/document_serde.h" -#include "smithy/protocoltests/rpcv2cbor/serde.h" -namespace smithy::protocoltests::rpcv2cbor { +namespace opal::protocoltests::rpcv2cbor { -namespace types = ::smithy::protocoltests::rpcv2cbor; +namespace types = ::opal::protocoltests::rpcv2cbor; -smithy::Document SerializeValidationExceptionField(const ValidationExceptionField& value) { - smithy::DocumentMap map; - map.emplace("path", smithy::Document(value.path)); - map.emplace("message", smithy::Document(value.message)); - return smithy::Document(std::move(map)); +opal::Document SerializeValidationExceptionField(const ValidationExceptionField& value) { + opal::DocumentMap map; + map.emplace("path", opal::Document(value.path)); + map.emplace("message", opal::Document(value.message)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeValidationExceptionField(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ValidationExceptionField: expected a map on the wire"); +opal::Outcome DeserializeValidationExceptionField(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ValidationExceptionField: expected a map on the wire"); ValidationExceptionField out; { - const smithy::Document* member = doc.Find("path"); + const opal::Document* member = doc.Find("path"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("ValidationExceptionField: missing required member: path"); + return opal::Error::Serialization("ValidationExceptionField: missing required member: path"); } - if (!member->is_string()) return smithy::Error::Serialization("ValidationExceptionField.path: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ValidationExceptionField.path: unexpected type on the wire"); out.path = member->as_string(); } { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("ValidationExceptionField: missing required member: message"); + return opal::Error::Serialization("ValidationExceptionField: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("ValidationExceptionField.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ValidationExceptionField.message: unexpected type on the wire"); out.message = member->as_string(); } return out; } -smithy::Document SerializeValidationExceptionFieldList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeValidationExceptionFieldList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { list.push_back(SerializeValidationExceptionField(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeValidationExceptionFieldList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeValidationExceptionFieldList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); ValidationExceptionField parsed_item{}; { auto parsed = DeserializeValidationExceptionField(*item); @@ -66,28 +66,28 @@ smithy::Outcome> DeserializeValidationExce return out; } -smithy::Document SerializeValidationException(const ValidationException& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); +opal::Document SerializeValidationException(const ValidationException& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); if (value.fieldList.has_value()) { map.emplace("fieldList", SerializeValidationExceptionFieldList((*value.fieldList))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeValidationException(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ValidationException: expected a map on the wire"); +opal::Outcome DeserializeValidationException(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ValidationException: expected a map on the wire"); ValidationException out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("ValidationException: missing required member: message"); + return opal::Error::Serialization("ValidationException: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("ValidationException.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ValidationException.message: unexpected type on the wire"); out.message = member->as_string(); } { - const smithy::Document* member = doc.Find("fieldList"); + const opal::Document* member = doc.Find("fieldList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -101,23 +101,23 @@ smithy::Outcome DeserializeValidationException(const smithy return out; } -smithy::Document SerializeClientOptionalDefaults(const ClientOptionalDefaults& value) { - smithy::DocumentMap map; +opal::Document SerializeClientOptionalDefaults(const ClientOptionalDefaults& value) { + opal::DocumentMap map; if (value.member.has_value()) { - map.emplace("member", smithy::Document(static_cast((*value.member)))); + map.emplace("member", opal::Document(static_cast((*value.member)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeClientOptionalDefaults(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ClientOptionalDefaults: expected a map on the wire"); +opal::Outcome DeserializeClientOptionalDefaults(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ClientOptionalDefaults: expected a map on the wire"); ClientOptionalDefaults out; { - const smithy::Document* member = doc.Find("member"); + const opal::Document* member = doc.Find("member"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("ClientOptionalDefaults.member: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("ClientOptionalDefaults.member: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("ClientOptionalDefaults.member: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("ClientOptionalDefaults.member: value out of range"); parsed_member = static_cast(member->as_int()); out.member = std::move(parsed_member); } @@ -125,22 +125,22 @@ smithy::Outcome DeserializeClientOptionalDefaults(const return out; } -smithy::Document SerializeComplexNestedErrorData(const ComplexNestedErrorData& value) { - smithy::DocumentMap map; +opal::Document SerializeComplexNestedErrorData(const ComplexNestedErrorData& value) { + opal::DocumentMap map; if (value.Foo.has_value()) { - map.emplace("Foo", smithy::Document((*value.Foo))); + map.emplace("Foo", opal::Document((*value.Foo))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeComplexNestedErrorData(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ComplexNestedErrorData: expected a map on the wire"); +opal::Outcome DeserializeComplexNestedErrorData(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ComplexNestedErrorData: expected a map on the wire"); ComplexNestedErrorData out; { - const smithy::Document* member = doc.Find("Foo"); + const opal::Document* member = doc.Find("Foo"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("ComplexNestedErrorData.Foo: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ComplexNestedErrorData.Foo: unexpected type on the wire"); parsed_member = member->as_string(); out.Foo = std::move(parsed_member); } @@ -148,31 +148,31 @@ smithy::Outcome DeserializeComplexNestedErrorData(const return out; } -smithy::Document SerializeComplexError(const ComplexError& value) { - smithy::DocumentMap map; +opal::Document SerializeComplexError(const ComplexError& value) { + opal::DocumentMap map; if (value.TopLevel.has_value()) { - map.emplace("TopLevel", smithy::Document((*value.TopLevel))); + map.emplace("TopLevel", opal::Document((*value.TopLevel))); } if (value.Nested.has_value()) { map.emplace("Nested", SerializeComplexNestedErrorData((*value.Nested))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeComplexError(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("ComplexError: expected a map on the wire"); +opal::Outcome DeserializeComplexError(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("ComplexError: expected a map on the wire"); ComplexError out; { - const smithy::Document* member = doc.Find("TopLevel"); + const opal::Document* member = doc.Find("TopLevel"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("ComplexError.TopLevel: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("ComplexError.TopLevel: unexpected type on the wire"); parsed_member = member->as_string(); out.TopLevel = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("Nested"); + const opal::Document* member = doc.Find("Nested"); if (member != nullptr && !member->is_null()) { types::ComplexNestedErrorData parsed_member{}; { @@ -186,104 +186,104 @@ smithy::Outcome DeserializeComplexError(const smithy::Document& do return out; } -smithy::Document SerializeTestStringList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeTestStringList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeTestStringList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeTestStringList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = item->as_string(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeTestStringMap(const std::map& value) { - smithy::DocumentMap map; +opal::Document SerializeTestStringMap(const std::map& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { - map.emplace(key, smithy::Document(item)); + map.emplace(key, opal::Document(item)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome> DeserializeTestStringMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map: expected a map on the wire"); +opal::Outcome> DeserializeTestStringMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map: expected a map on the wire"); std::map out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::map{}: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::map{}: unexpected type on the wire"); parsed_item = item->as_string(); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeDefaults(const Defaults& value) { - smithy::DocumentMap map; - map.emplace("defaultString", smithy::Document(value.defaultString)); - map.emplace("defaultBoolean", smithy::Document(value.defaultBoolean)); +opal::Document SerializeDefaults(const Defaults& value) { + opal::DocumentMap map; + map.emplace("defaultString", opal::Document(value.defaultString)); + map.emplace("defaultBoolean", opal::Document(value.defaultBoolean)); map.emplace("defaultList", SerializeTestStringList(value.defaultList)); - map.emplace("defaultTimestamp", smithy::Document::FromTimestamp(value.defaultTimestamp, smithy::TimestampFormat::kEpochSeconds)); - map.emplace("defaultBlob", smithy::Document(value.defaultBlob)); - map.emplace("defaultByte", smithy::Document(static_cast(value.defaultByte))); - map.emplace("defaultShort", smithy::Document(static_cast(value.defaultShort))); - map.emplace("defaultInteger", smithy::Document(static_cast(value.defaultInteger))); - map.emplace("defaultLong", smithy::Document(static_cast(value.defaultLong))); - map.emplace("defaultFloat", smithy::Document(static_cast(value.defaultFloat))); - map.emplace("defaultDouble", smithy::Document(static_cast(value.defaultDouble))); + map.emplace("defaultTimestamp", opal::Document::FromTimestamp(value.defaultTimestamp, opal::TimestampFormat::kEpochSeconds)); + map.emplace("defaultBlob", opal::Document(value.defaultBlob)); + map.emplace("defaultByte", opal::Document(static_cast(value.defaultByte))); + map.emplace("defaultShort", opal::Document(static_cast(value.defaultShort))); + map.emplace("defaultInteger", opal::Document(static_cast(value.defaultInteger))); + map.emplace("defaultLong", opal::Document(static_cast(value.defaultLong))); + map.emplace("defaultFloat", opal::Document(static_cast(value.defaultFloat))); + map.emplace("defaultDouble", opal::Document(static_cast(value.defaultDouble))); map.emplace("defaultMap", SerializeTestStringMap(value.defaultMap)); - map.emplace("defaultEnum", smithy::Document(std::string(value.defaultEnum.ToString()))); - map.emplace("defaultIntEnum", smithy::Document(static_cast(value.defaultIntEnum))); - map.emplace("emptyString", smithy::Document(value.emptyString)); - map.emplace("falseBoolean", smithy::Document(value.falseBoolean)); - map.emplace("emptyBlob", smithy::Document(value.emptyBlob)); - map.emplace("zeroByte", smithy::Document(static_cast(value.zeroByte))); - map.emplace("zeroShort", smithy::Document(static_cast(value.zeroShort))); - map.emplace("zeroInteger", smithy::Document(static_cast(value.zeroInteger))); - map.emplace("zeroLong", smithy::Document(static_cast(value.zeroLong))); - map.emplace("zeroFloat", smithy::Document(static_cast(value.zeroFloat))); - map.emplace("zeroDouble", smithy::Document(static_cast(value.zeroDouble))); - return smithy::Document(std::move(map)); -} - -smithy::Outcome DeserializeDefaults(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Defaults: expected a map on the wire"); + map.emplace("defaultEnum", opal::Document(std::string(value.defaultEnum.ToString()))); + map.emplace("defaultIntEnum", opal::Document(static_cast(value.defaultIntEnum))); + map.emplace("emptyString", opal::Document(value.emptyString)); + map.emplace("falseBoolean", opal::Document(value.falseBoolean)); + map.emplace("emptyBlob", opal::Document(value.emptyBlob)); + map.emplace("zeroByte", opal::Document(static_cast(value.zeroByte))); + map.emplace("zeroShort", opal::Document(static_cast(value.zeroShort))); + map.emplace("zeroInteger", opal::Document(static_cast(value.zeroInteger))); + map.emplace("zeroLong", opal::Document(static_cast(value.zeroLong))); + map.emplace("zeroFloat", opal::Document(static_cast(value.zeroFloat))); + map.emplace("zeroDouble", opal::Document(static_cast(value.zeroDouble))); + return opal::Document(std::move(map)); +} + +opal::Outcome DeserializeDefaults(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Defaults: expected a map on the wire"); Defaults out; { - const smithy::Document* member = doc.Find("defaultString"); + const opal::Document* member = doc.Find("defaultString"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("Defaults.defaultString: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Defaults.defaultString: unexpected type on the wire"); parsed_member = member->as_string(); out.defaultString = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultBoolean"); + const opal::Document* member = doc.Find("defaultBoolean"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("Defaults.defaultBoolean: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("Defaults.defaultBoolean: unexpected type on the wire"); parsed_member = member->as_bool(); out.defaultBoolean = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultList"); + const opal::Document* member = doc.Find("defaultList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -295,11 +295,11 @@ smithy::Outcome DeserializeDefaults(const smithy::Document& doc) { } } { - const smithy::Document* member = doc.Find("defaultTimestamp"); + const opal::Document* member = doc.Find("defaultTimestamp"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kEpochSeconds); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kEpochSeconds); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -307,11 +307,11 @@ smithy::Outcome DeserializeDefaults(const smithy::Document& doc) { } } { - const smithy::Document* member = doc.Find("defaultBlob"); + const opal::Document* member = doc.Find("defaultBlob"); if (member != nullptr && !member->is_null()) { - smithy::Blob parsed_member{}; + opal::Blob parsed_member{}; { - auto parsed = smithy::BlobFromDocument(*member); + auto parsed = opal::BlobFromDocument(*member); if (!parsed) return std::move(parsed).error(); parsed_member = std::move(*parsed); } @@ -319,72 +319,72 @@ smithy::Outcome DeserializeDefaults(const smithy::Document& doc) { } } { - const smithy::Document* member = doc.Find("defaultByte"); + const opal::Document* member = doc.Find("defaultByte"); if (member != nullptr && !member->is_null()) { std::int8_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("Defaults.defaultByte: unexpected type on the wire"); - if (member->as_int() < -128 || member->as_int() > 127) return smithy::Error::Serialization("Defaults.defaultByte: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("Defaults.defaultByte: unexpected type on the wire"); + if (member->as_int() < -128 || member->as_int() > 127) return opal::Error::Serialization("Defaults.defaultByte: value out of range"); parsed_member = static_cast(member->as_int()); out.defaultByte = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultShort"); + const opal::Document* member = doc.Find("defaultShort"); if (member != nullptr && !member->is_null()) { std::int16_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("Defaults.defaultShort: unexpected type on the wire"); - if (member->as_int() < -32768 || member->as_int() > 32767) return smithy::Error::Serialization("Defaults.defaultShort: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("Defaults.defaultShort: unexpected type on the wire"); + if (member->as_int() < -32768 || member->as_int() > 32767) return opal::Error::Serialization("Defaults.defaultShort: value out of range"); parsed_member = static_cast(member->as_int()); out.defaultShort = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultInteger"); + const opal::Document* member = doc.Find("defaultInteger"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("Defaults.defaultInteger: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("Defaults.defaultInteger: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("Defaults.defaultInteger: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("Defaults.defaultInteger: value out of range"); parsed_member = static_cast(member->as_int()); out.defaultInteger = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultLong"); + const opal::Document* member = doc.Find("defaultLong"); if (member != nullptr && !member->is_null()) { std::int64_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("Defaults.defaultLong: unexpected type on the wire"); + if (!member->is_int()) return opal::Error::Serialization("Defaults.defaultLong: unexpected type on the wire"); parsed_member = static_cast(member->as_int()); out.defaultLong = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultFloat"); + const opal::Document* member = doc.Find("defaultFloat"); if (member != nullptr && !member->is_null()) { float parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("Defaults.defaultFloat: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("Defaults.defaultFloat: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("Defaults.defaultFloat: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("Defaults.defaultFloat: value out of range"); parsed_member = *narrowed; } out.defaultFloat = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultDouble"); + const opal::Document* member = doc.Find("defaultDouble"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("Defaults.defaultDouble: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("Defaults.defaultDouble: expected a number"); parsed_member = static_cast(*parsed); } out.defaultDouble = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultMap"); + const opal::Document* member = doc.Find("defaultMap"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -396,48 +396,48 @@ smithy::Outcome DeserializeDefaults(const smithy::Document& doc) { } } { - const smithy::Document* member = doc.Find("defaultEnum"); + const opal::Document* member = doc.Find("defaultEnum"); if (member != nullptr && !member->is_null()) { types::TestEnum parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("Defaults.defaultEnum: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Defaults.defaultEnum: unexpected type on the wire"); parsed_member = types::TestEnum::FromString(member->as_string()); out.defaultEnum = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultIntEnum"); + const opal::Document* member = doc.Find("defaultIntEnum"); if (member != nullptr && !member->is_null()) { types::TestIntEnum parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("Defaults.defaultIntEnum: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("Defaults.defaultIntEnum: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("Defaults.defaultIntEnum: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("Defaults.defaultIntEnum: value out of range"); parsed_member = static_cast(member->as_int()); out.defaultIntEnum = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("emptyString"); + const opal::Document* member = doc.Find("emptyString"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("Defaults.emptyString: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Defaults.emptyString: unexpected type on the wire"); parsed_member = member->as_string(); out.emptyString = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("falseBoolean"); + const opal::Document* member = doc.Find("falseBoolean"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("Defaults.falseBoolean: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("Defaults.falseBoolean: unexpected type on the wire"); parsed_member = member->as_bool(); out.falseBoolean = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("emptyBlob"); + const opal::Document* member = doc.Find("emptyBlob"); if (member != nullptr && !member->is_null()) { - smithy::Blob parsed_member{}; + opal::Blob parsed_member{}; { - auto parsed = smithy::BlobFromDocument(*member); + auto parsed = opal::BlobFromDocument(*member); if (!parsed) return std::move(parsed).error(); parsed_member = std::move(*parsed); } @@ -445,65 +445,65 @@ smithy::Outcome DeserializeDefaults(const smithy::Document& doc) { } } { - const smithy::Document* member = doc.Find("zeroByte"); + const opal::Document* member = doc.Find("zeroByte"); if (member != nullptr && !member->is_null()) { std::int8_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("Defaults.zeroByte: unexpected type on the wire"); - if (member->as_int() < -128 || member->as_int() > 127) return smithy::Error::Serialization("Defaults.zeroByte: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("Defaults.zeroByte: unexpected type on the wire"); + if (member->as_int() < -128 || member->as_int() > 127) return opal::Error::Serialization("Defaults.zeroByte: value out of range"); parsed_member = static_cast(member->as_int()); out.zeroByte = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("zeroShort"); + const opal::Document* member = doc.Find("zeroShort"); if (member != nullptr && !member->is_null()) { std::int16_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("Defaults.zeroShort: unexpected type on the wire"); - if (member->as_int() < -32768 || member->as_int() > 32767) return smithy::Error::Serialization("Defaults.zeroShort: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("Defaults.zeroShort: unexpected type on the wire"); + if (member->as_int() < -32768 || member->as_int() > 32767) return opal::Error::Serialization("Defaults.zeroShort: value out of range"); parsed_member = static_cast(member->as_int()); out.zeroShort = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("zeroInteger"); + const opal::Document* member = doc.Find("zeroInteger"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("Defaults.zeroInteger: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("Defaults.zeroInteger: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("Defaults.zeroInteger: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("Defaults.zeroInteger: value out of range"); parsed_member = static_cast(member->as_int()); out.zeroInteger = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("zeroLong"); + const opal::Document* member = doc.Find("zeroLong"); if (member != nullptr && !member->is_null()) { std::int64_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("Defaults.zeroLong: unexpected type on the wire"); + if (!member->is_int()) return opal::Error::Serialization("Defaults.zeroLong: unexpected type on the wire"); parsed_member = static_cast(member->as_int()); out.zeroLong = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("zeroFloat"); + const opal::Document* member = doc.Find("zeroFloat"); if (member != nullptr && !member->is_null()) { float parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("Defaults.zeroFloat: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("Defaults.zeroFloat: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("Defaults.zeroFloat: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("Defaults.zeroFloat: value out of range"); parsed_member = *narrowed; } out.zeroFloat = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("zeroDouble"); + const opal::Document* member = doc.Find("zeroDouble"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("Defaults.zeroDouble: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("Defaults.zeroDouble: expected a number"); parsed_member = static_cast(*parsed); } out.zeroDouble = std::move(parsed_member); @@ -512,90 +512,90 @@ smithy::Outcome DeserializeDefaults(const smithy::Document& doc) { return out; } -smithy::Document SerializeDenseBooleanMap(const std::map& value) { - smithy::DocumentMap map; +opal::Document SerializeDenseBooleanMap(const std::map& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { - map.emplace(key, smithy::Document(item)); + map.emplace(key, opal::Document(item)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome> DeserializeDenseBooleanMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map: expected a map on the wire"); +opal::Outcome> DeserializeDenseBooleanMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map: expected a map on the wire"); std::map out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; bool parsed_item{}; - if (!item->is_bool()) return smithy::Error::Serialization("std::map{}: unexpected type on the wire"); + if (!item->is_bool()) return opal::Error::Serialization("std::map{}: unexpected type on the wire"); parsed_item = item->as_bool(); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeDenseNumberMap(const std::map& value) { - smithy::DocumentMap map; +opal::Document SerializeDenseNumberMap(const std::map& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { - map.emplace(key, smithy::Document(static_cast(item))); + map.emplace(key, opal::Document(static_cast(item))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome> DeserializeDenseNumberMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map: expected a map on the wire"); +opal::Outcome> DeserializeDenseNumberMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map: expected a map on the wire"); std::map out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; std::int32_t parsed_item{}; - if (!item->is_int()) return smithy::Error::Serialization("std::map{}: unexpected type on the wire"); - if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return smithy::Error::Serialization("std::map{}: value out of range"); + if (!item->is_int()) return opal::Error::Serialization("std::map{}: unexpected type on the wire"); + if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return opal::Error::Serialization("std::map{}: value out of range"); parsed_item = static_cast(item->as_int()); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeStringSet(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeStringSet(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeStringSet(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeStringSet(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = item->as_string(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeDenseSetMap(const std::map>& value) { - smithy::DocumentMap map; +opal::Document SerializeDenseSetMap(const std::map>& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { map.emplace(key, SerializeStringSet(item)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome>> DeserializeDenseSetMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map>: expected a map on the wire"); +opal::Outcome>> DeserializeDenseSetMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map>: expected a map on the wire"); std::map> out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; std::vector parsed_item{}; @@ -609,45 +609,45 @@ smithy::Outcome>> DeserializeDens return out; } -smithy::Document SerializeDenseStringMap(const std::map& value) { - smithy::DocumentMap map; +opal::Document SerializeDenseStringMap(const std::map& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { - map.emplace(key, smithy::Document(item)); + map.emplace(key, opal::Document(item)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome> DeserializeDenseStringMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map: expected a map on the wire"); +opal::Outcome> DeserializeDenseStringMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map: expected a map on the wire"); std::map out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::map{}: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::map{}: unexpected type on the wire"); parsed_item = item->as_string(); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeGreetingStruct(const GreetingStruct& value) { - smithy::DocumentMap map; +opal::Document SerializeGreetingStruct(const GreetingStruct& value) { + opal::DocumentMap map; if (value.hi.has_value()) { - map.emplace("hi", smithy::Document((*value.hi))); + map.emplace("hi", opal::Document((*value.hi))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGreetingStruct(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GreetingStruct: expected a map on the wire"); +opal::Outcome DeserializeGreetingStruct(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GreetingStruct: expected a map on the wire"); GreetingStruct out; { - const smithy::Document* member = doc.Find("hi"); + const opal::Document* member = doc.Find("hi"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("GreetingStruct.hi: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GreetingStruct.hi: unexpected type on the wire"); parsed_member = member->as_string(); out.hi = std::move(parsed_member); } @@ -655,19 +655,19 @@ smithy::Outcome DeserializeGreetingStruct(const smithy::Document return out; } -smithy::Document SerializeDenseStructMap(const std::map& value) { - smithy::DocumentMap map; +opal::Document SerializeDenseStructMap(const std::map& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { map.emplace(key, SerializeGreetingStruct(item)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome> DeserializeDenseStructMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map: expected a map on the wire"); +opal::Outcome> DeserializeDenseStructMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map: expected a map on the wire"); std::map out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; GreetingStruct parsed_item{}; @@ -681,57 +681,57 @@ smithy::Outcome> DeserializeDenseStructMap return out; } -smithy::Document SerializeEmptyInputOutputInput(const EmptyInputOutputInput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeEmptyInputOutputInput(const EmptyInputOutputInput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeEmptyInputOutputInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("EmptyInputOutputInput: expected a map on the wire"); +opal::Outcome DeserializeEmptyInputOutputInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("EmptyInputOutputInput: expected a map on the wire"); EmptyInputOutputInput out; return out; } -smithy::Document SerializeEmptyInputOutputOutput(const EmptyInputOutputOutput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeEmptyInputOutputOutput(const EmptyInputOutputOutput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeEmptyInputOutputOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("EmptyInputOutputOutput: expected a map on the wire"); +opal::Outcome DeserializeEmptyInputOutputOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("EmptyInputOutputOutput: expected a map on the wire"); EmptyInputOutputOutput out; return out; } -smithy::Document SerializeFloat16Input(const Float16Input& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeFloat16Input(const Float16Input& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeFloat16Input(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Float16Input: expected a map on the wire"); +opal::Outcome DeserializeFloat16Input(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Float16Input: expected a map on the wire"); Float16Input out; return out; } -smithy::Document SerializeFloat16Output(const Float16Output& value) { - smithy::DocumentMap map; +opal::Document SerializeFloat16Output(const Float16Output& value) { + opal::DocumentMap map; if (value.value.has_value()) { - map.emplace("value", smithy::Document(static_cast((*value.value)))); + map.emplace("value", opal::Document(static_cast((*value.value)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeFloat16Output(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Float16Output: expected a map on the wire"); +opal::Outcome DeserializeFloat16Output(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Float16Output: expected a map on the wire"); Float16Output out; { - const smithy::Document* member = doc.Find("value"); + const opal::Document* member = doc.Find("value"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("Float16Output.value: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("Float16Output.value: expected a number"); parsed_member = static_cast(*parsed); } out.value = std::move(parsed_member); @@ -740,34 +740,34 @@ smithy::Outcome DeserializeFloat16Output(const smithy::Document& return out; } -smithy::Document SerializeFractionalSecondsInput(const FractionalSecondsInput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeFractionalSecondsInput(const FractionalSecondsInput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeFractionalSecondsInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("FractionalSecondsInput: expected a map on the wire"); +opal::Outcome DeserializeFractionalSecondsInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("FractionalSecondsInput: expected a map on the wire"); FractionalSecondsInput out; return out; } -smithy::Document SerializeFractionalSecondsOutput(const FractionalSecondsOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeFractionalSecondsOutput(const FractionalSecondsOutput& value) { + opal::DocumentMap map; if (value.datetime.has_value()) { - map.emplace("datetime", smithy::Document::FromTimestamp((*value.datetime), smithy::TimestampFormat::kDateTime)); + map.emplace("datetime", opal::Document::FromTimestamp((*value.datetime), opal::TimestampFormat::kDateTime)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeFractionalSecondsOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("FractionalSecondsOutput: expected a map on the wire"); +opal::Outcome DeserializeFractionalSecondsOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("FractionalSecondsOutput: expected a map on the wire"); FractionalSecondsOutput out; { - const smithy::Document* member = doc.Find("datetime"); + const opal::Document* member = doc.Find("datetime"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kDateTime); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kDateTime); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -777,33 +777,33 @@ smithy::Outcome DeserializeFractionalSecondsOutput(cons return out; } -smithy::Document SerializeGreetingWithErrorsInput(const GreetingWithErrorsInput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeGreetingWithErrorsInput(const GreetingWithErrorsInput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGreetingWithErrorsInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GreetingWithErrorsInput: expected a map on the wire"); +opal::Outcome DeserializeGreetingWithErrorsInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GreetingWithErrorsInput: expected a map on the wire"); GreetingWithErrorsInput out; return out; } -smithy::Document SerializeGreetingWithErrorsOutput(const GreetingWithErrorsOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeGreetingWithErrorsOutput(const GreetingWithErrorsOutput& value) { + opal::DocumentMap map; if (value.greeting.has_value()) { - map.emplace("greeting", smithy::Document((*value.greeting))); + map.emplace("greeting", opal::Document((*value.greeting))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGreetingWithErrorsOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GreetingWithErrorsOutput: expected a map on the wire"); +opal::Outcome DeserializeGreetingWithErrorsOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GreetingWithErrorsOutput: expected a map on the wire"); GreetingWithErrorsOutput out; { - const smithy::Document* member = doc.Find("greeting"); + const opal::Document* member = doc.Find("greeting"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("GreetingWithErrorsOutput.greeting: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GreetingWithErrorsOutput.greeting: unexpected type on the wire"); parsed_member = member->as_string(); out.greeting = std::move(parsed_member); } @@ -811,22 +811,22 @@ smithy::Outcome DeserializeGreetingWithErrorsOutput(co return out; } -smithy::Document SerializeInvalidGreeting(const InvalidGreeting& value) { - smithy::DocumentMap map; +opal::Document SerializeInvalidGreeting(const InvalidGreeting& value) { + opal::DocumentMap map; if (value.Message.has_value()) { - map.emplace("Message", smithy::Document((*value.Message))); + map.emplace("Message", opal::Document((*value.Message))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeInvalidGreeting(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("InvalidGreeting: expected a map on the wire"); +opal::Outcome DeserializeInvalidGreeting(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("InvalidGreeting: expected a map on the wire"); InvalidGreeting out; { - const smithy::Document* member = doc.Find("Message"); + const opal::Document* member = doc.Find("Message"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("InvalidGreeting.Message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("InvalidGreeting.Message: unexpected type on the wire"); parsed_member = member->as_string(); out.Message = std::move(parsed_member); } @@ -834,30 +834,30 @@ smithy::Outcome DeserializeInvalidGreeting(const smithy::Docume return out; } -smithy::Document SerializeNoInputOutputInput(const NoInputOutputInput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeNoInputOutputInput(const NoInputOutputInput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNoInputOutputInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("NoInputOutputInput: expected a map on the wire"); +opal::Outcome DeserializeNoInputOutputInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("NoInputOutputInput: expected a map on the wire"); NoInputOutputInput out; return out; } -smithy::Document SerializeNoInputOutputOutput(const NoInputOutputOutput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeNoInputOutputOutput(const NoInputOutputOutput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNoInputOutputOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("NoInputOutputOutput: expected a map on the wire"); +opal::Outcome DeserializeNoInputOutputOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("NoInputOutputOutput: expected a map on the wire"); NoInputOutputOutput out; return out; } -smithy::Document SerializeOperationWithDefaultsInput(const OperationWithDefaultsInput& value) { - smithy::DocumentMap map; +opal::Document SerializeOperationWithDefaultsInput(const OperationWithDefaultsInput& value) { + opal::DocumentMap map; if (value.defaults.has_value()) { map.emplace("defaults", SerializeDefaults((*value.defaults))); } @@ -865,19 +865,19 @@ smithy::Document SerializeOperationWithDefaultsInput(const OperationWithDefaults map.emplace("clientOptionalDefaults", SerializeClientOptionalDefaults((*value.clientOptionalDefaults))); } if (value.topLevelDefault.has_value()) { - map.emplace("topLevelDefault", smithy::Document((*value.topLevelDefault))); + map.emplace("topLevelDefault", opal::Document((*value.topLevelDefault))); } if (value.otherTopLevelDefault.has_value()) { - map.emplace("otherTopLevelDefault", smithy::Document(static_cast((*value.otherTopLevelDefault)))); + map.emplace("otherTopLevelDefault", opal::Document(static_cast((*value.otherTopLevelDefault)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOperationWithDefaultsInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OperationWithDefaultsInput: expected a map on the wire"); +opal::Outcome DeserializeOperationWithDefaultsInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OperationWithDefaultsInput: expected a map on the wire"); OperationWithDefaultsInput out; { - const smithy::Document* member = doc.Find("defaults"); + const opal::Document* member = doc.Find("defaults"); if (member != nullptr && !member->is_null()) { types::Defaults parsed_member{}; { @@ -889,7 +889,7 @@ smithy::Outcome DeserializeOperationWithDefaultsInpu } } { - const smithy::Document* member = doc.Find("clientOptionalDefaults"); + const opal::Document* member = doc.Find("clientOptionalDefaults"); if (member != nullptr && !member->is_null()) { types::ClientOptionalDefaults parsed_member{}; { @@ -901,10 +901,10 @@ smithy::Outcome DeserializeOperationWithDefaultsInpu } } { - const smithy::Document* member = doc.Find("topLevelDefault"); + const opal::Document* member = doc.Find("topLevelDefault"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("OperationWithDefaultsInput.topLevelDefault: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OperationWithDefaultsInput.topLevelDefault: unexpected type on the wire"); parsed_member = member->as_string(); out.topLevelDefault = std::move(parsed_member); } else { @@ -912,11 +912,11 @@ smithy::Outcome DeserializeOperationWithDefaultsInpu } } { - const smithy::Document* member = doc.Find("otherTopLevelDefault"); + const opal::Document* member = doc.Find("otherTopLevelDefault"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("OperationWithDefaultsInput.otherTopLevelDefault: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("OperationWithDefaultsInput.otherTopLevelDefault: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("OperationWithDefaultsInput.otherTopLevelDefault: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("OperationWithDefaultsInput.otherTopLevelDefault: value out of range"); parsed_member = static_cast(member->as_int()); out.otherTopLevelDefault = std::move(parsed_member); } else { @@ -926,57 +926,57 @@ smithy::Outcome DeserializeOperationWithDefaultsInpu return out; } -smithy::Document SerializeOperationWithDefaultsOutput(const OperationWithDefaultsOutput& value) { - smithy::DocumentMap map; - map.emplace("defaultString", smithy::Document(value.defaultString)); - map.emplace("defaultBoolean", smithy::Document(value.defaultBoolean)); +opal::Document SerializeOperationWithDefaultsOutput(const OperationWithDefaultsOutput& value) { + opal::DocumentMap map; + map.emplace("defaultString", opal::Document(value.defaultString)); + map.emplace("defaultBoolean", opal::Document(value.defaultBoolean)); map.emplace("defaultList", SerializeTestStringList(value.defaultList)); - map.emplace("defaultTimestamp", smithy::Document::FromTimestamp(value.defaultTimestamp, smithy::TimestampFormat::kEpochSeconds)); - map.emplace("defaultBlob", smithy::Document(value.defaultBlob)); - map.emplace("defaultByte", smithy::Document(static_cast(value.defaultByte))); - map.emplace("defaultShort", smithy::Document(static_cast(value.defaultShort))); - map.emplace("defaultInteger", smithy::Document(static_cast(value.defaultInteger))); - map.emplace("defaultLong", smithy::Document(static_cast(value.defaultLong))); - map.emplace("defaultFloat", smithy::Document(static_cast(value.defaultFloat))); - map.emplace("defaultDouble", smithy::Document(static_cast(value.defaultDouble))); + map.emplace("defaultTimestamp", opal::Document::FromTimestamp(value.defaultTimestamp, opal::TimestampFormat::kEpochSeconds)); + map.emplace("defaultBlob", opal::Document(value.defaultBlob)); + map.emplace("defaultByte", opal::Document(static_cast(value.defaultByte))); + map.emplace("defaultShort", opal::Document(static_cast(value.defaultShort))); + map.emplace("defaultInteger", opal::Document(static_cast(value.defaultInteger))); + map.emplace("defaultLong", opal::Document(static_cast(value.defaultLong))); + map.emplace("defaultFloat", opal::Document(static_cast(value.defaultFloat))); + map.emplace("defaultDouble", opal::Document(static_cast(value.defaultDouble))); map.emplace("defaultMap", SerializeTestStringMap(value.defaultMap)); - map.emplace("defaultEnum", smithy::Document(std::string(value.defaultEnum.ToString()))); - map.emplace("defaultIntEnum", smithy::Document(static_cast(value.defaultIntEnum))); - map.emplace("emptyString", smithy::Document(value.emptyString)); - map.emplace("falseBoolean", smithy::Document(value.falseBoolean)); - map.emplace("emptyBlob", smithy::Document(value.emptyBlob)); - map.emplace("zeroByte", smithy::Document(static_cast(value.zeroByte))); - map.emplace("zeroShort", smithy::Document(static_cast(value.zeroShort))); - map.emplace("zeroInteger", smithy::Document(static_cast(value.zeroInteger))); - map.emplace("zeroLong", smithy::Document(static_cast(value.zeroLong))); - map.emplace("zeroFloat", smithy::Document(static_cast(value.zeroFloat))); - map.emplace("zeroDouble", smithy::Document(static_cast(value.zeroDouble))); - return smithy::Document(std::move(map)); -} - -smithy::Outcome DeserializeOperationWithDefaultsOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OperationWithDefaultsOutput: expected a map on the wire"); + map.emplace("defaultEnum", opal::Document(std::string(value.defaultEnum.ToString()))); + map.emplace("defaultIntEnum", opal::Document(static_cast(value.defaultIntEnum))); + map.emplace("emptyString", opal::Document(value.emptyString)); + map.emplace("falseBoolean", opal::Document(value.falseBoolean)); + map.emplace("emptyBlob", opal::Document(value.emptyBlob)); + map.emplace("zeroByte", opal::Document(static_cast(value.zeroByte))); + map.emplace("zeroShort", opal::Document(static_cast(value.zeroShort))); + map.emplace("zeroInteger", opal::Document(static_cast(value.zeroInteger))); + map.emplace("zeroLong", opal::Document(static_cast(value.zeroLong))); + map.emplace("zeroFloat", opal::Document(static_cast(value.zeroFloat))); + map.emplace("zeroDouble", opal::Document(static_cast(value.zeroDouble))); + return opal::Document(std::move(map)); +} + +opal::Outcome DeserializeOperationWithDefaultsOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OperationWithDefaultsOutput: expected a map on the wire"); OperationWithDefaultsOutput out; { - const smithy::Document* member = doc.Find("defaultString"); + const opal::Document* member = doc.Find("defaultString"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultString: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultString: unexpected type on the wire"); parsed_member = member->as_string(); out.defaultString = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultBoolean"); + const opal::Document* member = doc.Find("defaultBoolean"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultBoolean: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultBoolean: unexpected type on the wire"); parsed_member = member->as_bool(); out.defaultBoolean = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultList"); + const opal::Document* member = doc.Find("defaultList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -988,11 +988,11 @@ smithy::Outcome DeserializeOperationWithDefaultsOut } } { - const smithy::Document* member = doc.Find("defaultTimestamp"); + const opal::Document* member = doc.Find("defaultTimestamp"); if (member != nullptr && !member->is_null()) { - smithy::Timestamp parsed_member{}; + opal::Timestamp parsed_member{}; { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kEpochSeconds); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kEpochSeconds); if (!parsed) return std::move(parsed).error(); parsed_member = *parsed; } @@ -1000,11 +1000,11 @@ smithy::Outcome DeserializeOperationWithDefaultsOut } } { - const smithy::Document* member = doc.Find("defaultBlob"); + const opal::Document* member = doc.Find("defaultBlob"); if (member != nullptr && !member->is_null()) { - smithy::Blob parsed_member{}; + opal::Blob parsed_member{}; { - auto parsed = smithy::BlobFromDocument(*member); + auto parsed = opal::BlobFromDocument(*member); if (!parsed) return std::move(parsed).error(); parsed_member = std::move(*parsed); } @@ -1012,72 +1012,72 @@ smithy::Outcome DeserializeOperationWithDefaultsOut } } { - const smithy::Document* member = doc.Find("defaultByte"); + const opal::Document* member = doc.Find("defaultByte"); if (member != nullptr && !member->is_null()) { std::int8_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultByte: unexpected type on the wire"); - if (member->as_int() < -128 || member->as_int() > 127) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultByte: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultByte: unexpected type on the wire"); + if (member->as_int() < -128 || member->as_int() > 127) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultByte: value out of range"); parsed_member = static_cast(member->as_int()); out.defaultByte = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultShort"); + const opal::Document* member = doc.Find("defaultShort"); if (member != nullptr && !member->is_null()) { std::int16_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultShort: unexpected type on the wire"); - if (member->as_int() < -32768 || member->as_int() > 32767) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultShort: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultShort: unexpected type on the wire"); + if (member->as_int() < -32768 || member->as_int() > 32767) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultShort: value out of range"); parsed_member = static_cast(member->as_int()); out.defaultShort = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultInteger"); + const opal::Document* member = doc.Find("defaultInteger"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultInteger: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultInteger: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultInteger: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultInteger: value out of range"); parsed_member = static_cast(member->as_int()); out.defaultInteger = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultLong"); + const opal::Document* member = doc.Find("defaultLong"); if (member != nullptr && !member->is_null()) { std::int64_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultLong: unexpected type on the wire"); + if (!member->is_int()) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultLong: unexpected type on the wire"); parsed_member = static_cast(member->as_int()); out.defaultLong = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultFloat"); + const opal::Document* member = doc.Find("defaultFloat"); if (member != nullptr && !member->is_null()) { float parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultFloat: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultFloat: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultFloat: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultFloat: value out of range"); parsed_member = *narrowed; } out.defaultFloat = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultDouble"); + const opal::Document* member = doc.Find("defaultDouble"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultDouble: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultDouble: expected a number"); parsed_member = static_cast(*parsed); } out.defaultDouble = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultMap"); + const opal::Document* member = doc.Find("defaultMap"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -1089,48 +1089,48 @@ smithy::Outcome DeserializeOperationWithDefaultsOut } } { - const smithy::Document* member = doc.Find("defaultEnum"); + const opal::Document* member = doc.Find("defaultEnum"); if (member != nullptr && !member->is_null()) { types::TestEnum parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultEnum: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultEnum: unexpected type on the wire"); parsed_member = types::TestEnum::FromString(member->as_string()); out.defaultEnum = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("defaultIntEnum"); + const opal::Document* member = doc.Find("defaultIntEnum"); if (member != nullptr && !member->is_null()) { types::TestIntEnum parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultIntEnum: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("OperationWithDefaultsOutput.defaultIntEnum: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultIntEnum: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("OperationWithDefaultsOutput.defaultIntEnum: value out of range"); parsed_member = static_cast(member->as_int()); out.defaultIntEnum = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("emptyString"); + const opal::Document* member = doc.Find("emptyString"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("OperationWithDefaultsOutput.emptyString: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OperationWithDefaultsOutput.emptyString: unexpected type on the wire"); parsed_member = member->as_string(); out.emptyString = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("falseBoolean"); + const opal::Document* member = doc.Find("falseBoolean"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("OperationWithDefaultsOutput.falseBoolean: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("OperationWithDefaultsOutput.falseBoolean: unexpected type on the wire"); parsed_member = member->as_bool(); out.falseBoolean = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("emptyBlob"); + const opal::Document* member = doc.Find("emptyBlob"); if (member != nullptr && !member->is_null()) { - smithy::Blob parsed_member{}; + opal::Blob parsed_member{}; { - auto parsed = smithy::BlobFromDocument(*member); + auto parsed = opal::BlobFromDocument(*member); if (!parsed) return std::move(parsed).error(); parsed_member = std::move(*parsed); } @@ -1138,65 +1138,65 @@ smithy::Outcome DeserializeOperationWithDefaultsOut } } { - const smithy::Document* member = doc.Find("zeroByte"); + const opal::Document* member = doc.Find("zeroByte"); if (member != nullptr && !member->is_null()) { std::int8_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("OperationWithDefaultsOutput.zeroByte: unexpected type on the wire"); - if (member->as_int() < -128 || member->as_int() > 127) return smithy::Error::Serialization("OperationWithDefaultsOutput.zeroByte: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("OperationWithDefaultsOutput.zeroByte: unexpected type on the wire"); + if (member->as_int() < -128 || member->as_int() > 127) return opal::Error::Serialization("OperationWithDefaultsOutput.zeroByte: value out of range"); parsed_member = static_cast(member->as_int()); out.zeroByte = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("zeroShort"); + const opal::Document* member = doc.Find("zeroShort"); if (member != nullptr && !member->is_null()) { std::int16_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("OperationWithDefaultsOutput.zeroShort: unexpected type on the wire"); - if (member->as_int() < -32768 || member->as_int() > 32767) return smithy::Error::Serialization("OperationWithDefaultsOutput.zeroShort: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("OperationWithDefaultsOutput.zeroShort: unexpected type on the wire"); + if (member->as_int() < -32768 || member->as_int() > 32767) return opal::Error::Serialization("OperationWithDefaultsOutput.zeroShort: value out of range"); parsed_member = static_cast(member->as_int()); out.zeroShort = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("zeroInteger"); + const opal::Document* member = doc.Find("zeroInteger"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("OperationWithDefaultsOutput.zeroInteger: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("OperationWithDefaultsOutput.zeroInteger: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("OperationWithDefaultsOutput.zeroInteger: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("OperationWithDefaultsOutput.zeroInteger: value out of range"); parsed_member = static_cast(member->as_int()); out.zeroInteger = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("zeroLong"); + const opal::Document* member = doc.Find("zeroLong"); if (member != nullptr && !member->is_null()) { std::int64_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("OperationWithDefaultsOutput.zeroLong: unexpected type on the wire"); + if (!member->is_int()) return opal::Error::Serialization("OperationWithDefaultsOutput.zeroLong: unexpected type on the wire"); parsed_member = static_cast(member->as_int()); out.zeroLong = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("zeroFloat"); + const opal::Document* member = doc.Find("zeroFloat"); if (member != nullptr && !member->is_null()) { float parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("OperationWithDefaultsOutput.zeroFloat: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("OperationWithDefaultsOutput.zeroFloat: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("OperationWithDefaultsOutput.zeroFloat: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("OperationWithDefaultsOutput.zeroFloat: value out of range"); parsed_member = *narrowed; } out.zeroFloat = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("zeroDouble"); + const opal::Document* member = doc.Find("zeroDouble"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("OperationWithDefaultsOutput.zeroDouble: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("OperationWithDefaultsOutput.zeroDouble: expected a number"); parsed_member = static_cast(*parsed); } out.zeroDouble = std::move(parsed_member); @@ -1205,22 +1205,22 @@ smithy::Outcome DeserializeOperationWithDefaultsOut return out; } -smithy::Document SerializeOptionalInputOutputInput(const OptionalInputOutputInput& value) { - smithy::DocumentMap map; +opal::Document SerializeOptionalInputOutputInput(const OptionalInputOutputInput& value) { + opal::DocumentMap map; if (value.value.has_value()) { - map.emplace("value", smithy::Document((*value.value))); + map.emplace("value", opal::Document((*value.value))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOptionalInputOutputInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OptionalInputOutputInput: expected a map on the wire"); +opal::Outcome DeserializeOptionalInputOutputInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OptionalInputOutputInput: expected a map on the wire"); OptionalInputOutputInput out; { - const smithy::Document* member = doc.Find("value"); + const opal::Document* member = doc.Find("value"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("OptionalInputOutputInput.value: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OptionalInputOutputInput.value: unexpected type on the wire"); parsed_member = member->as_string(); out.value = std::move(parsed_member); } @@ -1228,22 +1228,22 @@ smithy::Outcome DeserializeOptionalInputOutputInput(co return out; } -smithy::Document SerializeOptionalInputOutputOutput(const OptionalInputOutputOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeOptionalInputOutputOutput(const OptionalInputOutputOutput& value) { + opal::DocumentMap map; if (value.value.has_value()) { - map.emplace("value", smithy::Document((*value.value))); + map.emplace("value", opal::Document((*value.value))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOptionalInputOutputOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OptionalInputOutputOutput: expected a map on the wire"); +opal::Outcome DeserializeOptionalInputOutputOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OptionalInputOutputOutput: expected a map on the wire"); OptionalInputOutputOutput out; { - const smithy::Document* member = doc.Find("value"); + const opal::Document* member = doc.Find("value"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("OptionalInputOutputOutput.value: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OptionalInputOutputOutput.value: unexpected type on the wire"); parsed_member = member->as_string(); out.value = std::move(parsed_member); } @@ -1251,8 +1251,8 @@ smithy::Outcome DeserializeOptionalInputOutputOutput( return out; } -smithy::Document SerializeRpcV2CborDenseMapsInput(const RpcV2CborDenseMapsInput& value) { - smithy::DocumentMap map; +opal::Document SerializeRpcV2CborDenseMapsInput(const RpcV2CborDenseMapsInput& value) { + opal::DocumentMap map; if (value.denseStructMap.has_value()) { map.emplace("denseStructMap", SerializeDenseStructMap((*value.denseStructMap))); } @@ -1268,14 +1268,14 @@ smithy::Document SerializeRpcV2CborDenseMapsInput(const RpcV2CborDenseMapsInput& if (value.denseSetMap.has_value()) { map.emplace("denseSetMap", SerializeDenseSetMap((*value.denseSetMap))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRpcV2CborDenseMapsInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RpcV2CborDenseMapsInput: expected a map on the wire"); +opal::Outcome DeserializeRpcV2CborDenseMapsInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RpcV2CborDenseMapsInput: expected a map on the wire"); RpcV2CborDenseMapsInput out; { - const smithy::Document* member = doc.Find("denseStructMap"); + const opal::Document* member = doc.Find("denseStructMap"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -1287,7 +1287,7 @@ smithy::Outcome DeserializeRpcV2CborDenseMapsInput(cons } } { - const smithy::Document* member = doc.Find("denseNumberMap"); + const opal::Document* member = doc.Find("denseNumberMap"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -1299,7 +1299,7 @@ smithy::Outcome DeserializeRpcV2CborDenseMapsInput(cons } } { - const smithy::Document* member = doc.Find("denseBooleanMap"); + const opal::Document* member = doc.Find("denseBooleanMap"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -1311,7 +1311,7 @@ smithy::Outcome DeserializeRpcV2CborDenseMapsInput(cons } } { - const smithy::Document* member = doc.Find("denseStringMap"); + const opal::Document* member = doc.Find("denseStringMap"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -1323,7 +1323,7 @@ smithy::Outcome DeserializeRpcV2CborDenseMapsInput(cons } } { - const smithy::Document* member = doc.Find("denseSetMap"); + const opal::Document* member = doc.Find("denseSetMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -1337,8 +1337,8 @@ smithy::Outcome DeserializeRpcV2CborDenseMapsInput(cons return out; } -smithy::Document SerializeRpcV2CborDenseMapsOutput(const RpcV2CborDenseMapsOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeRpcV2CborDenseMapsOutput(const RpcV2CborDenseMapsOutput& value) { + opal::DocumentMap map; if (value.denseStructMap.has_value()) { map.emplace("denseStructMap", SerializeDenseStructMap((*value.denseStructMap))); } @@ -1354,14 +1354,14 @@ smithy::Document SerializeRpcV2CborDenseMapsOutput(const RpcV2CborDenseMapsOutpu if (value.denseSetMap.has_value()) { map.emplace("denseSetMap", SerializeDenseSetMap((*value.denseSetMap))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRpcV2CborDenseMapsOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RpcV2CborDenseMapsOutput: expected a map on the wire"); +opal::Outcome DeserializeRpcV2CborDenseMapsOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RpcV2CborDenseMapsOutput: expected a map on the wire"); RpcV2CborDenseMapsOutput out; { - const smithy::Document* member = doc.Find("denseStructMap"); + const opal::Document* member = doc.Find("denseStructMap"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -1373,7 +1373,7 @@ smithy::Outcome DeserializeRpcV2CborDenseMapsOutput(co } } { - const smithy::Document* member = doc.Find("denseNumberMap"); + const opal::Document* member = doc.Find("denseNumberMap"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -1385,7 +1385,7 @@ smithy::Outcome DeserializeRpcV2CborDenseMapsOutput(co } } { - const smithy::Document* member = doc.Find("denseBooleanMap"); + const opal::Document* member = doc.Find("denseBooleanMap"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -1397,7 +1397,7 @@ smithy::Outcome DeserializeRpcV2CborDenseMapsOutput(co } } { - const smithy::Document* member = doc.Find("denseStringMap"); + const opal::Document* member = doc.Find("denseStringMap"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -1409,7 +1409,7 @@ smithy::Outcome DeserializeRpcV2CborDenseMapsOutput(co } } { - const smithy::Document* member = doc.Find("denseSetMap"); + const opal::Document* member = doc.Find("denseSetMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -1423,25 +1423,25 @@ smithy::Outcome DeserializeRpcV2CborDenseMapsOutput(co return out; } -smithy::Document SerializeBlobList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeBlobList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeBlobList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); - std::vector out; +opal::Outcome> DeserializeBlobList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); + std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); - smithy::Blob parsed_item{}; + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); + opal::Blob parsed_item{}; { - auto parsed = smithy::BlobFromDocument(*item); + auto parsed = opal::BlobFromDocument(*item); if (!parsed) return std::move(parsed).error(); parsed_item = std::move(*parsed); } @@ -1450,144 +1450,144 @@ smithy::Outcome> DeserializeBlobList(const smithy::Doc return out; } -smithy::Document SerializeBooleanList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeBooleanList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeBooleanList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeBooleanList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); bool parsed_item{}; - if (!item->is_bool()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_bool()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = item->as_bool(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeFooEnumList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeFooEnumList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(std::string(item.ToString()))); + list.push_back(opal::Document(std::string(item.ToString()))); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeFooEnumList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeFooEnumList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); FooEnum parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = types::FooEnum::FromString(item->as_string()); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeIntegerList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeIntegerList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(static_cast(item))); + list.push_back(opal::Document(static_cast(item))); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeIntegerList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeIntegerList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); std::int32_t parsed_item{}; - if (!item->is_int()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); - if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return smithy::Error::Serialization("std::vector[]: value out of range"); + if (!item->is_int()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return opal::Error::Serialization("std::vector[]: value out of range"); parsed_item = static_cast(item->as_int()); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeIntegerEnumList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeIntegerEnumList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(static_cast(item))); + list.push_back(opal::Document(static_cast(item))); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeIntegerEnumList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeIntegerEnumList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); IntegerEnum parsed_item{}; - if (!item->is_int()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); - if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return smithy::Error::Serialization("std::vector[]: value out of range"); + if (!item->is_int()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return opal::Error::Serialization("std::vector[]: value out of range"); parsed_item = static_cast(item->as_int()); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeStringList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeStringList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(item)); + list.push_back(opal::Document(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeStringList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeStringList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = item->as_string(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeNestedStringList(const std::vector>& value) { - smithy::DocumentList list; +opal::Document SerializeNestedStringList(const std::vector>& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { list.push_back(SerializeStringList(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome>> DeserializeNestedStringList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector>: expected a list on the wire"); +opal::Outcome>> DeserializeNestedStringList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector>: expected a list on the wire"); std::vector> out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector>: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector>: null element in a dense list"); std::vector parsed_item{}; { auto parsed = DeserializeStringList(*item); @@ -1599,34 +1599,34 @@ smithy::Outcome>> DeserializeNestedStringLi return out; } -smithy::Document SerializeStructureListMember(const StructureListMember& value) { - smithy::DocumentMap map; +opal::Document SerializeStructureListMember(const StructureListMember& value) { + opal::DocumentMap map; if (value.a.has_value()) { - map.emplace("a", smithy::Document((*value.a))); + map.emplace("a", opal::Document((*value.a))); } if (value.b.has_value()) { - map.emplace("b", smithy::Document((*value.b))); + map.emplace("b", opal::Document((*value.b))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeStructureListMember(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("StructureListMember: expected a map on the wire"); +opal::Outcome DeserializeStructureListMember(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("StructureListMember: expected a map on the wire"); StructureListMember out; { - const smithy::Document* member = doc.Find("a"); + const opal::Document* member = doc.Find("a"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("StructureListMember.a: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("StructureListMember.a: unexpected type on the wire"); parsed_member = member->as_string(); out.a = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("b"); + const opal::Document* member = doc.Find("b"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("StructureListMember.b: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("StructureListMember.b: unexpected type on the wire"); parsed_member = member->as_string(); out.b = std::move(parsed_member); } @@ -1634,22 +1634,22 @@ smithy::Outcome DeserializeStructureListMember(const smithy return out; } -smithy::Document SerializeStructureList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeStructureList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { list.push_back(SerializeStructureListMember(item)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeStructureList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeStructureList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); StructureListMember parsed_item{}; { auto parsed = DeserializeStructureListMember(*item); @@ -1661,25 +1661,25 @@ smithy::Outcome> DeserializeStructureList(const return out; } -smithy::Document SerializeTimestampList(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeTimestampList(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document::FromTimestamp(item, smithy::TimestampFormat::kEpochSeconds)); + list.push_back(opal::Document::FromTimestamp(item, opal::TimestampFormat::kEpochSeconds)); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeTimestampList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); - std::vector out; +opal::Outcome> DeserializeTimestampList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); + std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); - smithy::Timestamp parsed_item{}; + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); + opal::Timestamp parsed_item{}; { - auto parsed = smithy::TimestampFromDocument(*item, smithy::TimestampFormat::kEpochSeconds); + auto parsed = opal::TimestampFromDocument(*item, opal::TimestampFormat::kEpochSeconds); if (!parsed) return std::move(parsed).error(); parsed_item = *parsed; } @@ -1688,8 +1688,8 @@ smithy::Outcome> DeserializeTimestampList(const s return out; } -smithy::Document SerializeRpcV2CborListsInput(const RpcV2CborListsInput& value) { - smithy::DocumentMap map; +opal::Document SerializeRpcV2CborListsInput(const RpcV2CborListsInput& value) { + opal::DocumentMap map; if (value.stringList.has_value()) { map.emplace("stringList", SerializeStringList((*value.stringList))); } @@ -1720,14 +1720,14 @@ smithy::Document SerializeRpcV2CborListsInput(const RpcV2CborListsInput& value) if (value.blobList.has_value()) { map.emplace("blobList", SerializeBlobList((*value.blobList))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRpcV2CborListsInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RpcV2CborListsInput: expected a map on the wire"); +opal::Outcome DeserializeRpcV2CborListsInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RpcV2CborListsInput: expected a map on the wire"); RpcV2CborListsInput out; { - const smithy::Document* member = doc.Find("stringList"); + const opal::Document* member = doc.Find("stringList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1739,7 +1739,7 @@ smithy::Outcome DeserializeRpcV2CborListsInput(const smithy } } { - const smithy::Document* member = doc.Find("stringSet"); + const opal::Document* member = doc.Find("stringSet"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1751,7 +1751,7 @@ smithy::Outcome DeserializeRpcV2CborListsInput(const smithy } } { - const smithy::Document* member = doc.Find("integerList"); + const opal::Document* member = doc.Find("integerList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1763,7 +1763,7 @@ smithy::Outcome DeserializeRpcV2CborListsInput(const smithy } } { - const smithy::Document* member = doc.Find("booleanList"); + const opal::Document* member = doc.Find("booleanList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1775,9 +1775,9 @@ smithy::Outcome DeserializeRpcV2CborListsInput(const smithy } } { - const smithy::Document* member = doc.Find("timestampList"); + const opal::Document* member = doc.Find("timestampList"); if (member != nullptr && !member->is_null()) { - std::vector parsed_member{}; + std::vector parsed_member{}; { auto parsed = DeserializeTimestampList(*member); if (!parsed) return std::move(parsed).error(); @@ -1787,7 +1787,7 @@ smithy::Outcome DeserializeRpcV2CborListsInput(const smithy } } { - const smithy::Document* member = doc.Find("enumList"); + const opal::Document* member = doc.Find("enumList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1799,7 +1799,7 @@ smithy::Outcome DeserializeRpcV2CborListsInput(const smithy } } { - const smithy::Document* member = doc.Find("intEnumList"); + const opal::Document* member = doc.Find("intEnumList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1811,7 +1811,7 @@ smithy::Outcome DeserializeRpcV2CborListsInput(const smithy } } { - const smithy::Document* member = doc.Find("nestedStringList"); + const opal::Document* member = doc.Find("nestedStringList"); if (member != nullptr && !member->is_null()) { std::vector> parsed_member{}; { @@ -1823,7 +1823,7 @@ smithy::Outcome DeserializeRpcV2CborListsInput(const smithy } } { - const smithy::Document* member = doc.Find("structureList"); + const opal::Document* member = doc.Find("structureList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1835,9 +1835,9 @@ smithy::Outcome DeserializeRpcV2CborListsInput(const smithy } } { - const smithy::Document* member = doc.Find("blobList"); + const opal::Document* member = doc.Find("blobList"); if (member != nullptr && !member->is_null()) { - std::vector parsed_member{}; + std::vector parsed_member{}; { auto parsed = DeserializeBlobList(*member); if (!parsed) return std::move(parsed).error(); @@ -1849,8 +1849,8 @@ smithy::Outcome DeserializeRpcV2CborListsInput(const smithy return out; } -smithy::Document SerializeRpcV2CborListsOutput(const RpcV2CborListsOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeRpcV2CborListsOutput(const RpcV2CborListsOutput& value) { + opal::DocumentMap map; if (value.stringList.has_value()) { map.emplace("stringList", SerializeStringList((*value.stringList))); } @@ -1881,14 +1881,14 @@ smithy::Document SerializeRpcV2CborListsOutput(const RpcV2CborListsOutput& value if (value.blobList.has_value()) { map.emplace("blobList", SerializeBlobList((*value.blobList))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRpcV2CborListsOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RpcV2CborListsOutput: expected a map on the wire"); +opal::Outcome DeserializeRpcV2CborListsOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RpcV2CborListsOutput: expected a map on the wire"); RpcV2CborListsOutput out; { - const smithy::Document* member = doc.Find("stringList"); + const opal::Document* member = doc.Find("stringList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1900,7 +1900,7 @@ smithy::Outcome DeserializeRpcV2CborListsOutput(const smit } } { - const smithy::Document* member = doc.Find("stringSet"); + const opal::Document* member = doc.Find("stringSet"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1912,7 +1912,7 @@ smithy::Outcome DeserializeRpcV2CborListsOutput(const smit } } { - const smithy::Document* member = doc.Find("integerList"); + const opal::Document* member = doc.Find("integerList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1924,7 +1924,7 @@ smithy::Outcome DeserializeRpcV2CborListsOutput(const smit } } { - const smithy::Document* member = doc.Find("booleanList"); + const opal::Document* member = doc.Find("booleanList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1936,9 +1936,9 @@ smithy::Outcome DeserializeRpcV2CborListsOutput(const smit } } { - const smithy::Document* member = doc.Find("timestampList"); + const opal::Document* member = doc.Find("timestampList"); if (member != nullptr && !member->is_null()) { - std::vector parsed_member{}; + std::vector parsed_member{}; { auto parsed = DeserializeTimestampList(*member); if (!parsed) return std::move(parsed).error(); @@ -1948,7 +1948,7 @@ smithy::Outcome DeserializeRpcV2CborListsOutput(const smit } } { - const smithy::Document* member = doc.Find("enumList"); + const opal::Document* member = doc.Find("enumList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1960,7 +1960,7 @@ smithy::Outcome DeserializeRpcV2CborListsOutput(const smit } } { - const smithy::Document* member = doc.Find("intEnumList"); + const opal::Document* member = doc.Find("intEnumList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1972,7 +1972,7 @@ smithy::Outcome DeserializeRpcV2CborListsOutput(const smit } } { - const smithy::Document* member = doc.Find("nestedStringList"); + const opal::Document* member = doc.Find("nestedStringList"); if (member != nullptr && !member->is_null()) { std::vector> parsed_member{}; { @@ -1984,7 +1984,7 @@ smithy::Outcome DeserializeRpcV2CborListsOutput(const smit } } { - const smithy::Document* member = doc.Find("structureList"); + const opal::Document* member = doc.Find("structureList"); if (member != nullptr && !member->is_null()) { std::vector parsed_member{}; { @@ -1996,9 +1996,9 @@ smithy::Outcome DeserializeRpcV2CborListsOutput(const smit } } { - const smithy::Document* member = doc.Find("blobList"); + const opal::Document* member = doc.Find("blobList"); if (member != nullptr && !member->is_null()) { - std::vector parsed_member{}; + std::vector parsed_member{}; { auto parsed = DeserializeBlobList(*member); if (!parsed) return std::move(parsed).error(); @@ -2010,102 +2010,102 @@ smithy::Outcome DeserializeRpcV2CborListsOutput(const smit return out; } -smithy::Document SerializeRpcV2CborNestedUnion(const RpcV2CborNestedUnion& value) { - smithy::DocumentMap map; +opal::Document SerializeRpcV2CborNestedUnion(const RpcV2CborNestedUnion& value) { + opal::DocumentMap map; if (value.is_stringValue()) { - map.emplace("stringValue", smithy::Document(value.as_stringValue())); + map.emplace("stringValue", opal::Document(value.as_stringValue())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRpcV2CborNestedUnion(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RpcV2CborNestedUnion: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("RpcV2CborNestedUnion: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("stringValue"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeRpcV2CborNestedUnion(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RpcV2CborNestedUnion: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("RpcV2CborNestedUnion: expected exactly one union member"); + if (const opal::Document* member = doc.Find("stringValue"); member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RpcV2CborNestedUnion.stringValue: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RpcV2CborNestedUnion.stringValue: unexpected type on the wire"); parsed_member = member->as_string(); return RpcV2CborNestedUnion::FromStringvalue(std::move(parsed_member)); } - return smithy::Error::Serialization("RpcV2CborNestedUnion: unknown or missing union member"); + return opal::Error::Serialization("RpcV2CborNestedUnion: unknown or missing union member"); } -smithy::Document SerializeSparseBooleanMap(const std::map>& value) { - smithy::DocumentMap map; +opal::Document SerializeSparseBooleanMap(const std::map>& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { if (!item.has_value()) { - map.emplace(key, smithy::Document(nullptr)); + map.emplace(key, opal::Document(nullptr)); continue; } - map.emplace(key, smithy::Document((*item))); + map.emplace(key, opal::Document((*item))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome>> DeserializeSparseBooleanMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map>: expected a map on the wire"); +opal::Outcome>> DeserializeSparseBooleanMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map>: expected a map on the wire"); std::map> out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; if (item->is_null()) { out.emplace(key, std::nullopt); continue; } bool parsed_item{}; - if (!item->is_bool()) return smithy::Error::Serialization("std::map>{}: unexpected type on the wire"); + if (!item->is_bool()) return opal::Error::Serialization("std::map>{}: unexpected type on the wire"); parsed_item = item->as_bool(); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeSparseNumberMap(const std::map>& value) { - smithy::DocumentMap map; +opal::Document SerializeSparseNumberMap(const std::map>& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { if (!item.has_value()) { - map.emplace(key, smithy::Document(nullptr)); + map.emplace(key, opal::Document(nullptr)); continue; } - map.emplace(key, smithy::Document(static_cast((*item)))); + map.emplace(key, opal::Document(static_cast((*item)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome>> DeserializeSparseNumberMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map>: expected a map on the wire"); +opal::Outcome>> DeserializeSparseNumberMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map>: expected a map on the wire"); std::map> out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; if (item->is_null()) { out.emplace(key, std::nullopt); continue; } std::int32_t parsed_item{}; - if (!item->is_int()) return smithy::Error::Serialization("std::map>{}: unexpected type on the wire"); - if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return smithy::Error::Serialization("std::map>{}: value out of range"); + if (!item->is_int()) return opal::Error::Serialization("std::map>{}: unexpected type on the wire"); + if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return opal::Error::Serialization("std::map>{}: value out of range"); parsed_item = static_cast(item->as_int()); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeSparseSetMap(const std::map>>& value) { - smithy::DocumentMap map; +opal::Document SerializeSparseSetMap(const std::map>>& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { if (!item.has_value()) { - map.emplace(key, smithy::Document(nullptr)); + map.emplace(key, opal::Document(nullptr)); continue; } map.emplace(key, SerializeStringSet((*item))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome>>> DeserializeSparseSetMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map>>: expected a map on the wire"); +opal::Outcome>>> DeserializeSparseSetMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map>>: expected a map on the wire"); std::map>> out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; if (item->is_null()) { out.emplace(key, std::nullopt); continue; @@ -2121,52 +2121,52 @@ smithy::Outcome>>> return out; } -smithy::Document SerializeSparseStringMap(const std::map>& value) { - smithy::DocumentMap map; +opal::Document SerializeSparseStringMap(const std::map>& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { if (!item.has_value()) { - map.emplace(key, smithy::Document(nullptr)); + map.emplace(key, opal::Document(nullptr)); continue; } - map.emplace(key, smithy::Document((*item))); + map.emplace(key, opal::Document((*item))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome>> DeserializeSparseStringMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map>: expected a map on the wire"); +opal::Outcome>> DeserializeSparseStringMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map>: expected a map on the wire"); std::map> out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; if (item->is_null()) { out.emplace(key, std::nullopt); continue; } std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::map>{}: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::map>{}: unexpected type on the wire"); parsed_item = item->as_string(); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeSparseStructMap(const std::map>& value) { - smithy::DocumentMap map; +opal::Document SerializeSparseStructMap(const std::map>& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { if (!item.has_value()) { - map.emplace(key, smithy::Document(nullptr)); + map.emplace(key, opal::Document(nullptr)); continue; } map.emplace(key, SerializeGreetingStruct((*item))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome>> DeserializeSparseStructMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map>: expected a map on the wire"); +opal::Outcome>> DeserializeSparseStructMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map>: expected a map on the wire"); std::map> out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; if (item->is_null()) { out.emplace(key, std::nullopt); continue; @@ -2182,8 +2182,8 @@ smithy::Outcome>> Deserializ return out; } -smithy::Document SerializeRpcV2CborSparseMapsInput(const RpcV2CborSparseMapsInput& value) { - smithy::DocumentMap map; +opal::Document SerializeRpcV2CborSparseMapsInput(const RpcV2CborSparseMapsInput& value) { + opal::DocumentMap map; if (value.sparseStructMap.has_value()) { map.emplace("sparseStructMap", SerializeSparseStructMap((*value.sparseStructMap))); } @@ -2199,14 +2199,14 @@ smithy::Document SerializeRpcV2CborSparseMapsInput(const RpcV2CborSparseMapsInpu if (value.sparseSetMap.has_value()) { map.emplace("sparseSetMap", SerializeSparseSetMap((*value.sparseSetMap))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRpcV2CborSparseMapsInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RpcV2CborSparseMapsInput: expected a map on the wire"); +opal::Outcome DeserializeRpcV2CborSparseMapsInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RpcV2CborSparseMapsInput: expected a map on the wire"); RpcV2CborSparseMapsInput out; { - const smithy::Document* member = doc.Find("sparseStructMap"); + const opal::Document* member = doc.Find("sparseStructMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -2218,7 +2218,7 @@ smithy::Outcome DeserializeRpcV2CborSparseMapsInput(co } } { - const smithy::Document* member = doc.Find("sparseNumberMap"); + const opal::Document* member = doc.Find("sparseNumberMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -2230,7 +2230,7 @@ smithy::Outcome DeserializeRpcV2CborSparseMapsInput(co } } { - const smithy::Document* member = doc.Find("sparseBooleanMap"); + const opal::Document* member = doc.Find("sparseBooleanMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -2242,7 +2242,7 @@ smithy::Outcome DeserializeRpcV2CborSparseMapsInput(co } } { - const smithy::Document* member = doc.Find("sparseStringMap"); + const opal::Document* member = doc.Find("sparseStringMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -2254,7 +2254,7 @@ smithy::Outcome DeserializeRpcV2CborSparseMapsInput(co } } { - const smithy::Document* member = doc.Find("sparseSetMap"); + const opal::Document* member = doc.Find("sparseSetMap"); if (member != nullptr && !member->is_null()) { std::map>> parsed_member{}; { @@ -2268,8 +2268,8 @@ smithy::Outcome DeserializeRpcV2CborSparseMapsInput(co return out; } -smithy::Document SerializeRpcV2CborSparseMapsOutput(const RpcV2CborSparseMapsOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeRpcV2CborSparseMapsOutput(const RpcV2CborSparseMapsOutput& value) { + opal::DocumentMap map; if (value.sparseStructMap.has_value()) { map.emplace("sparseStructMap", SerializeSparseStructMap((*value.sparseStructMap))); } @@ -2285,14 +2285,14 @@ smithy::Document SerializeRpcV2CborSparseMapsOutput(const RpcV2CborSparseMapsOut if (value.sparseSetMap.has_value()) { map.emplace("sparseSetMap", SerializeSparseSetMap((*value.sparseSetMap))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRpcV2CborSparseMapsOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RpcV2CborSparseMapsOutput: expected a map on the wire"); +opal::Outcome DeserializeRpcV2CborSparseMapsOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RpcV2CborSparseMapsOutput: expected a map on the wire"); RpcV2CborSparseMapsOutput out; { - const smithy::Document* member = doc.Find("sparseStructMap"); + const opal::Document* member = doc.Find("sparseStructMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -2304,7 +2304,7 @@ smithy::Outcome DeserializeRpcV2CborSparseMapsOutput( } } { - const smithy::Document* member = doc.Find("sparseNumberMap"); + const opal::Document* member = doc.Find("sparseNumberMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -2316,7 +2316,7 @@ smithy::Outcome DeserializeRpcV2CborSparseMapsOutput( } } { - const smithy::Document* member = doc.Find("sparseBooleanMap"); + const opal::Document* member = doc.Find("sparseBooleanMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -2328,7 +2328,7 @@ smithy::Outcome DeserializeRpcV2CborSparseMapsOutput( } } { - const smithy::Document* member = doc.Find("sparseStringMap"); + const opal::Document* member = doc.Find("sparseStringMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -2340,7 +2340,7 @@ smithy::Outcome DeserializeRpcV2CborSparseMapsOutput( } } { - const smithy::Document* member = doc.Find("sparseSetMap"); + const opal::Document* member = doc.Find("sparseSetMap"); if (member != nullptr && !member->is_null()) { std::map>> parsed_member{}; { @@ -2354,27 +2354,27 @@ smithy::Outcome DeserializeRpcV2CborSparseMapsOutput( return out; } -smithy::Document SerializeRpcV2CborUnion(const RpcV2CborUnion& value) { - smithy::DocumentMap map; +opal::Document SerializeRpcV2CborUnion(const RpcV2CborUnion& value) { + opal::DocumentMap map; if (value.is_stringValue()) { - map.emplace("stringValue", smithy::Document(value.as_stringValue())); + map.emplace("stringValue", opal::Document(value.as_stringValue())); } if (value.is_unionValue()) { map.emplace("unionValue", SerializeRpcV2CborNestedUnion(value.as_unionValue())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRpcV2CborUnion(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RpcV2CborUnion: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("RpcV2CborUnion: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("stringValue"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeRpcV2CborUnion(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RpcV2CborUnion: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("RpcV2CborUnion: expected exactly one union member"); + if (const opal::Document* member = doc.Find("stringValue"); member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RpcV2CborUnion.stringValue: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RpcV2CborUnion.stringValue: unexpected type on the wire"); parsed_member = member->as_string(); return RpcV2CborUnion::FromStringvalue(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("unionValue"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("unionValue"); member != nullptr && !member->is_null()) { RpcV2CborNestedUnion parsed_member{}; { auto parsed = DeserializeRpcV2CborNestedUnion(*member); @@ -2383,25 +2383,25 @@ smithy::Outcome DeserializeRpcV2CborUnion(const smithy::Document } return RpcV2CborUnion::FromUnionvalue(std::move(parsed_member)); } - return smithy::Error::Serialization("RpcV2CborUnion: unknown or missing union member"); + return opal::Error::Serialization("RpcV2CborUnion: unknown or missing union member"); } -smithy::Document SerializeRpcV2CborUnionsInput(const RpcV2CborUnionsInput& value) { - smithy::DocumentMap map; +opal::Document SerializeRpcV2CborUnionsInput(const RpcV2CborUnionsInput& value) { + opal::DocumentMap map; if (value.contents.has_value()) { map.emplace("contents", SerializeRpcV2CborUnion((*value.contents))); } if (value.otherValue.has_value()) { - map.emplace("otherValue", smithy::Document((*value.otherValue))); + map.emplace("otherValue", opal::Document((*value.otherValue))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRpcV2CborUnionsInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RpcV2CborUnionsInput: expected a map on the wire"); +opal::Outcome DeserializeRpcV2CborUnionsInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RpcV2CborUnionsInput: expected a map on the wire"); RpcV2CborUnionsInput out; { - const smithy::Document* member = doc.Find("contents"); + const opal::Document* member = doc.Find("contents"); if (member != nullptr && !member->is_null()) { types::RpcV2CborUnion parsed_member{}; { @@ -2413,10 +2413,10 @@ smithy::Outcome DeserializeRpcV2CborUnionsInput(const smit } } { - const smithy::Document* member = doc.Find("otherValue"); + const opal::Document* member = doc.Find("otherValue"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RpcV2CborUnionsInput.otherValue: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RpcV2CborUnionsInput.otherValue: unexpected type on the wire"); parsed_member = member->as_string(); out.otherValue = std::move(parsed_member); } @@ -2424,22 +2424,22 @@ smithy::Outcome DeserializeRpcV2CborUnionsInput(const smit return out; } -smithy::Document SerializeRpcV2CborUnionsOutput(const RpcV2CborUnionsOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeRpcV2CborUnionsOutput(const RpcV2CborUnionsOutput& value) { + opal::DocumentMap map; if (value.contents.has_value()) { map.emplace("contents", SerializeRpcV2CborUnion((*value.contents))); } if (value.otherValue.has_value()) { - map.emplace("otherValue", smithy::Document((*value.otherValue))); + map.emplace("otherValue", opal::Document((*value.otherValue))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRpcV2CborUnionsOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RpcV2CborUnionsOutput: expected a map on the wire"); +opal::Outcome DeserializeRpcV2CborUnionsOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RpcV2CborUnionsOutput: expected a map on the wire"); RpcV2CborUnionsOutput out; { - const smithy::Document* member = doc.Find("contents"); + const opal::Document* member = doc.Find("contents"); if (member != nullptr && !member->is_null()) { types::RpcV2CborUnion parsed_member{}; { @@ -2451,10 +2451,10 @@ smithy::Outcome DeserializeRpcV2CborUnionsOutput(const sm } } { - const smithy::Document* member = doc.Find("otherValue"); + const opal::Document* member = doc.Find("otherValue"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RpcV2CborUnionsOutput.otherValue: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RpcV2CborUnionsOutput.otherValue: unexpected type on the wire"); parsed_member = member->as_string(); out.otherValue = std::move(parsed_member); } @@ -2462,142 +2462,142 @@ smithy::Outcome DeserializeRpcV2CborUnionsOutput(const sm return out; } -smithy::Document SerializeSimpleScalarPropertiesInput(const SimpleScalarPropertiesInput& value) { - smithy::DocumentMap map; +opal::Document SerializeSimpleScalarPropertiesInput(const SimpleScalarPropertiesInput& value) { + opal::DocumentMap map; if (value.trueBooleanValue.has_value()) { - map.emplace("trueBooleanValue", smithy::Document((*value.trueBooleanValue))); + map.emplace("trueBooleanValue", opal::Document((*value.trueBooleanValue))); } if (value.falseBooleanValue.has_value()) { - map.emplace("falseBooleanValue", smithy::Document((*value.falseBooleanValue))); + map.emplace("falseBooleanValue", opal::Document((*value.falseBooleanValue))); } if (value.byteValue.has_value()) { - map.emplace("byteValue", smithy::Document(static_cast((*value.byteValue)))); + map.emplace("byteValue", opal::Document(static_cast((*value.byteValue)))); } if (value.doubleValue.has_value()) { - map.emplace("doubleValue", smithy::Document(static_cast((*value.doubleValue)))); + map.emplace("doubleValue", opal::Document(static_cast((*value.doubleValue)))); } if (value.floatValue.has_value()) { - map.emplace("floatValue", smithy::Document(static_cast((*value.floatValue)))); + map.emplace("floatValue", opal::Document(static_cast((*value.floatValue)))); } if (value.integerValue.has_value()) { - map.emplace("integerValue", smithy::Document(static_cast((*value.integerValue)))); + map.emplace("integerValue", opal::Document(static_cast((*value.integerValue)))); } if (value.longValue.has_value()) { - map.emplace("longValue", smithy::Document(static_cast((*value.longValue)))); + map.emplace("longValue", opal::Document(static_cast((*value.longValue)))); } if (value.shortValue.has_value()) { - map.emplace("shortValue", smithy::Document(static_cast((*value.shortValue)))); + map.emplace("shortValue", opal::Document(static_cast((*value.shortValue)))); } if (value.stringValue.has_value()) { - map.emplace("stringValue", smithy::Document((*value.stringValue))); + map.emplace("stringValue", opal::Document((*value.stringValue))); } if (value.blobValue.has_value()) { - map.emplace("blobValue", smithy::Document((*value.blobValue))); + map.emplace("blobValue", opal::Document((*value.blobValue))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSimpleScalarPropertiesInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SimpleScalarPropertiesInput: expected a map on the wire"); +opal::Outcome DeserializeSimpleScalarPropertiesInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SimpleScalarPropertiesInput: expected a map on the wire"); SimpleScalarPropertiesInput out; { - const smithy::Document* member = doc.Find("trueBooleanValue"); + const opal::Document* member = doc.Find("trueBooleanValue"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("SimpleScalarPropertiesInput.trueBooleanValue: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("SimpleScalarPropertiesInput.trueBooleanValue: unexpected type on the wire"); parsed_member = member->as_bool(); out.trueBooleanValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("falseBooleanValue"); + const opal::Document* member = doc.Find("falseBooleanValue"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("SimpleScalarPropertiesInput.falseBooleanValue: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("SimpleScalarPropertiesInput.falseBooleanValue: unexpected type on the wire"); parsed_member = member->as_bool(); out.falseBooleanValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("byteValue"); + const opal::Document* member = doc.Find("byteValue"); if (member != nullptr && !member->is_null()) { std::int8_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SimpleScalarPropertiesInput.byteValue: unexpected type on the wire"); - if (member->as_int() < -128 || member->as_int() > 127) return smithy::Error::Serialization("SimpleScalarPropertiesInput.byteValue: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SimpleScalarPropertiesInput.byteValue: unexpected type on the wire"); + if (member->as_int() < -128 || member->as_int() > 127) return opal::Error::Serialization("SimpleScalarPropertiesInput.byteValue: value out of range"); parsed_member = static_cast(member->as_int()); out.byteValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("doubleValue"); + const opal::Document* member = doc.Find("doubleValue"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("SimpleScalarPropertiesInput.doubleValue: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("SimpleScalarPropertiesInput.doubleValue: expected a number"); parsed_member = static_cast(*parsed); } out.doubleValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("floatValue"); + const opal::Document* member = doc.Find("floatValue"); if (member != nullptr && !member->is_null()) { float parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("SimpleScalarPropertiesInput.floatValue: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("SimpleScalarPropertiesInput.floatValue: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("SimpleScalarPropertiesInput.floatValue: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("SimpleScalarPropertiesInput.floatValue: value out of range"); parsed_member = *narrowed; } out.floatValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("integerValue"); + const opal::Document* member = doc.Find("integerValue"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SimpleScalarPropertiesInput.integerValue: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("SimpleScalarPropertiesInput.integerValue: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SimpleScalarPropertiesInput.integerValue: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("SimpleScalarPropertiesInput.integerValue: value out of range"); parsed_member = static_cast(member->as_int()); out.integerValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("longValue"); + const opal::Document* member = doc.Find("longValue"); if (member != nullptr && !member->is_null()) { std::int64_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SimpleScalarPropertiesInput.longValue: unexpected type on the wire"); + if (!member->is_int()) return opal::Error::Serialization("SimpleScalarPropertiesInput.longValue: unexpected type on the wire"); parsed_member = static_cast(member->as_int()); out.longValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("shortValue"); + const opal::Document* member = doc.Find("shortValue"); if (member != nullptr && !member->is_null()) { std::int16_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SimpleScalarPropertiesInput.shortValue: unexpected type on the wire"); - if (member->as_int() < -32768 || member->as_int() > 32767) return smithy::Error::Serialization("SimpleScalarPropertiesInput.shortValue: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SimpleScalarPropertiesInput.shortValue: unexpected type on the wire"); + if (member->as_int() < -32768 || member->as_int() > 32767) return opal::Error::Serialization("SimpleScalarPropertiesInput.shortValue: value out of range"); parsed_member = static_cast(member->as_int()); out.shortValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("stringValue"); + const opal::Document* member = doc.Find("stringValue"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("SimpleScalarPropertiesInput.stringValue: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SimpleScalarPropertiesInput.stringValue: unexpected type on the wire"); parsed_member = member->as_string(); out.stringValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("blobValue"); + const opal::Document* member = doc.Find("blobValue"); if (member != nullptr && !member->is_null()) { - smithy::Blob parsed_member{}; + opal::Blob parsed_member{}; { - auto parsed = smithy::BlobFromDocument(*member); + auto parsed = opal::BlobFromDocument(*member); if (!parsed) return std::move(parsed).error(); parsed_member = std::move(*parsed); } @@ -2607,142 +2607,142 @@ smithy::Outcome DeserializeSimpleScalarPropertiesIn return out; } -smithy::Document SerializeSimpleScalarPropertiesOutput(const SimpleScalarPropertiesOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeSimpleScalarPropertiesOutput(const SimpleScalarPropertiesOutput& value) { + opal::DocumentMap map; if (value.trueBooleanValue.has_value()) { - map.emplace("trueBooleanValue", smithy::Document((*value.trueBooleanValue))); + map.emplace("trueBooleanValue", opal::Document((*value.trueBooleanValue))); } if (value.falseBooleanValue.has_value()) { - map.emplace("falseBooleanValue", smithy::Document((*value.falseBooleanValue))); + map.emplace("falseBooleanValue", opal::Document((*value.falseBooleanValue))); } if (value.byteValue.has_value()) { - map.emplace("byteValue", smithy::Document(static_cast((*value.byteValue)))); + map.emplace("byteValue", opal::Document(static_cast((*value.byteValue)))); } if (value.doubleValue.has_value()) { - map.emplace("doubleValue", smithy::Document(static_cast((*value.doubleValue)))); + map.emplace("doubleValue", opal::Document(static_cast((*value.doubleValue)))); } if (value.floatValue.has_value()) { - map.emplace("floatValue", smithy::Document(static_cast((*value.floatValue)))); + map.emplace("floatValue", opal::Document(static_cast((*value.floatValue)))); } if (value.integerValue.has_value()) { - map.emplace("integerValue", smithy::Document(static_cast((*value.integerValue)))); + map.emplace("integerValue", opal::Document(static_cast((*value.integerValue)))); } if (value.longValue.has_value()) { - map.emplace("longValue", smithy::Document(static_cast((*value.longValue)))); + map.emplace("longValue", opal::Document(static_cast((*value.longValue)))); } if (value.shortValue.has_value()) { - map.emplace("shortValue", smithy::Document(static_cast((*value.shortValue)))); + map.emplace("shortValue", opal::Document(static_cast((*value.shortValue)))); } if (value.stringValue.has_value()) { - map.emplace("stringValue", smithy::Document((*value.stringValue))); + map.emplace("stringValue", opal::Document((*value.stringValue))); } if (value.blobValue.has_value()) { - map.emplace("blobValue", smithy::Document((*value.blobValue))); + map.emplace("blobValue", opal::Document((*value.blobValue))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSimpleScalarPropertiesOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SimpleScalarPropertiesOutput: expected a map on the wire"); +opal::Outcome DeserializeSimpleScalarPropertiesOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SimpleScalarPropertiesOutput: expected a map on the wire"); SimpleScalarPropertiesOutput out; { - const smithy::Document* member = doc.Find("trueBooleanValue"); + const opal::Document* member = doc.Find("trueBooleanValue"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.trueBooleanValue: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("SimpleScalarPropertiesOutput.trueBooleanValue: unexpected type on the wire"); parsed_member = member->as_bool(); out.trueBooleanValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("falseBooleanValue"); + const opal::Document* member = doc.Find("falseBooleanValue"); if (member != nullptr && !member->is_null()) { bool parsed_member{}; - if (!member->is_bool()) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.falseBooleanValue: unexpected type on the wire"); + if (!member->is_bool()) return opal::Error::Serialization("SimpleScalarPropertiesOutput.falseBooleanValue: unexpected type on the wire"); parsed_member = member->as_bool(); out.falseBooleanValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("byteValue"); + const opal::Document* member = doc.Find("byteValue"); if (member != nullptr && !member->is_null()) { std::int8_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.byteValue: unexpected type on the wire"); - if (member->as_int() < -128 || member->as_int() > 127) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.byteValue: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SimpleScalarPropertiesOutput.byteValue: unexpected type on the wire"); + if (member->as_int() < -128 || member->as_int() > 127) return opal::Error::Serialization("SimpleScalarPropertiesOutput.byteValue: value out of range"); parsed_member = static_cast(member->as_int()); out.byteValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("doubleValue"); + const opal::Document* member = doc.Find("doubleValue"); if (member != nullptr && !member->is_null()) { double parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.doubleValue: expected a number"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("SimpleScalarPropertiesOutput.doubleValue: expected a number"); parsed_member = static_cast(*parsed); } out.doubleValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("floatValue"); + const opal::Document* member = doc.Find("floatValue"); if (member != nullptr && !member->is_null()) { float parsed_member{}; { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.floatValue: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.floatValue: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("SimpleScalarPropertiesOutput.floatValue: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("SimpleScalarPropertiesOutput.floatValue: value out of range"); parsed_member = *narrowed; } out.floatValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("integerValue"); + const opal::Document* member = doc.Find("integerValue"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.integerValue: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.integerValue: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SimpleScalarPropertiesOutput.integerValue: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("SimpleScalarPropertiesOutput.integerValue: value out of range"); parsed_member = static_cast(member->as_int()); out.integerValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("longValue"); + const opal::Document* member = doc.Find("longValue"); if (member != nullptr && !member->is_null()) { std::int64_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.longValue: unexpected type on the wire"); + if (!member->is_int()) return opal::Error::Serialization("SimpleScalarPropertiesOutput.longValue: unexpected type on the wire"); parsed_member = static_cast(member->as_int()); out.longValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("shortValue"); + const opal::Document* member = doc.Find("shortValue"); if (member != nullptr && !member->is_null()) { std::int16_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.shortValue: unexpected type on the wire"); - if (member->as_int() < -32768 || member->as_int() > 32767) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.shortValue: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("SimpleScalarPropertiesOutput.shortValue: unexpected type on the wire"); + if (member->as_int() < -32768 || member->as_int() > 32767) return opal::Error::Serialization("SimpleScalarPropertiesOutput.shortValue: value out of range"); parsed_member = static_cast(member->as_int()); out.shortValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("stringValue"); + const opal::Document* member = doc.Find("stringValue"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("SimpleScalarPropertiesOutput.stringValue: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SimpleScalarPropertiesOutput.stringValue: unexpected type on the wire"); parsed_member = member->as_string(); out.stringValue = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("blobValue"); + const opal::Document* member = doc.Find("blobValue"); if (member != nullptr && !member->is_null()) { - smithy::Blob parsed_member{}; + opal::Blob parsed_member{}; { - auto parsed = smithy::BlobFromDocument(*member); + auto parsed = opal::BlobFromDocument(*member); if (!parsed) return std::move(parsed).error(); parsed_member = std::move(*parsed); } @@ -2752,53 +2752,53 @@ smithy::Outcome DeserializeSimpleScalarPropertiesO return out; } -smithy::Document SerializeSparseStringList(const std::vector>& value) { - smithy::DocumentList list; +opal::Document SerializeSparseStringList(const std::vector>& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { if (!item.has_value()) { list.emplace_back(nullptr); continue; } - list.push_back(smithy::Document((*item))); + list.push_back(opal::Document((*item))); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome>> DeserializeSparseStringList(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector>: expected a list on the wire"); +opal::Outcome>> DeserializeSparseStringList(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector>: expected a list on the wire"); std::vector> out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; if (item->is_null()) { out.emplace_back(std::nullopt); continue; } std::string parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector>[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector>[]: unexpected type on the wire"); parsed_item = item->as_string(); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializeSparseNullsOperationInput(const SparseNullsOperationInput& value) { - smithy::DocumentMap map; +opal::Document SerializeSparseNullsOperationInput(const SparseNullsOperationInput& value) { + opal::DocumentMap map; if (value.sparseStringList.has_value()) { map.emplace("sparseStringList", SerializeSparseStringList((*value.sparseStringList))); } if (value.sparseStringMap.has_value()) { map.emplace("sparseStringMap", SerializeSparseStringMap((*value.sparseStringMap))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSparseNullsOperationInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SparseNullsOperationInput: expected a map on the wire"); +opal::Outcome DeserializeSparseNullsOperationInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SparseNullsOperationInput: expected a map on the wire"); SparseNullsOperationInput out; { - const smithy::Document* member = doc.Find("sparseStringList"); + const opal::Document* member = doc.Find("sparseStringList"); if (member != nullptr && !member->is_null()) { std::vector> parsed_member{}; { @@ -2810,7 +2810,7 @@ smithy::Outcome DeserializeSparseNullsOperationInput( } } { - const smithy::Document* member = doc.Find("sparseStringMap"); + const opal::Document* member = doc.Find("sparseStringMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -2824,22 +2824,22 @@ smithy::Outcome DeserializeSparseNullsOperationInput( return out; } -smithy::Document SerializeSparseNullsOperationOutput(const SparseNullsOperationOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeSparseNullsOperationOutput(const SparseNullsOperationOutput& value) { + opal::DocumentMap map; if (value.sparseStringList.has_value()) { map.emplace("sparseStringList", SerializeSparseStringList((*value.sparseStringList))); } if (value.sparseStringMap.has_value()) { map.emplace("sparseStringMap", SerializeSparseStringMap((*value.sparseStringMap))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSparseNullsOperationOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SparseNullsOperationOutput: expected a map on the wire"); +opal::Outcome DeserializeSparseNullsOperationOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SparseNullsOperationOutput: expected a map on the wire"); SparseNullsOperationOutput out; { - const smithy::Document* member = doc.Find("sparseStringList"); + const opal::Document* member = doc.Find("sparseStringList"); if (member != nullptr && !member->is_null()) { std::vector> parsed_member{}; { @@ -2851,7 +2851,7 @@ smithy::Outcome DeserializeSparseNullsOperationOutpu } } { - const smithy::Document* member = doc.Find("sparseStringMap"); + const opal::Document* member = doc.Find("sparseStringMap"); if (member != nullptr && !member->is_null()) { std::map> parsed_member{}; { @@ -2865,19 +2865,19 @@ smithy::Outcome DeserializeSparseNullsOperationOutpu return out; } -smithy::Document SerializeRecursiveShapesInput(const RecursiveShapesInput& value) { - smithy::DocumentMap map; +opal::Document SerializeRecursiveShapesInput(const RecursiveShapesInput& value) { + opal::DocumentMap map; if (value.nested.has_value()) { map.emplace("nested", SerializeRecursiveShapesInputOutputNested1((*value.nested))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRecursiveShapesInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RecursiveShapesInput: expected a map on the wire"); +opal::Outcome DeserializeRecursiveShapesInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RecursiveShapesInput: expected a map on the wire"); RecursiveShapesInput out; { - const smithy::Document* member = doc.Find("nested"); + const opal::Document* member = doc.Find("nested"); if (member != nullptr && !member->is_null()) { types::RecursiveShapesInputOutputNested1 parsed_member{}; { @@ -2891,31 +2891,31 @@ smithy::Outcome DeserializeRecursiveShapesInput(const smit return out; } -smithy::Document SerializeRecursiveShapesInputOutputNested1(const RecursiveShapesInputOutputNested1& value) { - smithy::DocumentMap map; +opal::Document SerializeRecursiveShapesInputOutputNested1(const RecursiveShapesInputOutputNested1& value) { + opal::DocumentMap map; if (value.foo.has_value()) { - map.emplace("foo", smithy::Document((*value.foo))); + map.emplace("foo", opal::Document((*value.foo))); } if (value.nested.has_value()) { map.emplace("nested", SerializeRecursiveShapesInputOutputNested2(*((*value.nested)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRecursiveShapesInputOutputNested1(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RecursiveShapesInputOutputNested1: expected a map on the wire"); +opal::Outcome DeserializeRecursiveShapesInputOutputNested1(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RecursiveShapesInputOutputNested1: expected a map on the wire"); RecursiveShapesInputOutputNested1 out; { - const smithy::Document* member = doc.Find("foo"); + const opal::Document* member = doc.Find("foo"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RecursiveShapesInputOutputNested1.foo: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RecursiveShapesInputOutputNested1.foo: unexpected type on the wire"); parsed_member = member->as_string(); out.foo = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("nested"); + const opal::Document* member = doc.Find("nested"); if (member != nullptr && !member->is_null()) { types::RecursiveShapesInputOutputNested2 parsed_member{}; { @@ -2929,31 +2929,31 @@ smithy::Outcome DeserializeRecursiveShapesInp return out; } -smithy::Document SerializeRecursiveShapesInputOutputNested2(const RecursiveShapesInputOutputNested2& value) { - smithy::DocumentMap map; +opal::Document SerializeRecursiveShapesInputOutputNested2(const RecursiveShapesInputOutputNested2& value) { + opal::DocumentMap map; if (value.bar.has_value()) { - map.emplace("bar", smithy::Document((*value.bar))); + map.emplace("bar", opal::Document((*value.bar))); } if (value.recursiveMember.has_value()) { map.emplace("recursiveMember", SerializeRecursiveShapesInputOutputNested1(*((*value.recursiveMember)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRecursiveShapesInputOutputNested2(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RecursiveShapesInputOutputNested2: expected a map on the wire"); +opal::Outcome DeserializeRecursiveShapesInputOutputNested2(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RecursiveShapesInputOutputNested2: expected a map on the wire"); RecursiveShapesInputOutputNested2 out; { - const smithy::Document* member = doc.Find("bar"); + const opal::Document* member = doc.Find("bar"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RecursiveShapesInputOutputNested2.bar: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RecursiveShapesInputOutputNested2.bar: unexpected type on the wire"); parsed_member = member->as_string(); out.bar = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("recursiveMember"); + const opal::Document* member = doc.Find("recursiveMember"); if (member != nullptr && !member->is_null()) { types::RecursiveShapesInputOutputNested1 parsed_member{}; { @@ -2967,19 +2967,19 @@ smithy::Outcome DeserializeRecursiveShapesInp return out; } -smithy::Document SerializeRecursiveShapesOutput(const RecursiveShapesOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeRecursiveShapesOutput(const RecursiveShapesOutput& value) { + opal::DocumentMap map; if (value.nested.has_value()) { map.emplace("nested", SerializeRecursiveShapesInputOutputNested1((*value.nested))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRecursiveShapesOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RecursiveShapesOutput: expected a map on the wire"); +opal::Outcome DeserializeRecursiveShapesOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RecursiveShapesOutput: expected a map on the wire"); RecursiveShapesOutput out; { - const smithy::Document* member = doc.Find("nested"); + const opal::Document* member = doc.Find("nested"); if (member != nullptr && !member->is_null()) { types::RecursiveShapesInputOutputNested1 parsed_member{}; { @@ -2993,4 +2993,4 @@ smithy::Outcome DeserializeRecursiveShapesOutput(const sm return out; } -} // namespace smithy::protocoltests::rpcv2cbor +} // namespace opal::protocoltests::rpcv2cbor diff --git a/protocol-tests/rpcv2cbor/generated/src/server.cc b/protocol-tests/rpcv2cbor/generated/src/server.cc index 0d59b19a..b4406bd2 100644 --- a/protocol-tests/rpcv2cbor/generated/src/server.cc +++ b/protocol-tests/rpcv2cbor/generated/src/server.cc @@ -7,85 +7,85 @@ #include #include +#include "opal/protocoltests/rpcv2cbor/serde.h" +#include "opal/protocoltests/rpcv2cbor/server.h" #include "smithy/cbor/cbor.h" #include "smithy/core/blob.h" #include "smithy/core/document.h" -#include "smithy/protocoltests/rpcv2cbor/serde.h" -#include "smithy/protocoltests/rpcv2cbor/server.h" #include "smithy/server/router.h" -namespace smithy::protocoltests::rpcv2cbor { +namespace opal::protocoltests::rpcv2cbor { -namespace types = ::smithy::protocoltests::rpcv2cbor; +namespace types = ::opal::protocoltests::rpcv2cbor; namespace { namespace helpers { -smithy::http::HttpResponse CborError(int status, const std::string& code, const std::string& message, smithy::DocumentMap body) { - if (!code.empty()) body.insert_or_assign("__type", smithy::Document(code)); - if (!message.empty()) body.insert_or_assign("message", smithy::Document(message)); - smithy::http::HttpResponse response; +opal::http::HttpResponse CborError(int status, const std::string& code, const std::string& message, opal::DocumentMap body) { + if (!code.empty()) body.insert_or_assign("__type", opal::Document(code)); + if (!message.empty()) body.insert_or_assign("message", opal::Document(message)); + opal::http::HttpResponse response; response.status = status; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(smithy::Document(std::move(body))).ToString(); + response.body = opal::cbor::Encode(opal::Document(std::move(body))).ToString(); return response; } // [[maybe_unused]]: only unary routes map handler errors here; a service // whose operations all stream reports errors on the stream instead. -[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& error) { - if (error.kind() == smithy::ErrorKind::kModeled) { +[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& error) { + if (error.kind() == opal::ErrorKind::kModeled) { if (error.code() == "ComplexError") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeComplexError(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::CborError(400, "smithy.protocoltests.rpcv2Cbor#ComplexError", "", std::move(body)); } if (error.code() == "InvalidGreeting") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeInvalidGreeting(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::CborError(400, "smithy.protocoltests.rpcv2Cbor#InvalidGreeting", "", std::move(body)); } if (error.code() == "ValidationException") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeValidationException(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } return helpers::CborError(400, "smithy.framework#ValidationException", "", std::move(body)); } return helpers::CborError(400, error.code(), error.message(), {}); } - if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) return helpers::CborError(400, "SerializationException", error.message(), {}); + if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) return helpers::CborError(400, "SerializationException", error.message(), {}); // Never leak internal detail on unexpected failures. return helpers::CborError(500, "InternalFailure", "internal failure", {}); } // Constraint validation (smithy.framework#ValidationException): messages // and '/member' paths follow the official validation conformance suite. -void AddValidationFailure(std::vector* failures, std::string path, std::string message) { +void AddValidationFailure(std::vector* failures, std::string path, std::string message) { failures->push_back({std::move(path), std::move(message)}); } -void ValidateDefaults(const types::Defaults& value, const std::string& path, std::vector* failures) { +void ValidateDefaults(const types::Defaults& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/defaultEnum"; if (value.defaultEnum.value() == TestEnum::Value::kUnknown) { @@ -100,7 +100,7 @@ void ValidateDefaults(const types::Defaults& value, const std::string& path, std } } -void ValidateDenseSetMap(const std::map>& value, const std::string& path, std::vector* failures) { +void ValidateDenseSetMap(const std::map>& value, const std::string& path, std::vector* failures) { for (const auto& [key, item] : value) { const std::string item_path = path + "/" + key; { @@ -117,21 +117,21 @@ void ValidateDenseSetMap(const std::map>& } } -void ValidateOperationWithDefaultsInput(const types::OperationWithDefaultsInput& value, const std::string& path, std::vector* failures) { +void ValidateOperationWithDefaultsInput(const types::OperationWithDefaultsInput& value, const std::string& path, std::vector* failures) { if (value.defaults.has_value()) { const std::string member_path = path + "/defaults"; helpers::ValidateDefaults((*value.defaults), member_path, failures); } } -void ValidateRpcV2CborDenseMapsInput(const types::RpcV2CborDenseMapsInput& value, const std::string& path, std::vector* failures) { +void ValidateRpcV2CborDenseMapsInput(const types::RpcV2CborDenseMapsInput& value, const std::string& path, std::vector* failures) { if (value.denseSetMap.has_value()) { const std::string member_path = path + "/denseSetMap"; helpers::ValidateDenseSetMap((*value.denseSetMap), member_path, failures); } } -void ValidateFooEnumList(const std::vector& value, const std::string& path, std::vector* failures) { +void ValidateFooEnumList(const std::vector& value, const std::string& path, std::vector* failures) { for (std::size_t i = 0; i < value.size(); ++i) { const std::string item_path = path + "/" + std::to_string(i); if (value[i].value() == FooEnum::Value::kUnknown) { @@ -140,7 +140,7 @@ void ValidateFooEnumList(const std::vector& value, const std::string& p } } -void ValidateIntegerEnumList(const std::vector& value, const std::string& path, std::vector* failures) { +void ValidateIntegerEnumList(const std::vector& value, const std::string& path, std::vector* failures) { for (std::size_t i = 0; i < value.size(); ++i) { const std::string item_path = path + "/" + std::to_string(i); if (value[i] != IntegerEnum::kA && value[i] != IntegerEnum::kB && value[i] != IntegerEnum::kC) { @@ -149,7 +149,7 @@ void ValidateIntegerEnumList(const std::vector& value, const std::s } } -void ValidateRpcV2CborListsInput(const types::RpcV2CborListsInput& value, const std::string& path, std::vector* failures) { +void ValidateRpcV2CborListsInput(const types::RpcV2CborListsInput& value, const std::string& path, std::vector* failures) { if (value.stringSet.has_value()) { const std::string member_path = path + "/stringSet"; { @@ -174,7 +174,7 @@ void ValidateRpcV2CborListsInput(const types::RpcV2CborListsInput& value, const } } -void ValidateSparseSetMap(const std::map>>& value, const std::string& path, std::vector* failures) { +void ValidateSparseSetMap(const std::map>>& value, const std::string& path, std::vector* failures) { for (const auto& [key, item] : value) { const std::string item_path = path + "/" + key; if (item.has_value()) { @@ -193,7 +193,7 @@ void ValidateSparseSetMap(const std::map* failures) { +void ValidateRpcV2CborSparseMapsInput(const types::RpcV2CborSparseMapsInput& value, const std::string& path, std::vector* failures) { if (value.sparseSetMap.has_value()) { const std::string member_path = path + "/sparseSetMap"; helpers::ValidateSparseSetMap((*value.sparseSetMap), member_path, failures); @@ -202,20 +202,20 @@ void ValidateRpcV2CborSparseMapsInput(const types::RpcV2CborSparseMapsInput& val // [[maybe_unused]]: only unary routes reject invalid input over HTTP; a // service whose operations all stream reports validation on the stream. -[[maybe_unused]] smithy::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { +[[maybe_unused]] opal::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { std::string summary = std::to_string(failures.size()) + " validation error" + (failures.size() == 1 ? "" : "s") + " detected. "; - smithy::DocumentList field_list; + opal::DocumentList field_list; for (std::size_t i = 0; i < failures.size(); ++i) { if (i > 0) summary += "; "; summary += failures[i].message; - smithy::DocumentMap field; - field.emplace("message", smithy::Document(failures[i].message)); - field.emplace("path", smithy::Document(failures[i].path)); - field_list.push_back(smithy::Document(std::move(field))); + opal::DocumentMap field; + field.emplace("message", opal::Document(failures[i].message)); + field.emplace("path", opal::Document(failures[i].path)); + field_list.push_back(opal::Document(std::move(field))); } - smithy::DocumentMap body; - body.emplace("fieldList", smithy::Document(std::move(field_list))); - smithy::http::HttpResponse response = helpers::CborError(400, "smithy.framework#ValidationException", summary, std::move(body)); + opal::DocumentMap body; + body.emplace("fieldList", opal::Document(std::move(field_list))); + opal::http::HttpResponse response = helpers::CborError(400, "smithy.framework#ValidationException", summary, std::move(body)); return response; } @@ -223,24 +223,24 @@ void ValidateRpcV2CborSparseMapsInput(const types::RpcV2CborSparseMapsInput& val } // namespace RpcV2ProtocolServer::RpcV2ProtocolServer(std::shared_ptr handler) - : router_(std::make_shared()) { + : router_(std::make_shared()) { // The route table is derived from the model's @http traits; conflicts are // a modeling error surfaced by Router::Add (checked at generation time in a // later phase), so registration results are intentionally discarded. - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/EmptyInputOutput", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/EmptyInputOutput", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } EmptyInputOutputInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } @@ -249,129 +249,129 @@ RpcV2ProtocolServer::RpcV2ProtocolServer(std::shared_ptr h input = *std::move(parsed); auto outcome = handler->EmptyInputOutput(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeEmptyInputOutputOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeEmptyInputOutputOutput(*outcome)).ToString(); return response; }, "EmptyInputOutput"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/Float16", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/Float16", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } Float16Input input{}; auto outcome = handler->Float16(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeFloat16Output(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeFloat16Output(*outcome)).ToString(); return response; }, "Float16"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/FractionalSeconds", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/FractionalSeconds", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } FractionalSecondsInput input{}; auto outcome = handler->FractionalSeconds(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeFractionalSecondsOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeFractionalSecondsOutput(*outcome)).ToString(); return response; }, "FractionalSeconds"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/GreetingWithErrors", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/GreetingWithErrors", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } GreetingWithErrorsInput input{}; auto outcome = handler->GreetingWithErrors(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeGreetingWithErrorsOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeGreetingWithErrorsOutput(*outcome)).ToString(); return response; }, "GreetingWithErrors"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/NoInputOutput", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/NoInputOutput", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } NoInputOutputInput input{}; auto outcome = handler->NoInputOutput(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeNoInputOutputOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeNoInputOutputOutput(*outcome)).ToString(); return response; }, "NoInputOutput"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/OperationWithDefaults", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/OperationWithDefaults", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } OperationWithDefaultsInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } auto parsed = DeserializeOperationWithDefaultsInput(body_doc); if (!parsed) return helpers::CborError(400, "SerializationException", parsed.error().message(), {}); input = *std::move(parsed); - std::vector validation_failures; + std::vector validation_failures; helpers::ValidateOperationWithDefaultsInput(input, "", &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); auto outcome = handler->OperationWithDefaults(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeOperationWithDefaultsOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeOperationWithDefaultsOutput(*outcome)).ToString(); return response; }, "OperationWithDefaults"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/OptionalInputOutput", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/OptionalInputOutput", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } OptionalInputOutputInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } @@ -380,26 +380,26 @@ RpcV2ProtocolServer::RpcV2ProtocolServer(std::shared_ptr h input = *std::move(parsed); auto outcome = handler->OptionalInputOutput(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeOptionalInputOutputOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeOptionalInputOutputOutput(*outcome)).ToString(); return response; }, "OptionalInputOutput"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/RecursiveShapes", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/RecursiveShapes", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } RecursiveShapesInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } @@ -408,119 +408,119 @@ RpcV2ProtocolServer::RpcV2ProtocolServer(std::shared_ptr h input = *std::move(parsed); auto outcome = handler->RecursiveShapes(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeRecursiveShapesOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeRecursiveShapesOutput(*outcome)).ToString(); return response; }, "RecursiveShapes"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } RpcV2CborDenseMapsInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } auto parsed = DeserializeRpcV2CborDenseMapsInput(body_doc); if (!parsed) return helpers::CborError(400, "SerializationException", parsed.error().message(), {}); input = *std::move(parsed); - std::vector validation_failures; + std::vector validation_failures; helpers::ValidateRpcV2CborDenseMapsInput(input, "", &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); auto outcome = handler->RpcV2CborDenseMaps(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeRpcV2CborDenseMapsOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeRpcV2CborDenseMapsOutput(*outcome)).ToString(); return response; }, "RpcV2CborDenseMaps"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/RpcV2CborLists", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/RpcV2CborLists", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } RpcV2CborListsInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } auto parsed = DeserializeRpcV2CborListsInput(body_doc); if (!parsed) return helpers::CborError(400, "SerializationException", parsed.error().message(), {}); input = *std::move(parsed); - std::vector validation_failures; + std::vector validation_failures; helpers::ValidateRpcV2CborListsInput(input, "", &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); auto outcome = handler->RpcV2CborLists(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeRpcV2CborListsOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeRpcV2CborListsOutput(*outcome)).ToString(); return response; }, "RpcV2CborLists"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } RpcV2CborSparseMapsInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } auto parsed = DeserializeRpcV2CborSparseMapsInput(body_doc); if (!parsed) return helpers::CborError(400, "SerializationException", parsed.error().message(), {}); input = *std::move(parsed); - std::vector validation_failures; + std::vector validation_failures; helpers::ValidateRpcV2CborSparseMapsInput(input, "", &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); auto outcome = handler->RpcV2CborSparseMaps(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeRpcV2CborSparseMapsOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeRpcV2CborSparseMapsOutput(*outcome)).ToString(); return response; }, "RpcV2CborSparseMaps"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/RpcV2CborUnions", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/RpcV2CborUnions", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } RpcV2CborUnionsInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } @@ -529,26 +529,26 @@ RpcV2ProtocolServer::RpcV2ProtocolServer(std::shared_ptr h input = *std::move(parsed); auto outcome = handler->RpcV2CborUnions(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeRpcV2CborUnionsOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeRpcV2CborUnionsOutput(*outcome)).ToString(); return response; }, "RpcV2CborUnions"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/SimpleScalarProperties", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/SimpleScalarProperties", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } SimpleScalarPropertiesInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } @@ -557,26 +557,26 @@ RpcV2ProtocolServer::RpcV2ProtocolServer(std::shared_ptr h input = *std::move(parsed); auto outcome = handler->SimpleScalarProperties(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeSimpleScalarPropertiesOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeSimpleScalarPropertiesOutput(*outcome)).ToString(); return response; }, "SimpleScalarProperties"); - (void)router_->Add("POST", "/service/RpcV2Protocol/operation/SparseNullsOperation", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/service/RpcV2Protocol/operation/SparseNullsOperation", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { if (request.headers.Get("smithy-protocol").value_or("") != "rpc-v2-cbor") { return helpers::CborError(400, "SerializationException", "expected smithy-protocol: rpc-v2-cbor", {}); } // Content-Type validation per the rpcv2Cbor spec: a present header must // carry application/cbor (parameters ignored); 415 otherwise. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/cbor") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/cbor") { return helpers::CborError(415, "UnsupportedMediaTypeException", "expected content-type: application/cbor", {}); } SparseNullsOperationInput input{}; // An absent body deserializes like an empty CBOR map. - smithy::Document body_doc{smithy::DocumentMap{}}; + opal::Document body_doc{opal::DocumentMap{}}; if (!request.body.empty()) { - auto decoded = smithy::cbor::Decode(smithy::Blob::FromString(request.body)); + auto decoded = opal::cbor::Decode(opal::Blob::FromString(request.body)); if (!decoded) return helpers::CborError(400, "SerializationException", decoded.error().message(), {}); body_doc = *std::move(decoded); } @@ -585,17 +585,17 @@ RpcV2ProtocolServer::RpcV2ProtocolServer(std::shared_ptr h input = *std::move(parsed); auto outcome = handler->SparseNullsOperation(input, context); if (!outcome) return helpers::ErrorToResponse(outcome.error()); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.headers.Set("smithy-protocol", "rpc-v2-cbor"); response.headers.Set("content-type", "application/cbor"); - response.body = smithy::cbor::Encode(SerializeSparseNullsOperationOutput(*outcome)).ToString(); + response.body = opal::cbor::Encode(SerializeSparseNullsOperationOutput(*outcome)).ToString(); return response; }, "SparseNullsOperation"); } -smithy::http::RequestHandler RpcV2ProtocolServer::Handler() const { +opal::http::RequestHandler RpcV2ProtocolServer::Handler() const { auto router = router_; - return [router](const smithy::http::HttpRequest& request) { return router->Route(request); }; + return [router](const opal::http::HttpRequest& request) { return router->Route(request); }; } -} // namespace smithy::protocoltests::rpcv2cbor +} // namespace opal::protocoltests::rpcv2cbor diff --git a/protocol-tests/rpcv2cbor/generated/tests/request_tests.cc b/protocol-tests/rpcv2cbor/generated/tests/request_tests.cc index 90c9ff02..e8a4a345 100644 --- a/protocol-tests/rpcv2cbor/generated/tests/request_tests.cc +++ b/protocol-tests/rpcv2cbor/generated/tests/request_tests.cc @@ -8,22 +8,22 @@ #include #include -#include "smithy/protocoltests/rpcv2cbor/client.h" +#include "opal/protocoltests/rpcv2cbor/client.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::rpcv2cbor { +namespace opal::protocoltests::rpcv2cbor { // Generated from smithy.test#httpRequestTests (client cases). namespace { struct Fixture { - std::shared_ptr transport; + std::shared_ptr transport; RpcV2ProtocolClient client; }; Fixture MakeFixture(const std::string& endpoint = "") { - auto transport = std::make_shared(); - smithy::ClientConfig config; + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; config.endpoint = endpoint; @@ -42,15 +42,15 @@ TEST(RpcV2ProtocolRequestTest, empty_input) { return v; }(); (void)fixture.client.EmptyInputOutput(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/EmptyInputOutput"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/EmptyInputOutput"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_FALSE(request.headers.Has("X-Amz-Target")); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v/8=", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v/8=", request.body)); } // Body is empty and no Content-Type header if no input @@ -61,9 +61,9 @@ TEST(RpcV2ProtocolRequestTest, no_input) { return v; }(); (void)fixture.client.NoInputOutput(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/NoInputOutput"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/NoInputOutput"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_FALSE(request.headers.Has("Content-Type")); @@ -83,14 +83,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborClientPopulatesDefaultValuesInInput) { return v; }(); (void)fixture.client.OperationWithDefaults(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OperationWithDefaults"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OperationWithDefaults"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2hkZWZhdWx0c79tZGVmYXVsdFN0cmluZ2JoaW5kZWZhdWx0Qm9vbGVhbvVrZGVmYXVsdExpc3Sf/3BkZWZhdWx0VGltZXN0YW1wwQBrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX6P4AAAGpkZWZhdWx0TWFwv/9rZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfoAAAAA//8=", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2hkZWZhdWx0c79tZGVmYXVsdFN0cmluZ2JoaW5kZWZhdWx0Qm9vbGVhbvVrZGVmYXVsdExpc3Sf/3BkZWZhdWx0VGltZXN0YW1wwQBrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX6P4AAAGpkZWZhdWx0TWFwv/9rZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfoAAAAA//8=", request.body)); } // Client skips top level default values in input. @@ -101,14 +101,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborClientSkipsTopLevelDefaultValuesInInput) return v; }(); (void)fixture.client.OperationWithDefaults(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OperationWithDefaults"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OperationWithDefaults"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v/8=", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v/8=", request.body)); } // Client uses explicitly provided member values over defaults @@ -121,8 +121,8 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborClientUsesExplicitlyProvidedMemberValues v.defaultString = "bye"; v.defaultBoolean = true; v.defaultList = std::vector{"a"}; - v.defaultTimestamp = smithy::Timestamp::FromEpochMilliseconds(1000LL); - v.defaultBlob = smithy::Blob::FromString("hi"); + v.defaultTimestamp = opal::Timestamp::FromEpochMilliseconds(1000LL); + v.defaultBlob = opal::Blob::FromString("hi"); v.defaultByte = 2; v.defaultShort = 2; v.defaultInteger = 20; @@ -134,7 +134,7 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborClientUsesExplicitlyProvidedMemberValues v.defaultIntEnum = static_cast(2); v.emptyString = "foo"; v.falseBoolean = true; - v.emptyBlob = smithy::Blob::FromString("hi"); + v.emptyBlob = opal::Blob::FromString("hi"); v.zeroByte = 1; v.zeroShort = 1; v.zeroInteger = 1; @@ -146,14 +146,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborClientUsesExplicitlyProvidedMemberValues return v; }(); (void)fixture.client.OperationWithDefaults(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OperationWithDefaults"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OperationWithDefaults"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2hkZWZhdWx0c7dtZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXDB+z/wAAAAAAAAa2RlZmF1bHRCbG9iQmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPpAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQJrZW1wdHlTdHJpbmdjZm9vbGZhbHNlQm9vbGVhbvVpZW1wdHlCbG9iQmhpaHplcm9CeXRlAWl6ZXJvU2hvcnQBa3plcm9JbnRlZ2VyAWh6ZXJvTG9uZwFpemVyb0Zsb2F0+j+AAABqemVyb0RvdWJsZfs/8AAAAAAAAP8=", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2hkZWZhdWx0c7dtZGVmYXVsdFN0cmluZ2NieWVuZGVmYXVsdEJvb2xlYW71a2RlZmF1bHRMaXN0gWFhcGRlZmF1bHRUaW1lc3RhbXDB+z/wAAAAAAAAa2RlZmF1bHRCbG9iQmhpa2RlZmF1bHRCeXRlAmxkZWZhdWx0U2hvcnQCbmRlZmF1bHRJbnRlZ2VyFGtkZWZhdWx0TG9uZxjIbGRlZmF1bHRGbG9hdPpAAAAAbWRlZmF1bHREb3VibGX7QAAAAAAAAABqZGVmYXVsdE1hcKFkbmFtZWRKYWNra2RlZmF1bHRFbnVtY0JBUm5kZWZhdWx0SW50RW51bQJrZW1wdHlTdHJpbmdjZm9vbGZhbHNlQm9vbGVhbvVpZW1wdHlCbG9iQmhpaHplcm9CeXRlAWl6ZXJvU2hvcnQBa3plcm9JbnRlZ2VyAWh6ZXJvTG9uZwFpemVyb0Zsb2F0+j+AAABqemVyb0RvdWJsZfs/8AAAAAAAAP8=", request.body)); } // Any time a value is provided for a member in the top level of input, it is used, regardless of if its the default. @@ -166,14 +166,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborClientUsesExplicitlyProvidedValuesInTopL return v; }(); (void)fixture.client.OperationWithDefaults(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OperationWithDefaults"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OperationWithDefaults"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v290b3BMZXZlbERlZmF1bHRiaGl0b3RoZXJUb3BMZXZlbERlZmF1bHQA/w==", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v290b3BMZXZlbERlZmF1bHRiaGl0b3RoZXJUb3BMZXZlbERlZmF1bHQA/w==", request.body)); } // Typically, non top-level members would have defaults filled in, but if they have the clientOptional trait, the defaults should be ignored. @@ -188,14 +188,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborClientIgnoresNonTopLevelDefaultsOnMember return v; }(); (void)fixture.client.OperationWithDefaults(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OperationWithDefaults"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OperationWithDefaults"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v3ZjbGllbnRPcHRpb25hbERlZmF1bHRzoP8=", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v3ZjbGllbnRPcHRpb25hbERlZmF1bHRzoP8=", request.body)); } // When input is empty we write CBOR equivalent of {} @@ -206,14 +206,14 @@ TEST(RpcV2ProtocolRequestTest, optional_input) { return v; }(); (void)fixture.client.OptionalInputOutput(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OptionalInputOutput"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/OptionalInputOutput"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_FALSE(request.headers.Has("X-Amz-Target")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v/8=", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v/8=", request.body)); } // Serializes recursive structures @@ -244,14 +244,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborRecursiveShapes) { return v; }(); (void)fixture.client.RecursiveShapes(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RecursiveShapes"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RecursiveShapes"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=", request.body)); } // Serializes maps @@ -271,14 +271,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborMaps) { return v; }(); (void)fixture.client.RpcV2CborDenseMaps(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==", request.body)); } // Ensure that 0 and false are sent over the wire in all maps and lists @@ -291,14 +291,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSerializesZeroValuesInMaps) { return v; }(); (void)fixture.client.RpcV2CborDenseMaps(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==", request.body)); } // A request that contains a dense map of sets. @@ -310,14 +310,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSerializesDenseSetMap) { return v; }(); (void)fixture.client.RpcV2CborDenseMaps(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("oWtkZW5zZVNldE1hcKJheIBheYJhYWFi", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("oWtkZW5zZVNldE1hcKJheIBheYJhYWFi", request.body)); } // Serializes RpcV2 Cbor lists @@ -329,7 +329,7 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborLists) { v.stringSet = std::vector{"foo", "bar"}; v.integerList = std::vector{1, 2}; v.booleanList = std::vector{true, false}; - v.timestampList = std::vector{smithy::Timestamp::FromEpochMilliseconds(1398796238000LL), smithy::Timestamp::FromEpochMilliseconds(1398796238000LL)}; + v.timestampList = std::vector{opal::Timestamp::FromEpochMilliseconds(1398796238000LL), opal::Timestamp::FromEpochMilliseconds(1398796238000LL)}; v.enumList = std::vector{FooEnum::FromString("Foo"), FooEnum::FromString("0")}; v.intEnumList = std::vector{static_cast(1), static_cast(2)}; v.nestedStringList = std::vector>{std::vector{"foo", "bar"}, std::vector{"baz", "qux"}}; @@ -344,18 +344,18 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborLists) { v.b = "4"; return v; }()}; - v.blobList = std::vector{smithy::Blob::FromString("foo"), smithy::Blob::FromString("bar")}; + v.blobList = std::vector{opal::Blob::FromString("foo"), opal::Blob::FromString("bar")}; return v; }(); (void)fixture.client.RpcV2CborLists(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborLists"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborLists"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2pzdHJpbmdMaXN0gmNmb29jYmFyaXN0cmluZ1NldIJjZm9vY2JhcmtpbnRlZ2VyTGlzdIIBAmtib29sZWFuTGlzdIL19G10aW1lc3RhbXBMaXN0gsH7QdTX+/OAAADB+0HU1/vzgAAAaGVudW1MaXN0gmNGb29hMGtpbnRFbnVtTGlzdIIBAnBuZXN0ZWRTdHJpbmdMaXN0goJjZm9vY2JhcoJjYmF6Y3F1eG1zdHJ1Y3R1cmVMaXN0gqJhYWExYWJhMqJhYWEzYWJhNGhibG9iTGlzdIJDZm9vQ2Jhcv8=", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2pzdHJpbmdMaXN0gmNmb29jYmFyaXN0cmluZ1NldIJjZm9vY2JhcmtpbnRlZ2VyTGlzdIIBAmtib29sZWFuTGlzdIL19G10aW1lc3RhbXBMaXN0gsH7QdTX+/OAAADB+0HU1/vzgAAAaGVudW1MaXN0gmNGb29hMGtpbnRFbnVtTGlzdIIBAnBuZXN0ZWRTdHJpbmdMaXN0goJjZm9vY2JhcoJjYmF6Y3F1eG1zdHJ1Y3R1cmVMaXN0gqJhYWExYWJhMqJhYWEzYWJhNGhibG9iTGlzdIJDZm9vQ2Jhcv8=", request.body)); } // Serializes empty JSON lists @@ -367,14 +367,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborListsEmpty) { return v; }(); (void)fixture.client.RpcV2CborLists(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborLists"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborLists"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2pzdHJpbmdMaXN0n///", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2pzdHJpbmdMaXN0n///", request.body)); } // Serializes empty JSON definite length lists @@ -386,14 +386,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborListsEmptyUsingDefiniteLength) { return v; }(); (void)fixture.client.RpcV2CborLists(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborLists"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborLists"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("oWpzdHJpbmdMaXN0gA==", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("oWpzdHJpbmdMaXN0gA==", request.body)); } // Serializes sparse maps @@ -413,14 +413,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSparseMaps) { return v; }(); (void)fixture.client.RpcV2CborSparseMaps(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////", request.body)); } // Serializes null map values in sparse maps @@ -435,14 +435,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSerializesNullMapValues) { return v; }(); (void)fixture.client.RpcV2CborSparseMaps(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", request.body)); } // A request that contains a sparse map of sets @@ -454,14 +454,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSerializesSparseSetMap) { return v; }(); (void)fixture.client.RpcV2CborSparseMaps(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8=", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8=", request.body)); } // A request that contains a sparse map of sets. @@ -473,14 +473,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSerializesSparseSetMapAndRetainsNull) { return v; }(); (void)fixture.client.RpcV2CborSparseMaps(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", request.body)); } // Ensure that 0 and false are sent over the wire in all maps and lists @@ -493,14 +493,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSerializesZeroValuesInSparseMaps) { return v; }(); (void)fixture.client.RpcV2CborSparseMaps(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//", request.body)); } // Serializes a union followed by another structure member @@ -513,14 +513,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSerializesUnionValue) { return v; }(); (void)fixture.client.RpcV2CborUnions(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborUnions"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborUnions"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("omhjb250ZW50c6Frc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("omhjb250ZW50c6Frc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy", request.body)); } // Serializes a nested union followed by another structure member @@ -533,14 +533,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSerializesNestedUnionValue) { return v; }(); (void)fixture.client.RpcV2CborUnions(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborUnions"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/RpcV2CborUnions"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("omhjb250ZW50c6FqdW5pb25WYWx1ZaFrc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("omhjb250ZW50c6FqdW5pb25WYWx1ZaFrc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy", request.body)); } // Serializes simple scalar properties @@ -557,18 +557,18 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSimpleScalarProperties) { v.longValue = 9873LL; v.shortValue = 9898; v.stringValue = "simple"; - v.blobValue = smithy::Blob::FromString("foo"); + v.blobValue = opal::Blob::FromString("foo"); return v; }(); (void)fixture.client.SimpleScalarProperties(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SimpleScalarProperties"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SimpleScalarProperties"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w==", request.body)); } // RpcV2 Cbor should not serialize null structure values @@ -579,14 +579,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborClientDoesntSerializeNullStructureValues return v; }(); (void)fixture.client.SimpleScalarProperties(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SimpleScalarProperties"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SimpleScalarProperties"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v/8=", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v/8=", request.body)); } // Supports handling NaN float values. @@ -599,14 +599,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSupportsNaNFloatInputs) { return v; }(); (void)fixture.client.SimpleScalarProperties(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SimpleScalarProperties"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SimpleScalarProperties"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/", request.body)); } // Supports handling Infinity float values. @@ -619,14 +619,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSupportsInfinityFloatInputs) { return v; }(); (void)fixture.client.SimpleScalarProperties(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SimpleScalarProperties"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SimpleScalarProperties"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/", request.body)); } // Supports handling Infinity float values. @@ -639,14 +639,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSupportsNegativeInfinityFloatInputs) { return v; }(); (void)fixture.client.SimpleScalarProperties(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SimpleScalarProperties"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SimpleScalarProperties"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/", request.body)); } // Serializes null values in maps @@ -658,14 +658,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSparseMapsSerializeNullValues) { return v; }(); (void)fixture.client.SparseNullsOperation(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SparseNullsOperation"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SparseNullsOperation"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==", request.body)); } // Serializes null values in lists @@ -677,14 +677,14 @@ TEST(RpcV2ProtocolRequestTest, RpcV2CborSparseListsSerializeNull) { return v; }(); (void)fixture.client.SparseNullsOperation(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SparseNullsOperation"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/service/RpcV2Protocol/operation/SparseNullsOperation"); EXPECT_EQ(request.headers.Get("Accept").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(request.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==", request.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==", request.body)); } -} // namespace smithy::protocoltests::rpcv2cbor +} // namespace opal::protocoltests::rpcv2cbor diff --git a/protocol-tests/rpcv2cbor/generated/tests/response_tests.cc b/protocol-tests/rpcv2cbor/generated/tests/response_tests.cc index 3e6759a0..3fc513f7 100644 --- a/protocol-tests/rpcv2cbor/generated/tests/response_tests.cc +++ b/protocol-tests/rpcv2cbor/generated/tests/response_tests.cc @@ -8,10 +8,10 @@ #include #include -#include "smithy/protocoltests/rpcv2cbor/client.h" +#include "opal/protocoltests/rpcv2cbor/client.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::rpcv2cbor { +namespace opal::protocoltests::rpcv2cbor { // Generated from smithy.test#httpResponseTests (client cases), // including the cases attached to modeled error shapes. @@ -24,13 +24,13 @@ namespace smithy::protocoltests::rpcv2cbor { namespace { struct Fixture { - std::shared_ptr transport; + std::shared_ptr transport; RpcV2ProtocolClient client; }; Fixture MakeFixture(const std::string& endpoint = "") { - auto transport = std::make_shared(); - smithy::ClientConfig config; + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; config.endpoint = endpoint; @@ -47,7 +47,7 @@ TEST(RpcV2ProtocolResponseTest, empty_output) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v/8="); + fixture.transport->next_response.body = opal::testing::FromBase64("v/8="); const auto outcome = fixture.client.EmptyInputOutput(EmptyInputOutputInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const EmptyInputOutputOutput expected = [] { @@ -63,7 +63,7 @@ TEST(RpcV2ProtocolResponseTest, empty_output_no_body) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64(""); + fixture.transport->next_response.body = opal::testing::FromBase64(""); const auto outcome = fixture.client.EmptyInputOutput(EmptyInputOutputInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const EmptyInputOutputOutput expected = [] { @@ -79,7 +79,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborFloat16Inf) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("oWV2YWx1Zfl8AA=="); + fixture.transport->next_response.body = opal::testing::FromBase64("oWV2YWx1Zfl8AA=="); const auto outcome = fixture.client.Float16(Float16Input{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const Float16Output expected = [] { @@ -96,7 +96,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborFloat16NegInf) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("oWV2YWx1Zfn8AA=="); + fixture.transport->next_response.body = opal::testing::FromBase64("oWV2YWx1Zfn8AA=="); const auto outcome = fixture.client.Float16(Float16Input{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const Float16Output expected = [] { @@ -113,7 +113,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborFloat16Subnormal) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("oWV2YWx1ZfkAUA=="); + fixture.transport->next_response.body = opal::testing::FromBase64("oWV2YWx1ZfkAUA=="); const auto outcome = fixture.client.Float16(Float16Input{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const Float16Output expected = [] { @@ -130,12 +130,12 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborDateTimeWithFractionalSeconds) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2hkYXRldGltZcH7Qcw32zgPvnf/"); + fixture.transport->next_response.body = opal::testing::FromBase64("v2hkYXRldGltZcH7Qcw32zgPvnf/"); const auto outcome = fixture.client.FractionalSeconds(FractionalSecondsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const FractionalSecondsOutput expected = [] { FractionalSecondsOutput v{}; - v.datetime = smithy::Timestamp::FromEpochMilliseconds(946845296123LL); + v.datetime = opal::Timestamp::FromEpochMilliseconds(946845296123LL); return v; }(); EXPECT_EQ(*outcome, expected); @@ -146,7 +146,7 @@ TEST(RpcV2ProtocolResponseTest, no_output) { Fixture fixture = MakeFixture(); fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64(""); + fixture.transport->next_response.body = opal::testing::FromBase64(""); const auto outcome = fixture.client.NoInputOutput(NoInputOutputInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const NoInputOutputOutput expected = [] { @@ -162,7 +162,7 @@ TEST(RpcV2ProtocolResponseTest, NoOutputClientAllowsEmptyCbor) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v/8="); + fixture.transport->next_response.body = opal::testing::FromBase64("v/8="); const auto outcome = fixture.client.NoInputOutput(NoInputOutputInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const NoInputOutputOutput expected = [] { @@ -179,7 +179,7 @@ TEST(RpcV2ProtocolResponseTest, NoOutputClientAllowsEmptyBody) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64(""); + fixture.transport->next_response.body = opal::testing::FromBase64(""); const auto outcome = fixture.client.NoInputOutput(NoInputOutputInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const NoInputOutputOutput expected = [] { @@ -195,7 +195,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborClientPopulatesDefaultsValuesWhenMissin fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v/8="); + fixture.transport->next_response.body = opal::testing::FromBase64("v/8="); const auto outcome = fixture.client.OperationWithDefaults(OperationWithDefaultsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const OperationWithDefaultsOutput expected = [] { @@ -203,8 +203,8 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborClientPopulatesDefaultsValuesWhenMissin v.defaultString = "hi"; v.defaultBoolean = true; v.defaultList = std::vector{}; - v.defaultTimestamp = smithy::Timestamp::FromEpochMilliseconds(0LL); - v.defaultBlob = smithy::Blob::FromString("abc"); + v.defaultTimestamp = opal::Timestamp::FromEpochMilliseconds(0LL); + v.defaultBlob = opal::Blob::FromString("abc"); v.defaultByte = 1; v.defaultShort = 1; v.defaultInteger = 10; @@ -216,7 +216,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborClientPopulatesDefaultsValuesWhenMissin v.defaultIntEnum = static_cast(1); v.emptyString = ""; v.falseBoolean = false; - v.emptyBlob = smithy::Blob::FromString(""); + v.emptyBlob = opal::Blob::FromString(""); v.zeroByte = 0; v.zeroShort = 0; v.zeroInteger = 0; @@ -234,7 +234,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborClientIgnoresDefaultValuesIfMemberValue fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcMH7QAAAAAAAAABrZGVmYXVsdEJsb2JCaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0+kAAAABtZGVmYXVsdERvdWJsZftAAAAAAAAAAGpkZWZhdWx0TWFwoWRuYW1lZEphY2trZGVmYXVsdEVudW1jQkFSbmRlZmF1bHRJbnRFbnVtAmtlbXB0eVN0cmluZ2Nmb29sZmFsc2VCb29sZWFu9WllbXB0eUJsb2JCaGloemVyb0J5dGUBaXplcm9TaG9ydAFremVyb0ludGVnZXIBaHplcm9Mb25nAWl6ZXJvRmxvYXT6P4AAAGp6ZXJvRG91Ymxl+z/wAAAAAAAA/w=="); + fixture.transport->next_response.body = opal::testing::FromBase64("v21kZWZhdWx0U3RyaW5nY2J5ZW5kZWZhdWx0Qm9vbGVhbvRrZGVmYXVsdExpc3SBYWFwZGVmYXVsdFRpbWVzdGFtcMH7QAAAAAAAAABrZGVmYXVsdEJsb2JCaGlrZGVmYXVsdEJ5dGUCbGRlZmF1bHRTaG9ydAJuZGVmYXVsdEludGVnZXIUa2RlZmF1bHRMb25nGMhsZGVmYXVsdEZsb2F0+kAAAABtZGVmYXVsdERvdWJsZftAAAAAAAAAAGpkZWZhdWx0TWFwoWRuYW1lZEphY2trZGVmYXVsdEVudW1jQkFSbmRlZmF1bHRJbnRFbnVtAmtlbXB0eVN0cmluZ2Nmb29sZmFsc2VCb29sZWFu9WllbXB0eUJsb2JCaGloemVyb0J5dGUBaXplcm9TaG9ydAFremVyb0ludGVnZXIBaHplcm9Mb25nAWl6ZXJvRmxvYXT6P4AAAGp6ZXJvRG91Ymxl+z/wAAAAAAAA/w=="); const auto outcome = fixture.client.OperationWithDefaults(OperationWithDefaultsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const OperationWithDefaultsOutput expected = [] { @@ -242,8 +242,8 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborClientIgnoresDefaultValuesIfMemberValue v.defaultString = "bye"; v.defaultBoolean = false; v.defaultList = std::vector{"a"}; - v.defaultTimestamp = smithy::Timestamp::FromEpochMilliseconds(2000LL); - v.defaultBlob = smithy::Blob::FromString("hi"); + v.defaultTimestamp = opal::Timestamp::FromEpochMilliseconds(2000LL); + v.defaultBlob = opal::Blob::FromString("hi"); v.defaultByte = 2; v.defaultShort = 2; v.defaultInteger = 20; @@ -255,7 +255,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborClientIgnoresDefaultValuesIfMemberValue v.defaultIntEnum = static_cast(2); v.emptyString = "foo"; v.falseBoolean = true; - v.emptyBlob = smithy::Blob::FromString("hi"); + v.emptyBlob = opal::Blob::FromString("hi"); v.zeroByte = 1; v.zeroShort = 1; v.zeroInteger = 1; @@ -273,7 +273,7 @@ TEST(RpcV2ProtocolResponseTest, optional_output) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v/8="); + fixture.transport->next_response.body = opal::testing::FromBase64("v/8="); const auto outcome = fixture.client.OptionalInputOutput(OptionalInputOutputInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const OptionalInputOutputOutput expected = [] { @@ -289,7 +289,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborRecursiveShapes) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8="); + fixture.transport->next_response.body = opal::testing::FromBase64("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8="); const auto outcome = fixture.client.RecursiveShapes(RecursiveShapesInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RecursiveShapesOutput expected = [] { @@ -325,7 +325,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborRecursiveShapesUsingDefiniteLength) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("oWZuZXN0ZWSiY2Zvb2RGb28xZm5lc3RlZKJjYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyomNmb29kRm9vMmZuZXN0ZWShY2JhcmRCYXIy"); + fixture.transport->next_response.body = opal::testing::FromBase64("oWZuZXN0ZWSiY2Zvb2RGb28xZm5lc3RlZKJjYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyomNmb29kRm9vMmZuZXN0ZWShY2JhcmRCYXIy"); const auto outcome = fixture.client.RecursiveShapes(RecursiveShapesInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RecursiveShapesOutput expected = [] { @@ -361,7 +361,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborMaps) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ=="); + fixture.transport->next_response.body = opal::testing::FromBase64("oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ=="); const auto outcome = fixture.client.RpcV2CborDenseMaps(RpcV2CborDenseMapsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborDenseMapsOutput expected = [] { @@ -386,7 +386,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborDeserializesZeroValuesInMaps) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A=="); + fixture.transport->next_response.body = opal::testing::FromBase64("om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A=="); const auto outcome = fixture.client.RpcV2CborDenseMaps(RpcV2CborDenseMapsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborDenseMapsOutput expected = [] { @@ -404,7 +404,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborDeserializesDenseSetMap) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("oWtkZW5zZVNldE1hcKJheIBheYJhYWFi"); + fixture.transport->next_response.body = opal::testing::FromBase64("oWtkZW5zZVNldE1hcKJheIBheYJhYWFi"); const auto outcome = fixture.client.RpcV2CborDenseMaps(RpcV2CborDenseMapsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborDenseMapsOutput expected = [] { @@ -421,7 +421,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborLists) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2pzdHJpbmdMaXN0n2Nmb29jYmFy/2lzdHJpbmdTZXSfY2Zvb2NiYXL/a2ludGVnZXJMaXN0nwEC/2tib29sZWFuTGlzdJ/19P9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9wbmVzdGVkU3RyaW5nTGlzdJ+fY2Zvb2NiYXL/n2NiYXpjcXV4//9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9oYmxvYkxpc3SfQ2Zvb0NiYXL//w=="); + fixture.transport->next_response.body = opal::testing::FromBase64("v2pzdHJpbmdMaXN0n2Nmb29jYmFy/2lzdHJpbmdTZXSfY2Zvb2NiYXL/a2ludGVnZXJMaXN0nwEC/2tib29sZWFuTGlzdJ/19P9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9wbmVzdGVkU3RyaW5nTGlzdJ+fY2Zvb2NiYXL/n2NiYXpjcXV4//9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9oYmxvYkxpc3SfQ2Zvb0NiYXL//w=="); const auto outcome = fixture.client.RpcV2CborLists(RpcV2CborListsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborListsOutput expected = [] { @@ -430,7 +430,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborLists) { v.stringSet = std::vector{"foo", "bar"}; v.integerList = std::vector{1, 2}; v.booleanList = std::vector{true, false}; - v.timestampList = std::vector{smithy::Timestamp::FromEpochMilliseconds(1398796238000LL), smithy::Timestamp::FromEpochMilliseconds(1398796238000LL)}; + v.timestampList = std::vector{opal::Timestamp::FromEpochMilliseconds(1398796238000LL), opal::Timestamp::FromEpochMilliseconds(1398796238000LL)}; v.enumList = std::vector{FooEnum::FromString("Foo"), FooEnum::FromString("0")}; v.intEnumList = std::vector{static_cast(1), static_cast(2)}; v.nestedStringList = std::vector>{std::vector{"foo", "bar"}, std::vector{"baz", "qux"}}; @@ -445,7 +445,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborLists) { v.b = "4"; return v; }()}; - v.blobList = std::vector{smithy::Blob::FromString("foo"), smithy::Blob::FromString("bar")}; + v.blobList = std::vector{opal::Blob::FromString("foo"), opal::Blob::FromString("bar")}; return v; }(); EXPECT_EQ(*outcome, expected); @@ -457,7 +457,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborListsEmpty) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2pzdHJpbmdMaXN0n///"); + fixture.transport->next_response.body = opal::testing::FromBase64("v2pzdHJpbmdMaXN0n///"); const auto outcome = fixture.client.RpcV2CborLists(RpcV2CborListsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborListsOutput expected = [] { @@ -474,7 +474,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborIndefiniteStringInsideIndefiniteListCan fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8="); + fixture.transport->next_response.body = opal::testing::FromBase64("v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8="); const auto outcome = fixture.client.RpcV2CborLists(RpcV2CborListsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborListsOutput expected = [] { @@ -491,7 +491,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborIndefiniteStringInsideDefiniteListCanDe fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n"); + fixture.transport->next_response.body = opal::testing::FromBase64("oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n"); const auto outcome = fixture.client.RpcV2CborLists(RpcV2CborListsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborListsOutput expected = [] { @@ -508,7 +508,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborSparseJsonMaps) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////"); + fixture.transport->next_response.body = opal::testing::FromBase64("v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////"); const auto outcome = fixture.client.RpcV2CborSparseMaps(RpcV2CborSparseMapsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborSparseMapsOutput expected = [] { @@ -533,7 +533,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborDeserializesNullMapValues) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//"); + fixture.transport->next_response.body = opal::testing::FromBase64("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//"); const auto outcome = fixture.client.RpcV2CborSparseMaps(RpcV2CborSparseMapsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborSparseMapsOutput expected = [] { @@ -553,7 +553,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborDeserializesSparseSetMap) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8="); + fixture.transport->next_response.body = opal::testing::FromBase64("v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8="); const auto outcome = fixture.client.RpcV2CborSparseMaps(RpcV2CborSparseMapsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborSparseMapsOutput expected = [] { @@ -570,7 +570,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborDeserializesSparseSetMapAndRetainsNull) fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8="); + fixture.transport->next_response.body = opal::testing::FromBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8="); const auto outcome = fixture.client.RpcV2CborSparseMaps(RpcV2CborSparseMapsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborSparseMapsOutput expected = [] { @@ -587,7 +587,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborDeserializesZeroValuesInSparseMaps) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//"); + fixture.transport->next_response.body = opal::testing::FromBase64("v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//"); const auto outcome = fixture.client.RpcV2CborSparseMaps(RpcV2CborSparseMapsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborSparseMapsOutput expected = [] { @@ -605,7 +605,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborDeserializesUnionValue) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("omhjb250ZW50c6Frc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy"); + fixture.transport->next_response.body = opal::testing::FromBase64("omhjb250ZW50c6Frc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy"); const auto outcome = fixture.client.RpcV2CborUnions(RpcV2CborUnionsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborUnionsOutput expected = [] { @@ -623,7 +623,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborDeserializesNestedUnionValue) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("omhjb250ZW50c6FqdW5pb25WYWx1ZaFrc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy"); + fixture.transport->next_response.body = opal::testing::FromBase64("omhjb250ZW50c6FqdW5pb25WYWx1ZaFrc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy"); const auto outcome = fixture.client.RpcV2CborUnions(RpcV2CborUnionsInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const RpcV2CborUnionsOutput expected = [] { @@ -641,7 +641,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborSimpleScalarProperties) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v3B0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb2//"); + fixture.transport->next_response.body = opal::testing::FromBase64("v3B0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb2//"); const auto outcome = fixture.client.SimpleScalarProperties(SimpleScalarPropertiesInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const SimpleScalarPropertiesOutput expected = [] { @@ -654,7 +654,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborSimpleScalarProperties) { v.integerValue = 256; v.shortValue = 9898; v.stringValue = "simple"; - v.blobValue = smithy::Blob::FromString("foo"); + v.blobValue = opal::Blob::FromString("foo"); return v; }(); EXPECT_EQ(*outcome, expected); @@ -666,7 +666,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborSimpleScalarPropertiesUsingDefiniteLeng fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("qXB0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb28="); + fixture.transport->next_response.body = opal::testing::FromBase64("qXB0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb28="); const auto outcome = fixture.client.SimpleScalarProperties(SimpleScalarPropertiesInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const SimpleScalarPropertiesOutput expected = [] { @@ -679,7 +679,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborSimpleScalarPropertiesUsingDefiniteLeng v.integerValue = 256; v.shortValue = 9898; v.stringValue = "simple"; - v.blobValue = smithy::Blob::FromString("foo"); + v.blobValue = opal::Blob::FromString("foo"); return v; }(); EXPECT_EQ(*outcome, expected); @@ -691,7 +691,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborClientDoesntDeserializeNullStructureVal fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2tzdHJpbmdWYWx1Zfb/"); + fixture.transport->next_response.body = opal::testing::FromBase64("v2tzdHJpbmdWYWx1Zfb/"); const auto outcome = fixture.client.SimpleScalarProperties(SimpleScalarPropertiesInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const SimpleScalarPropertiesOutput expected = [] { @@ -707,7 +707,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborSupportsInfinityFloatOutputs) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/"); + fixture.transport->next_response.body = opal::testing::FromBase64("v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/"); const auto outcome = fixture.client.SimpleScalarProperties(SimpleScalarPropertiesInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const SimpleScalarPropertiesOutput expected = [] { @@ -725,7 +725,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborSupportsNegativeInfinityFloatOutputs) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/"); + fixture.transport->next_response.body = opal::testing::FromBase64("v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/"); const auto outcome = fixture.client.SimpleScalarProperties(SimpleScalarPropertiesInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const SimpleScalarPropertiesOutput expected = [] { @@ -743,7 +743,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborSupportsUpcastingDataOnDeserialize) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8="); + fixture.transport->next_response.body = opal::testing::FromBase64("v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8="); const auto outcome = fixture.client.SimpleScalarProperties(SimpleScalarPropertiesInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const SimpleScalarPropertiesOutput expected = [] { @@ -766,7 +766,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborExtraFieldsInTheBodyShouldBeSkippedByCl fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABrZXh0cmFPYmplY3S/c2luZGVmaW5pdGVMZW5ndGhNYXC/a3dpdGhBbkFycmF5nwECA///cWRlZmluaXRlTGVuZ3RoTWFwo3J3aXRoQURlZmluaXRlQXJyYXmDAQIDeB1hbmRTb21lSW5kZWZpbml0ZUxlbmd0aFN0cmluZ3gfdGhhdCBoYXMsIGJlZW4gY2h1bmtlZCBvbiBjb21tYWxub3JtYWxTdHJpbmdjZm9vanNob3J0VmFsdWUZJw9uc29tZU90aGVyRmllbGR2dGhpcyBzaG91bGQgYmUgc2tpcHBlZP9saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w=="); + fixture.transport->next_response.body = opal::testing::FromBase64("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABrZXh0cmFPYmplY3S/c2luZGVmaW5pdGVMZW5ndGhNYXC/a3dpdGhBbkFycmF5nwECA///cWRlZmluaXRlTGVuZ3RoTWFwo3J3aXRoQURlZmluaXRlQXJyYXmDAQIDeB1hbmRTb21lSW5kZWZpbml0ZUxlbmd0aFN0cmluZ3gfdGhhdCBoYXMsIGJlZW4gY2h1bmtlZCBvbiBjb21tYWxub3JtYWxTdHJpbmdjZm9vanNob3J0VmFsdWUZJw9uc29tZU90aGVyRmllbGR2dGhpcyBzaG91bGQgYmUgc2tpcHBlZP9saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w=="); const auto outcome = fixture.client.SimpleScalarProperties(SimpleScalarPropertiesInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const SimpleScalarPropertiesOutput expected = [] { @@ -780,7 +780,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborExtraFieldsInTheBodyShouldBeSkippedByCl v.longValue = 9873LL; v.shortValue = 9898; v.stringValue = "simple"; - v.blobValue = smithy::Blob::FromString("foo"); + v.blobValue = opal::Blob::FromString("foo"); return v; }(); EXPECT_EQ(*outcome, expected); @@ -792,7 +792,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborSparseMapsDeserializeNullValues) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w=="); + fixture.transport->next_response.body = opal::testing::FromBase64("v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w=="); const auto outcome = fixture.client.SparseNullsOperation(SparseNullsOperationInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const SparseNullsOperationOutput expected = [] { @@ -809,7 +809,7 @@ TEST(RpcV2ProtocolResponseTest, RpcV2CborSparseListsDeserializeNull) { fixture.transport->next_response.status = 200; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v3BzcGFyc2VTdHJpbmdMaXN0n/b//w=="); + fixture.transport->next_response.body = opal::testing::FromBase64("v3BzcGFyc2VTdHJpbmdMaXN0n/b//w=="); const auto outcome = fixture.client.SparseNullsOperation(SparseNullsOperationInput{}); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); const SparseNullsOperationOutput expected = [] { @@ -826,7 +826,7 @@ TEST(RpcV2ProtocolErrorTest, RpcV2CborComplexError) { fixture.transport->next_response.status = 400; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//"); + fixture.transport->next_response.body = opal::testing::FromBase64("v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//"); const auto outcome = fixture.client.GreetingWithErrors(GreetingWithErrorsInput{}); ASSERT_FALSE(outcome.ok()); EXPECT_EQ(outcome.error().code(), "ComplexError"); @@ -850,7 +850,7 @@ TEST(RpcV2ProtocolErrorTest, RpcV2CborEmptyComplexError) { fixture.transport->next_response.status = 400; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/"); + fixture.transport->next_response.body = opal::testing::FromBase64("v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/"); const auto outcome = fixture.client.GreetingWithErrors(GreetingWithErrorsInput{}); ASSERT_FALSE(outcome.ok()); EXPECT_EQ(outcome.error().code(), "ComplexError"); @@ -869,7 +869,7 @@ TEST(RpcV2ProtocolErrorTest, RpcV2CborInvalidGreetingError) { fixture.transport->next_response.status = 400; fixture.transport->next_response.headers.Set("Content-Type", "application/cbor"); fixture.transport->next_response.headers.Set("smithy-protocol", "rpc-v2-cbor"); - fixture.transport->next_response.body = smithy::testing::FromBase64("v2ZfX3R5cGV4LnNtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8="); + fixture.transport->next_response.body = opal::testing::FromBase64("v2ZfX3R5cGV4LnNtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8="); const auto outcome = fixture.client.GreetingWithErrors(GreetingWithErrorsInput{}); ASSERT_FALSE(outcome.ok()); EXPECT_EQ(outcome.error().code(), "InvalidGreeting"); @@ -883,4 +883,4 @@ TEST(RpcV2ProtocolErrorTest, RpcV2CborInvalidGreetingError) { EXPECT_EQ(*detail, expected); } -} // namespace smithy::protocoltests::rpcv2cbor +} // namespace opal::protocoltests::rpcv2cbor diff --git a/protocol-tests/rpcv2cbor/generated/tests/server_request_tests.cc b/protocol-tests/rpcv2cbor/generated/tests/server_request_tests.cc index 7248abe9..63e33f35 100644 --- a/protocol-tests/rpcv2cbor/generated/tests/server_request_tests.cc +++ b/protocol-tests/rpcv2cbor/generated/tests/server_request_tests.cc @@ -8,11 +8,11 @@ #include #include -#include "smithy/protocoltests/rpcv2cbor/client.h" -#include "smithy/protocoltests/rpcv2cbor/server.h" +#include "opal/protocoltests/rpcv2cbor/client.h" +#include "opal/protocoltests/rpcv2cbor/server.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::rpcv2cbor { +namespace opal::protocoltests::rpcv2cbor { // Generated from smithy.test#httpRequestTests (server cases): the wire // request is routed into the generated server and the parsed input is @@ -123,72 +123,72 @@ SparseNullsOperationOutput MinimalSparseNullsOperationOutput() { class RecordingHandler : public RpcV2ProtocolHandler { public: - smithy::Outcome EmptyInputOutput(const EmptyInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EmptyInputOutput(const EmptyInputOutputInput& input, const opal::server::RequestContext&) override { lastEmptyInputOutput = input; return MinimalEmptyInputOutputOutput(); } std::optional lastEmptyInputOutput; - smithy::Outcome Float16(const Float16Input& input, const smithy::server::RequestContext&) override { + opal::Outcome Float16(const Float16Input& input, const opal::server::RequestContext&) override { lastFloat16 = input; return MinimalFloat16Output(); } std::optional lastFloat16; - smithy::Outcome FractionalSeconds(const FractionalSecondsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome FractionalSeconds(const FractionalSecondsInput& input, const opal::server::RequestContext&) override { lastFractionalSeconds = input; return MinimalFractionalSecondsOutput(); } std::optional lastFractionalSeconds; - smithy::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const opal::server::RequestContext&) override { lastGreetingWithErrors = input; return MinimalGreetingWithErrorsOutput(); } std::optional lastGreetingWithErrors; - smithy::Outcome NoInputOutput(const NoInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome NoInputOutput(const NoInputOutputInput& input, const opal::server::RequestContext&) override { lastNoInputOutput = input; return MinimalNoInputOutputOutput(); } std::optional lastNoInputOutput; - smithy::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input, const opal::server::RequestContext&) override { lastOperationWithDefaults = input; return MinimalOperationWithDefaultsOutput(); } std::optional lastOperationWithDefaults; - smithy::Outcome OptionalInputOutput(const OptionalInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OptionalInputOutput(const OptionalInputOutputInput& input, const opal::server::RequestContext&) override { lastOptionalInputOutput = input; return MinimalOptionalInputOutputOutput(); } std::optional lastOptionalInputOutput; - smithy::Outcome RecursiveShapes(const RecursiveShapesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RecursiveShapes(const RecursiveShapesInput& input, const opal::server::RequestContext&) override { lastRecursiveShapes = input; return MinimalRecursiveShapesOutput(); } std::optional lastRecursiveShapes; - smithy::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const opal::server::RequestContext&) override { lastRpcV2CborDenseMaps = input; return MinimalRpcV2CborDenseMapsOutput(); } std::optional lastRpcV2CborDenseMaps; - smithy::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const opal::server::RequestContext&) override { lastRpcV2CborLists = input; return MinimalRpcV2CborListsOutput(); } std::optional lastRpcV2CborLists; - smithy::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const opal::server::RequestContext&) override { lastRpcV2CborSparseMaps = input; return MinimalRpcV2CborSparseMapsOutput(); } std::optional lastRpcV2CborSparseMaps; - smithy::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const opal::server::RequestContext&) override { lastRpcV2CborUnions = input; return MinimalRpcV2CborUnionsOutput(); } std::optional lastRpcV2CborUnions; - smithy::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const opal::server::RequestContext&) override { lastSimpleScalarProperties = input; return MinimalSimpleScalarPropertiesOutput(); } std::optional lastSimpleScalarProperties; - smithy::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const opal::server::RequestContext&) override { lastSparseNullsOperation = input; return MinimalSparseNullsOperationOutput(); } @@ -201,14 +201,14 @@ class RecordingHandler : public RpcV2ProtocolHandler { TEST(RpcV2ProtocolServerRequestTest, empty_input) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/EmptyInputOutput"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v/8="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v/8="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastEmptyInputOutput.has_value()) << response.status << " " << response.body; const EmptyInputOutputInput expected = [] { EmptyInputOutputInput v{}; @@ -221,13 +221,13 @@ TEST(RpcV2ProtocolServerRequestTest, empty_input) { TEST(RpcV2ProtocolServerRequestTest, empty_input_no_body) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/EmptyInputOutput"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastEmptyInputOutput.has_value()) << response.status << " " << response.body; const EmptyInputOutputInput expected = [] { EmptyInputOutputInput v{}; @@ -241,13 +241,13 @@ TEST(RpcV2ProtocolServerRequestTest, empty_input_no_body) { TEST(RpcV2ProtocolServerRequestTest, empty_input_no_body_has_accept) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/EmptyInputOutput"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastEmptyInputOutput.has_value()) << response.status << " " << response.body; const EmptyInputOutputInput expected = [] { EmptyInputOutputInput v{}; @@ -260,12 +260,12 @@ TEST(RpcV2ProtocolServerRequestTest, empty_input_no_body_has_accept) { TEST(RpcV2ProtocolServerRequestTest, no_input) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/NoInputOutput"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastNoInputOutput.has_value()) << response.status << " " << response.body; const NoInputOutputInput expected = [] { NoInputOutputInput v{}; @@ -278,14 +278,14 @@ TEST(RpcV2ProtocolServerRequestTest, no_input) { TEST(RpcV2ProtocolServerRequestTest, NoInputServerAllowsEmptyCbor) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/NoInputOutput"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v/8="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v/8="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastNoInputOutput.has_value()) << response.status << " " << response.body; const NoInputOutputInput expected = [] { NoInputOutputInput v{}; @@ -299,13 +299,13 @@ TEST(RpcV2ProtocolServerRequestTest, NoInputServerAllowsEmptyCbor) { TEST(RpcV2ProtocolServerRequestTest, NoInputServerAllowsEmptyBody) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/NoInputOutput"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastNoInputOutput.has_value()) << response.status << " " << response.body; const NoInputOutputInput expected = [] { NoInputOutputInput v{}; @@ -318,14 +318,14 @@ TEST(RpcV2ProtocolServerRequestTest, NoInputServerAllowsEmptyBody) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborServerPopulatesDefaultsWhenMissingInRequestBody) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/OperationWithDefaults"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2hkZWZhdWx0c6D/"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2hkZWZhdWx0c6D/"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastOperationWithDefaults.has_value()) << response.status << " " << response.body; const OperationWithDefaultsInput expected = [] { OperationWithDefaultsInput v{}; @@ -334,8 +334,8 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborServerPopulatesDefaultsWhenMissing v.defaultString = "hi"; v.defaultBoolean = true; v.defaultList = std::vector{}; - v.defaultTimestamp = smithy::Timestamp::FromEpochMilliseconds(0LL); - v.defaultBlob = smithy::Blob::FromString("abc"); + v.defaultTimestamp = opal::Timestamp::FromEpochMilliseconds(0LL); + v.defaultBlob = opal::Blob::FromString("abc"); v.defaultByte = 1; v.defaultShort = 1; v.defaultInteger = 10; @@ -347,7 +347,7 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborServerPopulatesDefaultsWhenMissing v.defaultIntEnum = static_cast(1); v.emptyString = ""; v.falseBoolean = false; - v.emptyBlob = smithy::Blob::FromString(""); + v.emptyBlob = opal::Blob::FromString(""); v.zeroByte = 0; v.zeroShort = 0; v.zeroInteger = 0; @@ -367,14 +367,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborServerPopulatesDefaultsWhenMissing TEST(RpcV2ProtocolServerRequestTest, optional_input) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/OptionalInputOutput"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v/8="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v/8="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastOptionalInputOutput.has_value()) << response.status << " " << response.body; const OptionalInputOutputInput expected = [] { OptionalInputOutputInput v{}; @@ -387,14 +387,14 @@ TEST(RpcV2ProtocolServerRequestTest, optional_input) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborRecursiveShapes) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RecursiveShapes"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRecursiveShapes.has_value()) << response.status << " " << response.body; const RecursiveShapesInput expected = [] { RecursiveShapesInput v{}; @@ -427,14 +427,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborRecursiveShapes) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborMaps) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ=="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ=="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborDenseMaps.has_value()) << response.status << " " << response.body; const RpcV2CborDenseMapsInput expected = [] { RpcV2CborDenseMapsInput v{}; @@ -456,14 +456,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborMaps) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesZeroValuesInMaps) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A=="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A=="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborDenseMaps.has_value()) << response.status << " " << response.body; const RpcV2CborDenseMapsInput expected = [] { RpcV2CborDenseMapsInput v{}; @@ -478,14 +478,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesZeroValuesInMaps) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesDenseSetMap) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborDenseMaps"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("oWtkZW5zZVNldE1hcKJheIBheYJhYWFi"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("oWtkZW5zZVNldE1hcKJheIBheYJhYWFi"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborDenseMaps.has_value()) << response.status << " " << response.body; const RpcV2CborDenseMapsInput expected = [] { RpcV2CborDenseMapsInput v{}; @@ -499,14 +499,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesDenseSetMap) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborLists) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborLists"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2pzdHJpbmdMaXN0gmNmb29jYmFyaXN0cmluZ1NldIJjZm9vY2JhcmtpbnRlZ2VyTGlzdIIBAmtib29sZWFuTGlzdIL19G10aW1lc3RhbXBMaXN0gsH7QdTX+/OAAADB+0HU1/vzgAAAaGVudW1MaXN0gmNGb29hMGtpbnRFbnVtTGlzdIIBAnBuZXN0ZWRTdHJpbmdMaXN0goJjZm9vY2JhcoJjYmF6Y3F1eG1zdHJ1Y3R1cmVMaXN0gqJhYWExYWJhMqJhYWEzYWJhNGhibG9iTGlzdIJDZm9vQ2Jhcv8="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2pzdHJpbmdMaXN0gmNmb29jYmFyaXN0cmluZ1NldIJjZm9vY2JhcmtpbnRlZ2VyTGlzdIIBAmtib29sZWFuTGlzdIL19G10aW1lc3RhbXBMaXN0gsH7QdTX+/OAAADB+0HU1/vzgAAAaGVudW1MaXN0gmNGb29hMGtpbnRFbnVtTGlzdIIBAnBuZXN0ZWRTdHJpbmdMaXN0goJjZm9vY2JhcoJjYmF6Y3F1eG1zdHJ1Y3R1cmVMaXN0gqJhYWExYWJhMqJhYWEzYWJhNGhibG9iTGlzdIJDZm9vQ2Jhcv8="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborLists.has_value()) << response.status << " " << response.body; const RpcV2CborListsInput expected = [] { RpcV2CborListsInput v{}; @@ -514,7 +514,7 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborLists) { v.stringSet = std::vector{"foo", "bar"}; v.integerList = std::vector{1, 2}; v.booleanList = std::vector{true, false}; - v.timestampList = std::vector{smithy::Timestamp::FromEpochMilliseconds(1398796238000LL), smithy::Timestamp::FromEpochMilliseconds(1398796238000LL)}; + v.timestampList = std::vector{opal::Timestamp::FromEpochMilliseconds(1398796238000LL), opal::Timestamp::FromEpochMilliseconds(1398796238000LL)}; v.enumList = std::vector{FooEnum::FromString("Foo"), FooEnum::FromString("0")}; v.intEnumList = std::vector{static_cast(1), static_cast(2)}; v.nestedStringList = std::vector>{std::vector{"foo", "bar"}, std::vector{"baz", "qux"}}; @@ -529,7 +529,7 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborLists) { v.b = "4"; return v; }()}; - v.blobList = std::vector{smithy::Blob::FromString("foo"), smithy::Blob::FromString("bar")}; + v.blobList = std::vector{opal::Blob::FromString("foo"), opal::Blob::FromString("bar")}; return v; }(); EXPECT_EQ(*handler->lastRpcV2CborLists, expected); @@ -539,14 +539,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborLists) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborListsEmpty) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborLists"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2pzdHJpbmdMaXN0n///"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2pzdHJpbmdMaXN0n///"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborLists.has_value()) << response.status << " " << response.body; const RpcV2CborListsInput expected = [] { RpcV2CborListsInput v{}; @@ -560,14 +560,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborListsEmpty) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborListsEmptyUsingDefiniteLength) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborLists"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("oWpzdHJpbmdMaXN0gA=="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("oWpzdHJpbmdMaXN0gA=="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborLists.has_value()) << response.status << " " << response.body; const RpcV2CborListsInput expected = [] { RpcV2CborListsInput v{}; @@ -581,14 +581,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborListsEmptyUsingDefiniteLength) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborIndefiniteStringInsideIndefiniteList) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborLists"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2pzdHJpbmdMaXN0n394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n//8="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborLists.has_value()) << response.status << " " << response.body; const RpcV2CborListsInput expected = [] { RpcV2CborListsInput v{}; @@ -602,14 +602,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborIndefiniteStringInsideIndefiniteLi TEST(RpcV2ProtocolServerRequestTest, RpcV2CborIndefiniteStringInsideDefiniteList) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborLists"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("oWpzdHJpbmdMaXN0g394HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcsdyB3aGljaCB3aWxsIGJlIGNodW5rZWQsbiBvbiBlYWNoIGNvbW1h/394NUFub3RoZXIgZXhhbXBsZSBpbmRlZmluaXRlIHN0cmluZyB3aXRoIG9ubHkgb25lIGNodW5r/3ZUaGlzIGlzIGEgcGxhaW4gc3RyaW5n"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborLists.has_value()) << response.status << " " << response.body; const RpcV2CborListsInput expected = [] { RpcV2CborListsInput v{}; @@ -623,14 +623,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborIndefiniteStringInsideDefiniteList TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSparseMaps) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborSparseMaps.has_value()) << response.status << " " << response.body; const RpcV2CborSparseMapsInput expected = [] { RpcV2CborSparseMapsInput v{}; @@ -652,14 +652,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSparseMaps) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesNullMapValues) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborSparseMaps.has_value()) << response.status << " " << response.body; const RpcV2CborSparseMapsInput expected = [] { RpcV2CborSparseMapsInput v{}; @@ -676,14 +676,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesNullMapValues) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesSparseSetMap) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL///8="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborSparseMaps.has_value()) << response.status << " " << response.body; const RpcV2CborSparseMapsInput expected = [] { RpcV2CborSparseMapsInput v{}; @@ -697,14 +697,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesSparseSetMap) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesSparseSetMapAndRetainsNull) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborSparseMaps.has_value()) << response.status << " " << response.body; const RpcV2CborSparseMapsInput expected = [] { RpcV2CborSparseMapsInput v{}; @@ -718,14 +718,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesSparseSetMapAndRetainsNu TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesZeroValuesInSparseMaps) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborSparseMaps"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborSparseMaps.has_value()) << response.status << " " << response.body; const RpcV2CborSparseMapsInput expected = [] { RpcV2CborSparseMapsInput v{}; @@ -740,14 +740,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesZeroValuesInSparseMaps) TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesUnionValue) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborUnions"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("omhjb250ZW50c6Frc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("omhjb250ZW50c6Frc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborUnions.has_value()) << response.status << " " << response.body; const RpcV2CborUnionsInput expected = [] { RpcV2CborUnionsInput v{}; @@ -762,14 +762,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesUnionValue) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesNestedUnionValue) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/RpcV2CborUnions"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("omhjb250ZW50c6FqdW5pb25WYWx1ZaFrc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("omhjb250ZW50c6FqdW5pb25WYWx1ZaFrc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRpcV2CborUnions.has_value()) << response.status << " " << response.body; const RpcV2CborUnionsInput expected = [] { RpcV2CborUnionsInput v{}; @@ -784,14 +784,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSerializesNestedUnionValue) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSimpleScalarProperties) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SimpleScalarProperties"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w=="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w=="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSimpleScalarProperties.has_value()) << response.status << " " << response.body; const SimpleScalarPropertiesInput expected = [] { SimpleScalarPropertiesInput v{}; @@ -804,7 +804,7 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSimpleScalarProperties) { v.longValue = 9873LL; v.shortValue = 9898; v.stringValue = "simple"; - v.blobValue = smithy::Blob::FromString("foo"); + v.blobValue = opal::Blob::FromString("foo"); return v; }(); EXPECT_EQ(*handler->lastSimpleScalarProperties, expected); @@ -816,14 +816,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSimpleScalarProperties) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSimpleScalarPropertiesUsingIndefiniteLength) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SimpleScalarProperties"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("qmlieXRlVmFsdWUFf2Zkb3VibGVlVmFsdWX/+z/+OVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl//RqZmxvYXRWYWx1ZfpA9AAAbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqn9mc3RyaW5nZVZhbHVl/2ZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw=="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("qmlieXRlVmFsdWUFf2Zkb3VibGVlVmFsdWX/+z/+OVgQYk3Tf2VmYWxzZWdCb29sZWFuZVZhbHVl//RqZmxvYXRWYWx1ZfpA9AAAbGludGVnZXJWYWx1ZRkBAGlsb25nVmFsdWUZJpFqc2hvcnRWYWx1ZRkmqn9mc3RyaW5nZVZhbHVl/2ZzaW1wbGVwdHJ1ZUJvb2xlYW5WYWx1ZfVpYmxvYlZhbHVlQ2Zvbw=="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSimpleScalarProperties.has_value()) << response.status << " " << response.body; const SimpleScalarPropertiesInput expected = [] { SimpleScalarPropertiesInput v{}; @@ -836,7 +836,7 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSimpleScalarPropertiesUsingIndefin v.longValue = 9873LL; v.shortValue = 9898; v.stringValue = "simple"; - v.blobValue = smithy::Blob::FromString("foo"); + v.blobValue = opal::Blob::FromString("foo"); return v; }(); EXPECT_EQ(*handler->lastSimpleScalarProperties, expected); @@ -846,14 +846,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSimpleScalarPropertiesUsingIndefin TEST(RpcV2ProtocolServerRequestTest, RpcV2CborServerDoesntDeSerializeNullStructureValues) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SimpleScalarProperties"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2tzdHJpbmdWYWx1Zfb/"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2tzdHJpbmdWYWx1Zfb/"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSimpleScalarProperties.has_value()) << response.status << " " << response.body; const SimpleScalarPropertiesInput expected = [] { SimpleScalarPropertiesInput v{}; @@ -866,14 +866,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborServerDoesntDeSerializeNullStructu TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSupportsInfinityFloatInputs) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SimpleScalarProperties"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSimpleScalarProperties.has_value()) << response.status << " " << response.body; const SimpleScalarPropertiesInput expected = [] { SimpleScalarPropertiesInput v{}; @@ -888,14 +888,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSupportsInfinityFloatInputs) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSupportsNegativeInfinityFloatInputs) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SimpleScalarProperties"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/"); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/"); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSimpleScalarProperties.has_value()) << response.status << " " << response.body; const SimpleScalarPropertiesInput expected = [] { SimpleScalarPropertiesInput v{}; @@ -910,14 +910,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSupportsNegativeInfinityFloatInput TEST(RpcV2ProtocolServerRequestTest, RpcV2CborIndefiniteLengthStringsCanBeDeserialized) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SimpleScalarProperties"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("oWtzdHJpbmdWYWx1ZX94HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcscSBjaHVua2VkIG9uIGNvbW1h/w=="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("oWtzdHJpbmdWYWx1ZX94HUFuIGV4YW1wbGUgaW5kZWZpbml0ZSBzdHJpbmcscSBjaHVua2VkIG9uIGNvbW1h/w=="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSimpleScalarProperties.has_value()) << response.status << " " << response.body; const SimpleScalarPropertiesInput expected = [] { SimpleScalarPropertiesInput v{}; @@ -931,18 +931,18 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborIndefiniteLengthStringsCanBeDeseri TEST(RpcV2ProtocolServerRequestTest, RpcV2CborIndefiniteLengthByteStringsCanBeDeserialized) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SimpleScalarProperties"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("oWlibG9iVmFsdWVfWCJBbiBleGFtcGxlIGluZGVmaW5pdGUtYnl0ZSBzdHJpbmcsUSBjaHVua2VkIG9uIGNvbW1h/w=="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("oWlibG9iVmFsdWVfWCJBbiBleGFtcGxlIGluZGVmaW5pdGUtYnl0ZSBzdHJpbmcsUSBjaHVua2VkIG9uIGNvbW1h/w=="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSimpleScalarProperties.has_value()) << response.status << " " << response.body; const SimpleScalarPropertiesInput expected = [] { SimpleScalarPropertiesInput v{}; - v.blobValue = smithy::Blob::FromString("An example indefinite-byte string, chunked on comma"); + v.blobValue = opal::Blob::FromString("An example indefinite-byte string, chunked on comma"); return v; }(); EXPECT_EQ(*handler->lastSimpleScalarProperties, expected); @@ -952,14 +952,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborIndefiniteLengthByteStringsCanBeDe TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSupportsUpcastingData) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SimpleScalarProperties"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2tkb3VibGVWYWx1Zfk+AGpmbG9hdFZhbHVl+UegbGludGVnZXJWYWx1ZRg4aWxvbmdWYWx1ZRkBAGpzaG9ydFZhbHVlCv8="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSimpleScalarProperties.has_value()) << response.status << " " << response.body; const SimpleScalarPropertiesInput expected = [] { SimpleScalarPropertiesInput v{}; @@ -979,14 +979,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSupportsUpcastingData) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborExtraFieldsInTheBodyShouldBeSkippedByServers) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SimpleScalarProperties"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABrZXh0cmFPYmplY3S/c2luZGVmaW5pdGVMZW5ndGhNYXC/a3dpdGhBbkFycmF5nwECA///cWRlZmluaXRlTGVuZ3RoTWFwo3J3aXRoQURlZmluaXRlQXJyYXmDAQIDeB1hbmRTb21lSW5kZWZpbml0ZUxlbmd0aFN0cmluZ3gfdGhhdCBoYXMsIGJlZW4gY2h1bmtlZCBvbiBjb21tYWxub3JtYWxTdHJpbmdjZm9vanNob3J0VmFsdWUZJw9uc29tZU90aGVyRmllbGR2dGhpcyBzaG91bGQgYmUgc2tpcHBlZP9saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w=="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABrZXh0cmFPYmplY3S/c2luZGVmaW5pdGVMZW5ndGhNYXC/a3dpdGhBbkFycmF5nwECA///cWRlZmluaXRlTGVuZ3RoTWFwo3J3aXRoQURlZmluaXRlQXJyYXmDAQIDeB1hbmRTb21lSW5kZWZpbml0ZUxlbmd0aFN0cmluZ3gfdGhhdCBoYXMsIGJlZW4gY2h1bmtlZCBvbiBjb21tYWxub3JtYWxTdHJpbmdjZm9vanNob3J0VmFsdWUZJw9uc29tZU90aGVyRmllbGR2dGhpcyBzaG91bGQgYmUgc2tpcHBlZP9saW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w=="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSimpleScalarProperties.has_value()) << response.status << " " << response.body; const SimpleScalarPropertiesInput expected = [] { SimpleScalarPropertiesInput v{}; @@ -999,7 +999,7 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborExtraFieldsInTheBodyShouldBeSkippe v.longValue = 9873LL; v.shortValue = 9898; v.stringValue = "simple"; - v.blobValue = smithy::Blob::FromString("foo"); + v.blobValue = opal::Blob::FromString("foo"); return v; }(); EXPECT_EQ(*handler->lastSimpleScalarProperties, expected); @@ -1009,13 +1009,13 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborExtraFieldsInTheBodyShouldBeSkippe TEST(RpcV2ProtocolServerRequestTest, RpcV2CborServersShouldHandleNoAcceptHeader) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SimpleScalarProperties"; request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w=="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v2lieXRlVmFsdWUFa2RvdWJsZVZhbHVl+z/+OVgQYk3TcWZhbHNlQm9vbGVhblZhbHVl9GpmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAaWxvbmdWYWx1ZRkmkWpzaG9ydFZhbHVlGSaqa3N0cmluZ1ZhbHVlZnNpbXBsZXB0cnVlQm9vbGVhblZhbHVl9WlibG9iVmFsdWVDZm9v/w=="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSimpleScalarProperties.has_value()) << response.status << " " << response.body; const SimpleScalarPropertiesInput expected = [] { SimpleScalarPropertiesInput v{}; @@ -1028,7 +1028,7 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborServersShouldHandleNoAcceptHeader) v.longValue = 9873LL; v.shortValue = 9898; v.stringValue = "simple"; - v.blobValue = smithy::Blob::FromString("foo"); + v.blobValue = opal::Blob::FromString("foo"); return v; }(); EXPECT_EQ(*handler->lastSimpleScalarProperties, expected); @@ -1038,14 +1038,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborServersShouldHandleNoAcceptHeader) TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSparseMapsSerializeNullValues) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SparseNullsOperation"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w=="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w=="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSparseNullsOperation.has_value()) << response.status << " " << response.body; const SparseNullsOperationInput expected = [] { SparseNullsOperationInput v{}; @@ -1059,14 +1059,14 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSparseMapsSerializeNullValues) { TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSparseListsSerializeNull) { auto handler = std::make_shared(); RpcV2ProtocolServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/RpcV2Protocol/operation/SparseNullsOperation"; request.headers.Set("Accept", "application/cbor"); request.headers.Set("Content-Type", "application/cbor"); request.headers.Set("smithy-protocol", "rpc-v2-cbor"); - request.body = smithy::testing::FromBase64("v3BzcGFyc2VTdHJpbmdMaXN0n/b//w=="); - const smithy::http::HttpResponse response = server.Handler()(request); + request.body = opal::testing::FromBase64("v3BzcGFyc2VTdHJpbmdMaXN0n/b//w=="); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastSparseNullsOperation.has_value()) << response.status << " " << response.body; const SparseNullsOperationInput expected = [] { SparseNullsOperationInput v{}; @@ -1076,4 +1076,4 @@ TEST(RpcV2ProtocolServerRequestTest, RpcV2CborSparseListsSerializeNull) { EXPECT_EQ(*handler->lastSparseNullsOperation, expected); } -} // namespace smithy::protocoltests::rpcv2cbor +} // namespace opal::protocoltests::rpcv2cbor diff --git a/protocol-tests/rpcv2cbor/generated/tests/server_response_tests.cc b/protocol-tests/rpcv2cbor/generated/tests/server_response_tests.cc index 9db8b41e..c8e11d44 100644 --- a/protocol-tests/rpcv2cbor/generated/tests/server_response_tests.cc +++ b/protocol-tests/rpcv2cbor/generated/tests/server_response_tests.cc @@ -8,11 +8,11 @@ #include #include -#include "smithy/protocoltests/rpcv2cbor/client.h" -#include "smithy/protocoltests/rpcv2cbor/server.h" +#include "opal/protocoltests/rpcv2cbor/client.h" +#include "opal/protocoltests/rpcv2cbor/server.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::rpcv2cbor { +namespace opal::protocoltests::rpcv2cbor { // Generated from smithy.test#httpResponseTests (server cases): a stub // handler returns the expected params and the wire response the server @@ -119,81 +119,81 @@ SparseNullsOperationOutput MinimalSparseNullsOperationOutput() { class RecordingHandler : public RpcV2ProtocolHandler { public: - smithy::Outcome EmptyInputOutput(const EmptyInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EmptyInputOutput(const EmptyInputOutputInput& input, const opal::server::RequestContext&) override { lastEmptyInputOutput = input; return MinimalEmptyInputOutputOutput(); } std::optional lastEmptyInputOutput; - smithy::Outcome Float16(const Float16Input& input, const smithy::server::RequestContext&) override { + opal::Outcome Float16(const Float16Input& input, const opal::server::RequestContext&) override { lastFloat16 = input; return MinimalFloat16Output(); } std::optional lastFloat16; - smithy::Outcome FractionalSeconds(const FractionalSecondsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome FractionalSeconds(const FractionalSecondsInput& input, const opal::server::RequestContext&) override { lastFractionalSeconds = input; return MinimalFractionalSecondsOutput(); } std::optional lastFractionalSeconds; - smithy::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const opal::server::RequestContext&) override { lastGreetingWithErrors = input; return MinimalGreetingWithErrorsOutput(); } std::optional lastGreetingWithErrors; - smithy::Outcome NoInputOutput(const NoInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome NoInputOutput(const NoInputOutputInput& input, const opal::server::RequestContext&) override { lastNoInputOutput = input; return MinimalNoInputOutputOutput(); } std::optional lastNoInputOutput; - smithy::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input, const opal::server::RequestContext&) override { lastOperationWithDefaults = input; return MinimalOperationWithDefaultsOutput(); } std::optional lastOperationWithDefaults; - smithy::Outcome OptionalInputOutput(const OptionalInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OptionalInputOutput(const OptionalInputOutputInput& input, const opal::server::RequestContext&) override { lastOptionalInputOutput = input; return MinimalOptionalInputOutputOutput(); } std::optional lastOptionalInputOutput; - smithy::Outcome RecursiveShapes(const RecursiveShapesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RecursiveShapes(const RecursiveShapesInput& input, const opal::server::RequestContext&) override { lastRecursiveShapes = input; return MinimalRecursiveShapesOutput(); } std::optional lastRecursiveShapes; - smithy::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const opal::server::RequestContext&) override { lastRpcV2CborDenseMaps = input; return MinimalRpcV2CborDenseMapsOutput(); } std::optional lastRpcV2CborDenseMaps; - smithy::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const opal::server::RequestContext&) override { lastRpcV2CborLists = input; return MinimalRpcV2CborListsOutput(); } std::optional lastRpcV2CborLists; - smithy::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const opal::server::RequestContext&) override { lastRpcV2CborSparseMaps = input; return MinimalRpcV2CborSparseMapsOutput(); } std::optional lastRpcV2CborSparseMaps; - smithy::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const opal::server::RequestContext&) override { lastRpcV2CborUnions = input; return MinimalRpcV2CborUnionsOutput(); } std::optional lastRpcV2CborUnions; - smithy::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const opal::server::RequestContext&) override { lastSimpleScalarProperties = input; return MinimalSimpleScalarPropertiesOutput(); } std::optional lastSimpleScalarProperties; - smithy::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const opal::server::RequestContext&) override { lastSparseNullsOperation = input; return MinimalSparseNullsOperationOutput(); } std::optional lastSparseNullsOperation; }; -smithy::http::HttpRequest MinimalRequestForEmptyInputOutput() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForEmptyInputOutput() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -205,9 +205,9 @@ smithy::http::HttpRequest MinimalRequestForEmptyInputOutput() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForNoInputOutput() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForNoInputOutput() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -219,9 +219,9 @@ smithy::http::HttpRequest MinimalRequestForNoInputOutput() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForOperationWithDefaults() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForOperationWithDefaults() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -233,9 +233,9 @@ smithy::http::HttpRequest MinimalRequestForOperationWithDefaults() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForOptionalInputOutput() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForOptionalInputOutput() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -247,9 +247,9 @@ smithy::http::HttpRequest MinimalRequestForOptionalInputOutput() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForRecursiveShapes() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForRecursiveShapes() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -261,9 +261,9 @@ smithy::http::HttpRequest MinimalRequestForRecursiveShapes() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForRpcV2CborDenseMaps() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForRpcV2CborDenseMaps() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -275,9 +275,9 @@ smithy::http::HttpRequest MinimalRequestForRpcV2CborDenseMaps() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForRpcV2CborLists() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForRpcV2CborLists() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -289,9 +289,9 @@ smithy::http::HttpRequest MinimalRequestForRpcV2CborLists() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForRpcV2CborSparseMaps() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForRpcV2CborSparseMaps() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -303,9 +303,9 @@ smithy::http::HttpRequest MinimalRequestForRpcV2CborSparseMaps() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForRpcV2CborUnions() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForRpcV2CborUnions() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -317,9 +317,9 @@ smithy::http::HttpRequest MinimalRequestForRpcV2CborUnions() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForSimpleScalarProperties() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForSimpleScalarProperties() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -331,9 +331,9 @@ smithy::http::HttpRequest MinimalRequestForSimpleScalarProperties() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForSparseNullsOperation() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForSparseNullsOperation() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -345,9 +345,9 @@ smithy::http::HttpRequest MinimalRequestForSparseNullsOperation() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForGreetingWithErrors() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForGreetingWithErrors() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *RpcV2ProtocolClient::Create(std::move(config)); @@ -365,7 +365,7 @@ smithy::http::HttpRequest MinimalRequestForGreetingWithErrors() { TEST(RpcV2ProtocolServerResponseTest, empty_output) { class Handler final : public RecordingHandler { public: - smithy::Outcome EmptyInputOutput(const EmptyInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EmptyInputOutput(const EmptyInputOutputInput& input, const opal::server::RequestContext&) override { (void)input; return [] { EmptyInputOutputOutput v{}; @@ -374,18 +374,18 @@ TEST(RpcV2ProtocolServerResponseTest, empty_output) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForEmptyInputOutput()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForEmptyInputOutput()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v/8=", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v/8=", response.body)); } // A `Content-Type` header should not be set if the response body is empty. TEST(RpcV2ProtocolServerResponseTest, no_output) { class Handler final : public RecordingHandler { public: - smithy::Outcome NoInputOutput(const NoInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome NoInputOutput(const NoInputOutputInput& input, const opal::server::RequestContext&) override { (void)input; return [] { NoInputOutputOutput v{}; @@ -394,7 +394,7 @@ TEST(RpcV2ProtocolServerResponseTest, no_output) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForNoInputOutput()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForNoInputOutput()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); } @@ -403,7 +403,7 @@ TEST(RpcV2ProtocolServerResponseTest, no_output) { TEST(RpcV2ProtocolServerResponseTest, RpcV2CborServerPopulatesDefaultsInResponseWhenMissingInParams) { class Handler final : public RecordingHandler { public: - smithy::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { OperationWithDefaultsOutput v{}; @@ -412,18 +412,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborServerPopulatesDefaultsInResponse } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForOperationWithDefaults()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForOperationWithDefaults()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX7P/AAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8=", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v21kZWZhdWx0U3RyaW5nYmhpbmRlZmF1bHRCb29sZWFu9WtkZWZhdWx0TGlzdIBwZGVmYXVsdFRpbWVzdGFtcMH7AAAAAAAAAABrZGVmYXVsdEJsb2JDYWJja2RlZmF1bHRCeXRlAWxkZWZhdWx0U2hvcnQBbmRlZmF1bHRJbnRlZ2VyCmtkZWZhdWx0TG9uZxhkbGRlZmF1bHRGbG9hdPo/gAAAbWRlZmF1bHREb3VibGX7P/AAAAAAAABqZGVmYXVsdE1hcKBrZGVmYXVsdEVudW1jRk9PbmRlZmF1bHRJbnRFbnVtAWtlbXB0eVN0cmluZ2BsZmFsc2VCb29sZWFu9GllbXB0eUJsb2JAaHplcm9CeXRlAGl6ZXJvU2hvcnQAa3plcm9JbnRlZ2VyAGh6ZXJvTG9uZwBpemVyb0Zsb2F0+gAAAABqemVyb0RvdWJsZfsAAAAAAAAAAP8=", response.body)); } // When output is empty we write CBOR equivalent of {} TEST(RpcV2ProtocolServerResponseTest, optional_output) { class Handler final : public RecordingHandler { public: - smithy::Outcome OptionalInputOutput(const OptionalInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OptionalInputOutput(const OptionalInputOutputInput& input, const opal::server::RequestContext&) override { (void)input; return [] { OptionalInputOutputOutput v{}; @@ -432,18 +432,18 @@ TEST(RpcV2ProtocolServerResponseTest, optional_output) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForOptionalInputOutput()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForOptionalInputOutput()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v/8=", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v/8=", response.body)); } // Serializes recursive structures TEST(RpcV2ProtocolServerResponseTest, RpcV2CborRecursiveShapes) { class Handler final : public RecordingHandler { public: - smithy::Outcome RecursiveShapes(const RecursiveShapesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RecursiveShapes(const RecursiveShapesInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RecursiveShapesOutput v{}; @@ -472,18 +472,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborRecursiveShapes) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRecursiveShapes()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRecursiveShapes()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2ZuZXN0ZWS/Y2Zvb2RGb28xZm5lc3RlZL9jYmFyZEJhcjFvcmVjdXJzaXZlTWVtYmVyv2Nmb29kRm9vMmZuZXN0ZWS/Y2JhcmRCYXIy//////8=", response.body)); } // Deserializes maps TEST(RpcV2ProtocolServerResponseTest, RpcV2CborMaps) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborDenseMapsOutput v{}; @@ -501,18 +501,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborMaps) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborDenseMaps()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborDenseMaps()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("oW5kZW5zZVN0cnVjdE1hcKJjZm9voWJoaWV0aGVyZWNiYXqhYmhpY2J5ZQ==", response.body)); } // Ensure that 0 and false are sent over the wire in all maps and lists TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesZeroValuesInMaps) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborDenseMapsOutput v{}; @@ -523,18 +523,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesZeroValuesInMaps) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborDenseMaps()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborDenseMaps()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("om5kZW5zZU51bWJlck1hcKFheABvZGVuc2VCb29sZWFuTWFwoWF49A==", response.body)); } // A response that contains a dense map of sets TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesDenseSetMap) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborDenseMapsOutput v{}; @@ -544,18 +544,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesDenseSetMap) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborDenseMaps()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborDenseMaps()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("oWtkZW5zZVNldE1hcKJheIBheYJhYWFi", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("oWtkZW5zZVNldE1hcKJheIBheYJhYWFi", response.body)); } // Serializes RpcV2 Cbor lists TEST(RpcV2ProtocolServerResponseTest, RpcV2CborLists) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborListsOutput v{}; @@ -563,7 +563,7 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborLists) { v.stringSet = std::vector{"foo", "bar"}; v.integerList = std::vector{1, 2}; v.booleanList = std::vector{true, false}; - v.timestampList = std::vector{smithy::Timestamp::FromEpochMilliseconds(1398796238000LL), smithy::Timestamp::FromEpochMilliseconds(1398796238000LL)}; + v.timestampList = std::vector{opal::Timestamp::FromEpochMilliseconds(1398796238000LL), opal::Timestamp::FromEpochMilliseconds(1398796238000LL)}; v.enumList = std::vector{FooEnum::FromString("Foo"), FooEnum::FromString("0")}; v.intEnumList = std::vector{static_cast(1), static_cast(2)}; v.nestedStringList = std::vector>{std::vector{"foo", "bar"}, std::vector{"baz", "qux"}}; @@ -578,24 +578,24 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborLists) { v.b = "4"; return v; }()}; - v.blobList = std::vector{smithy::Blob::FromString("foo"), smithy::Blob::FromString("bar")}; + v.blobList = std::vector{opal::Blob::FromString("foo"), opal::Blob::FromString("bar")}; return v; }(); } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborLists()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborLists()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2pzdHJpbmdMaXN0n2Nmb29jYmFy/2lzdHJpbmdTZXSfY2Zvb2NiYXL/a2ludGVnZXJMaXN0nwEC/2tib29sZWFuTGlzdJ/19P9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9wbmVzdGVkU3RyaW5nTGlzdJ+fY2Zvb2NiYXL/n2NiYXpjcXV4//9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9oYmxvYkxpc3SfQ2Zvb0NiYXL//w==", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2pzdHJpbmdMaXN0n2Nmb29jYmFy/2lzdHJpbmdTZXSfY2Zvb2NiYXL/a2ludGVnZXJMaXN0nwEC/2tib29sZWFuTGlzdJ/19P9tdGltZXN0YW1wTGlzdJ/B+0HU1/vzgAAAwftB1Nf784AAAP9oZW51bUxpc3SfY0Zvb2Ew/2tpbnRFbnVtTGlzdJ8BAv9wbmVzdGVkU3RyaW5nTGlzdJ+fY2Zvb2NiYXL/n2NiYXpjcXV4//9tc3RydWN0dXJlTGlzdJ+/YWFhMWFiYTL/v2FhYTNhYmE0//9oYmxvYkxpc3SfQ2Zvb0NiYXL//w==", response.body)); } // Serializes empty RpcV2 Cbor lists TEST(RpcV2ProtocolServerResponseTest, RpcV2CborListsEmpty) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborListsOutput v{}; @@ -605,18 +605,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborListsEmpty) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborLists()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborLists()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2pzdHJpbmdMaXN0n///", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2pzdHJpbmdMaXN0n///", response.body)); } // Deserializes sparse maps TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSparseJsonMaps) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborSparseMapsOutput v{}; @@ -634,18 +634,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSparseJsonMaps) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborSparseMaps()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborSparseMaps()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v29zcGFyc2VTdHJ1Y3RNYXC/Y2Zvb79iaGlldGhlcmX/Y2Jher9iaGljYnll////", response.body)); } // Deserializes null map values TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesNullMapValues) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborSparseMapsOutput v{}; @@ -658,18 +658,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesNullMapValues) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborSparseMaps()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborSparseMaps()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v3BzcGFyc2VCb29sZWFuTWFwv2F49v9vc3BhcnNlTnVtYmVyTWFwv2F49v9vc3BhcnNlU3RyaW5nTWFwv2F49v9vc3BhcnNlU3RydWN0TWFwv2F49v//", response.body)); } // A response that contains a sparse map of sets TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesSparseSetMap) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborSparseMapsOutput v{}; @@ -679,18 +679,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesSparseSetMap) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborSparseMaps()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborSparseMaps()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2xzcGFyc2VTZXRNYXC/YXmfYWFhYv9heJ////8=", response.body)); } // A response that contains a sparse map of sets with a null TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesSparseSetMapAndRetainsNull) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborSparseMapsOutput v{}; @@ -700,18 +700,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesSparseSetMapAndRetain } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborSparseMaps()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborSparseMaps()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2xzcGFyc2VTZXRNYXC/YXif/2F5n2FhYWL/YXr2//8=", response.body)); } // Ensure that 0 and false are sent over the wire in all maps and lists TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesZeroValuesInSparseMaps) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborSparseMapsOutput v{}; @@ -722,18 +722,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesZeroValuesInSparseMap } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborSparseMaps()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborSparseMaps()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v29zcGFyc2VOdW1iZXJNYXC/YXgA/3BzcGFyc2VCb29sZWFuTWFwv2F49P//", response.body)); } // Deserializes a tagged union followed by another structure member TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesUnionValue) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborUnionsOutput v{}; @@ -744,18 +744,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesUnionValue) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborUnions()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborUnions()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("omhjb250ZW50c6Frc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("omhjb250ZW50c6Frc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy", response.body)); } // Deserializes a nested union followed by another structure member TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesNestedUnionValue) { class Handler final : public RecordingHandler { public: - smithy::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RpcV2CborUnionsOutput v{}; @@ -766,18 +766,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborDeserializesNestedUnionValue) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborUnions()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRpcV2CborUnions()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("omhjb250ZW50c6FqdW5pb25WYWx1ZaFrc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("omhjb250ZW50c6FqdW5pb25WYWx1ZaFrc3RyaW5nVmFsdWVjZm9vam90aGVyVmFsdWVjYmFy", response.body)); } // Serializes simple scalar properties TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSimpleScalarProperties) { class Handler final : public RecordingHandler { public: - smithy::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const opal::server::RequestContext&) override { (void)input; return [] { SimpleScalarPropertiesOutput v{}; @@ -789,24 +789,24 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSimpleScalarProperties) { v.integerValue = 256; v.shortValue = 9898; v.stringValue = "simple"; - v.blobValue = smithy::Blob::FromString("foo"); + v.blobValue = opal::Blob::FromString("foo"); return v; }(); } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForSimpleScalarProperties()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForSimpleScalarProperties()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v3B0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb2//", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v3B0cnVlQm9vbGVhblZhbHVl9XFmYWxzZUJvb2xlYW5WYWx1ZfRpYnl0ZVZhbHVlBWtkb3VibGVWYWx1Zfs//jlYEGJN02pmbG9hdFZhbHVl+kD0AABsaW50ZWdlclZhbHVlGQEAanNob3J0VmFsdWUZJqprc3RyaW5nVmFsdWVmc2ltcGxlaWJsb2JWYWx1ZUNmb2//", response.body)); } // RpcV2 Cbor should not serialize null structure values TEST(RpcV2ProtocolServerResponseTest, RpcV2CborServerDoesntSerializeNullStructureValues) { class Handler final : public RecordingHandler { public: - smithy::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const opal::server::RequestContext&) override { (void)input; return [] { SimpleScalarPropertiesOutput v{}; @@ -815,18 +815,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborServerDoesntSerializeNullStructur } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForSimpleScalarProperties()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForSimpleScalarProperties()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v/8=", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v/8=", response.body)); } // Supports handling NaN float values. TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSupportsNaNFloatOutputs) { class Handler final : public RecordingHandler { public: - smithy::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const opal::server::RequestContext&) override { (void)input; return [] { SimpleScalarPropertiesOutput v{}; @@ -837,18 +837,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSupportsNaNFloatOutputs) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForSimpleScalarProperties()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForSimpleScalarProperties()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zft/+AAAAAAAAGpmbG9hdFZhbHVl+n/AAAD/", response.body)); } // Supports handling Infinity float values. TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSupportsInfinityFloatOutputs) { class Handler final : public RecordingHandler { public: - smithy::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const opal::server::RequestContext&) override { (void)input; return [] { SimpleScalarPropertiesOutput v{}; @@ -859,18 +859,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSupportsInfinityFloatOutputs) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForSimpleScalarProperties()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForSimpleScalarProperties()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zft/8AAAAAAAAGpmbG9hdFZhbHVl+n+AAAD/", response.body)); } // Supports handling Negative Infinity float values. TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSupportsNegativeInfinityFloatOutputs) { class Handler final : public RecordingHandler { public: - smithy::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const opal::server::RequestContext&) override { (void)input; return [] { SimpleScalarPropertiesOutput v{}; @@ -881,18 +881,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSupportsNegativeInfinityFloatOutp } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForSimpleScalarProperties()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForSimpleScalarProperties()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2tkb3VibGVWYWx1Zfv/8AAAAAAAAGpmbG9hdFZhbHVl+v+AAAD/", response.body)); } // Deserializes null values in maps TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSparseMapsDeserializeNullValues) { class Handler final : public RecordingHandler { public: - smithy::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const opal::server::RequestContext&) override { (void)input; return [] { SparseNullsOperationOutput v{}; @@ -902,18 +902,18 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSparseMapsDeserializeNullValues) } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForSparseNullsOperation()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForSparseNullsOperation()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v29zcGFyc2VTdHJpbmdNYXC/Y2Zvb/b//w==", response.body)); } // Deserializes null values in lists TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSparseListsDeserializeNull) { class Handler final : public RecordingHandler { public: - smithy::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const opal::server::RequestContext&) override { (void)input; return [] { SparseNullsOperationOutput v{}; @@ -923,20 +923,20 @@ TEST(RpcV2ProtocolServerResponseTest, RpcV2CborSparseListsDeserializeNull) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForSparseNullsOperation()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForSparseNullsOperation()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v3BzcGFyc2VTdHJpbmdMaXN0n/b//w==", response.body)); } // Parses a complex error with no message member TEST(RpcV2ProtocolServerErrorTest, RpcV2CborComplexError) { class Handler final : public RecordingHandler { public: - smithy::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("ComplexError", ""); + opal::Error error = opal::Error::Modeled("ComplexError", ""); error.set_detail([] { ComplexError v{}; v.TopLevel = "Top level"; @@ -951,19 +951,19 @@ TEST(RpcV2ProtocolServerErrorTest, RpcV2CborComplexError) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForGreetingWithErrors()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForGreetingWithErrors()); EXPECT_EQ(response.status, 400); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3JoVG9wTGV2ZWxpVG9wIGxldmVsZk5lc3RlZL9jRm9vY2Jhcv//", response.body)); } TEST(RpcV2ProtocolServerErrorTest, RpcV2CborEmptyComplexError) { class Handler final : public RecordingHandler { public: - smithy::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("ComplexError", ""); + opal::Error error = opal::Error::Modeled("ComplexError", ""); error.set_detail([] { ComplexError v{}; return v; @@ -972,20 +972,20 @@ TEST(RpcV2ProtocolServerErrorTest, RpcV2CborEmptyComplexError) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForGreetingWithErrors()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForGreetingWithErrors()); EXPECT_EQ(response.status, 400); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2ZfX3R5cGV4K3NtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNDb21wbGV4RXJyb3L/", response.body)); } // Parses simple RpcV2 Cbor errors TEST(RpcV2ProtocolServerErrorTest, RpcV2CborInvalidGreetingError) { class Handler final : public RecordingHandler { public: - smithy::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("InvalidGreeting", ""); + opal::Error error = opal::Error::Modeled("InvalidGreeting", ""); error.set_detail([] { InvalidGreeting v{}; v.Message = "Hi"; @@ -995,11 +995,11 @@ TEST(RpcV2ProtocolServerErrorTest, RpcV2CborInvalidGreetingError) { } }; RpcV2ProtocolServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForGreetingWithErrors()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForGreetingWithErrors()); EXPECT_EQ(response.status, 400); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/cbor"); EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); - EXPECT_TRUE(smithy::testing::CborBodyEqualsBase64("v2ZfX3R5cGV4LnNtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8=", response.body)); + EXPECT_TRUE(opal::testing::CborBodyEqualsBase64("v2ZfX3R5cGV4LnNtaXRoeS5wcm90b2NvbHRlc3RzLnJwY3YyQ2JvciNJbnZhbGlkR3JlZXRpbmdnTWVzc2FnZWJIaf8=", response.body)); } -} // namespace smithy::protocoltests::rpcv2cbor +} // namespace opal::protocoltests::rpcv2cbor diff --git a/protocol-tests/rpcv2cbor/generated/tests/smoke_test.cc b/protocol-tests/rpcv2cbor/generated/tests/smoke_test.cc index d93fdd0a..836f143e 100644 --- a/protocol-tests/rpcv2cbor/generated/tests/smoke_test.cc +++ b/protocol-tests/rpcv2cbor/generated/tests/smoke_test.cc @@ -4,12 +4,12 @@ #include #include +#include "opal/protocoltests/rpcv2cbor/client.h" +#include "opal/protocoltests/rpcv2cbor/server.h" #include "smithy/client/config.h" #include "smithy/http/loopback.h" -#include "smithy/protocoltests/rpcv2cbor/client.h" -#include "smithy/protocoltests/rpcv2cbor/server.h" -namespace smithy::protocoltests::rpcv2cbor { +namespace opal::protocoltests::rpcv2cbor { // Smoke tests for the generated RpcV2Protocol service: the generated client calls the // generated server over the in-memory loopback transport. A passing suite @@ -118,59 +118,59 @@ SparseNullsOperationOutput MinimalSparseNullsOperationOutput() { class SmokeHandler : public RpcV2ProtocolHandler { public: - smithy::Outcome EmptyInputOutput(const EmptyInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome EmptyInputOutput(const EmptyInputOutputInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalEmptyInputOutputOutput(); } - smithy::Outcome Float16(const Float16Input& input, const smithy::server::RequestContext&) override { + opal::Outcome Float16(const Float16Input& input, const opal::server::RequestContext&) override { (void)input; return MinimalFloat16Output(); } - smithy::Outcome FractionalSeconds(const FractionalSecondsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome FractionalSeconds(const FractionalSecondsInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalFractionalSecondsOutput(); } - smithy::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalGreetingWithErrorsOutput(); } - smithy::Outcome NoInputOutput(const NoInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome NoInputOutput(const NoInputOutputInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalNoInputOutputOutput(); } - smithy::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OperationWithDefaults(const OperationWithDefaultsInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalOperationWithDefaultsOutput(); } - smithy::Outcome OptionalInputOutput(const OptionalInputOutputInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OptionalInputOutput(const OptionalInputOutputInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalOptionalInputOutputOutput(); } - smithy::Outcome RecursiveShapes(const RecursiveShapesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RecursiveShapes(const RecursiveShapesInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalRecursiveShapesOutput(); } - smithy::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborDenseMaps(const RpcV2CborDenseMapsInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalRpcV2CborDenseMapsOutput(); } - smithy::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborLists(const RpcV2CborListsInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalRpcV2CborListsOutput(); } - smithy::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborSparseMaps(const RpcV2CborSparseMapsInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalRpcV2CborSparseMapsOutput(); } - smithy::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborUnions(const RpcV2CborUnionsInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalRpcV2CborUnionsOutput(); } - smithy::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SimpleScalarProperties(const SimpleScalarPropertiesInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalSimpleScalarPropertiesOutput(); } - smithy::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const smithy::server::RequestContext&) override { + opal::Outcome SparseNullsOperation(const SparseNullsOperationInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalSparseNullsOperationOutput(); } @@ -178,9 +178,9 @@ class SmokeHandler : public RpcV2ProtocolHandler { RpcV2ProtocolClient MakeClient(std::shared_ptr handler) { RpcV2ProtocolServer server(std::move(handler)); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = loopback; // Create cannot fail when a transport is injected. @@ -346,9 +346,9 @@ TEST(RpcV2ProtocolSmokeTest, SparseNullsOperationRoundTrips) { TEST(RpcV2ProtocolSmokeTest, ModeledErrorsMapAcrossTheWire) { class FailingHandler final : public SmokeHandler { public: - smithy::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GreetingWithErrors(const GreetingWithErrorsInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("InvalidGreeting", "smoke"); + opal::Error error = opal::Error::Modeled("InvalidGreeting", "smoke"); auto detail = [] { InvalidGreeting v{}; return v; @@ -365,10 +365,10 @@ TEST(RpcV2ProtocolSmokeTest, ModeledErrorsMapAcrossTheWire) { }(); const auto outcome = client.GreetingWithErrors(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "InvalidGreeting"); EXPECT_EQ(outcome.error().message(), "smoke"); EXPECT_NE(outcome.error().detail(), nullptr); } -} // namespace smithy::protocoltests::rpcv2cbor +} // namespace opal::protocoltests::rpcv2cbor diff --git a/protocol-tests/rpcv2cbor/malformed/server_malformed_test.cc b/protocol-tests/rpcv2cbor/malformed/server_malformed_test.cc index a90b1189..b7848c60 100644 --- a/protocol-tests/rpcv2cbor/malformed/server_malformed_test.cc +++ b/protocol-tests/rpcv2cbor/malformed/server_malformed_test.cc @@ -10,108 +10,108 @@ #include #include +#include "opal/protocoltests/rpcv2cbor/server.h" #include "smithy/cbor/cbor.h" -#include "smithy/protocoltests/rpcv2cbor/server.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::rpcv2cbor { +namespace opal::protocoltests::rpcv2cbor { namespace { class RecordingHandler : public RpcV2ProtocolHandler { public: - smithy::Outcome EmptyInputOutput( - const EmptyInputOutputInput&, const smithy::server::RequestContext&) override { + opal::Outcome EmptyInputOutput( + const EmptyInputOutputInput&, const opal::server::RequestContext&) override { ++calls; return EmptyInputOutputOutput{}; } - smithy::Outcome Float16(const Float16Input&, - const smithy::server::RequestContext&) override { + opal::Outcome Float16(const Float16Input&, + const opal::server::RequestContext&) override { ++calls; return Float16Output{}; } - smithy::Outcome FractionalSeconds( - const FractionalSecondsInput&, const smithy::server::RequestContext&) override { + opal::Outcome FractionalSeconds( + const FractionalSecondsInput&, const opal::server::RequestContext&) override { ++calls; return FractionalSecondsOutput{}; } - smithy::Outcome GreetingWithErrors( - const GreetingWithErrorsInput&, const smithy::server::RequestContext&) override { + opal::Outcome GreetingWithErrors( + const GreetingWithErrorsInput&, const opal::server::RequestContext&) override { ++calls; return GreetingWithErrorsOutput{}; } - smithy::Outcome NoInputOutput( - const NoInputOutputInput&, const smithy::server::RequestContext&) override { + opal::Outcome NoInputOutput(const NoInputOutputInput&, + const opal::server::RequestContext&) override { ++calls; return NoInputOutputOutput{}; } - smithy::Outcome OperationWithDefaults( - const OperationWithDefaultsInput&, const smithy::server::RequestContext&) override { + opal::Outcome OperationWithDefaults( + const OperationWithDefaultsInput&, const opal::server::RequestContext&) override { ++calls; return OperationWithDefaultsOutput{}; } - smithy::Outcome OptionalInputOutput( - const OptionalInputOutputInput&, const smithy::server::RequestContext&) override { + opal::Outcome OptionalInputOutput( + const OptionalInputOutputInput&, const opal::server::RequestContext&) override { ++calls; return OptionalInputOutputOutput{}; } - smithy::Outcome RecursiveShapes( - const RecursiveShapesInput&, const smithy::server::RequestContext&) override { + opal::Outcome RecursiveShapes( + const RecursiveShapesInput&, const opal::server::RequestContext&) override { ++calls; return RecursiveShapesOutput{}; } - smithy::Outcome RpcV2CborDenseMaps( - const RpcV2CborDenseMapsInput&, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborDenseMaps( + const RpcV2CborDenseMapsInput&, const opal::server::RequestContext&) override { ++calls; return RpcV2CborDenseMapsOutput{}; } - smithy::Outcome RpcV2CborLists( - const RpcV2CborListsInput&, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborLists(const RpcV2CborListsInput&, + const opal::server::RequestContext&) override { ++calls; return RpcV2CborListsOutput{}; } - smithy::Outcome RpcV2CborSparseMaps( - const RpcV2CborSparseMapsInput&, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborSparseMaps( + const RpcV2CborSparseMapsInput&, const opal::server::RequestContext&) override { ++calls; return RpcV2CborSparseMapsOutput{}; } - smithy::Outcome RpcV2CborUnions( - const RpcV2CborUnionsInput&, const smithy::server::RequestContext&) override { + opal::Outcome RpcV2CborUnions( + const RpcV2CborUnionsInput&, const opal::server::RequestContext&) override { ++calls; return RpcV2CborUnionsOutput{}; } - smithy::Outcome SimpleScalarProperties( - const SimpleScalarPropertiesInput&, const smithy::server::RequestContext&) override { + opal::Outcome SimpleScalarProperties( + const SimpleScalarPropertiesInput&, const opal::server::RequestContext&) override { ++calls; return SimpleScalarPropertiesOutput{}; } - smithy::Outcome SparseNullsOperation( - const SparseNullsOperationInput&, const smithy::server::RequestContext&) override { + opal::Outcome SparseNullsOperation( + const SparseNullsOperationInput&, const opal::server::RequestContext&) override { ++calls; return SparseNullsOperationOutput{}; } int calls = 0; }; -// ::testing, not testing: inside namespace smithy::*, protocol_test.h's -// smithy::testing shadows gtest's global namespace for unqualified lookup. +// ::testing, not testing: inside namespace opal::*, protocol_test.h's +// opal::testing shadows gtest's global namespace for unqualified lookup. class RpcV2CborMalformedTest : public ::testing::Test { protected: - smithy::http::HttpRequest WellFormedRequest(const std::string& operation) { - return smithy::testing::Rpcv2CborRequest("RpcV2Protocol", operation); + opal::http::HttpRequest WellFormedRequest(const std::string& operation) { + return opal::testing::Rpcv2CborRequest("RpcV2Protocol", operation); } - smithy::http::HttpResponse Send(const smithy::http::HttpRequest& request) { + opal::http::HttpResponse Send(const opal::http::HttpRequest& request) { return server_.Handler()(request); } // The protocol serializes errors as a CBOR map carrying __type. - std::string ErrorTypeOf(const smithy::http::HttpResponse& response) { + std::string ErrorTypeOf(const opal::http::HttpResponse& response) { EXPECT_EQ(response.headers.Get("smithy-protocol").value_or(""), "rpc-v2-cbor"); EXPECT_EQ(response.headers.Get("content-type").value_or(""), "application/cbor"); - const auto body = smithy::cbor::Decode(Blob::FromString(response.body)); + const auto body = opal::cbor::Decode(Blob::FromString(response.body)); EXPECT_TRUE(body.ok()); if (!body.ok() || !body->is_map()) return ""; - const smithy::Document* type = body->Find("__type"); + const opal::Document* type = body->Find("__type"); return type == nullptr ? "" : std::string(type->as_string()); } @@ -180,4 +180,4 @@ TEST_F(RpcV2CborMalformedTest, WrongMethodIs405) { } } // namespace -} // namespace smithy::protocoltests::rpcv2cbor +} // namespace opal::protocoltests::rpcv2cbor diff --git a/protocol-tests/simplerestjson/generated/BUILD.bazel b/protocol-tests/simplerestjson/generated/BUILD.bazel index 2aa00a89..528de7f7 100644 --- a/protocol-tests/simplerestjson/generated/BUILD.bazel +++ b/protocol-tests/simplerestjson/generated/BUILD.bazel @@ -6,7 +6,7 @@ package(default_visibility = ["//visibility:public"]) cc_library( name = "types", - hdrs = ["include/smithy/protocoltests/simplerestjson/types.h"], + hdrs = ["include/opal/protocoltests/simplerestjson/types.h"], copts = [ "-Wall", "-Wextra", @@ -18,7 +18,7 @@ cc_library( cc_library( name = "serde", srcs = ["src/serde.cc"], - hdrs = ["include/smithy/protocoltests/simplerestjson/serde.h"], + hdrs = ["include/opal/protocoltests/simplerestjson/serde.h"], copts = [ "-Wall", "-Wextra", @@ -33,7 +33,7 @@ cc_library( cc_library( name = "client", srcs = ["src/client.cc"], - hdrs = ["include/smithy/protocoltests/simplerestjson/client.h"], + hdrs = ["include/opal/protocoltests/simplerestjson/client.h"], copts = [ "-Wall", "-Wextra", @@ -52,7 +52,7 @@ cc_library( cc_library( name = "server", srcs = ["src/server.cc"], - hdrs = ["include/smithy/protocoltests/simplerestjson/server.h"], + hdrs = ["include/opal/protocoltests/simplerestjson/server.h"], copts = [ "-Wall", "-Wextra", diff --git a/protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/client.h b/protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/client.h similarity index 81% rename from protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/client.h rename to protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/client.h index 2bf798d4..4bdd5f3b 100644 --- a/protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/client.h +++ b/protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/client.h @@ -1,7 +1,7 @@ // Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. -#ifndef SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_CLIENT_H_ -#define SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_CLIENT_H_ +#ifndef OPAL_PROTOCOLTESTS_SIMPLERESTJSON_CLIENT_H_ +#define OPAL_PROTOCOLTESTS_SIMPLERESTJSON_CLIENT_H_ #include #include @@ -12,50 +12,50 @@ #include #include +#include "opal/protocoltests/simplerestjson/types.h" #include "smithy/client/config.h" #include "smithy/core/fatal.h" #include "smithy/core/hash.h" #include "smithy/core/outcome.h" #include "smithy/core/print.h" #include "smithy/http/transport.h" -#include "smithy/protocoltests/simplerestjson/types.h" -namespace smithy::protocoltests::simplerestjson { +namespace opal::protocoltests::simplerestjson { /// simpleRestJson client for alloy.test#PizzaAdminService. -/// Modeled service errors surface as smithy::Error with kind kModeled, +/// Modeled service errors surface as opal::Error with kind kModeled, /// code() set to the error shape name, and the deserialized error /// structure attached. Dispatch on them through the per-operation /// Errors listings below rather than comparing code() text. class PizzaAdminServiceClient { public: /// Fails when the endpoint cannot be parsed and no transport is injected. - static smithy::Outcome Create(smithy::ClientConfig config); - - smithy::Outcome AddMenuItem(const AddMenuItemInput& input) const; - smithy::Outcome CustomCode(const CustomCodeInput& input) const; - smithy::Outcome GetEnum(const GetEnumInput& input) const; - smithy::Outcome GetIntEnum(const GetIntEnumInput& input) const; - smithy::Outcome GetMenu(const GetMenuInput& input) const; - smithy::Outcome HeaderEndpoint(const HeaderEndpointInput& input) const; - smithy::Outcome Health(const HealthInput& input) const; - smithy::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input) const; - smithy::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input) const; - smithy::Outcome OpenUnions(const OpenUnionsInput& input) const; - smithy::Outcome PreserveOrder(const PreserveOrderInput& input) const; - smithy::Outcome RoundTrip(const RoundTripInput& input) const; - smithy::Outcome Version(const VersionInput& input = {}) const; + static opal::Outcome Create(opal::ClientConfig config); + + opal::Outcome AddMenuItem(const AddMenuItemInput& input) const; + opal::Outcome CustomCode(const CustomCodeInput& input) const; + opal::Outcome GetEnum(const GetEnumInput& input) const; + opal::Outcome GetIntEnum(const GetIntEnumInput& input) const; + opal::Outcome GetMenu(const GetMenuInput& input) const; + opal::Outcome HeaderEndpoint(const HeaderEndpointInput& input) const; + opal::Outcome Health(const HealthInput& input) const; + opal::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input) const; + opal::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input) const; + opal::Outcome OpenUnions(const OpenUnionsInput& input) const; + opal::Outcome PreserveOrder(const PreserveOrderInput& input) const; + opal::Outcome RoundTrip(const RoundTripInput& input) const; + opal::Outcome Version(const VersionInput& input = {}) const; private: - PizzaAdminServiceClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix); - smithy::Outcome Send(smithy::http::HttpRequest request) const; + PizzaAdminServiceClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix); + opal::Outcome Send(opal::http::HttpRequest request) const; - smithy::ClientConfig config_; - std::shared_ptr transport_; + opal::ClientConfig config_; + std::shared_ptr transport_; std::string path_prefix_; }; -/// The modeled errors of AddMenuItem, matched from a smithy::Error so dispatch is +/// The modeled errors of AddMenuItem, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -66,9 +66,9 @@ class AddMenuItemErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static AddMenuItemErrors FromError(const smithy::Error& error) { + static AddMenuItemErrors FromError(const opal::Error& error) { AddMenuItemErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "PriceError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : PriceError{}); @@ -133,15 +133,15 @@ class AddMenuItemErrors { switch (value_.index()) { case 1: out += "price_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; default: break; @@ -160,14 +160,14 @@ class AddMenuItemErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("AddMenuItemErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("AddMenuItemErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of CustomCode, matched from a smithy::Error so dispatch is +/// The modeled errors of CustomCode, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -178,9 +178,9 @@ class CustomCodeErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static CustomCodeErrors FromError(const smithy::Error& error) { + static CustomCodeErrors FromError(const opal::Error& error) { CustomCodeErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "UnknownServerError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : UnknownServerError{}); @@ -245,15 +245,15 @@ class CustomCodeErrors { switch (value_.index()) { case 1: out += "unknown_server_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; default: break; @@ -272,14 +272,14 @@ class CustomCodeErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("CustomCodeErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("CustomCodeErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of GetEnum, matched from a smithy::Error so dispatch is +/// The modeled errors of GetEnum, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -290,9 +290,9 @@ class GetEnumErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static GetEnumErrors FromError(const smithy::Error& error) { + static GetEnumErrors FromError(const opal::Error& error) { GetEnumErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "UnknownServerError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : UnknownServerError{}); @@ -357,15 +357,15 @@ class GetEnumErrors { switch (value_.index()) { case 1: out += "unknown_server_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; default: break; @@ -384,14 +384,14 @@ class GetEnumErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("GetEnumErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("GetEnumErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of GetIntEnum, matched from a smithy::Error so dispatch is +/// The modeled errors of GetIntEnum, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -402,9 +402,9 @@ class GetIntEnumErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static GetIntEnumErrors FromError(const smithy::Error& error) { + static GetIntEnumErrors FromError(const opal::Error& error) { GetIntEnumErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "UnknownServerError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : UnknownServerError{}); @@ -469,15 +469,15 @@ class GetIntEnumErrors { switch (value_.index()) { case 1: out += "unknown_server_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; default: break; @@ -496,14 +496,14 @@ class GetIntEnumErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("GetIntEnumErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("GetIntEnumErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of GetMenu, matched from a smithy::Error so dispatch is +/// The modeled errors of GetMenu, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -514,9 +514,9 @@ class GetMenuErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static GetMenuErrors FromError(const smithy::Error& error) { + static GetMenuErrors FromError(const opal::Error& error) { GetMenuErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "NotFoundError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : NotFoundError{}); @@ -594,19 +594,19 @@ class GetMenuErrors { switch (value_.index()) { case 1: out += "not_found_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "fallback_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; case 4: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<4>(value_)); + opal::DebugAppend(out, std::get<4>(value_)); break; default: break; @@ -625,14 +625,14 @@ class GetMenuErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("GetMenuErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("GetMenuErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of HeaderEndpoint, matched from a smithy::Error so dispatch is +/// The modeled errors of HeaderEndpoint, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -643,9 +643,9 @@ class HeaderEndpointErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static HeaderEndpointErrors FromError(const smithy::Error& error) { + static HeaderEndpointErrors FromError(const opal::Error& error) { HeaderEndpointErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "GenericServerError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : GenericServerError{}); @@ -697,11 +697,11 @@ class HeaderEndpointErrors { switch (value_.index()) { case 1: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -720,14 +720,14 @@ class HeaderEndpointErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("HeaderEndpointErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("HeaderEndpointErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of Health, matched from a smithy::Error so dispatch is +/// The modeled errors of Health, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -738,9 +738,9 @@ class HealthErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static HealthErrors FromError(const smithy::Error& error) { + static HealthErrors FromError(const opal::Error& error) { HealthErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "UnknownServerError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : UnknownServerError{}); @@ -805,15 +805,15 @@ class HealthErrors { switch (value_.index()) { case 1: out += "unknown_server_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; case 3: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<3>(value_)); + opal::DebugAppend(out, std::get<3>(value_)); break; default: break; @@ -832,14 +832,14 @@ class HealthErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("HealthErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("HealthErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of HttpPayloadRequiredWithDefault, matched from a smithy::Error so dispatch is +/// The modeled errors of HttpPayloadRequiredWithDefault, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -850,9 +850,9 @@ class HttpPayloadRequiredWithDefaultErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static HttpPayloadRequiredWithDefaultErrors FromError(const smithy::Error& error) { + static HttpPayloadRequiredWithDefaultErrors FromError(const opal::Error& error) { HttpPayloadRequiredWithDefaultErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "GenericServerError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : GenericServerError{}); @@ -904,11 +904,11 @@ class HttpPayloadRequiredWithDefaultErrors { switch (value_.index()) { case 1: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -927,14 +927,14 @@ class HttpPayloadRequiredWithDefaultErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("HttpPayloadRequiredWithDefaultErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("HttpPayloadRequiredWithDefaultErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of HttpPayloadWithDefault, matched from a smithy::Error so dispatch is +/// The modeled errors of HttpPayloadWithDefault, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -945,9 +945,9 @@ class HttpPayloadWithDefaultErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static HttpPayloadWithDefaultErrors FromError(const smithy::Error& error) { + static HttpPayloadWithDefaultErrors FromError(const opal::Error& error) { HttpPayloadWithDefaultErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "GenericServerError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : GenericServerError{}); @@ -999,11 +999,11 @@ class HttpPayloadWithDefaultErrors { switch (value_.index()) { case 1: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -1022,14 +1022,14 @@ class HttpPayloadWithDefaultErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("HttpPayloadWithDefaultErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("HttpPayloadWithDefaultErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of OpenUnions, matched from a smithy::Error so dispatch is +/// The modeled errors of OpenUnions, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -1040,9 +1040,9 @@ class OpenUnionsErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static OpenUnionsErrors FromError(const smithy::Error& error) { + static OpenUnionsErrors FromError(const opal::Error& error) { OpenUnionsErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "GenericServerError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : GenericServerError{}); @@ -1094,11 +1094,11 @@ class OpenUnionsErrors { switch (value_.index()) { case 1: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -1117,14 +1117,14 @@ class OpenUnionsErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("OpenUnionsErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("OpenUnionsErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of PreserveOrder, matched from a smithy::Error so dispatch is +/// The modeled errors of PreserveOrder, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -1135,9 +1135,9 @@ class PreserveOrderErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static PreserveOrderErrors FromError(const smithy::Error& error) { + static PreserveOrderErrors FromError(const opal::Error& error) { PreserveOrderErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "GenericServerError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : GenericServerError{}); @@ -1189,11 +1189,11 @@ class PreserveOrderErrors { switch (value_.index()) { case 1: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -1212,14 +1212,14 @@ class PreserveOrderErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("PreserveOrderErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("PreserveOrderErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of RoundTrip, matched from a smithy::Error so dispatch is +/// The modeled errors of RoundTrip, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -1230,9 +1230,9 @@ class RoundTripErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static RoundTripErrors FromError(const smithy::Error& error) { + static RoundTripErrors FromError(const opal::Error& error) { RoundTripErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "GenericServerError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : GenericServerError{}); @@ -1284,11 +1284,11 @@ class RoundTripErrors { switch (value_.index()) { case 1: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -1307,14 +1307,14 @@ class RoundTripErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("RoundTripErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("RoundTripErrors", requested, case_name()); } } std::variant value_; }; -/// The modeled errors of Version, matched from a smithy::Error so dispatch is +/// The modeled errors of Version, matched from a opal::Error so dispatch is /// typed and exhaustive instead of string-compared. FromError() is empty() /// when the error is none of this operation's modeled errors (transport, /// serialization, unknown, or another operation's error). @@ -1325,9 +1325,9 @@ class VersionErrors { /// Matches `error` against this operation's modeled errors. An engaged /// member carries the deserialized error detail, default-initialized when /// the error arrived without one. - static VersionErrors FromError(const smithy::Error& error) { + static VersionErrors FromError(const opal::Error& error) { VersionErrors result; - if (error.kind() != smithy::ErrorKind::kModeled) return result; + if (error.kind() != opal::ErrorKind::kModeled) return result; if (error.code() == "GenericServerError") { const auto* detail = error.detail(); result.value_.emplace<1>(detail != nullptr ? *detail : GenericServerError{}); @@ -1379,11 +1379,11 @@ class VersionErrors { switch (value_.index()) { case 1: out += "generic_server_error = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "generic_client_error = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -1402,134 +1402,134 @@ class VersionErrors { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("VersionErrors", requested, case_name()); + opal::internal::FatalWrongUnionAccess("VersionErrors", requested, case_name()); } } std::variant value_; }; -} // namespace smithy::protocoltests::simplerestjson +} // namespace opal::protocoltests::simplerestjson // std::hash so generated types key std::unordered_map/std::unordered_set — // emitted exactly for the types that get operator<=> (issue #49). Hash // values are process-local: never persist or compare them across runs. template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::AddMenuItemErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::AddMenuItemErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::CustomCodeErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::CustomCodeErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::GetEnumErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::GetEnumErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::GetIntEnumErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::GetIntEnumErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::GetMenuErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::GetMenuErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HeaderEndpointErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HeaderEndpointErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HealthErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HealthErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HttpPayloadRequiredWithDefaultErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HttpPayloadRequiredWithDefaultErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HttpPayloadWithDefaultErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HttpPayloadWithDefaultErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::OpenUnionsErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::OpenUnionsErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::PreserveOrderErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::PreserveOrderErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::RoundTripErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::RoundTripErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::VersionErrors& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::VersionErrors& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; -#endif // SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_CLIENT_H_ +#endif // OPAL_PROTOCOLTESTS_SIMPLERESTJSON_CLIENT_H_ diff --git a/protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/serde.h b/protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/serde.h new file mode 100644 index 00000000..9b118554 --- /dev/null +++ b/protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/serde.h @@ -0,0 +1,152 @@ +// Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. + +#ifndef OPAL_PROTOCOLTESTS_SIMPLERESTJSON_SERDE_H_ +#define OPAL_PROTOCOLTESTS_SIMPLERESTJSON_SERDE_H_ + +#include +#include +#include +#include + +#include "opal/protocoltests/simplerestjson/types.h" +#include "smithy/core/document.h" +#include "smithy/core/outcome.h" + +namespace opal::protocoltests::simplerestjson { + +// Document-pivot serde for every aggregate shape in the model closure. +// Serializers never fail; deserializers return opal::Error on wire +// mismatches and enforce @required members. + +opal::Document SerializeIngredients(const std::vector& value); +opal::Outcome> DeserializeIngredients(const opal::Document& doc); + +opal::Document SerializePizza(const Pizza& value); +opal::Outcome DeserializePizza(const opal::Document& doc); + +opal::Document SerializeSalad(const Salad& value); +opal::Outcome DeserializeSalad(const opal::Document& doc); + +opal::Document SerializeFood(const Food& value); +opal::Outcome DeserializeFood(const opal::Document& doc); + +opal::Document SerializeMenuItem(const MenuItem& value); +opal::Outcome DeserializeMenuItem(const opal::Document& doc); + +opal::Document SerializeAddMenuItemInput(const AddMenuItemInput& value); +opal::Outcome DeserializeAddMenuItemInput(const opal::Document& doc); + +opal::Document SerializeAddMenuItemOutput(const AddMenuItemOutput& value); +opal::Outcome DeserializeAddMenuItemOutput(const opal::Document& doc); + +opal::Document SerializeGenericClientError(const GenericClientError& value); +opal::Outcome DeserializeGenericClientError(const opal::Document& doc); + +opal::Document SerializeGenericServerError(const GenericServerError& value); +opal::Outcome DeserializeGenericServerError(const opal::Document& doc); + +opal::Document SerializePriceError(const PriceError& value); +opal::Outcome DeserializePriceError(const opal::Document& doc); + +opal::Document SerializeCustomCodeInput(const CustomCodeInput& value); +opal::Outcome DeserializeCustomCodeInput(const opal::Document& doc); + +opal::Document SerializeCustomCodeOutput(const CustomCodeOutput& value); +opal::Outcome DeserializeCustomCodeOutput(const opal::Document& doc); + +opal::Document SerializeUnknownServerError(const UnknownServerError& value); +opal::Outcome DeserializeUnknownServerError(const opal::Document& doc); + +opal::Document SerializeFallbackError(const FallbackError& value); +opal::Outcome DeserializeFallbackError(const opal::Document& doc); + +opal::Document SerializeGetEnumInput(const GetEnumInput& value); +opal::Outcome DeserializeGetEnumInput(const opal::Document& doc); + +opal::Document SerializeGetEnumOutput(const GetEnumOutput& value); +opal::Outcome DeserializeGetEnumOutput(const opal::Document& doc); + +opal::Document SerializeGetIntEnumInput(const GetIntEnumInput& value); +opal::Outcome DeserializeGetIntEnumInput(const opal::Document& doc); + +opal::Document SerializeGetIntEnumOutput(const GetIntEnumOutput& value); +opal::Outcome DeserializeGetIntEnumOutput(const opal::Document& doc); + +opal::Document SerializeGetMenuInput(const GetMenuInput& value); +opal::Outcome DeserializeGetMenuInput(const opal::Document& doc); + +opal::Document SerializeMenu(const std::map& value); +opal::Outcome> DeserializeMenu(const opal::Document& doc); + +opal::Document SerializeGetMenuOutput(const GetMenuOutput& value); +opal::Outcome DeserializeGetMenuOutput(const opal::Document& doc); + +opal::Document SerializeNotFoundError(const NotFoundError& value); +opal::Outcome DeserializeNotFoundError(const opal::Document& doc); + +opal::Document SerializeHeaderEndpointInput(const HeaderEndpointInput& value); +opal::Outcome DeserializeHeaderEndpointInput(const opal::Document& doc); + +opal::Document SerializeHeaderEndpointOutput(const HeaderEndpointOutput& value); +opal::Outcome DeserializeHeaderEndpointOutput(const opal::Document& doc); + +opal::Document SerializeHealthInput(const HealthInput& value); +opal::Outcome DeserializeHealthInput(const opal::Document& doc); + +opal::Document SerializeHealthOutput(const HealthOutput& value); +opal::Outcome DeserializeHealthOutput(const opal::Document& doc); + +opal::Document SerializeHttpPayloadRequiredWithDefaultInput(const HttpPayloadRequiredWithDefaultInput& value); +opal::Outcome DeserializeHttpPayloadRequiredWithDefaultInput(const opal::Document& doc); + +opal::Document SerializeHttpPayloadRequiredWithDefaultOutput(const HttpPayloadRequiredWithDefaultOutput& value); +opal::Outcome DeserializeHttpPayloadRequiredWithDefaultOutput(const opal::Document& doc); + +opal::Document SerializeHttpPayloadWithDefaultInput(const HttpPayloadWithDefaultInput& value); +opal::Outcome DeserializeHttpPayloadWithDefaultInput(const opal::Document& doc); + +opal::Document SerializeHttpPayloadWithDefaultOutput(const HttpPayloadWithDefaultOutput& value); +opal::Outcome DeserializeHttpPayloadWithDefaultOutput(const opal::Document& doc); + +opal::Document SerializeMyMap(const std::map& value); +opal::Outcome> DeserializeMyMap(const opal::Document& doc); + +opal::Document SerializeSmallStruct(const SmallStruct& value); +opal::Outcome DeserializeSmallStruct(const opal::Document& doc); + +opal::Document SerializeOpenDiscriminatedUnion(const OpenDiscriminatedUnion& value); +opal::Outcome DeserializeOpenDiscriminatedUnion(const opal::Document& doc); + +opal::Document SerializeOpenTaggedUnion(const OpenTaggedUnion& value); +opal::Outcome DeserializeOpenTaggedUnion(const opal::Document& doc); + +opal::Document SerializeOpenUnionsPayload(const OpenUnionsPayload& value); +opal::Outcome DeserializeOpenUnionsPayload(const opal::Document& doc); + +opal::Document SerializeOpenUnionsInput(const OpenUnionsInput& value); +opal::Outcome DeserializeOpenUnionsInput(const opal::Document& doc); + +opal::Document SerializeOpenUnionsOutput(const OpenUnionsOutput& value); +opal::Outcome DeserializeOpenUnionsOutput(const opal::Document& doc); + +opal::Document SerializePreserveOrderInput(const PreserveOrderInput& value); +opal::Outcome DeserializePreserveOrderInput(const opal::Document& doc); + +opal::Document SerializePreserveOrderOutput(const PreserveOrderOutput& value); +opal::Outcome DeserializePreserveOrderOutput(const opal::Document& doc); + +opal::Document SerializeRoundTripInput(const RoundTripInput& value); +opal::Outcome DeserializeRoundTripInput(const opal::Document& doc); + +opal::Document SerializeRoundTripOutput(const RoundTripOutput& value); +opal::Outcome DeserializeRoundTripOutput(const opal::Document& doc); + +opal::Document SerializeVersionInput(const VersionInput& value); +opal::Outcome DeserializeVersionInput(const opal::Document& doc); + +opal::Document SerializeVersionOutput(const VersionOutput& value); +opal::Outcome DeserializeVersionOutput(const opal::Document& doc); + +} // namespace opal::protocoltests::simplerestjson + +#endif // OPAL_PROTOCOLTESTS_SIMPLERESTJSON_SERDE_H_ diff --git a/protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/server.h b/protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/server.h new file mode 100644 index 00000000..9af6a356 --- /dev/null +++ b/protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/server.h @@ -0,0 +1,56 @@ +// Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. + +#ifndef OPAL_PROTOCOLTESTS_SIMPLERESTJSON_SERVER_H_ +#define OPAL_PROTOCOLTESTS_SIMPLERESTJSON_SERVER_H_ + +#include + +#include "opal/protocoltests/simplerestjson/types.h" +#include "smithy/core/outcome.h" +#include "smithy/http/transport.h" +#include "smithy/server/router.h" + +namespace opal::protocoltests::simplerestjson { + +/// Implement one method per operation. Return a modeled error as +/// opal::Error::Modeled("", message), optionally with the +/// typed error structure attached via set_detail() so it serializes fully. +/// The context carries the raw request and routing captures — see +/// opal::server::RequestContext; leave the parameter unnamed when unused. +/// Implementations must be thread-safe: transports may invoke any mix of +/// operations concurrently on the one handler instance. +class PizzaAdminServiceHandler { + public: + virtual ~PizzaAdminServiceHandler() = default; + + virtual opal::Outcome AddMenuItem(const AddMenuItemInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome CustomCode(const CustomCodeInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome GetEnum(const GetEnumInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome GetIntEnum(const GetIntEnumInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome GetMenu(const GetMenuInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome HeaderEndpoint(const HeaderEndpointInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome Health(const HealthInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome OpenUnions(const OpenUnionsInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome PreserveOrder(const PreserveOrderInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome RoundTrip(const RoundTripInput& input, const opal::server::RequestContext& context) = 0; + virtual opal::Outcome Version(const VersionInput& input, const opal::server::RequestContext& context) = 0; +}; + +/// simpleRestJson server for alloy.test#PizzaAdminService: routing, deserialization, handler dispatch, +/// response serialization, and modeled-error mapping. Pass Handler() to any +/// opal::http::HttpServerTransport. +class PizzaAdminServiceServer { + public: + explicit PizzaAdminServiceServer(std::shared_ptr handler); + + opal::http::RequestHandler Handler() const; + + private: + std::shared_ptr router_; +}; + +} // namespace opal::protocoltests::simplerestjson + +#endif // OPAL_PROTOCOLTESTS_SIMPLERESTJSON_SERVER_H_ diff --git a/protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/types.h b/protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/types.h similarity index 75% rename from protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/types.h rename to protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/types.h index 0c93493d..2edc7fd9 100644 --- a/protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/types.h +++ b/protocol-tests/simplerestjson/generated/include/opal/protocoltests/simplerestjson/types.h @@ -1,7 +1,7 @@ // Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. -#ifndef SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_TYPES_H_ -#define SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_TYPES_H_ +#ifndef OPAL_PROTOCOLTESTS_SIMPLERESTJSON_TYPES_H_ +#define OPAL_PROTOCOLTESTS_SIMPLERESTJSON_TYPES_H_ #include #include @@ -22,7 +22,7 @@ #include "smithy/core/print.h" #include "smithy/core/timestamp.h" -namespace smithy::protocoltests::simplerestjson { +namespace opal::protocoltests::simplerestjson { class PizzaBase { public: @@ -179,15 +179,15 @@ struct Pizza { out += sep; sep = ", "; out += ".name = "; - smithy::DebugAppend(out, this->name); + opal::DebugAppend(out, this->name); out += sep; sep = ", "; out += ".base = "; - smithy::DebugAppend(out, this->base); + opal::DebugAppend(out, this->base); out += sep; sep = ", "; out += ".toppings = "; - smithy::DebugAppend(out, this->toppings); + opal::DebugAppend(out, this->toppings); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -211,11 +211,11 @@ struct Salad { out += sep; sep = ", "; out += ".name = "; - smithy::DebugAppend(out, this->name); + opal::DebugAppend(out, this->name); out += sep; sep = ", "; out += ".ingredients = "; - smithy::DebugAppend(out, this->ingredients); + opal::DebugAppend(out, this->ingredients); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -280,11 +280,11 @@ class Food { switch (value_.index()) { case 1: out += "pizza = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "salad = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -303,7 +303,7 @@ class Food { private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("Food", requested, case_name()); + opal::internal::FatalWrongUnionAccess("Food", requested, case_name()); } } @@ -322,11 +322,11 @@ struct MenuItem { out += sep; sep = ", "; out += ".food = "; - smithy::DebugAppend(out, this->food); + opal::DebugAppend(out, this->food); out += sep; sep = ", "; out += ".price = "; - smithy::DebugAppend(out, this->price); + opal::DebugAppend(out, this->price); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -350,11 +350,11 @@ struct AddMenuItemInput { out += sep; sep = ", "; out += ".restaurant = "; - smithy::DebugAppend(out, this->restaurant); + opal::DebugAppend(out, this->restaurant); out += sep; sep = ", "; out += ".menuItem = "; - smithy::DebugAppend(out, this->menuItem); + opal::DebugAppend(out, this->menuItem); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -369,7 +369,7 @@ struct AddMenuItemInput { struct AddMenuItemOutput { std::string itemId{}; - smithy::Timestamp added{}; + opal::Timestamp added{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -378,11 +378,11 @@ struct AddMenuItemOutput { out += sep; sep = ", "; out += ".itemId = "; - smithy::DebugAppend(out, this->itemId); + opal::DebugAppend(out, this->itemId); out += sep; sep = ", "; out += ".added = "; - smithy::DebugAppend(out, this->added); + opal::DebugAppend(out, this->added); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -405,7 +405,7 @@ struct GenericClientError { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -428,7 +428,7 @@ struct GenericServerError { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -452,11 +452,11 @@ struct PriceError { out += sep; sep = ", "; out += ".message = "; - smithy::DebugAppend(out, this->message); + opal::DebugAppend(out, this->message); out += sep; sep = ", "; out += ".code = "; - smithy::DebugAppend(out, this->code); + opal::DebugAppend(out, this->code); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -479,7 +479,7 @@ struct CustomCodeInput { out += sep; sep = ", "; out += ".code = "; - smithy::DebugAppend(out, this->code); + opal::DebugAppend(out, this->code); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -503,7 +503,7 @@ struct CustomCodeOutput { out += sep; sep = ", "; out += ".code = "; - smithy::DebugAppend(out, *this->code); + opal::DebugAppend(out, *this->code); } out += '}'; } @@ -584,18 +584,18 @@ struct UnknownServerError { out += sep; sep = ", "; out += ".errorCode = "; - smithy::DebugAppend(out, this->errorCode); + opal::DebugAppend(out, this->errorCode); if (this->description.has_value()) { out += sep; sep = ", "; out += ".description = "; - smithy::DebugAppend(out, *this->description); + opal::DebugAppend(out, *this->description); } if (this->stateHash.has_value()) { out += sep; sep = ", "; out += ".stateHash = "; - smithy::DebugAppend(out, *this->stateHash); + opal::DebugAppend(out, *this->stateHash); } out += '}'; } @@ -625,7 +625,7 @@ struct FallbackError { out += sep; sep = ", "; out += ".error = "; - smithy::DebugAppend(out, this->error); + opal::DebugAppend(out, this->error); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -706,7 +706,7 @@ struct GetEnumInput { out += sep; sep = ", "; out += ".aa = "; - smithy::DebugAppend(out, this->aa); + opal::DebugAppend(out, this->aa); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -730,7 +730,7 @@ struct GetEnumOutput { out += sep; sep = ", "; out += ".result = "; - smithy::DebugAppend(out, *this->result); + opal::DebugAppend(out, *this->result); } out += '}'; } @@ -754,7 +754,7 @@ struct GetIntEnumInput { out += sep; sep = ", "; out += ".aa = "; - smithy::DebugAppend(out, this->aa); + opal::DebugAppend(out, this->aa); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -777,7 +777,7 @@ struct GetIntEnumOutput { out += sep; sep = ", "; out += ".result = "; - smithy::DebugAppend(out, this->result); + opal::DebugAppend(out, this->result); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -800,7 +800,7 @@ struct GetMenuInput { out += sep; sep = ", "; out += ".restaurant = "; - smithy::DebugAppend(out, this->restaurant); + opal::DebugAppend(out, this->restaurant); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -823,7 +823,7 @@ struct GetMenuOutput { out += sep; sep = ", "; out += ".menu = "; - smithy::DebugAppend(out, this->menu); + opal::DebugAppend(out, this->menu); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -846,7 +846,7 @@ struct NotFoundError { out += sep; sep = ", "; out += ".name = "; - smithy::DebugAppend(out, this->name); + opal::DebugAppend(out, this->name); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -873,25 +873,25 @@ struct HeaderEndpointInput { out += sep; sep = ", "; out += ".uppercaseHeader = "; - smithy::DebugAppend(out, *this->uppercaseHeader); + opal::DebugAppend(out, *this->uppercaseHeader); } if (this->capitalizedHeader.has_value()) { out += sep; sep = ", "; out += ".capitalizedHeader = "; - smithy::DebugAppend(out, *this->capitalizedHeader); + opal::DebugAppend(out, *this->capitalizedHeader); } if (this->lowercaseHeader.has_value()) { out += sep; sep = ", "; out += ".lowercaseHeader = "; - smithy::DebugAppend(out, *this->lowercaseHeader); + opal::DebugAppend(out, *this->lowercaseHeader); } if (this->mixedHeader.has_value()) { out += sep; sep = ", "; out += ".mixedHeader = "; - smithy::DebugAppend(out, *this->mixedHeader); + opal::DebugAppend(out, *this->mixedHeader); } out += '}'; } @@ -919,25 +919,25 @@ struct HeaderEndpointOutput { out += sep; sep = ", "; out += ".uppercaseHeader = "; - smithy::DebugAppend(out, *this->uppercaseHeader); + opal::DebugAppend(out, *this->uppercaseHeader); } if (this->capitalizedHeader.has_value()) { out += sep; sep = ", "; out += ".capitalizedHeader = "; - smithy::DebugAppend(out, *this->capitalizedHeader); + opal::DebugAppend(out, *this->capitalizedHeader); } if (this->lowercaseHeader.has_value()) { out += sep; sep = ", "; out += ".lowercaseHeader = "; - smithy::DebugAppend(out, *this->lowercaseHeader); + opal::DebugAppend(out, *this->lowercaseHeader); } if (this->mixedHeader.has_value()) { out += sep; sep = ", "; out += ".mixedHeader = "; - smithy::DebugAppend(out, *this->mixedHeader); + opal::DebugAppend(out, *this->mixedHeader); } out += '}'; } @@ -962,7 +962,7 @@ struct HealthInput { out += sep; sep = ", "; out += ".query = "; - smithy::DebugAppend(out, *this->query); + opal::DebugAppend(out, *this->query); } out += '}'; } @@ -986,7 +986,7 @@ struct HealthOutput { out += sep; sep = ", "; out += ".status = "; - smithy::DebugAppend(out, this->status); + opal::DebugAppend(out, this->status); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -1009,7 +1009,7 @@ struct HttpPayloadRequiredWithDefaultInput { out += sep; sep = ", "; out += ".body = "; - smithy::DebugAppend(out, this->body); + opal::DebugAppend(out, this->body); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -1032,7 +1032,7 @@ struct HttpPayloadRequiredWithDefaultOutput { out += sep; sep = ", "; out += ".body = "; - smithy::DebugAppend(out, this->body); + opal::DebugAppend(out, this->body); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -1056,7 +1056,7 @@ struct HttpPayloadWithDefaultInput { out += sep; sep = ", "; out += ".body = "; - smithy::DebugAppend(out, *this->body); + opal::DebugAppend(out, *this->body); } out += '}'; } @@ -1080,7 +1080,7 @@ struct HttpPayloadWithDefaultOutput { out += sep; sep = ", "; out += ".body = "; - smithy::DebugAppend(out, this->body); + opal::DebugAppend(out, this->body); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -1103,7 +1103,7 @@ struct SmallStruct { out += sep; sep = ", "; out += ".content = "; - smithy::DebugAppend(out, this->content); + opal::DebugAppend(out, this->content); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -1133,18 +1133,18 @@ class OpenDiscriminatedUnion { /// The engaged member, or nullptr when another member (or none) is set. const SmallStruct* as_smol_or_null() const { return std::get_if<1>(&value_); } - static OpenDiscriminatedUnion FromOther(smithy::Document value) { + static OpenDiscriminatedUnion FromOther(opal::Document value) { OpenDiscriminatedUnion result; result.value_.emplace<2>(std::move(value)); return result; } bool is_other() const { return value_.index() == 2; } - const smithy::Document& as_other() const { + const opal::Document& as_other() const { require_is(2, "other"); return std::get<2>(value_); } /// The engaged member, or nullptr when another member (or none) is set. - const smithy::Document* as_other_or_null() const { return std::get_if<2>(&value_); } + const opal::Document* as_other_or_null() const { return std::get_if<2>(&value_); } /// True until one of the From* factories has been used. bool empty() const { return value_.index() == 0; } @@ -1168,11 +1168,11 @@ class OpenDiscriminatedUnion { switch (value_.index()) { case 1: out += "smol = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "other = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -1185,17 +1185,17 @@ class OpenDiscriminatedUnion { } friend bool operator==(const OpenDiscriminatedUnion&, const OpenDiscriminatedUnion&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("OpenDiscriminatedUnion", requested, case_name()); + opal::internal::FatalWrongUnionAccess("OpenDiscriminatedUnion", requested, case_name()); } } - std::variant value_; + std::variant value_; }; @@ -1216,18 +1216,18 @@ class OpenTaggedUnion { /// The engaged member, or nullptr when another member (or none) is set. const std::string* as_str_or_null() const { return std::get_if<1>(&value_); } - static OpenTaggedUnion FromOther(smithy::Document value) { + static OpenTaggedUnion FromOther(opal::Document value) { OpenTaggedUnion result; result.value_.emplace<2>(std::move(value)); return result; } bool is_other() const { return value_.index() == 2; } - const smithy::Document& as_other() const { + const opal::Document& as_other() const { require_is(2, "other"); return std::get<2>(value_); } /// The engaged member, or nullptr when another member (or none) is set. - const smithy::Document* as_other_or_null() const { return std::get_if<2>(&value_); } + const opal::Document* as_other_or_null() const { return std::get_if<2>(&value_); } /// True until one of the From* factories has been used. bool empty() const { return value_.index() == 0; } @@ -1251,11 +1251,11 @@ class OpenTaggedUnion { switch (value_.index()) { case 1: out += "str = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "other = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -1268,17 +1268,17 @@ class OpenTaggedUnion { } friend bool operator==(const OpenTaggedUnion&, const OpenTaggedUnion&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("OpenTaggedUnion", requested, case_name()); + opal::internal::FatalWrongUnionAccess("OpenTaggedUnion", requested, case_name()); } } - std::variant value_; + std::variant value_; }; @@ -1334,11 +1334,11 @@ class OpenUnionsPayload { switch (value_.index()) { case 1: out += "tagged = "; - smithy::DebugAppend(out, std::get<1>(value_)); + opal::DebugAppend(out, std::get<1>(value_)); break; case 2: out += "discriminated = "; - smithy::DebugAppend(out, std::get<2>(value_)); + opal::DebugAppend(out, std::get<2>(value_)); break; default: break; @@ -1351,13 +1351,13 @@ class OpenUnionsPayload { } friend bool operator==(const OpenUnionsPayload&, const OpenUnionsPayload&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. private: void require_is(std::size_t index, const char* requested) const { if (value_.index() != index) { - smithy::internal::FatalWrongUnionAccess("OpenUnionsPayload", requested, case_name()); + opal::internal::FatalWrongUnionAccess("OpenUnionsPayload", requested, case_name()); } } @@ -1375,7 +1375,7 @@ struct OpenUnionsInput { out += sep; sep = ", "; out += ".data = "; - smithy::DebugAppend(out, this->data); + opal::DebugAppend(out, this->data); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -1384,8 +1384,8 @@ struct OpenUnionsInput { } friend bool operator==(const OpenUnionsInput&, const OpenUnionsInput&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. }; @@ -1399,7 +1399,7 @@ struct OpenUnionsOutput { out += sep; sep = ", "; out += ".data = "; - smithy::DebugAppend(out, this->data); + opal::DebugAppend(out, this->data); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -1408,14 +1408,14 @@ struct OpenUnionsOutput { } friend bool operator==(const OpenUnionsOutput&, const OpenUnionsOutput&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. }; struct PreserveOrderInput { std::optional> map{}; - std::optional document{}; + std::optional document{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -1425,13 +1425,13 @@ struct PreserveOrderInput { out += sep; sep = ", "; out += ".map = "; - smithy::DebugAppend(out, *this->map); + opal::DebugAppend(out, *this->map); } if (this->document.has_value()) { out += sep; sep = ", "; out += ".document = "; - smithy::DebugAppend(out, *this->document); + opal::DebugAppend(out, *this->document); } out += '}'; } @@ -1441,14 +1441,14 @@ struct PreserveOrderInput { } friend bool operator==(const PreserveOrderInput&, const PreserveOrderInput&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. }; struct PreserveOrderOutput { std::optional> map{}; - std::optional document{}; + std::optional document{}; /// Debug rendering for logs and tests — for humans, never parse it. void AppendDebugTo(std::string& out) const { @@ -1458,13 +1458,13 @@ struct PreserveOrderOutput { out += sep; sep = ", "; out += ".map = "; - smithy::DebugAppend(out, *this->map); + opal::DebugAppend(out, *this->map); } if (this->document.has_value()) { out += sep; sep = ", "; out += ".document = "; - smithy::DebugAppend(out, *this->document); + opal::DebugAppend(out, *this->document); } out += '}'; } @@ -1474,8 +1474,8 @@ struct PreserveOrderOutput { } friend bool operator==(const PreserveOrderOutput&, const PreserveOrderOutput&) = default; - // Equality-only: a member type has no ordering (smithy::Document or - // recursion via smithy::Boxed) — see generated-types.md. + // Equality-only: a member type has no ordering (opal::Document or + // recursion via opal::Boxed) — see generated-types.md. }; @@ -1492,24 +1492,24 @@ struct RoundTripInput { out += sep; sep = ", "; out += ".label = "; - smithy::DebugAppend(out, this->label); + opal::DebugAppend(out, this->label); if (this->header.has_value()) { out += sep; sep = ", "; out += ".header = "; - smithy::DebugAppend(out, *this->header); + opal::DebugAppend(out, *this->header); } if (this->query.has_value()) { out += sep; sep = ", "; out += ".query = "; - smithy::DebugAppend(out, *this->query); + opal::DebugAppend(out, *this->query); } if (this->body.has_value()) { out += sep; sep = ", "; out += ".body = "; - smithy::DebugAppend(out, *this->body); + opal::DebugAppend(out, *this->body); } out += '}'; } @@ -1536,24 +1536,24 @@ struct RoundTripOutput { out += sep; sep = ", "; out += ".label = "; - smithy::DebugAppend(out, this->label); + opal::DebugAppend(out, this->label); if (this->header.has_value()) { out += sep; sep = ", "; out += ".header = "; - smithy::DebugAppend(out, *this->header); + opal::DebugAppend(out, *this->header); } if (this->query.has_value()) { out += sep; sep = ", "; out += ".query = "; - smithy::DebugAppend(out, *this->query); + opal::DebugAppend(out, *this->query); } if (this->body.has_value()) { out += sep; sep = ", "; out += ".body = "; - smithy::DebugAppend(out, *this->body); + opal::DebugAppend(out, *this->body); } out += '}'; } @@ -1593,7 +1593,7 @@ struct VersionOutput { out += sep; sep = ", "; out += ".version = "; - smithy::DebugAppend(out, this->version); + opal::DebugAppend(out, this->version); out += '}'; } std::string DebugString() const { std::string out; AppendDebugTo(out); return out; } @@ -1605,356 +1605,356 @@ struct VersionOutput { friend auto operator<=>(const VersionOutput&, const VersionOutput&) = default; }; -} // namespace smithy::protocoltests::simplerestjson +} // namespace opal::protocoltests::simplerestjson // std::hash so generated types key std::unordered_map/std::unordered_set — // emitted exactly for the types that get operator<=> (issue #49). Hash // values are process-local: never persist or compare them across runs. template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::PizzaBase& value) const noexcept { - return smithy::HashCombine(static_cast(value.value_), - smithy::HashValue(value.unknown_)); +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::PizzaBase& value) const noexcept { + return opal::HashCombine(static_cast(value.value_), + opal::HashValue(value.unknown_)); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::Ingredient& value) const noexcept { - return smithy::HashCombine(static_cast(value.value_), - smithy::HashValue(value.unknown_)); +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::Ingredient& value) const noexcept { + return opal::HashCombine(static_cast(value.value_), + opal::HashValue(value.unknown_)); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::Pizza& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::Pizza& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.name)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.base)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.toppings)); + seed = opal::HashCombine(seed, opal::HashValue(value.name)); + seed = opal::HashCombine(seed, opal::HashValue(value.base)); + seed = opal::HashCombine(seed, opal::HashValue(value.toppings)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::Salad& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::Salad& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.name)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.ingredients)); + seed = opal::HashCombine(seed, opal::HashValue(value.name)); + seed = opal::HashCombine(seed, opal::HashValue(value.ingredients)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::Food& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::Food& value) const noexcept { const std::size_t member = - std::visit([](const auto& v) { return smithy::HashValue(v); }, value.value_); - return smithy::HashCombine(value.value_.index(), member); + std::visit([](const auto& v) { return opal::HashValue(v); }, value.value_); + return opal::HashCombine(value.value_.index(), member); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::MenuItem& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::MenuItem& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.food)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.price)); + seed = opal::HashCombine(seed, opal::HashValue(value.food)); + seed = opal::HashCombine(seed, opal::HashValue(value.price)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::AddMenuItemInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::AddMenuItemInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.restaurant)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.menuItem)); + seed = opal::HashCombine(seed, opal::HashValue(value.restaurant)); + seed = opal::HashCombine(seed, opal::HashValue(value.menuItem)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::AddMenuItemOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::AddMenuItemOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.itemId)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.added)); + seed = opal::HashCombine(seed, opal::HashValue(value.itemId)); + seed = opal::HashCombine(seed, opal::HashValue(value.added)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::GenericClientError& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::GenericClientError& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::GenericServerError& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::GenericServerError& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::PriceError& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::PriceError& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.message)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.code)); + seed = opal::HashCombine(seed, opal::HashValue(value.message)); + seed = opal::HashCombine(seed, opal::HashValue(value.code)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::CustomCodeInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::CustomCodeInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.code)); + seed = opal::HashCombine(seed, opal::HashValue(value.code)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::CustomCodeOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::CustomCodeOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.code)); + seed = opal::HashCombine(seed, opal::HashValue(value.code)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::UnknownServerErrorCode& value) const noexcept { - return smithy::HashCombine(static_cast(value.value_), - smithy::HashValue(value.unknown_)); +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::UnknownServerErrorCode& value) const noexcept { + return opal::HashCombine(static_cast(value.value_), + opal::HashValue(value.unknown_)); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::UnknownServerError& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::UnknownServerError& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.errorCode)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.description)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.stateHash)); + seed = opal::HashCombine(seed, opal::HashValue(value.errorCode)); + seed = opal::HashCombine(seed, opal::HashValue(value.description)); + seed = opal::HashCombine(seed, opal::HashValue(value.stateHash)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::FallbackError& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::FallbackError& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.error)); + seed = opal::HashCombine(seed, opal::HashValue(value.error)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::TheEnum& value) const noexcept { - return smithy::HashCombine(static_cast(value.value_), - smithy::HashValue(value.unknown_)); +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::TheEnum& value) const noexcept { + return opal::HashCombine(static_cast(value.value_), + opal::HashValue(value.unknown_)); } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::GetEnumInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::GetEnumInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.aa)); + seed = opal::HashCombine(seed, opal::HashValue(value.aa)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::GetEnumOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::GetEnumOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.result)); + seed = opal::HashCombine(seed, opal::HashValue(value.result)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::GetIntEnumInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::GetIntEnumInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.aa)); + seed = opal::HashCombine(seed, opal::HashValue(value.aa)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::GetIntEnumOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::GetIntEnumOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.result)); + seed = opal::HashCombine(seed, opal::HashValue(value.result)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::GetMenuInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::GetMenuInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.restaurant)); + seed = opal::HashCombine(seed, opal::HashValue(value.restaurant)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::GetMenuOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::GetMenuOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.menu)); + seed = opal::HashCombine(seed, opal::HashValue(value.menu)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::NotFoundError& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::NotFoundError& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.name)); + seed = opal::HashCombine(seed, opal::HashValue(value.name)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HeaderEndpointInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HeaderEndpointInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.uppercaseHeader)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.capitalizedHeader)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.lowercaseHeader)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.mixedHeader)); + seed = opal::HashCombine(seed, opal::HashValue(value.uppercaseHeader)); + seed = opal::HashCombine(seed, opal::HashValue(value.capitalizedHeader)); + seed = opal::HashCombine(seed, opal::HashValue(value.lowercaseHeader)); + seed = opal::HashCombine(seed, opal::HashValue(value.mixedHeader)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HeaderEndpointOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HeaderEndpointOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.uppercaseHeader)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.capitalizedHeader)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.lowercaseHeader)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.mixedHeader)); + seed = opal::HashCombine(seed, opal::HashValue(value.uppercaseHeader)); + seed = opal::HashCombine(seed, opal::HashValue(value.capitalizedHeader)); + seed = opal::HashCombine(seed, opal::HashValue(value.lowercaseHeader)); + seed = opal::HashCombine(seed, opal::HashValue(value.mixedHeader)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HealthInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HealthInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.query)); + seed = opal::HashCombine(seed, opal::HashValue(value.query)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HealthOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HealthOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.status)); + seed = opal::HashCombine(seed, opal::HashValue(value.status)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HttpPayloadRequiredWithDefaultInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HttpPayloadRequiredWithDefaultInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.body)); + seed = opal::HashCombine(seed, opal::HashValue(value.body)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HttpPayloadRequiredWithDefaultOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HttpPayloadRequiredWithDefaultOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.body)); + seed = opal::HashCombine(seed, opal::HashValue(value.body)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HttpPayloadWithDefaultInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HttpPayloadWithDefaultInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.body)); + seed = opal::HashCombine(seed, opal::HashValue(value.body)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::HttpPayloadWithDefaultOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::HttpPayloadWithDefaultOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.body)); + seed = opal::HashCombine(seed, opal::HashValue(value.body)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::SmallStruct& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::SmallStruct& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.content)); + seed = opal::HashCombine(seed, opal::HashValue(value.content)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::RoundTripInput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::RoundTripInput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.label)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.header)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.query)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.body)); + seed = opal::HashCombine(seed, opal::HashValue(value.label)); + seed = opal::HashCombine(seed, opal::HashValue(value.header)); + seed = opal::HashCombine(seed, opal::HashValue(value.query)); + seed = opal::HashCombine(seed, opal::HashValue(value.body)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::RoundTripOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::RoundTripOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.label)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.header)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.query)); - seed = smithy::HashCombine(seed, smithy::HashValue(value.body)); + seed = opal::HashCombine(seed, opal::HashValue(value.label)); + seed = opal::HashCombine(seed, opal::HashValue(value.header)); + seed = opal::HashCombine(seed, opal::HashValue(value.query)); + seed = opal::HashCombine(seed, opal::HashValue(value.body)); return seed; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::VersionInput& /*value*/) const noexcept { return 0; } +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::VersionInput& /*value*/) const noexcept { return 0; } }; template <> -struct std::hash { - std::size_t operator()(const smithy::protocoltests::simplerestjson::VersionOutput& value) const noexcept { +struct std::hash { + std::size_t operator()(const opal::protocoltests::simplerestjson::VersionOutput& value) const noexcept { std::size_t seed = 0; - seed = smithy::HashCombine(seed, smithy::HashValue(value.version)); + seed = opal::HashCombine(seed, opal::HashValue(value.version)); return seed; } }; -#endif // SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_TYPES_H_ +#endif // OPAL_PROTOCOLTESTS_SIMPLERESTJSON_TYPES_H_ diff --git a/protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/serde.h b/protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/serde.h deleted file mode 100644 index 035fe7a6..00000000 --- a/protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/serde.h +++ /dev/null @@ -1,152 +0,0 @@ -// Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. - -#ifndef SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_SERDE_H_ -#define SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_SERDE_H_ - -#include -#include -#include -#include - -#include "smithy/core/document.h" -#include "smithy/core/outcome.h" -#include "smithy/protocoltests/simplerestjson/types.h" - -namespace smithy::protocoltests::simplerestjson { - -// Document-pivot serde for every aggregate shape in the model closure. -// Serializers never fail; deserializers return smithy::Error on wire -// mismatches and enforce @required members. - -smithy::Document SerializeIngredients(const std::vector& value); -smithy::Outcome> DeserializeIngredients(const smithy::Document& doc); - -smithy::Document SerializePizza(const Pizza& value); -smithy::Outcome DeserializePizza(const smithy::Document& doc); - -smithy::Document SerializeSalad(const Salad& value); -smithy::Outcome DeserializeSalad(const smithy::Document& doc); - -smithy::Document SerializeFood(const Food& value); -smithy::Outcome DeserializeFood(const smithy::Document& doc); - -smithy::Document SerializeMenuItem(const MenuItem& value); -smithy::Outcome DeserializeMenuItem(const smithy::Document& doc); - -smithy::Document SerializeAddMenuItemInput(const AddMenuItemInput& value); -smithy::Outcome DeserializeAddMenuItemInput(const smithy::Document& doc); - -smithy::Document SerializeAddMenuItemOutput(const AddMenuItemOutput& value); -smithy::Outcome DeserializeAddMenuItemOutput(const smithy::Document& doc); - -smithy::Document SerializeGenericClientError(const GenericClientError& value); -smithy::Outcome DeserializeGenericClientError(const smithy::Document& doc); - -smithy::Document SerializeGenericServerError(const GenericServerError& value); -smithy::Outcome DeserializeGenericServerError(const smithy::Document& doc); - -smithy::Document SerializePriceError(const PriceError& value); -smithy::Outcome DeserializePriceError(const smithy::Document& doc); - -smithy::Document SerializeCustomCodeInput(const CustomCodeInput& value); -smithy::Outcome DeserializeCustomCodeInput(const smithy::Document& doc); - -smithy::Document SerializeCustomCodeOutput(const CustomCodeOutput& value); -smithy::Outcome DeserializeCustomCodeOutput(const smithy::Document& doc); - -smithy::Document SerializeUnknownServerError(const UnknownServerError& value); -smithy::Outcome DeserializeUnknownServerError(const smithy::Document& doc); - -smithy::Document SerializeFallbackError(const FallbackError& value); -smithy::Outcome DeserializeFallbackError(const smithy::Document& doc); - -smithy::Document SerializeGetEnumInput(const GetEnumInput& value); -smithy::Outcome DeserializeGetEnumInput(const smithy::Document& doc); - -smithy::Document SerializeGetEnumOutput(const GetEnumOutput& value); -smithy::Outcome DeserializeGetEnumOutput(const smithy::Document& doc); - -smithy::Document SerializeGetIntEnumInput(const GetIntEnumInput& value); -smithy::Outcome DeserializeGetIntEnumInput(const smithy::Document& doc); - -smithy::Document SerializeGetIntEnumOutput(const GetIntEnumOutput& value); -smithy::Outcome DeserializeGetIntEnumOutput(const smithy::Document& doc); - -smithy::Document SerializeGetMenuInput(const GetMenuInput& value); -smithy::Outcome DeserializeGetMenuInput(const smithy::Document& doc); - -smithy::Document SerializeMenu(const std::map& value); -smithy::Outcome> DeserializeMenu(const smithy::Document& doc); - -smithy::Document SerializeGetMenuOutput(const GetMenuOutput& value); -smithy::Outcome DeserializeGetMenuOutput(const smithy::Document& doc); - -smithy::Document SerializeNotFoundError(const NotFoundError& value); -smithy::Outcome DeserializeNotFoundError(const smithy::Document& doc); - -smithy::Document SerializeHeaderEndpointInput(const HeaderEndpointInput& value); -smithy::Outcome DeserializeHeaderEndpointInput(const smithy::Document& doc); - -smithy::Document SerializeHeaderEndpointOutput(const HeaderEndpointOutput& value); -smithy::Outcome DeserializeHeaderEndpointOutput(const smithy::Document& doc); - -smithy::Document SerializeHealthInput(const HealthInput& value); -smithy::Outcome DeserializeHealthInput(const smithy::Document& doc); - -smithy::Document SerializeHealthOutput(const HealthOutput& value); -smithy::Outcome DeserializeHealthOutput(const smithy::Document& doc); - -smithy::Document SerializeHttpPayloadRequiredWithDefaultInput(const HttpPayloadRequiredWithDefaultInput& value); -smithy::Outcome DeserializeHttpPayloadRequiredWithDefaultInput(const smithy::Document& doc); - -smithy::Document SerializeHttpPayloadRequiredWithDefaultOutput(const HttpPayloadRequiredWithDefaultOutput& value); -smithy::Outcome DeserializeHttpPayloadRequiredWithDefaultOutput(const smithy::Document& doc); - -smithy::Document SerializeHttpPayloadWithDefaultInput(const HttpPayloadWithDefaultInput& value); -smithy::Outcome DeserializeHttpPayloadWithDefaultInput(const smithy::Document& doc); - -smithy::Document SerializeHttpPayloadWithDefaultOutput(const HttpPayloadWithDefaultOutput& value); -smithy::Outcome DeserializeHttpPayloadWithDefaultOutput(const smithy::Document& doc); - -smithy::Document SerializeMyMap(const std::map& value); -smithy::Outcome> DeserializeMyMap(const smithy::Document& doc); - -smithy::Document SerializeSmallStruct(const SmallStruct& value); -smithy::Outcome DeserializeSmallStruct(const smithy::Document& doc); - -smithy::Document SerializeOpenDiscriminatedUnion(const OpenDiscriminatedUnion& value); -smithy::Outcome DeserializeOpenDiscriminatedUnion(const smithy::Document& doc); - -smithy::Document SerializeOpenTaggedUnion(const OpenTaggedUnion& value); -smithy::Outcome DeserializeOpenTaggedUnion(const smithy::Document& doc); - -smithy::Document SerializeOpenUnionsPayload(const OpenUnionsPayload& value); -smithy::Outcome DeserializeOpenUnionsPayload(const smithy::Document& doc); - -smithy::Document SerializeOpenUnionsInput(const OpenUnionsInput& value); -smithy::Outcome DeserializeOpenUnionsInput(const smithy::Document& doc); - -smithy::Document SerializeOpenUnionsOutput(const OpenUnionsOutput& value); -smithy::Outcome DeserializeOpenUnionsOutput(const smithy::Document& doc); - -smithy::Document SerializePreserveOrderInput(const PreserveOrderInput& value); -smithy::Outcome DeserializePreserveOrderInput(const smithy::Document& doc); - -smithy::Document SerializePreserveOrderOutput(const PreserveOrderOutput& value); -smithy::Outcome DeserializePreserveOrderOutput(const smithy::Document& doc); - -smithy::Document SerializeRoundTripInput(const RoundTripInput& value); -smithy::Outcome DeserializeRoundTripInput(const smithy::Document& doc); - -smithy::Document SerializeRoundTripOutput(const RoundTripOutput& value); -smithy::Outcome DeserializeRoundTripOutput(const smithy::Document& doc); - -smithy::Document SerializeVersionInput(const VersionInput& value); -smithy::Outcome DeserializeVersionInput(const smithy::Document& doc); - -smithy::Document SerializeVersionOutput(const VersionOutput& value); -smithy::Outcome DeserializeVersionOutput(const smithy::Document& doc); - -} // namespace smithy::protocoltests::simplerestjson - -#endif // SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_SERDE_H_ diff --git a/protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/server.h b/protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/server.h deleted file mode 100644 index 5ab977ff..00000000 --- a/protocol-tests/simplerestjson/generated/include/smithy/protocoltests/simplerestjson/server.h +++ /dev/null @@ -1,56 +0,0 @@ -// Code generated by smithy-cpp (cpp-codegen). DO NOT EDIT. - -#ifndef SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_SERVER_H_ -#define SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_SERVER_H_ - -#include - -#include "smithy/core/outcome.h" -#include "smithy/http/transport.h" -#include "smithy/protocoltests/simplerestjson/types.h" -#include "smithy/server/router.h" - -namespace smithy::protocoltests::simplerestjson { - -/// Implement one method per operation. Return a modeled error as -/// smithy::Error::Modeled("", message), optionally with the -/// typed error structure attached via set_detail() so it serializes fully. -/// The context carries the raw request and routing captures — see -/// smithy::server::RequestContext; leave the parameter unnamed when unused. -/// Implementations must be thread-safe: transports may invoke any mix of -/// operations concurrently on the one handler instance. -class PizzaAdminServiceHandler { - public: - virtual ~PizzaAdminServiceHandler() = default; - - virtual smithy::Outcome AddMenuItem(const AddMenuItemInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome CustomCode(const CustomCodeInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome GetEnum(const GetEnumInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome GetIntEnum(const GetIntEnumInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome GetMenu(const GetMenuInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome HeaderEndpoint(const HeaderEndpointInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome Health(const HealthInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome OpenUnions(const OpenUnionsInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome PreserveOrder(const PreserveOrderInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome RoundTrip(const RoundTripInput& input, const smithy::server::RequestContext& context) = 0; - virtual smithy::Outcome Version(const VersionInput& input, const smithy::server::RequestContext& context) = 0; -}; - -/// simpleRestJson server for alloy.test#PizzaAdminService: routing, deserialization, handler dispatch, -/// response serialization, and modeled-error mapping. Pass Handler() to any -/// smithy::http::HttpServerTransport. -class PizzaAdminServiceServer { - public: - explicit PizzaAdminServiceServer(std::shared_ptr handler); - - smithy::http::RequestHandler Handler() const; - - private: - std::shared_ptr router_; -}; - -} // namespace smithy::protocoltests::simplerestjson - -#endif // SMITHY_PROTOCOLTESTS_SIMPLERESTJSON_SERVER_H_ diff --git a/protocol-tests/simplerestjson/generated/src/client.cc b/protocol-tests/simplerestjson/generated/src/client.cc index b20c6f8c..c27846f5 100644 --- a/protocol-tests/simplerestjson/generated/src/client.cc +++ b/protocol-tests/simplerestjson/generated/src/client.cc @@ -10,6 +10,8 @@ #include #include +#include "opal/protocoltests/simplerestjson/client.h" +#include "opal/protocoltests/simplerestjson/serde.h" #include "smithy/core/base64.h" #include "smithy/core/blob.h" #include "smithy/core/document_serde.h" @@ -18,10 +20,8 @@ #include "smithy/http/socket_transport.h" #include "smithy/http/uri.h" #include "smithy/json/json.h" -#include "smithy/protocoltests/simplerestjson/client.h" -#include "smithy/protocoltests/simplerestjson/serde.h" -namespace smithy::protocoltests::simplerestjson { +namespace opal::protocoltests::simplerestjson { namespace { namespace helpers { @@ -38,51 +38,51 @@ struct ParsedError { int status = 0; std::string code = "UnknownError"; std::string message; - smithy::Document doc; + opal::Document doc; }; // [[maybe_unused]]: only unary response paths parse wire errors; a // service whose operations all stream never calls this. -[[maybe_unused]] ParsedError ParseError(const smithy::http::HttpResponse& response) { +[[maybe_unused]] ParsedError ParseError(const opal::http::HttpResponse& response) { ParsedError parsed; parsed.status = response.status; parsed.message = "HTTP " + std::to_string(response.status); - auto doc = smithy::json::Decode(response.body); + auto doc = opal::json::Decode(response.body); if (doc.ok()) parsed.doc = *std::move(doc); const auto type_header = response.headers.Get("x-error-type"); if (type_header.has_value()) parsed.code = helpers::SanitizeErrorCode(*type_header); if (parsed.doc.is_map()) { - const smithy::Document* type = parsed.doc.Find("__type"); + const opal::Document* type = parsed.doc.Find("__type"); if (type == nullptr) type = parsed.doc.Find("code"); if (parsed.code == "UnknownError" && type != nullptr && type->is_string()) parsed.code = helpers::SanitizeErrorCode(type->as_string()); - const smithy::Document* text = parsed.doc.Find("message"); + const opal::Document* text = parsed.doc.Find("message"); if (text != nullptr && text->is_string()) parsed.message = text->as_string(); } return parsed; } -smithy::Error GenericError(ParsedError parsed) { +opal::Error GenericError(ParsedError parsed) { const bool retryable = parsed.status >= 500; - if (parsed.code == "UnknownError") return smithy::Error(smithy::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); - return smithy::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); + if (parsed.code == "UnknownError") return opal::Error(opal::ErrorKind::kUnknown, std::move(parsed.code), std::move(parsed.message), retryable); + return opal::Error::Modeled(std::move(parsed.code), std::move(parsed.message), retryable); } // Strict text parsing for label/query/header bindings ([[maybe_unused]]: // emitted for every service; not every service binds numeric values). // Trailing text, floats-for-ints, and out-of-range values are rejected // (the malformed-request suites pin this). -[[maybe_unused]] smithy::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { +[[maybe_unused]] opal::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { std::int64_t value = 0; const char* first = text.data(); const char* last = first + text.size(); const auto result = std::from_chars(first, last, value, 10); if (text.empty() || result.ec != std::errc() || result.ptr != last || value < min_value || value > max_value) { - return smithy::Error::Serialization("invalid integer: " + text); + return opal::Error::Serialization("invalid integer: " + text); } return value; } -[[maybe_unused]] smithy::Outcome ParseDoubleText(const std::string& text) { +[[maybe_unused]] opal::Outcome ParseDoubleText(const std::string& text) { if (text == "NaN") return std::numeric_limits::quiet_NaN(); if (text == "Infinity") return std::numeric_limits::infinity(); if (text == "-Infinity") return -std::numeric_limits::infinity(); @@ -90,21 +90,21 @@ smithy::Error GenericError(ParsedError parsed) { return (c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' || c == '+' || c == '-'; }; if (text.empty() || text.front() == '+' || !std::all_of(text.begin(), text.end(), valid_char)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } char* parse_end = nullptr; const double value = std::strtod(text.c_str(), &parse_end); if (parse_end != text.c_str() + text.size() || !std::isfinite(value)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } return value; } -smithy::Error MakeFallbackErrorError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeFallbackErrorError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("FallbackError", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("FallbackError", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeFallbackError(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -112,11 +112,11 @@ smithy::Error MakeFallbackErrorError(const smithy::http::HttpResponse& response, return error; } -smithy::Error MakeGenericClientErrorError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeGenericClientErrorError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("GenericClientError", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("GenericClientError", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeGenericClientError(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -124,11 +124,11 @@ smithy::Error MakeGenericClientErrorError(const smithy::http::HttpResponse& resp return error; } -smithy::Error MakeGenericServerErrorError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeGenericServerErrorError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("GenericServerError", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("GenericServerError", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeGenericServerError(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -136,11 +136,11 @@ smithy::Error MakeGenericServerErrorError(const smithy::http::HttpResponse& resp return error; } -smithy::Error MakeNotFoundErrorError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeNotFoundErrorError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("NotFoundError", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("NotFoundError", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeNotFoundError(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -148,13 +148,13 @@ smithy::Error MakeNotFoundErrorError(const smithy::http::HttpResponse& response, return error; } -smithy::Error MakePriceErrorError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakePriceErrorError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("PriceError", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("PriceError", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); if (const auto header_value = response.headers.Get("X-CODE"); header_value.has_value()) { - if (auto parsed_num = helpers::ParseInt64Text(*header_value, -2147483648LL, 2147483647LL)) parsed.doc.as_map().insert_or_assign("code", smithy::Document(*parsed_num)); + if (auto parsed_num = helpers::ParseInt64Text(*header_value, -2147483648LL, 2147483647LL)) parsed.doc.as_map().insert_or_assign("code", opal::Document(*parsed_num)); } auto detail = DeserializePriceError(parsed.doc); if (detail.ok()) { @@ -163,11 +163,11 @@ smithy::Error MakePriceErrorError(const smithy::http::HttpResponse& response, Pa return error; } -smithy::Error MakeUnknownServerErrorError(const smithy::http::HttpResponse& response, ParsedError parsed) { +opal::Error MakeUnknownServerErrorError(const opal::http::HttpResponse& response, ParsedError parsed) { (void)response; const bool retryable = parsed.status >= 500; - smithy::Error error = smithy::Error::Modeled("UnknownServerError", std::move(parsed.message), retryable); - if (!parsed.doc.is_map()) parsed.doc = smithy::Document(smithy::DocumentMap{}); + opal::Error error = opal::Error::Modeled("UnknownServerError", std::move(parsed.message), retryable); + if (!parsed.doc.is_map()) parsed.doc = opal::Document(opal::DocumentMap{}); auto detail = DeserializeUnknownServerError(parsed.doc); if (detail.ok()) { error.set_detail(*std::move(detail)); @@ -175,7 +175,7 @@ smithy::Error MakeUnknownServerErrorError(const smithy::http::HttpResponse& resp return error; } -smithy::Error ParseAddMenuItemError(const smithy::http::HttpResponse& response) { +opal::Error ParseAddMenuItemError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -186,7 +186,7 @@ smithy::Error ParseAddMenuItemError(const smithy::http::HttpResponse& response) return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseCustomCodeError(const smithy::http::HttpResponse& response) { +opal::Error ParseCustomCodeError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -197,7 +197,7 @@ smithy::Error ParseCustomCodeError(const smithy::http::HttpResponse& response) { return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseGetEnumError(const smithy::http::HttpResponse& response) { +opal::Error ParseGetEnumError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -208,7 +208,7 @@ smithy::Error ParseGetEnumError(const smithy::http::HttpResponse& response) { return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseGetIntEnumError(const smithy::http::HttpResponse& response) { +opal::Error ParseGetIntEnumError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -219,7 +219,7 @@ smithy::Error ParseGetIntEnumError(const smithy::http::HttpResponse& response) { return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseGetMenuError(const smithy::http::HttpResponse& response) { +opal::Error ParseGetMenuError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "FallbackError") return helpers::MakeFallbackErrorError(response, std::move(parsed)); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); @@ -232,7 +232,7 @@ smithy::Error ParseGetMenuError(const smithy::http::HttpResponse& response) { return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseHeaderEndpointError(const smithy::http::HttpResponse& response) { +opal::Error ParseHeaderEndpointError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -241,7 +241,7 @@ smithy::Error ParseHeaderEndpointError(const smithy::http::HttpResponse& respons return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseHealthError(const smithy::http::HttpResponse& response) { +opal::Error ParseHealthError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -252,7 +252,7 @@ smithy::Error ParseHealthError(const smithy::http::HttpResponse& response) { return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseHttpPayloadRequiredWithDefaultError(const smithy::http::HttpResponse& response) { +opal::Error ParseHttpPayloadRequiredWithDefaultError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -261,7 +261,7 @@ smithy::Error ParseHttpPayloadRequiredWithDefaultError(const smithy::http::HttpR return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseHttpPayloadWithDefaultError(const smithy::http::HttpResponse& response) { +opal::Error ParseHttpPayloadWithDefaultError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -270,7 +270,7 @@ smithy::Error ParseHttpPayloadWithDefaultError(const smithy::http::HttpResponse& return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseOpenUnionsError(const smithy::http::HttpResponse& response) { +opal::Error ParseOpenUnionsError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -279,7 +279,7 @@ smithy::Error ParseOpenUnionsError(const smithy::http::HttpResponse& response) { return helpers::GenericError(std::move(parsed)); } -smithy::Error ParsePreserveOrderError(const smithy::http::HttpResponse& response) { +opal::Error ParsePreserveOrderError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -288,7 +288,7 @@ smithy::Error ParsePreserveOrderError(const smithy::http::HttpResponse& response return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseRoundTripError(const smithy::http::HttpResponse& response) { +opal::Error ParseRoundTripError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -297,7 +297,7 @@ smithy::Error ParseRoundTripError(const smithy::http::HttpResponse& response) { return helpers::GenericError(std::move(parsed)); } -smithy::Error ParseVersionError(const smithy::http::HttpResponse& response) { +opal::Error ParseVersionError(const opal::http::HttpResponse& response) { ParsedError parsed = helpers::ParseError(response); if (parsed.code == "GenericClientError") return helpers::MakeGenericClientErrorError(response, std::move(parsed)); if (parsed.code == "GenericServerError") return helpers::MakeGenericServerErrorError(response, std::move(parsed)); @@ -309,54 +309,54 @@ smithy::Error ParseVersionError(const smithy::http::HttpResponse& response) { } // namespace helpers } // namespace -smithy::Outcome PizzaAdminServiceClient::Create(smithy::ClientConfig config) { - std::shared_ptr transport = config.http_client; +opal::Outcome PizzaAdminServiceClient::Create(opal::ClientConfig config) { + std::shared_ptr transport = config.http_client; std::string prefix; if (!config.endpoint.empty()) { - auto endpoint = smithy::http::ParseEndpoint(config.endpoint); + auto endpoint = opal::http::ParseEndpoint(config.endpoint); if (!endpoint) return std::move(endpoint).error(); prefix = endpoint->path_prefix; if (transport == nullptr) { // The built-in socket transport is plaintext-only; https needs a - // TLS-capable transport (e.g. smithy::http::BeastHttpClient). + // TLS-capable transport (e.g. opal::http::BeastHttpClient). if (endpoint->tls()) { - return smithy::Error::Validation("PizzaAdminServiceClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. smithy::http::BeastHttpClient::FromConfig)"); + return opal::Error::Validation("PizzaAdminServiceClient: https endpoints need a TLS-capable transport (set config.http_client, e.g. opal::http::BeastHttpClient::FromConfig)"); } - transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); + transport = std::make_shared(endpoint->host, endpoint->port, config.request_timeout_ms); } } if (transport == nullptr) { - return smithy::Error::Validation("PizzaAdminServiceClient: config needs an endpoint or an http_client"); + return opal::Error::Validation("PizzaAdminServiceClient: config needs an endpoint or an http_client"); } return PizzaAdminServiceClient(std::move(config), std::move(transport), std::move(prefix)); } -PizzaAdminServiceClient::PizzaAdminServiceClient(smithy::ClientConfig config, std::shared_ptr transport, std::string path_prefix) +PizzaAdminServiceClient::PizzaAdminServiceClient(opal::ClientConfig config, std::shared_ptr transport, std::string path_prefix) : config_(std::move(config)), transport_(std::move(transport)), path_prefix_(std::move(path_prefix)) {} -smithy::Outcome PizzaAdminServiceClient::Send(smithy::http::HttpRequest request) const { +opal::Outcome PizzaAdminServiceClient::Send(opal::http::HttpRequest request) const { // Operations with a non-document response payload set their own accept. if (!request.headers.Get("accept").has_value()) request.headers.Set("accept", "application/json"); request.headers.Set("user-agent", config_.user_agent); if (!request.body.empty()) { request.headers.Set("content-length", std::to_string(request.body.size())); } - return smithy::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); + return opal::SendWithRetries(*transport_, request, config_.retry, config_.interceptors); } -smithy::Outcome PizzaAdminServiceClient::AddMenuItem(const AddMenuItemInput& input) const { +opal::Outcome PizzaAdminServiceClient::AddMenuItem(const AddMenuItemInput& input) const { std::string target = path_prefix_; target += "/restaurant"; target += "/"; - target += smithy::http::EncodePathSegment(input.restaurant); + target += opal::http::EncodePathSegment(input.restaurant); target += "/menu"; target += "/item"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = std::move(target); - request.body = smithy::json::Encode(SerializeMenuItem(input.menuItem)); + request.body = opal::json::Encode(SerializeMenuItem(input.menuItem)); if (!request.headers.Get("content-type").has_value()) request.headers.Set("content-type", "application/json"); request.headers.Set("accept", "application/json"); auto response = Send(std::move(request)); @@ -364,26 +364,26 @@ smithy::Outcome PizzaAdminServiceClient::AddMenuItem(const Ad if (response->status != 201) return helpers::ParseAddMenuItemError(*response); AddMenuItemOutput out{}; if (!response->body.empty()) { - auto payload_doc = smithy::json::Decode(response->body); + auto payload_doc = opal::json::Decode(response->body); if (!payload_doc) return std::move(payload_doc).error(); - if (!payload_doc->is_string()) return smithy::Error::Serialization("expected a JSON string payload"); + if (!payload_doc->is_string()) return opal::Error::Serialization("expected a JSON string payload"); out.itemId = payload_doc->as_string(); } if (const auto header_value = response->headers.Get("X-ADDED-AT"); header_value.has_value()) { - auto parsed_ts = smithy::Timestamp::Parse((*header_value), smithy::TimestampFormat::kEpochSeconds); + auto parsed_ts = opal::Timestamp::Parse((*header_value), opal::TimestampFormat::kEpochSeconds); if (!parsed_ts) return std::move(parsed_ts).error(); out.added = *std::move(parsed_ts); } - if (!response->headers.Get("X-ADDED-AT").has_value()) return smithy::Error::Serialization("missing required header: X-ADDED-AT"); + if (!response->headers.Get("X-ADDED-AT").has_value()) return opal::Error::Serialization("missing required header: X-ADDED-AT"); return out; } -smithy::Outcome PizzaAdminServiceClient::CustomCode(const CustomCodeInput& input) const { +opal::Outcome PizzaAdminServiceClient::CustomCode(const CustomCodeInput& input) const { std::string target = path_prefix_; target += "/custom-code"; target += "/"; - target += smithy::http::EncodePathSegment(std::to_string(static_cast(input.code))); - smithy::http::HttpRequest request; + target += opal::http::EncodePathSegment(std::to_string(static_cast(input.code))); + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); @@ -394,46 +394,46 @@ smithy::Outcome PizzaAdminServiceClient::CustomCode(const Cust return out; } -smithy::Outcome PizzaAdminServiceClient::GetEnum(const GetEnumInput& input) const { +opal::Outcome PizzaAdminServiceClient::GetEnum(const GetEnumInput& input) const { std::string target = path_prefix_; target += "/get-enum"; target += "/"; - target += smithy::http::EncodePathSegment(std::string(input.aa.ToString())); - smithy::http::HttpRequest request; + target += opal::http::EncodePathSegment(std::string(input.aa.ToString())); + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseGetEnumError(*response); if (response->body.empty()) return GetEnumOutput{}; - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializeGetEnumOutput(*body_doc); } -smithy::Outcome PizzaAdminServiceClient::GetIntEnum(const GetIntEnumInput& input) const { +opal::Outcome PizzaAdminServiceClient::GetIntEnum(const GetIntEnumInput& input) const { std::string target = path_prefix_; target += "/get-int-enum"; target += "/"; - target += smithy::http::EncodePathSegment(std::to_string(static_cast(input.aa))); - smithy::http::HttpRequest request; + target += opal::http::EncodePathSegment(std::to_string(static_cast(input.aa))); + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseGetIntEnumError(*response); - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializeGetIntEnumOutput(*body_doc); } -smithy::Outcome PizzaAdminServiceClient::GetMenu(const GetMenuInput& input) const { +opal::Outcome PizzaAdminServiceClient::GetMenu(const GetMenuInput& input) const { std::string target = path_prefix_; target += "/restaurant"; target += "/"; - target += smithy::http::EncodePathSegment(input.restaurant); + target += opal::http::EncodePathSegment(input.restaurant); target += "/menu"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); request.headers.Set("accept", "application/json"); @@ -442,9 +442,9 @@ smithy::Outcome PizzaAdminServiceClient::GetMenu(const GetMenuInp if (response->status != 200) return helpers::ParseGetMenuError(*response); GetMenuOutput out{}; if (!response->body.empty()) { - auto payload_doc = smithy::json::Decode(response->body); + auto payload_doc = opal::json::Decode(response->body); if (!payload_doc) return std::move(payload_doc).error(); - const smithy::Document* payload_ptr = &*payload_doc; + const opal::Document* payload_ptr = &*payload_doc; { auto parsed = DeserializeMenu(*payload_ptr); if (!parsed) return std::move(parsed).error(); @@ -454,10 +454,10 @@ smithy::Outcome PizzaAdminServiceClient::GetMenu(const GetMenuInp return out; } -smithy::Outcome PizzaAdminServiceClient::HeaderEndpoint(const HeaderEndpointInput& input) const { +opal::Outcome PizzaAdminServiceClient::HeaderEndpoint(const HeaderEndpointInput& input) const { std::string target = path_prefix_; target += "/headers"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = std::move(target); if (input.capitalizedHeader.has_value()) { @@ -491,32 +491,32 @@ smithy::Outcome PizzaAdminServiceClient::HeaderEndpoint(co return out; } -smithy::Outcome PizzaAdminServiceClient::Health(const HealthInput& input) const { +opal::Outcome PizzaAdminServiceClient::Health(const HealthInput& input) const { std::string target = path_prefix_; target += "/health"; - smithy::http::QueryString query; + opal::http::QueryString query; if (input.query.has_value()) { query.Add("query", (*input.query)); } target += query.ToString(); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseHealthError(*response); - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializeHealthOutput(*body_doc); } -smithy::Outcome PizzaAdminServiceClient::HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input) const { +opal::Outcome PizzaAdminServiceClient::HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input) const { std::string target = path_prefix_; target += "/httpPayloadRequiredWithDefault"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = std::move(target); - request.body = smithy::json::Encode(smithy::Document(input.body)); + request.body = opal::json::Encode(opal::Document(input.body)); if (!request.headers.Get("content-type").has_value()) request.headers.Set("content-type", "application/json"); request.headers.Set("accept", "application/json"); auto response = Send(std::move(request)); @@ -524,22 +524,22 @@ smithy::Outcome PizzaAdminServiceClient::H if (response->status != 200) return helpers::ParseHttpPayloadRequiredWithDefaultError(*response); HttpPayloadRequiredWithDefaultOutput out{}; if (!response->body.empty()) { - auto payload_doc = smithy::json::Decode(response->body); + auto payload_doc = opal::json::Decode(response->body); if (!payload_doc) return std::move(payload_doc).error(); - if (!payload_doc->is_string()) return smithy::Error::Serialization("expected a JSON string payload"); + if (!payload_doc->is_string()) return opal::Error::Serialization("expected a JSON string payload"); out.body = payload_doc->as_string(); } return out; } -smithy::Outcome PizzaAdminServiceClient::HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input) const { +opal::Outcome PizzaAdminServiceClient::HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input) const { std::string target = path_prefix_; target += "/httpPayloadWithDefault"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = std::move(target); if (input.body.has_value()) { - request.body = smithy::json::Encode(smithy::Document((*input.body))); + request.body = opal::json::Encode(opal::Document((*input.body))); if (!request.headers.Get("content-type").has_value()) request.headers.Set("content-type", "application/json"); } request.headers.Set("accept", "application/json"); @@ -548,21 +548,21 @@ smithy::Outcome PizzaAdminServiceClient::HttpPaylo if (response->status != 200) return helpers::ParseHttpPayloadWithDefaultError(*response); HttpPayloadWithDefaultOutput out{}; if (!response->body.empty()) { - auto payload_doc = smithy::json::Decode(response->body); + auto payload_doc = opal::json::Decode(response->body); if (!payload_doc) return std::move(payload_doc).error(); - if (!payload_doc->is_string()) return smithy::Error::Serialization("expected a JSON string payload"); + if (!payload_doc->is_string()) return opal::Error::Serialization("expected a JSON string payload"); out.body = payload_doc->as_string(); } return out; } -smithy::Outcome PizzaAdminServiceClient::OpenUnions(const OpenUnionsInput& input) const { +opal::Outcome PizzaAdminServiceClient::OpenUnions(const OpenUnionsInput& input) const { std::string target = path_prefix_; target += "/openUnions"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = std::move(target); - request.body = smithy::json::Encode(SerializeOpenUnionsPayload(input.data)); + request.body = opal::json::Encode(SerializeOpenUnionsPayload(input.data)); if (!request.headers.Get("content-type").has_value()) request.headers.Set("content-type", "application/json"); request.headers.Set("accept", "application/json"); auto response = Send(std::move(request)); @@ -570,9 +570,9 @@ smithy::Outcome PizzaAdminServiceClient::OpenUnions(const Open if (response->status != 200) return helpers::ParseOpenUnionsError(*response); OpenUnionsOutput out{}; if (!response->body.empty()) { - auto payload_doc = smithy::json::Decode(response->body); + auto payload_doc = opal::json::Decode(response->body); if (!payload_doc) return std::move(payload_doc).error(); - const smithy::Document* payload_ptr = &*payload_doc; + const opal::Document* payload_ptr = &*payload_doc; { auto parsed = DeserializeOpenUnionsPayload(*payload_ptr); if (!parsed) return std::move(parsed).error(); @@ -582,57 +582,57 @@ smithy::Outcome PizzaAdminServiceClient::OpenUnions(const Open return out; } -smithy::Outcome PizzaAdminServiceClient::PreserveOrder(const PreserveOrderInput& input) const { +opal::Outcome PizzaAdminServiceClient::PreserveOrder(const PreserveOrderInput& input) const { std::string target = path_prefix_; target += "/preserveKeyOrder"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = std::move(target); - smithy::DocumentMap body_map; + opal::DocumentMap body_map; if (input.document.has_value()) { body_map.emplace("document", (*input.document)); } if (input.map.has_value()) { body_map.emplace("map", SerializeMyMap((*input.map))); } - request.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + request.body = opal::json::Encode(opal::Document(std::move(body_map))); request.headers.Set("content-type", "application/json"); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParsePreserveOrderError(*response); if (response->body.empty()) return PreserveOrderOutput{}; - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); return DeserializePreserveOrderOutput(*body_doc); } -smithy::Outcome PizzaAdminServiceClient::RoundTrip(const RoundTripInput& input) const { +opal::Outcome PizzaAdminServiceClient::RoundTrip(const RoundTripInput& input) const { std::string target = path_prefix_; target += "/roundTrip"; target += "/"; - target += smithy::http::EncodePathSegment(input.label); - smithy::http::QueryString query; + target += opal::http::EncodePathSegment(input.label); + opal::http::QueryString query; if (input.query.has_value()) { query.Add("query", (*input.query)); } target += query.ToString(); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = std::move(target); if (input.header.has_value()) { request.headers.Set("HEADER", (*input.header)); } - smithy::DocumentMap body_map; + opal::DocumentMap body_map; if (input.body.has_value()) { - body_map.emplace("body", smithy::Document((*input.body))); + body_map.emplace("body", opal::Document((*input.body))); } - request.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + request.body = opal::json::Encode(opal::Document(std::move(body_map))); request.headers.Set("content-type", "application/json"); auto response = Send(std::move(request)); if (!response) return std::move(response).error(); if (response->status != 200) return helpers::ParseRoundTripError(*response); RoundTripOutput out{}; - auto body_doc = smithy::json::Decode(response->body); + auto body_doc = opal::json::Decode(response->body); if (!body_doc) return std::move(body_doc).error(); auto parsed = DeserializeRoundTripOutput(*body_doc); if (!parsed) return std::move(parsed).error(); @@ -643,11 +643,11 @@ smithy::Outcome PizzaAdminServiceClient::RoundTrip(const RoundT return out; } -smithy::Outcome PizzaAdminServiceClient::Version(const VersionInput& input) const { +opal::Outcome PizzaAdminServiceClient::Version(const VersionInput& input) const { (void)input; std::string target = path_prefix_; target += "/version"; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = std::move(target); request.headers.Set("accept", "application/json"); @@ -656,12 +656,12 @@ smithy::Outcome PizzaAdminServiceClient::Version(const VersionInp if (response->status != 200) return helpers::ParseVersionError(*response); VersionOutput out{}; if (!response->body.empty()) { - auto payload_doc = smithy::json::Decode(response->body); + auto payload_doc = opal::json::Decode(response->body); if (!payload_doc) return std::move(payload_doc).error(); - if (!payload_doc->is_string()) return smithy::Error::Serialization("expected a JSON string payload"); + if (!payload_doc->is_string()) return opal::Error::Serialization("expected a JSON string payload"); out.version = payload_doc->as_string(); } return out; } -} // namespace smithy::protocoltests::simplerestjson +} // namespace opal::protocoltests::simplerestjson diff --git a/protocol-tests/simplerestjson/generated/src/serde.cc b/protocol-tests/simplerestjson/generated/src/serde.cc index 05415c72..5d1a151f 100644 --- a/protocol-tests/simplerestjson/generated/src/serde.cc +++ b/protocol-tests/simplerestjson/generated/src/serde.cc @@ -3,68 +3,68 @@ #include #include +#include "opal/protocoltests/simplerestjson/serde.h" #include "smithy/core/document_serde.h" -#include "smithy/protocoltests/simplerestjson/serde.h" -namespace smithy::protocoltests::simplerestjson { +namespace opal::protocoltests::simplerestjson { -namespace types = ::smithy::protocoltests::simplerestjson; +namespace types = ::opal::protocoltests::simplerestjson; -smithy::Document SerializeIngredients(const std::vector& value) { - smithy::DocumentList list; +opal::Document SerializeIngredients(const std::vector& value) { + opal::DocumentList list; list.reserve(value.size()); for (const auto& item : value) { - list.push_back(smithy::Document(std::string(item.ToString()))); + list.push_back(opal::Document(std::string(item.ToString()))); } - return smithy::Document(std::move(list)); + return opal::Document(std::move(list)); } -smithy::Outcome> DeserializeIngredients(const smithy::Document& doc) { - if (!doc.is_list()) return smithy::Error::Serialization("std::vector: expected a list on the wire"); +opal::Outcome> DeserializeIngredients(const opal::Document& doc) { + if (!doc.is_list()) return opal::Error::Serialization("std::vector: expected a list on the wire"); std::vector out; out.reserve(doc.as_list().size()); - for (const smithy::Document& item_doc : doc.as_list()) { - const smithy::Document* item = &item_doc; - if (item->is_null()) return smithy::Error::Serialization("std::vector: null element in a dense list"); + for (const opal::Document& item_doc : doc.as_list()) { + const opal::Document* item = &item_doc; + if (item->is_null()) return opal::Error::Serialization("std::vector: null element in a dense list"); Ingredient parsed_item{}; - if (!item->is_string()) return smithy::Error::Serialization("std::vector[]: unexpected type on the wire"); + if (!item->is_string()) return opal::Error::Serialization("std::vector[]: unexpected type on the wire"); parsed_item = types::Ingredient::FromString(item->as_string()); out.push_back(std::move(parsed_item)); } return out; } -smithy::Document SerializePizza(const Pizza& value) { - smithy::DocumentMap map; - map.emplace("name", smithy::Document(value.name)); - map.emplace("base", smithy::Document(std::string(value.base.ToString()))); +opal::Document SerializePizza(const Pizza& value) { + opal::DocumentMap map; + map.emplace("name", opal::Document(value.name)); + map.emplace("base", opal::Document(std::string(value.base.ToString()))); map.emplace("toppings", SerializeIngredients(value.toppings)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePizza(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Pizza: expected a map on the wire"); +opal::Outcome DeserializePizza(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Pizza: expected a map on the wire"); Pizza out; { - const smithy::Document* member = doc.Find("name"); + const opal::Document* member = doc.Find("name"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Pizza: missing required member: name"); + return opal::Error::Serialization("Pizza: missing required member: name"); } - if (!member->is_string()) return smithy::Error::Serialization("Pizza.name: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Pizza.name: unexpected type on the wire"); out.name = member->as_string(); } { - const smithy::Document* member = doc.Find("base"); + const opal::Document* member = doc.Find("base"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Pizza: missing required member: base"); + return opal::Error::Serialization("Pizza: missing required member: base"); } - if (!member->is_string()) return smithy::Error::Serialization("Pizza.base: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Pizza.base: unexpected type on the wire"); out.base = types::PizzaBase::FromString(member->as_string()); } { - const smithy::Document* member = doc.Find("toppings"); + const opal::Document* member = doc.Find("toppings"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Pizza: missing required member: toppings"); + return opal::Error::Serialization("Pizza: missing required member: toppings"); } { auto parsed = DeserializeIngredients(*member); @@ -75,28 +75,28 @@ smithy::Outcome DeserializePizza(const smithy::Document& doc) { return out; } -smithy::Document SerializeSalad(const Salad& value) { - smithy::DocumentMap map; - map.emplace("name", smithy::Document(value.name)); +opal::Document SerializeSalad(const Salad& value) { + opal::DocumentMap map; + map.emplace("name", opal::Document(value.name)); map.emplace("ingredients", SerializeIngredients(value.ingredients)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSalad(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Salad: expected a map on the wire"); +opal::Outcome DeserializeSalad(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Salad: expected a map on the wire"); Salad out; { - const smithy::Document* member = doc.Find("name"); + const opal::Document* member = doc.Find("name"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Salad: missing required member: name"); + return opal::Error::Serialization("Salad: missing required member: name"); } - if (!member->is_string()) return smithy::Error::Serialization("Salad.name: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("Salad.name: unexpected type on the wire"); out.name = member->as_string(); } { - const smithy::Document* member = doc.Find("ingredients"); + const opal::Document* member = doc.Find("ingredients"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("Salad: missing required member: ingredients"); + return opal::Error::Serialization("Salad: missing required member: ingredients"); } { auto parsed = DeserializeIngredients(*member); @@ -107,21 +107,21 @@ smithy::Outcome DeserializeSalad(const smithy::Document& doc) { return out; } -smithy::Document SerializeFood(const Food& value) { - smithy::DocumentMap map; +opal::Document SerializeFood(const Food& value) { + opal::DocumentMap map; if (value.is_pizza()) { map.emplace("pizza", SerializePizza(value.as_pizza())); } if (value.is_salad()) { map.emplace("salad", SerializeSalad(value.as_salad())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeFood(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("Food: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("Food: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("pizza"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeFood(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("Food: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("Food: expected exactly one union member"); + if (const opal::Document* member = doc.Find("pizza"); member != nullptr && !member->is_null()) { Pizza parsed_member{}; { auto parsed = DeserializePizza(*member); @@ -130,7 +130,7 @@ smithy::Outcome DeserializeFood(const smithy::Document& doc) { } return Food::FromPizza(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("salad"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("salad"); member != nullptr && !member->is_null()) { Salad parsed_member{}; { auto parsed = DeserializeSalad(*member); @@ -139,23 +139,23 @@ smithy::Outcome DeserializeFood(const smithy::Document& doc) { } return Food::FromSalad(std::move(parsed_member)); } - return smithy::Error::Serialization("Food: unknown or missing union member"); + return opal::Error::Serialization("Food: unknown or missing union member"); } -smithy::Document SerializeMenuItem(const MenuItem& value) { - smithy::DocumentMap map; +opal::Document SerializeMenuItem(const MenuItem& value) { + opal::DocumentMap map; map.emplace("food", SerializeFood(value.food)); - map.emplace("price", smithy::Document(static_cast(value.price))); - return smithy::Document(std::move(map)); + map.emplace("price", opal::Document(static_cast(value.price))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeMenuItem(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("MenuItem: expected a map on the wire"); +opal::Outcome DeserializeMenuItem(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("MenuItem: expected a map on the wire"); MenuItem out; { - const smithy::Document* member = doc.Find("food"); + const opal::Document* member = doc.Find("food"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("MenuItem: missing required member: food"); + return opal::Error::Serialization("MenuItem: missing required member: food"); } { auto parsed = DeserializeFood(*member); @@ -164,43 +164,43 @@ smithy::Outcome DeserializeMenuItem(const smithy::Document& doc) { } } { - const smithy::Document* member = doc.Find("price"); + const opal::Document* member = doc.Find("price"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("MenuItem: missing required member: price"); + return opal::Error::Serialization("MenuItem: missing required member: price"); } { - auto parsed = smithy::DoubleFromDocument(*member); - if (!parsed) return smithy::Error::Serialization("MenuItem.price: expected a number"); - auto narrowed = smithy::FloatFromDouble(*parsed); - if (!narrowed) return smithy::Error::Serialization("MenuItem.price: value out of range"); + auto parsed = opal::DoubleFromDocument(*member); + if (!parsed) return opal::Error::Serialization("MenuItem.price: expected a number"); + auto narrowed = opal::FloatFromDouble(*parsed); + if (!narrowed) return opal::Error::Serialization("MenuItem.price: value out of range"); out.price = *narrowed; } } return out; } -smithy::Document SerializeAddMenuItemInput(const AddMenuItemInput& value) { - smithy::DocumentMap map; - map.emplace("restaurant", smithy::Document(value.restaurant)); +opal::Document SerializeAddMenuItemInput(const AddMenuItemInput& value) { + opal::DocumentMap map; + map.emplace("restaurant", opal::Document(value.restaurant)); map.emplace("menuItem", SerializeMenuItem(value.menuItem)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeAddMenuItemInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("AddMenuItemInput: expected a map on the wire"); +opal::Outcome DeserializeAddMenuItemInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("AddMenuItemInput: expected a map on the wire"); AddMenuItemInput out; { - const smithy::Document* member = doc.Find("restaurant"); + const opal::Document* member = doc.Find("restaurant"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AddMenuItemInput: missing required member: restaurant"); + return opal::Error::Serialization("AddMenuItemInput: missing required member: restaurant"); } - if (!member->is_string()) return smithy::Error::Serialization("AddMenuItemInput.restaurant: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("AddMenuItemInput.restaurant: unexpected type on the wire"); out.restaurant = member->as_string(); } { - const smithy::Document* member = doc.Find("menuItem"); + const opal::Document* member = doc.Find("menuItem"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AddMenuItemInput: missing required member: menuItem"); + return opal::Error::Serialization("AddMenuItemInput: missing required member: menuItem"); } { auto parsed = DeserializeMenuItem(*member); @@ -211,31 +211,31 @@ smithy::Outcome DeserializeAddMenuItemInput(const smithy::Docu return out; } -smithy::Document SerializeAddMenuItemOutput(const AddMenuItemOutput& value) { - smithy::DocumentMap map; - map.emplace("itemId", smithy::Document(value.itemId)); - map.emplace("added", smithy::Document::FromTimestamp(value.added, smithy::TimestampFormat::kEpochSeconds)); - return smithy::Document(std::move(map)); +opal::Document SerializeAddMenuItemOutput(const AddMenuItemOutput& value) { + opal::DocumentMap map; + map.emplace("itemId", opal::Document(value.itemId)); + map.emplace("added", opal::Document::FromTimestamp(value.added, opal::TimestampFormat::kEpochSeconds)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeAddMenuItemOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("AddMenuItemOutput: expected a map on the wire"); +opal::Outcome DeserializeAddMenuItemOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("AddMenuItemOutput: expected a map on the wire"); AddMenuItemOutput out; { - const smithy::Document* member = doc.Find("itemId"); + const opal::Document* member = doc.Find("itemId"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AddMenuItemOutput: missing required member: itemId"); + return opal::Error::Serialization("AddMenuItemOutput: missing required member: itemId"); } - if (!member->is_string()) return smithy::Error::Serialization("AddMenuItemOutput.itemId: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("AddMenuItemOutput.itemId: unexpected type on the wire"); out.itemId = member->as_string(); } { - const smithy::Document* member = doc.Find("added"); + const opal::Document* member = doc.Find("added"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("AddMenuItemOutput: missing required member: added"); + return opal::Error::Serialization("AddMenuItemOutput: missing required member: added"); } { - auto parsed = smithy::TimestampFromDocument(*member, smithy::TimestampFormat::kEpochSeconds); + auto parsed = opal::TimestampFromDocument(*member, opal::TimestampFormat::kEpochSeconds); if (!parsed) return std::move(parsed).error(); out.added = *parsed; } @@ -243,114 +243,114 @@ smithy::Outcome DeserializeAddMenuItemOutput(const smithy::Do return out; } -smithy::Document SerializeGenericClientError(const GenericClientError& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); - return smithy::Document(std::move(map)); +opal::Document SerializeGenericClientError(const GenericClientError& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGenericClientError(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GenericClientError: expected a map on the wire"); +opal::Outcome DeserializeGenericClientError(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GenericClientError: expected a map on the wire"); GenericClientError out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GenericClientError: missing required member: message"); + return opal::Error::Serialization("GenericClientError: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("GenericClientError.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GenericClientError.message: unexpected type on the wire"); out.message = member->as_string(); } return out; } -smithy::Document SerializeGenericServerError(const GenericServerError& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); - return smithy::Document(std::move(map)); +opal::Document SerializeGenericServerError(const GenericServerError& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGenericServerError(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GenericServerError: expected a map on the wire"); +opal::Outcome DeserializeGenericServerError(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GenericServerError: expected a map on the wire"); GenericServerError out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GenericServerError: missing required member: message"); + return opal::Error::Serialization("GenericServerError: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("GenericServerError.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GenericServerError.message: unexpected type on the wire"); out.message = member->as_string(); } return out; } -smithy::Document SerializePriceError(const PriceError& value) { - smithy::DocumentMap map; - map.emplace("message", smithy::Document(value.message)); - map.emplace("code", smithy::Document(static_cast(value.code))); - return smithy::Document(std::move(map)); +opal::Document SerializePriceError(const PriceError& value) { + opal::DocumentMap map; + map.emplace("message", opal::Document(value.message)); + map.emplace("code", opal::Document(static_cast(value.code))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePriceError(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PriceError: expected a map on the wire"); +opal::Outcome DeserializePriceError(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PriceError: expected a map on the wire"); PriceError out; { - const smithy::Document* member = doc.Find("message"); + const opal::Document* member = doc.Find("message"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PriceError: missing required member: message"); + return opal::Error::Serialization("PriceError: missing required member: message"); } - if (!member->is_string()) return smithy::Error::Serialization("PriceError.message: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("PriceError.message: unexpected type on the wire"); out.message = member->as_string(); } { - const smithy::Document* member = doc.Find("code"); + const opal::Document* member = doc.Find("code"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("PriceError: missing required member: code"); + return opal::Error::Serialization("PriceError: missing required member: code"); } - if (!member->is_int()) return smithy::Error::Serialization("PriceError.code: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("PriceError.code: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("PriceError.code: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("PriceError.code: value out of range"); out.code = static_cast(member->as_int()); } return out; } -smithy::Document SerializeCustomCodeInput(const CustomCodeInput& value) { - smithy::DocumentMap map; - map.emplace("code", smithy::Document(static_cast(value.code))); - return smithy::Document(std::move(map)); +opal::Document SerializeCustomCodeInput(const CustomCodeInput& value) { + opal::DocumentMap map; + map.emplace("code", opal::Document(static_cast(value.code))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeCustomCodeInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("CustomCodeInput: expected a map on the wire"); +opal::Outcome DeserializeCustomCodeInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("CustomCodeInput: expected a map on the wire"); CustomCodeInput out; { - const smithy::Document* member = doc.Find("code"); + const opal::Document* member = doc.Find("code"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("CustomCodeInput: missing required member: code"); + return opal::Error::Serialization("CustomCodeInput: missing required member: code"); } - if (!member->is_int()) return smithy::Error::Serialization("CustomCodeInput.code: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("CustomCodeInput.code: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("CustomCodeInput.code: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("CustomCodeInput.code: value out of range"); out.code = static_cast(member->as_int()); } return out; } -smithy::Document SerializeCustomCodeOutput(const CustomCodeOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeCustomCodeOutput(const CustomCodeOutput& value) { + opal::DocumentMap map; if (value.code.has_value()) { - map.emplace("code", smithy::Document(static_cast((*value.code)))); + map.emplace("code", opal::Document(static_cast((*value.code)))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeCustomCodeOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("CustomCodeOutput: expected a map on the wire"); +opal::Outcome DeserializeCustomCodeOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("CustomCodeOutput: expected a map on the wire"); CustomCodeOutput out; { - const smithy::Document* member = doc.Find("code"); + const opal::Document* member = doc.Find("code"); if (member != nullptr && !member->is_null()) { std::int32_t parsed_member{}; - if (!member->is_int()) return smithy::Error::Serialization("CustomCodeOutput.code: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("CustomCodeOutput.code: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("CustomCodeOutput.code: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("CustomCodeOutput.code: value out of range"); parsed_member = static_cast(member->as_int()); out.code = std::move(parsed_member); } @@ -358,43 +358,43 @@ smithy::Outcome DeserializeCustomCodeOutput(const smithy::Docu return out; } -smithy::Document SerializeUnknownServerError(const UnknownServerError& value) { - smithy::DocumentMap map; - map.emplace("errorCode", smithy::Document(std::string(value.errorCode.ToString()))); +opal::Document SerializeUnknownServerError(const UnknownServerError& value) { + opal::DocumentMap map; + map.emplace("errorCode", opal::Document(std::string(value.errorCode.ToString()))); if (value.description.has_value()) { - map.emplace("description", smithy::Document((*value.description))); + map.emplace("description", opal::Document((*value.description))); } if (value.stateHash.has_value()) { - map.emplace("stateHash", smithy::Document((*value.stateHash))); + map.emplace("stateHash", opal::Document((*value.stateHash))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeUnknownServerError(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("UnknownServerError: expected a map on the wire"); +opal::Outcome DeserializeUnknownServerError(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("UnknownServerError: expected a map on the wire"); UnknownServerError out; { - const smithy::Document* member = doc.Find("errorCode"); + const opal::Document* member = doc.Find("errorCode"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("UnknownServerError: missing required member: errorCode"); + return opal::Error::Serialization("UnknownServerError: missing required member: errorCode"); } - if (!member->is_string()) return smithy::Error::Serialization("UnknownServerError.errorCode: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("UnknownServerError.errorCode: unexpected type on the wire"); out.errorCode = types::UnknownServerErrorCode::FromString(member->as_string()); } { - const smithy::Document* member = doc.Find("description"); + const opal::Document* member = doc.Find("description"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("UnknownServerError.description: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("UnknownServerError.description: unexpected type on the wire"); parsed_member = member->as_string(); out.description = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("stateHash"); + const opal::Document* member = doc.Find("stateHash"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("UnknownServerError.stateHash: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("UnknownServerError.stateHash: unexpected type on the wire"); parsed_member = member->as_string(); out.stateHash = std::move(parsed_member); } @@ -402,62 +402,62 @@ smithy::Outcome DeserializeUnknownServerError(const smithy:: return out; } -smithy::Document SerializeFallbackError(const FallbackError& value) { - smithy::DocumentMap map; - map.emplace("error", smithy::Document(value.error)); - return smithy::Document(std::move(map)); +opal::Document SerializeFallbackError(const FallbackError& value) { + opal::DocumentMap map; + map.emplace("error", opal::Document(value.error)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeFallbackError(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("FallbackError: expected a map on the wire"); +opal::Outcome DeserializeFallbackError(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("FallbackError: expected a map on the wire"); FallbackError out; { - const smithy::Document* member = doc.Find("error"); + const opal::Document* member = doc.Find("error"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("FallbackError: missing required member: error"); + return opal::Error::Serialization("FallbackError: missing required member: error"); } - if (!member->is_string()) return smithy::Error::Serialization("FallbackError.error: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("FallbackError.error: unexpected type on the wire"); out.error = member->as_string(); } return out; } -smithy::Document SerializeGetEnumInput(const GetEnumInput& value) { - smithy::DocumentMap map; - map.emplace("aa", smithy::Document(std::string(value.aa.ToString()))); - return smithy::Document(std::move(map)); +opal::Document SerializeGetEnumInput(const GetEnumInput& value) { + opal::DocumentMap map; + map.emplace("aa", opal::Document(std::string(value.aa.ToString()))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetEnumInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetEnumInput: expected a map on the wire"); +opal::Outcome DeserializeGetEnumInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetEnumInput: expected a map on the wire"); GetEnumInput out; { - const smithy::Document* member = doc.Find("aa"); + const opal::Document* member = doc.Find("aa"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetEnumInput: missing required member: aa"); + return opal::Error::Serialization("GetEnumInput: missing required member: aa"); } - if (!member->is_string()) return smithy::Error::Serialization("GetEnumInput.aa: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetEnumInput.aa: unexpected type on the wire"); out.aa = types::TheEnum::FromString(member->as_string()); } return out; } -smithy::Document SerializeGetEnumOutput(const GetEnumOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeGetEnumOutput(const GetEnumOutput& value) { + opal::DocumentMap map; if (value.result.has_value()) { - map.emplace("result", smithy::Document((*value.result))); + map.emplace("result", opal::Document((*value.result))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetEnumOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetEnumOutput: expected a map on the wire"); +opal::Outcome DeserializeGetEnumOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetEnumOutput: expected a map on the wire"); GetEnumOutput out; { - const smithy::Document* member = doc.Find("result"); + const opal::Document* member = doc.Find("result"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("GetEnumOutput.result: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetEnumOutput.result: unexpected type on the wire"); parsed_member = member->as_string(); out.result = std::move(parsed_member); } @@ -465,81 +465,81 @@ smithy::Outcome DeserializeGetEnumOutput(const smithy::Document& return out; } -smithy::Document SerializeGetIntEnumInput(const GetIntEnumInput& value) { - smithy::DocumentMap map; - map.emplace("aa", smithy::Document(static_cast(value.aa))); - return smithy::Document(std::move(map)); +opal::Document SerializeGetIntEnumInput(const GetIntEnumInput& value) { + opal::DocumentMap map; + map.emplace("aa", opal::Document(static_cast(value.aa))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetIntEnumInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetIntEnumInput: expected a map on the wire"); +opal::Outcome DeserializeGetIntEnumInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetIntEnumInput: expected a map on the wire"); GetIntEnumInput out; { - const smithy::Document* member = doc.Find("aa"); + const opal::Document* member = doc.Find("aa"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetIntEnumInput: missing required member: aa"); + return opal::Error::Serialization("GetIntEnumInput: missing required member: aa"); } - if (!member->is_int()) return smithy::Error::Serialization("GetIntEnumInput.aa: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("GetIntEnumInput.aa: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("GetIntEnumInput.aa: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("GetIntEnumInput.aa: value out of range"); out.aa = static_cast(member->as_int()); } return out; } -smithy::Document SerializeGetIntEnumOutput(const GetIntEnumOutput& value) { - smithy::DocumentMap map; - map.emplace("result", smithy::Document(static_cast(value.result))); - return smithy::Document(std::move(map)); +opal::Document SerializeGetIntEnumOutput(const GetIntEnumOutput& value) { + opal::DocumentMap map; + map.emplace("result", opal::Document(static_cast(value.result))); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetIntEnumOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetIntEnumOutput: expected a map on the wire"); +opal::Outcome DeserializeGetIntEnumOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetIntEnumOutput: expected a map on the wire"); GetIntEnumOutput out; { - const smithy::Document* member = doc.Find("result"); + const opal::Document* member = doc.Find("result"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetIntEnumOutput: missing required member: result"); + return opal::Error::Serialization("GetIntEnumOutput: missing required member: result"); } - if (!member->is_int()) return smithy::Error::Serialization("GetIntEnumOutput.result: unexpected type on the wire"); - if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return smithy::Error::Serialization("GetIntEnumOutput.result: value out of range"); + if (!member->is_int()) return opal::Error::Serialization("GetIntEnumOutput.result: unexpected type on the wire"); + if (member->as_int() < -2147483648LL || member->as_int() > 2147483647LL) return opal::Error::Serialization("GetIntEnumOutput.result: value out of range"); out.result = static_cast(member->as_int()); } return out; } -smithy::Document SerializeGetMenuInput(const GetMenuInput& value) { - smithy::DocumentMap map; - map.emplace("restaurant", smithy::Document(value.restaurant)); - return smithy::Document(std::move(map)); +opal::Document SerializeGetMenuInput(const GetMenuInput& value) { + opal::DocumentMap map; + map.emplace("restaurant", opal::Document(value.restaurant)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetMenuInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetMenuInput: expected a map on the wire"); +opal::Outcome DeserializeGetMenuInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetMenuInput: expected a map on the wire"); GetMenuInput out; { - const smithy::Document* member = doc.Find("restaurant"); + const opal::Document* member = doc.Find("restaurant"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetMenuInput: missing required member: restaurant"); + return opal::Error::Serialization("GetMenuInput: missing required member: restaurant"); } - if (!member->is_string()) return smithy::Error::Serialization("GetMenuInput.restaurant: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("GetMenuInput.restaurant: unexpected type on the wire"); out.restaurant = member->as_string(); } return out; } -smithy::Document SerializeMenu(const std::map& value) { - smithy::DocumentMap map; +opal::Document SerializeMenu(const std::map& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { map.emplace(key, SerializeMenuItem(item)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome> DeserializeMenu(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map: expected a map on the wire"); +opal::Outcome> DeserializeMenu(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map: expected a map on the wire"); std::map out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; MenuItem parsed_item{}; @@ -553,19 +553,19 @@ smithy::Outcome> DeserializeMenu(const smithy::D return out; } -smithy::Document SerializeGetMenuOutput(const GetMenuOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeGetMenuOutput(const GetMenuOutput& value) { + opal::DocumentMap map; map.emplace("menu", SerializeMenu(value.menu)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeGetMenuOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("GetMenuOutput: expected a map on the wire"); +opal::Outcome DeserializeGetMenuOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("GetMenuOutput: expected a map on the wire"); GetMenuOutput out; { - const smithy::Document* member = doc.Find("menu"); + const opal::Document* member = doc.Find("menu"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("GetMenuOutput: missing required member: menu"); + return opal::Error::Serialization("GetMenuOutput: missing required member: menu"); } { auto parsed = DeserializeMenu(*member); @@ -576,78 +576,78 @@ smithy::Outcome DeserializeGetMenuOutput(const smithy::Document& return out; } -smithy::Document SerializeNotFoundError(const NotFoundError& value) { - smithy::DocumentMap map; - map.emplace("name", smithy::Document(value.name)); - return smithy::Document(std::move(map)); +opal::Document SerializeNotFoundError(const NotFoundError& value) { + opal::DocumentMap map; + map.emplace("name", opal::Document(value.name)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeNotFoundError(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("NotFoundError: expected a map on the wire"); +opal::Outcome DeserializeNotFoundError(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("NotFoundError: expected a map on the wire"); NotFoundError out; { - const smithy::Document* member = doc.Find("name"); + const opal::Document* member = doc.Find("name"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("NotFoundError: missing required member: name"); + return opal::Error::Serialization("NotFoundError: missing required member: name"); } - if (!member->is_string()) return smithy::Error::Serialization("NotFoundError.name: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("NotFoundError.name: unexpected type on the wire"); out.name = member->as_string(); } return out; } -smithy::Document SerializeHeaderEndpointInput(const HeaderEndpointInput& value) { - smithy::DocumentMap map; +opal::Document SerializeHeaderEndpointInput(const HeaderEndpointInput& value) { + opal::DocumentMap map; if (value.uppercaseHeader.has_value()) { - map.emplace("uppercaseHeader", smithy::Document((*value.uppercaseHeader))); + map.emplace("uppercaseHeader", opal::Document((*value.uppercaseHeader))); } if (value.capitalizedHeader.has_value()) { - map.emplace("capitalizedHeader", smithy::Document((*value.capitalizedHeader))); + map.emplace("capitalizedHeader", opal::Document((*value.capitalizedHeader))); } if (value.lowercaseHeader.has_value()) { - map.emplace("lowercaseHeader", smithy::Document((*value.lowercaseHeader))); + map.emplace("lowercaseHeader", opal::Document((*value.lowercaseHeader))); } if (value.mixedHeader.has_value()) { - map.emplace("mixedHeader", smithy::Document((*value.mixedHeader))); + map.emplace("mixedHeader", opal::Document((*value.mixedHeader))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeHeaderEndpointInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("HeaderEndpointInput: expected a map on the wire"); +opal::Outcome DeserializeHeaderEndpointInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("HeaderEndpointInput: expected a map on the wire"); HeaderEndpointInput out; { - const smithy::Document* member = doc.Find("uppercaseHeader"); + const opal::Document* member = doc.Find("uppercaseHeader"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("HeaderEndpointInput.uppercaseHeader: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HeaderEndpointInput.uppercaseHeader: unexpected type on the wire"); parsed_member = member->as_string(); out.uppercaseHeader = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("capitalizedHeader"); + const opal::Document* member = doc.Find("capitalizedHeader"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("HeaderEndpointInput.capitalizedHeader: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HeaderEndpointInput.capitalizedHeader: unexpected type on the wire"); parsed_member = member->as_string(); out.capitalizedHeader = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("lowercaseHeader"); + const opal::Document* member = doc.Find("lowercaseHeader"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("HeaderEndpointInput.lowercaseHeader: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HeaderEndpointInput.lowercaseHeader: unexpected type on the wire"); parsed_member = member->as_string(); out.lowercaseHeader = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("mixedHeader"); + const opal::Document* member = doc.Find("mixedHeader"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("HeaderEndpointInput.mixedHeader: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HeaderEndpointInput.mixedHeader: unexpected type on the wire"); parsed_member = member->as_string(); out.mixedHeader = std::move(parsed_member); } @@ -655,58 +655,58 @@ smithy::Outcome DeserializeHeaderEndpointInput(const smithy return out; } -smithy::Document SerializeHeaderEndpointOutput(const HeaderEndpointOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeHeaderEndpointOutput(const HeaderEndpointOutput& value) { + opal::DocumentMap map; if (value.uppercaseHeader.has_value()) { - map.emplace("uppercaseHeader", smithy::Document((*value.uppercaseHeader))); + map.emplace("uppercaseHeader", opal::Document((*value.uppercaseHeader))); } if (value.capitalizedHeader.has_value()) { - map.emplace("capitalizedHeader", smithy::Document((*value.capitalizedHeader))); + map.emplace("capitalizedHeader", opal::Document((*value.capitalizedHeader))); } if (value.lowercaseHeader.has_value()) { - map.emplace("lowercaseHeader", smithy::Document((*value.lowercaseHeader))); + map.emplace("lowercaseHeader", opal::Document((*value.lowercaseHeader))); } if (value.mixedHeader.has_value()) { - map.emplace("mixedHeader", smithy::Document((*value.mixedHeader))); + map.emplace("mixedHeader", opal::Document((*value.mixedHeader))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeHeaderEndpointOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("HeaderEndpointOutput: expected a map on the wire"); +opal::Outcome DeserializeHeaderEndpointOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("HeaderEndpointOutput: expected a map on the wire"); HeaderEndpointOutput out; { - const smithy::Document* member = doc.Find("uppercaseHeader"); + const opal::Document* member = doc.Find("uppercaseHeader"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("HeaderEndpointOutput.uppercaseHeader: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HeaderEndpointOutput.uppercaseHeader: unexpected type on the wire"); parsed_member = member->as_string(); out.uppercaseHeader = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("capitalizedHeader"); + const opal::Document* member = doc.Find("capitalizedHeader"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("HeaderEndpointOutput.capitalizedHeader: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HeaderEndpointOutput.capitalizedHeader: unexpected type on the wire"); parsed_member = member->as_string(); out.capitalizedHeader = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("lowercaseHeader"); + const opal::Document* member = doc.Find("lowercaseHeader"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("HeaderEndpointOutput.lowercaseHeader: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HeaderEndpointOutput.lowercaseHeader: unexpected type on the wire"); parsed_member = member->as_string(); out.lowercaseHeader = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("mixedHeader"); + const opal::Document* member = doc.Find("mixedHeader"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("HeaderEndpointOutput.mixedHeader: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HeaderEndpointOutput.mixedHeader: unexpected type on the wire"); parsed_member = member->as_string(); out.mixedHeader = std::move(parsed_member); } @@ -714,22 +714,22 @@ smithy::Outcome DeserializeHeaderEndpointOutput(const smit return out; } -smithy::Document SerializeHealthInput(const HealthInput& value) { - smithy::DocumentMap map; +opal::Document SerializeHealthInput(const HealthInput& value) { + opal::DocumentMap map; if (value.query.has_value()) { - map.emplace("query", smithy::Document((*value.query))); + map.emplace("query", opal::Document((*value.query))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeHealthInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("HealthInput: expected a map on the wire"); +opal::Outcome DeserializeHealthInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("HealthInput: expected a map on the wire"); HealthInput out; { - const smithy::Document* member = doc.Find("query"); + const opal::Document* member = doc.Find("query"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("HealthInput.query: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HealthInput.query: unexpected type on the wire"); parsed_member = member->as_string(); out.query = std::move(parsed_member); } @@ -737,80 +737,80 @@ smithy::Outcome DeserializeHealthInput(const smithy::Document& doc) return out; } -smithy::Document SerializeHealthOutput(const HealthOutput& value) { - smithy::DocumentMap map; - map.emplace("status", smithy::Document(value.status)); - return smithy::Document(std::move(map)); +opal::Document SerializeHealthOutput(const HealthOutput& value) { + opal::DocumentMap map; + map.emplace("status", opal::Document(value.status)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeHealthOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("HealthOutput: expected a map on the wire"); +opal::Outcome DeserializeHealthOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("HealthOutput: expected a map on the wire"); HealthOutput out; { - const smithy::Document* member = doc.Find("status"); + const opal::Document* member = doc.Find("status"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("HealthOutput: missing required member: status"); + return opal::Error::Serialization("HealthOutput: missing required member: status"); } - if (!member->is_string()) return smithy::Error::Serialization("HealthOutput.status: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HealthOutput.status: unexpected type on the wire"); out.status = member->as_string(); } return out; } -smithy::Document SerializeHttpPayloadRequiredWithDefaultInput(const HttpPayloadRequiredWithDefaultInput& value) { - smithy::DocumentMap map; - map.emplace("body", smithy::Document(value.body)); - return smithy::Document(std::move(map)); +opal::Document SerializeHttpPayloadRequiredWithDefaultInput(const HttpPayloadRequiredWithDefaultInput& value) { + opal::DocumentMap map; + map.emplace("body", opal::Document(value.body)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeHttpPayloadRequiredWithDefaultInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("HttpPayloadRequiredWithDefaultInput: expected a map on the wire"); +opal::Outcome DeserializeHttpPayloadRequiredWithDefaultInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("HttpPayloadRequiredWithDefaultInput: expected a map on the wire"); HttpPayloadRequiredWithDefaultInput out; { - const smithy::Document* member = doc.Find("body"); + const opal::Document* member = doc.Find("body"); if (member != nullptr && !member->is_null()) { - if (!member->is_string()) return smithy::Error::Serialization("HttpPayloadRequiredWithDefaultInput.body: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HttpPayloadRequiredWithDefaultInput.body: unexpected type on the wire"); out.body = member->as_string(); } } return out; } -smithy::Document SerializeHttpPayloadRequiredWithDefaultOutput(const HttpPayloadRequiredWithDefaultOutput& value) { - smithy::DocumentMap map; - map.emplace("body", smithy::Document(value.body)); - return smithy::Document(std::move(map)); +opal::Document SerializeHttpPayloadRequiredWithDefaultOutput(const HttpPayloadRequiredWithDefaultOutput& value) { + opal::DocumentMap map; + map.emplace("body", opal::Document(value.body)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeHttpPayloadRequiredWithDefaultOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("HttpPayloadRequiredWithDefaultOutput: expected a map on the wire"); +opal::Outcome DeserializeHttpPayloadRequiredWithDefaultOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("HttpPayloadRequiredWithDefaultOutput: expected a map on the wire"); HttpPayloadRequiredWithDefaultOutput out; { - const smithy::Document* member = doc.Find("body"); + const opal::Document* member = doc.Find("body"); if (member != nullptr && !member->is_null()) { - if (!member->is_string()) return smithy::Error::Serialization("HttpPayloadRequiredWithDefaultOutput.body: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HttpPayloadRequiredWithDefaultOutput.body: unexpected type on the wire"); out.body = member->as_string(); } } return out; } -smithy::Document SerializeHttpPayloadWithDefaultInput(const HttpPayloadWithDefaultInput& value) { - smithy::DocumentMap map; +opal::Document SerializeHttpPayloadWithDefaultInput(const HttpPayloadWithDefaultInput& value) { + opal::DocumentMap map; if (value.body.has_value()) { - map.emplace("body", smithy::Document((*value.body))); + map.emplace("body", opal::Document((*value.body))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeHttpPayloadWithDefaultInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("HttpPayloadWithDefaultInput: expected a map on the wire"); +opal::Outcome DeserializeHttpPayloadWithDefaultInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("HttpPayloadWithDefaultInput: expected a map on the wire"); HttpPayloadWithDefaultInput out; { - const smithy::Document* member = doc.Find("body"); + const opal::Document* member = doc.Find("body"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("HttpPayloadWithDefaultInput.body: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HttpPayloadWithDefaultInput.body: unexpected type on the wire"); parsed_member = member->as_string(); out.body = std::move(parsed_member); } else { @@ -820,20 +820,20 @@ smithy::Outcome DeserializeHttpPayloadWithDefaultIn return out; } -smithy::Document SerializeHttpPayloadWithDefaultOutput(const HttpPayloadWithDefaultOutput& value) { - smithy::DocumentMap map; - map.emplace("body", smithy::Document(value.body)); - return smithy::Document(std::move(map)); +opal::Document SerializeHttpPayloadWithDefaultOutput(const HttpPayloadWithDefaultOutput& value) { + opal::DocumentMap map; + map.emplace("body", opal::Document(value.body)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeHttpPayloadWithDefaultOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("HttpPayloadWithDefaultOutput: expected a map on the wire"); +opal::Outcome DeserializeHttpPayloadWithDefaultOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("HttpPayloadWithDefaultOutput: expected a map on the wire"); HttpPayloadWithDefaultOutput out; { - const smithy::Document* member = doc.Find("body"); + const opal::Document* member = doc.Find("body"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("HttpPayloadWithDefaultOutput.body: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("HttpPayloadWithDefaultOutput.body: unexpected type on the wire"); parsed_member = member->as_string(); out.body = std::move(parsed_member); } @@ -841,65 +841,65 @@ smithy::Outcome DeserializeHttpPayloadWithDefaultO return out; } -smithy::Document SerializeMyMap(const std::map& value) { - smithy::DocumentMap map; +opal::Document SerializeMyMap(const std::map& value) { + opal::DocumentMap map; for (const auto& [key, item] : value) { - map.emplace(key, smithy::Document(static_cast(item))); + map.emplace(key, opal::Document(static_cast(item))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome> DeserializeMyMap(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("std::map: expected a map on the wire"); +opal::Outcome> DeserializeMyMap(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("std::map: expected a map on the wire"); std::map out; for (const auto& [key, item_doc] : doc.as_map()) { - const smithy::Document* item = &item_doc; + const opal::Document* item = &item_doc; // Tolerant read: null values in dense maps are skipped, not errors. if (item->is_null()) continue; std::int32_t parsed_item{}; - if (!item->is_int()) return smithy::Error::Serialization("std::map{}: unexpected type on the wire"); - if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return smithy::Error::Serialization("std::map{}: value out of range"); + if (!item->is_int()) return opal::Error::Serialization("std::map{}: unexpected type on the wire"); + if (item->as_int() < -2147483648LL || item->as_int() > 2147483647LL) return opal::Error::Serialization("std::map{}: value out of range"); parsed_item = static_cast(item->as_int()); out.emplace(key, std::move(parsed_item)); } return out; } -smithy::Document SerializeSmallStruct(const SmallStruct& value) { - smithy::DocumentMap map; - map.emplace("content", smithy::Document(value.content)); - return smithy::Document(std::move(map)); +opal::Document SerializeSmallStruct(const SmallStruct& value) { + opal::DocumentMap map; + map.emplace("content", opal::Document(value.content)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeSmallStruct(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("SmallStruct: expected a map on the wire"); +opal::Outcome DeserializeSmallStruct(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("SmallStruct: expected a map on the wire"); SmallStruct out; { - const smithy::Document* member = doc.Find("content"); + const opal::Document* member = doc.Find("content"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("SmallStruct: missing required member: content"); + return opal::Error::Serialization("SmallStruct: missing required member: content"); } - if (!member->is_string()) return smithy::Error::Serialization("SmallStruct.content: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("SmallStruct.content: unexpected type on the wire"); out.content = member->as_string(); } return out; } -smithy::Document SerializeOpenDiscriminatedUnion(const OpenDiscriminatedUnion& value) { +opal::Document SerializeOpenDiscriminatedUnion(const OpenDiscriminatedUnion& value) { if (value.is_smol()) { - smithy::Document member_doc = SerializeSmallStruct(value.as_smol()); - member_doc.as_map().insert_or_assign("key", smithy::Document(std::string("smol"))); + opal::Document member_doc = SerializeSmallStruct(value.as_smol()); + member_doc.as_map().insert_or_assign("key", opal::Document(std::string("smol"))); return member_doc; } if (value.is_other()) return value.as_other(); - return smithy::Document(smithy::DocumentMap{}); + return opal::Document(opal::DocumentMap{}); } -smithy::Outcome DeserializeOpenDiscriminatedUnion(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OpenDiscriminatedUnion: expected a map on the wire"); - if (const smithy::Document* discriminator = doc.Find("key"); discriminator != nullptr && discriminator->is_string()) { +opal::Outcome DeserializeOpenDiscriminatedUnion(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OpenDiscriminatedUnion: expected a map on the wire"); + if (const opal::Document* discriminator = doc.Find("key"); discriminator != nullptr && discriminator->is_string()) { if (discriminator->as_string() == "smol") { - const smithy::Document* member = &doc; + const opal::Document* member = &doc; SmallStruct parsed_member{}; { auto parsed = DeserializeSmallStruct(*member); @@ -912,21 +912,21 @@ smithy::Outcome DeserializeOpenDiscriminatedUnion(const return OpenDiscriminatedUnion::FromOther(doc); } -smithy::Document SerializeOpenTaggedUnion(const OpenTaggedUnion& value) { - smithy::DocumentMap map; +opal::Document SerializeOpenTaggedUnion(const OpenTaggedUnion& value) { + opal::DocumentMap map; if (value.is_str()) { - map.emplace("str", smithy::Document(value.as_str())); + map.emplace("str", opal::Document(value.as_str())); } if (value.is_other()) return value.as_other(); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOpenTaggedUnion(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OpenTaggedUnion: expected a map on the wire"); +opal::Outcome DeserializeOpenTaggedUnion(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OpenTaggedUnion: expected a map on the wire"); if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) == 1) { - if (const smithy::Document* member = doc.Find("str"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("str"); member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("OpenTaggedUnion.str: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("OpenTaggedUnion.str: unexpected type on the wire"); parsed_member = member->as_string(); return OpenTaggedUnion::FromStr(std::move(parsed_member)); } @@ -934,21 +934,21 @@ smithy::Outcome DeserializeOpenTaggedUnion(const smithy::Docume return OpenTaggedUnion::FromOther(doc); } -smithy::Document SerializeOpenUnionsPayload(const OpenUnionsPayload& value) { - smithy::DocumentMap map; +opal::Document SerializeOpenUnionsPayload(const OpenUnionsPayload& value) { + opal::DocumentMap map; if (value.is_tagged()) { map.emplace("tagged", SerializeOpenTaggedUnion(value.as_tagged())); } if (value.is_discriminated()) { map.emplace("discriminated", SerializeOpenDiscriminatedUnion(value.as_discriminated())); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOpenUnionsPayload(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OpenUnionsPayload: expected a map on the wire"); - if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return smithy::Error::Serialization("OpenUnionsPayload: expected exactly one union member"); - if (const smithy::Document* member = doc.Find("tagged"); member != nullptr && !member->is_null()) { +opal::Outcome DeserializeOpenUnionsPayload(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OpenUnionsPayload: expected a map on the wire"); + if (doc.as_map().size() - (doc.Find("__type") != nullptr ? 1 : 0) != 1) return opal::Error::Serialization("OpenUnionsPayload: expected exactly one union member"); + if (const opal::Document* member = doc.Find("tagged"); member != nullptr && !member->is_null()) { OpenTaggedUnion parsed_member{}; { auto parsed = DeserializeOpenTaggedUnion(*member); @@ -957,7 +957,7 @@ smithy::Outcome DeserializeOpenUnionsPayload(const smithy::Do } return OpenUnionsPayload::FromTagged(std::move(parsed_member)); } - if (const smithy::Document* member = doc.Find("discriminated"); member != nullptr && !member->is_null()) { + if (const opal::Document* member = doc.Find("discriminated"); member != nullptr && !member->is_null()) { OpenDiscriminatedUnion parsed_member{}; { auto parsed = DeserializeOpenDiscriminatedUnion(*member); @@ -966,22 +966,22 @@ smithy::Outcome DeserializeOpenUnionsPayload(const smithy::Do } return OpenUnionsPayload::FromDiscriminated(std::move(parsed_member)); } - return smithy::Error::Serialization("OpenUnionsPayload: unknown or missing union member"); + return opal::Error::Serialization("OpenUnionsPayload: unknown or missing union member"); } -smithy::Document SerializeOpenUnionsInput(const OpenUnionsInput& value) { - smithy::DocumentMap map; +opal::Document SerializeOpenUnionsInput(const OpenUnionsInput& value) { + opal::DocumentMap map; map.emplace("data", SerializeOpenUnionsPayload(value.data)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOpenUnionsInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OpenUnionsInput: expected a map on the wire"); +opal::Outcome DeserializeOpenUnionsInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OpenUnionsInput: expected a map on the wire"); OpenUnionsInput out; { - const smithy::Document* member = doc.Find("data"); + const opal::Document* member = doc.Find("data"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("OpenUnionsInput: missing required member: data"); + return opal::Error::Serialization("OpenUnionsInput: missing required member: data"); } { auto parsed = DeserializeOpenUnionsPayload(*member); @@ -992,19 +992,19 @@ smithy::Outcome DeserializeOpenUnionsInput(const smithy::Docume return out; } -smithy::Document SerializeOpenUnionsOutput(const OpenUnionsOutput& value) { - smithy::DocumentMap map; +opal::Document SerializeOpenUnionsOutput(const OpenUnionsOutput& value) { + opal::DocumentMap map; map.emplace("data", SerializeOpenUnionsPayload(value.data)); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeOpenUnionsOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("OpenUnionsOutput: expected a map on the wire"); +opal::Outcome DeserializeOpenUnionsOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("OpenUnionsOutput: expected a map on the wire"); OpenUnionsOutput out; { - const smithy::Document* member = doc.Find("data"); + const opal::Document* member = doc.Find("data"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("OpenUnionsOutput: missing required member: data"); + return opal::Error::Serialization("OpenUnionsOutput: missing required member: data"); } { auto parsed = DeserializeOpenUnionsPayload(*member); @@ -1015,22 +1015,22 @@ smithy::Outcome DeserializeOpenUnionsOutput(const smithy::Docu return out; } -smithy::Document SerializePreserveOrderInput(const PreserveOrderInput& value) { - smithy::DocumentMap map; +opal::Document SerializePreserveOrderInput(const PreserveOrderInput& value) { + opal::DocumentMap map; if (value.map.has_value()) { map.emplace("map", SerializeMyMap((*value.map))); } if (value.document.has_value()) { map.emplace("document", (*value.document)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePreserveOrderInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PreserveOrderInput: expected a map on the wire"); +opal::Outcome DeserializePreserveOrderInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PreserveOrderInput: expected a map on the wire"); PreserveOrderInput out; { - const smithy::Document* member = doc.Find("map"); + const opal::Document* member = doc.Find("map"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -1042,9 +1042,9 @@ smithy::Outcome DeserializePreserveOrderInput(const smithy:: } } { - const smithy::Document* member = doc.Find("document"); + const opal::Document* member = doc.Find("document"); if (member != nullptr && !member->is_null()) { - smithy::Document parsed_member{}; + opal::Document parsed_member{}; parsed_member = *member; out.document = std::move(parsed_member); } @@ -1052,22 +1052,22 @@ smithy::Outcome DeserializePreserveOrderInput(const smithy:: return out; } -smithy::Document SerializePreserveOrderOutput(const PreserveOrderOutput& value) { - smithy::DocumentMap map; +opal::Document SerializePreserveOrderOutput(const PreserveOrderOutput& value) { + opal::DocumentMap map; if (value.map.has_value()) { map.emplace("map", SerializeMyMap((*value.map))); } if (value.document.has_value()) { map.emplace("document", (*value.document)); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializePreserveOrderOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("PreserveOrderOutput: expected a map on the wire"); +opal::Outcome DeserializePreserveOrderOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("PreserveOrderOutput: expected a map on the wire"); PreserveOrderOutput out; { - const smithy::Document* member = doc.Find("map"); + const opal::Document* member = doc.Find("map"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -1079,9 +1079,9 @@ smithy::Outcome DeserializePreserveOrderOutput(const smithy } } { - const smithy::Document* member = doc.Find("document"); + const opal::Document* member = doc.Find("document"); if (member != nullptr && !member->is_null()) { - smithy::Document parsed_member{}; + opal::Document parsed_member{}; parsed_member = *member; out.document = std::move(parsed_member); } @@ -1089,55 +1089,55 @@ smithy::Outcome DeserializePreserveOrderOutput(const smithy return out; } -smithy::Document SerializeRoundTripInput(const RoundTripInput& value) { - smithy::DocumentMap map; - map.emplace("label", smithy::Document(value.label)); +opal::Document SerializeRoundTripInput(const RoundTripInput& value) { + opal::DocumentMap map; + map.emplace("label", opal::Document(value.label)); if (value.header.has_value()) { - map.emplace("header", smithy::Document((*value.header))); + map.emplace("header", opal::Document((*value.header))); } if (value.query.has_value()) { - map.emplace("query", smithy::Document((*value.query))); + map.emplace("query", opal::Document((*value.query))); } if (value.body.has_value()) { - map.emplace("body", smithy::Document((*value.body))); + map.emplace("body", opal::Document((*value.body))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRoundTripInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RoundTripInput: expected a map on the wire"); +opal::Outcome DeserializeRoundTripInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RoundTripInput: expected a map on the wire"); RoundTripInput out; { - const smithy::Document* member = doc.Find("label"); + const opal::Document* member = doc.Find("label"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("RoundTripInput: missing required member: label"); + return opal::Error::Serialization("RoundTripInput: missing required member: label"); } - if (!member->is_string()) return smithy::Error::Serialization("RoundTripInput.label: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RoundTripInput.label: unexpected type on the wire"); out.label = member->as_string(); } { - const smithy::Document* member = doc.Find("header"); + const opal::Document* member = doc.Find("header"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RoundTripInput.header: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RoundTripInput.header: unexpected type on the wire"); parsed_member = member->as_string(); out.header = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("query"); + const opal::Document* member = doc.Find("query"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RoundTripInput.query: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RoundTripInput.query: unexpected type on the wire"); parsed_member = member->as_string(); out.query = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("body"); + const opal::Document* member = doc.Find("body"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RoundTripInput.body: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RoundTripInput.body: unexpected type on the wire"); parsed_member = member->as_string(); out.body = std::move(parsed_member); } @@ -1145,55 +1145,55 @@ smithy::Outcome DeserializeRoundTripInput(const smithy::Document return out; } -smithy::Document SerializeRoundTripOutput(const RoundTripOutput& value) { - smithy::DocumentMap map; - map.emplace("label", smithy::Document(value.label)); +opal::Document SerializeRoundTripOutput(const RoundTripOutput& value) { + opal::DocumentMap map; + map.emplace("label", opal::Document(value.label)); if (value.header.has_value()) { - map.emplace("header", smithy::Document((*value.header))); + map.emplace("header", opal::Document((*value.header))); } if (value.query.has_value()) { - map.emplace("query", smithy::Document((*value.query))); + map.emplace("query", opal::Document((*value.query))); } if (value.body.has_value()) { - map.emplace("body", smithy::Document((*value.body))); + map.emplace("body", opal::Document((*value.body))); } - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeRoundTripOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("RoundTripOutput: expected a map on the wire"); +opal::Outcome DeserializeRoundTripOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("RoundTripOutput: expected a map on the wire"); RoundTripOutput out; { - const smithy::Document* member = doc.Find("label"); + const opal::Document* member = doc.Find("label"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("RoundTripOutput: missing required member: label"); + return opal::Error::Serialization("RoundTripOutput: missing required member: label"); } - if (!member->is_string()) return smithy::Error::Serialization("RoundTripOutput.label: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RoundTripOutput.label: unexpected type on the wire"); out.label = member->as_string(); } { - const smithy::Document* member = doc.Find("header"); + const opal::Document* member = doc.Find("header"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RoundTripOutput.header: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RoundTripOutput.header: unexpected type on the wire"); parsed_member = member->as_string(); out.header = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("query"); + const opal::Document* member = doc.Find("query"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RoundTripOutput.query: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RoundTripOutput.query: unexpected type on the wire"); parsed_member = member->as_string(); out.query = std::move(parsed_member); } } { - const smithy::Document* member = doc.Find("body"); + const opal::Document* member = doc.Find("body"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RoundTripOutput.body: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RoundTripOutput.body: unexpected type on the wire"); parsed_member = member->as_string(); out.body = std::move(parsed_member); } @@ -1201,35 +1201,35 @@ smithy::Outcome DeserializeRoundTripOutput(const smithy::Docume return out; } -smithy::Document SerializeVersionInput(const VersionInput& /*value*/) { - smithy::DocumentMap map; - return smithy::Document(std::move(map)); +opal::Document SerializeVersionInput(const VersionInput& /*value*/) { + opal::DocumentMap map; + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeVersionInput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("VersionInput: expected a map on the wire"); +opal::Outcome DeserializeVersionInput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("VersionInput: expected a map on the wire"); VersionInput out; return out; } -smithy::Document SerializeVersionOutput(const VersionOutput& value) { - smithy::DocumentMap map; - map.emplace("version", smithy::Document(value.version)); - return smithy::Document(std::move(map)); +opal::Document SerializeVersionOutput(const VersionOutput& value) { + opal::DocumentMap map; + map.emplace("version", opal::Document(value.version)); + return opal::Document(std::move(map)); } -smithy::Outcome DeserializeVersionOutput(const smithy::Document& doc) { - if (!doc.is_map()) return smithy::Error::Serialization("VersionOutput: expected a map on the wire"); +opal::Outcome DeserializeVersionOutput(const opal::Document& doc) { + if (!doc.is_map()) return opal::Error::Serialization("VersionOutput: expected a map on the wire"); VersionOutput out; { - const smithy::Document* member = doc.Find("version"); + const opal::Document* member = doc.Find("version"); if (member == nullptr || member->is_null()) { - return smithy::Error::Serialization("VersionOutput: missing required member: version"); + return opal::Error::Serialization("VersionOutput: missing required member: version"); } - if (!member->is_string()) return smithy::Error::Serialization("VersionOutput.version: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("VersionOutput.version: unexpected type on the wire"); out.version = member->as_string(); } return out; } -} // namespace smithy::protocoltests::simplerestjson +} // namespace opal::protocoltests::simplerestjson diff --git a/protocol-tests/simplerestjson/generated/src/server.cc b/protocol-tests/simplerestjson/generated/src/server.cc index 30ac90db..34968aaf 100644 --- a/protocol-tests/simplerestjson/generated/src/server.cc +++ b/protocol-tests/simplerestjson/generated/src/server.cc @@ -13,6 +13,8 @@ #include #include +#include "opal/protocoltests/simplerestjson/serde.h" +#include "opal/protocoltests/simplerestjson/server.h" #include "smithy/core/base64.h" #include "smithy/core/blob.h" #include "smithy/core/document.h" @@ -20,13 +22,11 @@ #include "smithy/core/text.h" #include "smithy/http/headers.h" #include "smithy/json/json.h" -#include "smithy/protocoltests/simplerestjson/serde.h" -#include "smithy/protocoltests/simplerestjson/server.h" #include "smithy/server/router.h" -namespace smithy::protocoltests::simplerestjson { +namespace opal::protocoltests::simplerestjson { -namespace types = ::smithy::protocoltests::simplerestjson; +namespace types = ::opal::protocoltests::simplerestjson; namespace { namespace helpers { @@ -35,18 +35,18 @@ namespace helpers { // emitted for every service; not every service binds numeric values). // Trailing text, floats-for-ints, and out-of-range values are rejected // (the malformed-request suites pin this). -[[maybe_unused]] smithy::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { +[[maybe_unused]] opal::Outcome ParseInt64Text(const std::string& text, std::int64_t min_value, std::int64_t max_value) { std::int64_t value = 0; const char* first = text.data(); const char* last = first + text.size(); const auto result = std::from_chars(first, last, value, 10); if (text.empty() || result.ec != std::errc() || result.ptr != last || value < min_value || value > max_value) { - return smithy::Error::Serialization("invalid integer: " + text); + return opal::Error::Serialization("invalid integer: " + text); } return value; } -[[maybe_unused]] smithy::Outcome ParseDoubleText(const std::string& text) { +[[maybe_unused]] opal::Outcome ParseDoubleText(const std::string& text) { if (text == "NaN") return std::numeric_limits::quiet_NaN(); if (text == "Infinity") return std::numeric_limits::infinity(); if (text == "-Infinity") return -std::numeric_limits::infinity(); @@ -54,12 +54,12 @@ namespace helpers { return (c >= '0' && c <= '9') || c == '.' || c == 'e' || c == 'E' || c == '+' || c == '-'; }; if (text.empty() || text.front() == '+' || !std::all_of(text.begin(), text.end(), valid_char)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } char* parse_end = nullptr; const double value = std::strtod(text.c_str(), &parse_end); if (parse_end != text.c_str() + text.size() || !std::isfinite(value)) { - return smithy::Error::Serialization("invalid number: " + text); + return opal::Error::Serialization("invalid number: " + text); } return value; } @@ -70,31 +70,31 @@ namespace helpers { return status >= 200 && status != 204 && status != 205 && status != 304; } -smithy::http::HttpResponse JsonError(int status, const std::string& code, const std::string& message, smithy::DocumentMap body) { - if (!code.empty()) body.insert_or_assign("__type", smithy::Document(code)); - if (!message.empty()) body.insert_or_assign("message", smithy::Document(message)); - smithy::http::HttpResponse response; +opal::http::HttpResponse JsonError(int status, const std::string& code, const std::string& message, opal::DocumentMap body) { + if (!code.empty()) body.insert_or_assign("__type", opal::Document(code)); + if (!message.empty()) body.insert_or_assign("message", opal::Document(message)); + opal::http::HttpResponse response; response.status = status; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body))); + response.body = opal::json::Encode(opal::Document(std::move(body))); return response; } // [[maybe_unused]]: only unary routes map handler errors here; a service // whose operations all stream reports errors on the stream instead. -[[maybe_unused]] smithy::http::HttpResponse ErrorToResponse(const smithy::Error& error) { +[[maybe_unused]] opal::http::HttpResponse ErrorToResponse(const opal::Error& error) { std::vector> header_values; (void)header_values; - if (error.kind() == smithy::ErrorKind::kModeled) { + if (error.kind() == opal::ErrorKind::kModeled) { if (error.code() == "FallbackError") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeFallbackError(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } auto response = helpers::JsonError(400, "", "", std::move(body)); response.headers.Set("x-error-type", error.code()); @@ -102,14 +102,14 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const return response; } if (error.code() == "GenericClientError") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeGenericClientError(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } auto response = helpers::JsonError(418, "", "", std::move(body)); response.headers.Set("x-error-type", error.code()); @@ -117,14 +117,14 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const return response; } if (error.code() == "GenericServerError") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeGenericServerError(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } auto response = helpers::JsonError(502, "", "", std::move(body)); response.headers.Set("x-error-type", error.code()); @@ -132,14 +132,14 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const return response; } if (error.code() == "NotFoundError") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeNotFoundError(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } auto response = helpers::JsonError(404, "", "", std::move(body)); response.headers.Set("x-error-type", error.code()); @@ -147,14 +147,14 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const return response; } if (error.code() == "PriceError") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializePriceError(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } if (auto it = body.find("code"); it != body.end()) { if (it->second.is_int()) header_values.emplace_back("X-CODE", std::to_string(it->second.as_int())); @@ -166,14 +166,14 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const return response; } if (error.code() == "UnknownServerError") { - smithy::DocumentMap body; + opal::DocumentMap body; if (const auto* detail = error.detail()) { body = SerializeUnknownServerError(*detail).as_map(); } // The typed detail's own message member wins over the generic one. const bool has_message = body.count("message") != 0 || body.count("Message") != 0; if (!has_message && !error.message().empty()) { - body.emplace("message", smithy::Document(error.message())); + body.emplace("message", opal::Document(error.message())); } auto response = helpers::JsonError(500, "", "", std::move(body)); response.headers.Set("x-error-type", error.code()); @@ -182,7 +182,7 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const } return helpers::JsonError(400, error.code(), error.message(), {}); } - if (error.kind() == smithy::ErrorKind::kValidation || error.kind() == smithy::ErrorKind::kSerialization) { + if (error.kind() == opal::ErrorKind::kValidation || error.kind() == opal::ErrorKind::kSerialization) { auto response = helpers::JsonError(400, "", error.message(), {}); response.headers.Set("x-error-type", "SerializationException"); return response; @@ -193,11 +193,11 @@ smithy::http::HttpResponse JsonError(int status, const std::string& code, const // Constraint validation (smithy.framework#ValidationException): messages // and '/member' paths follow the official validation conformance suite. -void AddValidationFailure(std::vector* failures, std::string path, std::string message) { +void AddValidationFailure(std::vector* failures, std::string path, std::string message) { failures->push_back({std::move(path), std::move(message)}); } -void ValidateIngredients(const std::vector& value, const std::string& path, std::vector* failures) { +void ValidateIngredients(const std::vector& value, const std::string& path, std::vector* failures) { for (std::size_t i = 0; i < value.size(); ++i) { const std::string item_path = path + "/" + std::to_string(i); if (value[i].value() == Ingredient::Value::kUnknown) { @@ -206,7 +206,7 @@ void ValidateIngredients(const std::vector& value, const std::string } } -void ValidatePizza(const types::Pizza& value, const std::string& path, std::vector* failures) { +void ValidatePizza(const types::Pizza& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/base"; if (value.base.value() == PizzaBase::Value::kUnknown) { @@ -219,14 +219,14 @@ void ValidatePizza(const types::Pizza& value, const std::string& path, std::vect } } -void ValidateSalad(const types::Salad& value, const std::string& path, std::vector* failures) { +void ValidateSalad(const types::Salad& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/ingredients"; helpers::ValidateIngredients(value.ingredients, member_path, failures); } } -void ValidateFood(const types::Food& value, const std::string& path, std::vector* failures) { +void ValidateFood(const types::Food& value, const std::string& path, std::vector* failures) { if (value.is_pizza()) { const std::string member_path = path + "/pizza"; helpers::ValidatePizza(value.as_pizza(), member_path, failures); @@ -237,21 +237,21 @@ void ValidateFood(const types::Food& value, const std::string& path, std::vector } } -void ValidateMenuItem(const types::MenuItem& value, const std::string& path, std::vector* failures) { +void ValidateMenuItem(const types::MenuItem& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/food"; helpers::ValidateFood(value.food, member_path, failures); } } -void ValidateAddMenuItemInput(const types::AddMenuItemInput& value, const std::string& path, std::vector* failures) { +void ValidateAddMenuItemInput(const types::AddMenuItemInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/menuItem"; helpers::ValidateMenuItem(value.menuItem, member_path, failures); } } -void ValidateGetEnumInput(const types::GetEnumInput& value, const std::string& path, std::vector* failures) { +void ValidateGetEnumInput(const types::GetEnumInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/aa"; if (value.aa.value() == TheEnum::Value::kUnknown) { @@ -260,7 +260,7 @@ void ValidateGetEnumInput(const types::GetEnumInput& value, const std::string& p } } -void ValidateGetIntEnumInput(const types::GetIntEnumInput& value, const std::string& path, std::vector* failures) { +void ValidateGetIntEnumInput(const types::GetIntEnumInput& value, const std::string& path, std::vector* failures) { { const std::string member_path = path + "/aa"; if (value.aa != EnumResult::kFirst && value.aa != EnumResult::kSecond) { @@ -269,11 +269,11 @@ void ValidateGetIntEnumInput(const types::GetIntEnumInput& value, const std::str } } -void ValidateHealthInput(const types::HealthInput& value, const std::string& path, std::vector* failures) { +void ValidateHealthInput(const types::HealthInput& value, const std::string& path, std::vector* failures) { if (value.query.has_value()) { const std::string member_path = path + "/query"; { - const std::size_t member_length = smithy::Utf8CodePointCount((*value.query)); + const std::size_t member_length = opal::Utf8CodePointCount((*value.query)); if (member_length > 5ULL) { helpers::AddValidationFailure(failures, member_path, "Value with length " + std::to_string(member_length) + " at '" + member_path + "' failed to satisfy constraint: Member must have length between 0 and 5, inclusive"); } @@ -283,25 +283,25 @@ void ValidateHealthInput(const types::HealthInput& value, const std::string& pat // [[maybe_unused]]: only unary routes reject invalid input over HTTP; a // service whose operations all stream reports validation on the stream. -[[maybe_unused]] smithy::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { +[[maybe_unused]] opal::http::HttpResponse ValidationErrorResponse(const std::vector& failures) { std::string summary = std::to_string(failures.size()) + " validation error" + (failures.size() == 1 ? "" : "s") + " detected. "; - smithy::DocumentList field_list; + opal::DocumentList field_list; for (std::size_t i = 0; i < failures.size(); ++i) { if (i > 0) summary += "; "; summary += failures[i].message; - smithy::DocumentMap field; - field.emplace("message", smithy::Document(failures[i].message)); - field.emplace("path", smithy::Document(failures[i].path)); - field_list.push_back(smithy::Document(std::move(field))); - } - smithy::DocumentMap body; - body.emplace("fieldList", smithy::Document(std::move(field_list))); - smithy::http::HttpResponse response = helpers::JsonError(400, "", summary, std::move(body)); + opal::DocumentMap field; + field.emplace("message", opal::Document(failures[i].message)); + field.emplace("path", opal::Document(failures[i].path)); + field_list.push_back(opal::Document(std::move(field))); + } + opal::DocumentMap body; + body.emplace("fieldList", opal::Document(std::move(field_list))); + opal::http::HttpResponse response = helpers::JsonError(400, "", summary, std::move(body)); response.headers.Set("x-error-type", "ValidationException"); return response; } -smithy::Outcome ParseAddMenuItemInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseAddMenuItemInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -311,9 +311,9 @@ smithy::Outcome ParseAddMenuItemInput(const smithy::htt input.restaurant = label_value; } if (!request.body.empty()) { - auto payload_doc = smithy::json::Decode(request.body); + auto payload_doc = opal::json::Decode(request.body); if (!payload_doc) return std::move(payload_doc).error(); - const smithy::Document* payload_ptr = &*payload_doc; + const opal::Document* payload_ptr = &*payload_doc; { auto parsed = DeserializeMenuItem(*payload_ptr); if (!parsed) return std::move(parsed).error(); @@ -323,18 +323,18 @@ smithy::Outcome ParseAddMenuItemInput(const smithy::htt return input; } -smithy::http::HttpResponse BuildAddMenuItemResponse(const types::AddMenuItemOutput& output) { +opal::http::HttpResponse BuildAddMenuItemResponse(const types::AddMenuItemOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 201; - response.headers.Set("X-ADDED-AT", output.added.Format(smithy::TimestampFormat::kEpochSeconds)); - response.body = smithy::json::Encode(smithy::Document(output.itemId)); + response.headers.Set("X-ADDED-AT", output.added.Format(opal::TimestampFormat::kEpochSeconds)); + response.body = opal::json::Encode(opal::Document(output.itemId)); if (!response.headers.Get("content-type").has_value()) response.headers.Set("content-type", "application/json"); response.headers.Set("content-length", std::to_string(response.body.size())); return response; } -smithy::Outcome ParseCustomCodeInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseCustomCodeInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -348,20 +348,20 @@ smithy::Outcome ParseCustomCodeInput(const smithy::http: return input; } -smithy::http::HttpResponse BuildCustomCodeResponse(const types::CustomCodeOutput& output) { +opal::http::HttpResponse BuildCustomCodeResponse(const types::CustomCodeOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; if (output.code.has_value()) response.status = static_cast(*output.code); if (helpers::StatusAllowsContent(response.status)) { - smithy::DocumentMap body_map; + opal::DocumentMap body_map; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); } return response; } -smithy::Outcome ParseGetEnumInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseGetEnumInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -373,20 +373,20 @@ smithy::Outcome ParseGetEnumInput(const smithy::http::HttpR return input; } -smithy::http::HttpResponse BuildGetEnumResponse(const types::GetEnumOutput& output) { +opal::http::HttpResponse BuildGetEnumResponse(const types::GetEnumOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; + opal::DocumentMap body_map; if (output.result.has_value()) { - body_map.emplace("result", smithy::Document((*output.result))); + body_map.emplace("result", opal::Document((*output.result))); } response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseGetIntEnumInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseGetIntEnumInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -400,18 +400,18 @@ smithy::Outcome ParseGetIntEnumInput(const smithy::http: return input; } -smithy::http::HttpResponse BuildGetIntEnumResponse(const types::GetIntEnumOutput& output) { +opal::http::HttpResponse BuildGetIntEnumResponse(const types::GetIntEnumOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; - body_map.emplace("result", smithy::Document(static_cast(output.result))); + opal::DocumentMap body_map; + body_map.emplace("result", opal::Document(static_cast(output.result))); response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseGetMenuInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseGetMenuInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -423,17 +423,17 @@ smithy::Outcome ParseGetMenuInput(const smithy::http::HttpR return input; } -smithy::http::HttpResponse BuildGetMenuResponse(const types::GetMenuOutput& output) { +opal::http::HttpResponse BuildGetMenuResponse(const types::GetMenuOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - response.body = smithy::json::Encode(SerializeMenu(output.menu)); + response.body = opal::json::Encode(SerializeMenu(output.menu)); if (!response.headers.Get("content-type").has_value()) response.headers.Set("content-type", "application/json"); response.headers.Set("content-length", std::to_string(response.body.size())); return response; } -smithy::Outcome ParseHeaderEndpointInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseHeaderEndpointInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -453,9 +453,9 @@ smithy::Outcome ParseHeaderEndpointInput(const smith return input; } -smithy::http::HttpResponse BuildHeaderEndpointResponse(const types::HeaderEndpointOutput& output) { +opal::http::HttpResponse BuildHeaderEndpointResponse(const types::HeaderEndpointOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; if (output.capitalizedHeader.has_value()) { response.headers.Set("X-Capitalized-Header", (*output.capitalizedHeader)); @@ -469,13 +469,13 @@ smithy::http::HttpResponse BuildHeaderEndpointResponse(const types::HeaderEndpoi if (output.lowercaseHeader.has_value()) { response.headers.Set("x-lowercase-header", (*output.lowercaseHeader)); } - smithy::DocumentMap body_map; + opal::DocumentMap body_map; response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseHealthInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseHealthInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -489,75 +489,75 @@ smithy::Outcome ParseHealthInput(const smithy::http::HttpReq return input; } -smithy::http::HttpResponse BuildHealthResponse(const types::HealthOutput& output) { +opal::http::HttpResponse BuildHealthResponse(const types::HealthOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; - body_map.emplace("status", smithy::Document(output.status)); + opal::DocumentMap body_map; + body_map.emplace("status", opal::Document(output.status)); response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseHttpPayloadRequiredWithDefaultInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseHttpPayloadRequiredWithDefaultInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; types::HttpPayloadRequiredWithDefaultInput input{}; if (!request.body.empty()) { - auto payload_doc = smithy::json::Decode(request.body); + auto payload_doc = opal::json::Decode(request.body); if (!payload_doc) return std::move(payload_doc).error(); - if (!payload_doc->is_string()) return smithy::Error::Serialization("expected a JSON string payload"); + if (!payload_doc->is_string()) return opal::Error::Serialization("expected a JSON string payload"); input.body = payload_doc->as_string(); } return input; } -smithy::http::HttpResponse BuildHttpPayloadRequiredWithDefaultResponse(const types::HttpPayloadRequiredWithDefaultOutput& output) { +opal::http::HttpResponse BuildHttpPayloadRequiredWithDefaultResponse(const types::HttpPayloadRequiredWithDefaultOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - response.body = smithy::json::Encode(smithy::Document(output.body)); + response.body = opal::json::Encode(opal::Document(output.body)); if (!response.headers.Get("content-type").has_value()) response.headers.Set("content-type", "application/json"); response.headers.Set("content-length", std::to_string(response.body.size())); return response; } -smithy::Outcome ParseHttpPayloadWithDefaultInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseHttpPayloadWithDefaultInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; types::HttpPayloadWithDefaultInput input{}; if (!request.body.empty()) { - auto payload_doc = smithy::json::Decode(request.body); + auto payload_doc = opal::json::Decode(request.body); if (!payload_doc) return std::move(payload_doc).error(); - if (!payload_doc->is_string()) return smithy::Error::Serialization("expected a JSON string payload"); + if (!payload_doc->is_string()) return opal::Error::Serialization("expected a JSON string payload"); input.body = payload_doc->as_string(); } if (!input.body.has_value()) input.body = "default value"; return input; } -smithy::http::HttpResponse BuildHttpPayloadWithDefaultResponse(const types::HttpPayloadWithDefaultOutput& output) { +opal::http::HttpResponse BuildHttpPayloadWithDefaultResponse(const types::HttpPayloadWithDefaultOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - response.body = smithy::json::Encode(smithy::Document(output.body)); + response.body = opal::json::Encode(opal::Document(output.body)); if (!response.headers.Get("content-type").has_value()) response.headers.Set("content-type", "application/json"); response.headers.Set("content-length", std::to_string(response.body.size())); return response; } -smithy::Outcome ParseOpenUnionsInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseOpenUnionsInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; types::OpenUnionsInput input{}; if (!request.body.empty()) { - auto payload_doc = smithy::json::Decode(request.body); + auto payload_doc = opal::json::Decode(request.body); if (!payload_doc) return std::move(payload_doc).error(); - const smithy::Document* payload_ptr = &*payload_doc; + const opal::Document* payload_ptr = &*payload_doc; { auto parsed = DeserializeOpenUnionsPayload(*payload_ptr); if (!parsed) return std::move(parsed).error(); @@ -567,34 +567,34 @@ smithy::Outcome ParseOpenUnionsInput(const smithy::http: return input; } -smithy::http::HttpResponse BuildOpenUnionsResponse(const types::OpenUnionsOutput& output) { +opal::http::HttpResponse BuildOpenUnionsResponse(const types::OpenUnionsOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - response.body = smithy::json::Encode(SerializeOpenUnionsPayload(output.data)); + response.body = opal::json::Encode(SerializeOpenUnionsPayload(output.data)); if (!response.headers.Get("content-type").has_value()) response.headers.Set("content-type", "application/json"); response.headers.Set("content-length", std::to_string(response.body.size())); return response; } -smithy::Outcome ParsePreserveOrderInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParsePreserveOrderInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; types::PreserveOrderInput input{}; - auto body_doc = smithy::json::Decode(request.body.empty() ? "{}" : request.body); + auto body_doc = opal::json::Decode(request.body.empty() ? "{}" : request.body); if (!body_doc) return std::move(body_doc).error(); - if (!body_doc->is_map()) return smithy::Error::Serialization("PreserveOrder: expected a JSON object body"); + if (!body_doc->is_map()) return opal::Error::Serialization("PreserveOrder: expected a JSON object body"); { - const smithy::Document* member = body_doc->Find("document"); + const opal::Document* member = body_doc->Find("document"); if (member != nullptr && !member->is_null()) { - smithy::Document parsed_member{}; + opal::Document parsed_member{}; parsed_member = *member; input.document = std::move(parsed_member); } } { - const smithy::Document* member = body_doc->Find("map"); + const opal::Document* member = body_doc->Find("map"); if (member != nullptr && !member->is_null()) { std::map parsed_member{}; { @@ -608,11 +608,11 @@ smithy::Outcome ParsePreserveOrderInput(const smithy: return input; } -smithy::http::HttpResponse BuildPreserveOrderResponse(const types::PreserveOrderOutput& output) { +opal::http::HttpResponse BuildPreserveOrderResponse(const types::PreserveOrderOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - smithy::DocumentMap body_map; + opal::DocumentMap body_map; if (output.document.has_value()) { body_map.emplace("document", (*output.document)); } @@ -620,11 +620,11 @@ smithy::http::HttpResponse BuildPreserveOrderResponse(const types::PreserveOrder body_map.emplace("map", SerializeMyMap((*output.map))); } response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseRoundTripInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseRoundTripInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -642,14 +642,14 @@ smithy::Outcome ParseRoundTripInput(const smithy::http::H continue; } } - auto body_doc = smithy::json::Decode(request.body.empty() ? "{}" : request.body); + auto body_doc = opal::json::Decode(request.body.empty() ? "{}" : request.body); if (!body_doc) return std::move(body_doc).error(); - if (!body_doc->is_map()) return smithy::Error::Serialization("RoundTrip: expected a JSON object body"); + if (!body_doc->is_map()) return opal::Error::Serialization("RoundTrip: expected a JSON object body"); { - const smithy::Document* member = body_doc->Find("body"); + const opal::Document* member = body_doc->Find("body"); if (member != nullptr && !member->is_null()) { std::string parsed_member{}; - if (!member->is_string()) return smithy::Error::Serialization("RoundTripInput.body: unexpected type on the wire"); + if (!member->is_string()) return opal::Error::Serialization("RoundTripInput.body: unexpected type on the wire"); parsed_member = member->as_string(); input.body = std::move(parsed_member); } @@ -657,27 +657,27 @@ smithy::Outcome ParseRoundTripInput(const smithy::http::H return input; } -smithy::http::HttpResponse BuildRoundTripResponse(const types::RoundTripOutput& output) { +opal::http::HttpResponse BuildRoundTripResponse(const types::RoundTripOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; if (output.header.has_value()) { response.headers.Set("HEADER", (*output.header)); } - smithy::DocumentMap body_map; + opal::DocumentMap body_map; if (output.query.has_value()) { - body_map.emplace("query", smithy::Document((*output.query))); + body_map.emplace("query", opal::Document((*output.query))); } - body_map.emplace("label", smithy::Document(output.label)); + body_map.emplace("label", opal::Document(output.label)); if (output.body.has_value()) { - body_map.emplace("body", smithy::Document((*output.body))); + body_map.emplace("body", opal::Document((*output.body))); } response.headers.Set("content-type", "application/json"); - response.body = smithy::json::Encode(smithy::Document(std::move(body_map))); + response.body = opal::json::Encode(opal::Document(std::move(body_map))); return response; } -smithy::Outcome ParseVersionInput(const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context, std::vector* validation_failures) { +opal::Outcome ParseVersionInput(const opal::http::HttpRequest& request, const opal::server::RequestContext& context, std::vector* validation_failures) { (void)request; (void)context; (void)validation_failures; @@ -685,11 +685,11 @@ smithy::Outcome ParseVersionInput(const smithy::http::HttpR return input; } -smithy::http::HttpResponse BuildVersionResponse(const types::VersionOutput& output) { +opal::http::HttpResponse BuildVersionResponse(const types::VersionOutput& output) { (void)output; - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 200; - response.body = smithy::json::Encode(smithy::Document(output.version)); + response.body = opal::json::Encode(opal::Document(output.version)); if (!response.headers.Get("content-type").has_value()) response.headers.Set("content-type", "application/json"); response.headers.Set("content-length", std::to_string(response.body.size())); return response; @@ -699,26 +699,26 @@ smithy::http::HttpResponse BuildVersionResponse(const types::VersionOutput& outp } // namespace PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptr handler) - : router_(std::make_shared()) { + : router_(std::make_shared()) { // The route table is derived from the model's @http traits; conflicts are // a modeling error surfaced by Router::Add (checked at generation time in a // later phase), so registration results are intentionally discarded. - (void)router_->Add("POST", "/restaurant/{restaurant}/menu/item", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/restaurant/{restaurant}/menu/item", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() ? smithy::http::MediaTypeOf(*content_type) != "application/json" : !request.body.empty()) { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() ? opal::http::MediaTypeOf(*content_type) != "application/json" : !request.body.empty()) { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseAddMenuItemInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -728,17 +728,17 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("GET", "/custom-code/{code}", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/custom-code/{code}", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseCustomCodeInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -746,22 +746,22 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("GET", "/get-enum/{aa}", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/get-enum/{aa}", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseGetEnumInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -771,22 +771,22 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("GET", "/get-int-enum/{aa}", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/get-int-enum/{aa}", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseGetIntEnumInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -796,22 +796,22 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("GET", "/restaurant/{restaurant}/menu", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/restaurant/{restaurant}/menu", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseGetMenuInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -819,17 +819,17 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("POST", "/headers", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/headers", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseHeaderEndpointInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -837,22 +837,22 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("GET", "/health", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/health", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseHealthInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -862,22 +862,22 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("PUT", "/httpPayloadRequiredWithDefault", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("PUT", "/httpPayloadRequiredWithDefault", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() ? smithy::http::MediaTypeOf(*content_type) != "application/json" : !request.body.empty()) { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() ? opal::http::MediaTypeOf(*content_type) != "application/json" : !request.body.empty()) { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseHttpPayloadRequiredWithDefaultInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -885,22 +885,22 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("PUT", "/httpPayloadWithDefault", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("PUT", "/httpPayloadWithDefault", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() ? smithy::http::MediaTypeOf(*content_type) != "application/json" : !request.body.empty()) { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() ? opal::http::MediaTypeOf(*content_type) != "application/json" : !request.body.empty()) { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseHttpPayloadWithDefaultInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -908,22 +908,22 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("PUT", "/openUnions", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("PUT", "/openUnions", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() ? smithy::http::MediaTypeOf(*content_type) != "application/json" : !request.body.empty()) { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() ? opal::http::MediaTypeOf(*content_type) != "application/json" : !request.body.empty()) { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseOpenUnionsInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -931,22 +931,22 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("POST", "/preserveKeyOrder", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/preserveKeyOrder", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParsePreserveOrderInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -954,22 +954,22 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("POST", "/roundTrip/{label}", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("POST", "/roundTrip/{label}", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept // any content type / accept. - if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && smithy::http::MediaTypeOf(*content_type) != "application/json") { + if (const auto content_type = request.headers.Get("content-type"); content_type.has_value() && opal::http::MediaTypeOf(*content_type) != "application/json") { auto error_response = helpers::JsonError(415, "", "unsupported media type", {}); error_response.headers.Set("x-error-type", "UnsupportedMediaTypeException"); return error_response; } - if (const auto accept = request.headers.Get("accept"); accept.has_value() && !smithy::http::AcceptMatches(*accept, "application/json")) { + if (const auto accept = request.headers.Get("accept"); accept.has_value() && !opal::http::AcceptMatches(*accept, "application/json")) { auto error_response = helpers::JsonError(406, "", "not acceptable", {}); error_response.headers.Set("x-error-type", "NotAcceptableException"); return error_response; } - std::vector validation_failures; + std::vector validation_failures; auto input = helpers::ParseRoundTripInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -977,7 +977,7 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrAdd("GET", "/version", [handler](const smithy::http::HttpRequest& request, const smithy::server::RequestContext& context) -> smithy::http::HttpResponse { + (void)router_->Add("GET", "/version", [handler](const opal::http::HttpRequest& request, const opal::server::RequestContext& context) -> opal::http::HttpResponse { // Content-Type validation per the HTTP binding spec (415), then Accept (406); // the malformed-request suite pins the error-identity headers. A missing // content-type is tolerated, and blob payloads without @mediaType accept @@ -987,12 +987,12 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptr validation_failures; + std::vector validation_failures; auto input = helpers::ParseVersionInput(request, context, &validation_failures); if (!validation_failures.empty()) return helpers::ValidationErrorResponse(validation_failures); if (!input) return helpers::ErrorToResponse(input.error()); @@ -1002,9 +1002,9 @@ PizzaAdminServiceServer::PizzaAdminServiceServer(std::shared_ptrRoute(request); }; + return [router](const opal::http::HttpRequest& request) { return router->Route(request); }; } -} // namespace smithy::protocoltests::simplerestjson +} // namespace opal::protocoltests::simplerestjson diff --git a/protocol-tests/simplerestjson/generated/tests/request_tests.cc b/protocol-tests/simplerestjson/generated/tests/request_tests.cc index 0d81a294..dfa81003 100644 --- a/protocol-tests/simplerestjson/generated/tests/request_tests.cc +++ b/protocol-tests/simplerestjson/generated/tests/request_tests.cc @@ -8,22 +8,22 @@ #include #include -#include "smithy/protocoltests/simplerestjson/client.h" +#include "opal/protocoltests/simplerestjson/client.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::simplerestjson { +namespace opal::protocoltests::simplerestjson { // Generated from smithy.test#httpRequestTests (client cases). namespace { struct Fixture { - std::shared_ptr transport; + std::shared_ptr transport; PizzaAdminServiceClient client; }; Fixture MakeFixture(const std::string& endpoint = "") { - auto transport = std::make_shared(); - smithy::ClientConfig config; + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; config.endpoint = endpoint; @@ -55,11 +55,11 @@ TEST(PizzaAdminServiceRequestTest, AddMenuItem) { return v; }(); (void)fixture.client.AddMenuItem(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/restaurant/bobs/menu/item"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/restaurant/bobs/menu/item"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"food\":{\"pizza\":{\"name\":\"margharita\",\"base\":\"T\",\"toppings\":[\"MUSHROOM\",\"TOMATO\"]}},\"price\":9.0}", request.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"food\":{\"pizza\":{\"name\":\"margharita\",\"base\":\"T\",\"toppings\":[\"MUSHROOM\",\"TOMATO\"]}},\"price\":9.0}", request.body)); } // tests custom code as a label @@ -71,9 +71,9 @@ TEST(PizzaAdminServiceRequestTest, CustomCodeInput) { return v; }(); (void)fixture.client.CustomCode(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "GET"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/custom-code/399"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/custom-code/399"); EXPECT_TRUE(request.body.empty()) << request.body; } @@ -85,9 +85,9 @@ TEST(PizzaAdminServiceRequestTest, GetEnumInput) { return v; }(); (void)fixture.client.GetEnum(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "GET"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/get-enum/v1"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/get-enum/v1"); } TEST(PizzaAdminServiceRequestTest, GetIntEnumInput) { @@ -98,9 +98,9 @@ TEST(PizzaAdminServiceRequestTest, GetIntEnumInput) { return v; }(); (void)fixture.client.GetIntEnum(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "GET"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/get-int-enum/1"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/get-int-enum/1"); } TEST(PizzaAdminServiceRequestTest, GetMenuRequest) { @@ -111,9 +111,9 @@ TEST(PizzaAdminServiceRequestTest, GetMenuRequest) { return v; }(); (void)fixture.client.GetMenu(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "GET"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/restaurant/uncle%3Amikes/menu"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/restaurant/uncle%3Amikes/menu"); } // tests variety of casing scenarios for writing http headers @@ -128,9 +128,9 @@ TEST(PizzaAdminServiceRequestTest, HeaderEndpointInput) { return v; }(); (void)fixture.client.HeaderEndpoint(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/headers"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/headers"); EXPECT_EQ(request.headers.Get("X-Capitalized-Header").value_or(""), "Capitalized_value"); EXPECT_EQ(request.headers.Get("X-UPPERCASE-HEADER").value_or(""), "UPPERCASE_VALUE"); EXPECT_EQ(request.headers.Get("x-MiXeD-hEaDEr").value_or(""), "aLLMiXedUP"); @@ -147,10 +147,10 @@ TEST(PizzaAdminServiceRequestTest, HealthGet) { return v; }(); (void)fixture.client.Health(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "GET"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/health"); - EXPECT_TRUE(smithy::testing::QueryContains(request.target, {"query=hello"})); + EXPECT_EQ(opal::testing::UriPath(request.target), "/health"); + EXPECT_TRUE(opal::testing::QueryContains(request.target, {"query=hello"})); EXPECT_TRUE(request.body.empty()) << request.body; } @@ -163,12 +163,12 @@ TEST(PizzaAdminServiceRequestTest, SimpleRestJsonSomeRequiredHttpPayloadWithDefa return v; }(); (void)fixture.client.HttpPayloadRequiredWithDefault(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "PUT"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/httpPayloadRequiredWithDefault"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/httpPayloadRequiredWithDefault"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/json"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("\"custom value\"", request.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("\"custom value\"", request.body)); } // Use default value when there is no payload @@ -180,9 +180,9 @@ TEST(PizzaAdminServiceRequestTest, SimpleRestJsonNoneRequiredHttpPayloadWithDefa return v; }(); (void)fixture.client.HttpPayloadRequiredWithDefault(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "PUT"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/httpPayloadRequiredWithDefault"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/httpPayloadRequiredWithDefault"); } // Pass JSON string value as is if payload provided @@ -194,12 +194,12 @@ TEST(PizzaAdminServiceRequestTest, SimpleRestJsonSomeHttpPayloadWithDefault) { return v; }(); (void)fixture.client.HttpPayloadWithDefault(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "PUT"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/httpPayloadWithDefault"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/httpPayloadWithDefault"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/json"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("\"custom value\"", request.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("\"custom value\"", request.body)); } // Use default value when there is no payload @@ -211,9 +211,9 @@ TEST(PizzaAdminServiceRequestTest, SimpleRestJsonNoneHttpPayloadWithDefault) { return v; }(); (void)fixture.client.HttpPayloadWithDefault(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "PUT"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/httpPayloadWithDefault"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/httpPayloadWithDefault"); } // Pass a known tagged union value in an open union @@ -225,12 +225,12 @@ TEST(PizzaAdminServiceRequestTest, OpenUnionsKnownTaggedUnionCase) { return v; }(); (void)fixture.client.OpenUnions(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "PUT"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/openUnions"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/openUnions"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/json"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"tagged\": {\"str\": \"string value\"}}", request.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"tagged\": {\"str\": \"string value\"}}", request.body)); } // Pass an unknown tagged union value in an open union @@ -239,23 +239,23 @@ TEST(PizzaAdminServiceRequestTest, OpenUnionsUnknownTaggedUnionCase) { const OpenUnionsInput input = [] { OpenUnionsInput v{}; v.data = OpenUnionsPayload::FromTagged(OpenTaggedUnion::FromOther([] { - smithy::DocumentMap map; + opal::DocumentMap map; map.emplace("whatisthis", [] { - smithy::DocumentMap map; - map.emplace("nested", smithy::Document(std::string("something different"))); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("nested", opal::Document(std::string("something different"))); + return opal::Document(std::move(map)); }()); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); }())); return v; }(); (void)fixture.client.OpenUnions(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "PUT"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/openUnions"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/openUnions"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/json"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"tagged\": {\"whatisthis\": {\"nested\": \"something different\"}}}", request.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"tagged\": {\"whatisthis\": {\"nested\": \"something different\"}}}", request.body)); } // Pass a known discriminated union value in an open union @@ -271,12 +271,12 @@ TEST(PizzaAdminServiceRequestTest, OpenUnionsKnownDiscriminatedUnionCase) { return v; }(); (void)fixture.client.OpenUnions(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "PUT"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/openUnions"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/openUnions"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/json"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"discriminated\": {\"key\": \"smol\", \"content\": \"some string\"}}", request.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"discriminated\": {\"key\": \"smol\", \"content\": \"some string\"}}", request.body)); } // Pass an unknown discriminated union value in an open union @@ -285,20 +285,20 @@ TEST(PizzaAdminServiceRequestTest, OpenUnionsUnknownDiscriminatedUnionCase) { const OpenUnionsInput input = [] { OpenUnionsInput v{}; v.data = OpenUnionsPayload::FromDiscriminated(OpenDiscriminatedUnion::FromOther([] { - smithy::DocumentMap map; - map.emplace("key", smithy::Document(std::string("mysterious_and_important"))); - map.emplace("extras", smithy::Document(std::int64_t{42})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("key", opal::Document(std::string("mysterious_and_important"))); + map.emplace("extras", opal::Document(std::int64_t{42})); + return opal::Document(std::move(map)); }())); return v; }(); (void)fixture.client.OpenUnions(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "PUT"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/openUnions"); + EXPECT_EQ(opal::testing::UriPath(request.target), "/openUnions"); EXPECT_EQ(request.headers.Get("Content-Type").value_or(""), "application/json"); EXPECT_TRUE(request.headers.Has("Content-Length")); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"discriminated\": {\"key\": \"mysterious_and_important\", \"extras\": 42}}", request.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"discriminated\": {\"key\": \"mysterious_and_important\", \"extras\": 42}}", request.body)); } TEST(PizzaAdminServiceRequestTest, PreserveKeyOrderRequest) { @@ -307,23 +307,23 @@ TEST(PizzaAdminServiceRequestTest, PreserveKeyOrderRequest) { PreserveOrderInput v{}; v.map = std::map{{"a", 1}, {"d", 2}, {"e", 3}, {"b", 4}}; v.document = [] { - smithy::DocumentMap map; - map.emplace("foo", smithy::Document(std::int64_t{1})); - map.emplace("a", smithy::Document(std::string("b"))); + opal::DocumentMap map; + map.emplace("foo", opal::Document(std::int64_t{1})); + map.emplace("a", opal::Document(std::string("b"))); map.emplace("c", [] { - smithy::DocumentList list; - return smithy::Document(std::move(list)); + opal::DocumentList list; + return opal::Document(std::move(list)); }()); - map.emplace("bar", smithy::Document(nullptr)); - return smithy::Document(std::move(map)); + map.emplace("bar", opal::Document(nullptr)); + return opal::Document(std::move(map)); }(); return v; }(); (void)fixture.client.PreserveOrder(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/preserveKeyOrder"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"map\":{\"a\":1,\"d\":2,\"e\":3,\"b\":4},\"document\":{\"foo\":1,\"a\":\"b\",\"c\":[],\"bar\":null}}", request.body)); + EXPECT_EQ(opal::testing::UriPath(request.target), "/preserveKeyOrder"); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"map\":{\"a\":1,\"d\":2,\"e\":3,\"b\":4},\"document\":{\"foo\":1,\"a\":\"b\",\"c\":[],\"bar\":null}}", request.body)); } TEST(PizzaAdminServiceRequestTest, RoundTripRequest) { @@ -337,12 +337,12 @@ TEST(PizzaAdminServiceRequestTest, RoundTripRequest) { return v; }(); (void)fixture.client.RoundTrip(input); - const smithy::http::HttpRequest& request = fixture.transport->last_request; + const opal::http::HttpRequest& request = fixture.transport->last_request; EXPECT_EQ(request.method, "POST"); - EXPECT_EQ(smithy::testing::UriPath(request.target), "/roundTrip/thelabel"); - EXPECT_TRUE(smithy::testing::QueryContains(request.target, {"query=the query"})); + EXPECT_EQ(opal::testing::UriPath(request.target), "/roundTrip/thelabel"); + EXPECT_TRUE(opal::testing::QueryContains(request.target, {"query=the query"})); EXPECT_EQ(request.headers.Get("HEADER").value_or(""), "the header"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"body\":\"the body\"}", request.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"body\":\"the body\"}", request.body)); } -} // namespace smithy::protocoltests::simplerestjson +} // namespace opal::protocoltests::simplerestjson diff --git a/protocol-tests/simplerestjson/generated/tests/response_tests.cc b/protocol-tests/simplerestjson/generated/tests/response_tests.cc index f9fa41bb..cb3cbbcb 100644 --- a/protocol-tests/simplerestjson/generated/tests/response_tests.cc +++ b/protocol-tests/simplerestjson/generated/tests/response_tests.cc @@ -8,23 +8,23 @@ #include #include -#include "smithy/protocoltests/simplerestjson/client.h" +#include "opal/protocoltests/simplerestjson/client.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::simplerestjson { +namespace opal::protocoltests::simplerestjson { // Generated from smithy.test#httpResponseTests (client cases), // including the cases attached to modeled error shapes. namespace { struct Fixture { - std::shared_ptr transport; + std::shared_ptr transport; PizzaAdminServiceClient client; }; Fixture MakeFixture(const std::string& endpoint = "") { - auto transport = std::make_shared(); - smithy::ClientConfig config; + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; config.endpoint = endpoint; @@ -47,7 +47,7 @@ TEST(PizzaAdminServiceResponseTest, AddMenuItemResult) { const AddMenuItemOutput expected = [] { AddMenuItemOutput v{}; v.itemId = "1"; - v.added = smithy::Timestamp::FromEpochMilliseconds(1576540098000LL); + v.added = opal::Timestamp::FromEpochMilliseconds(1576540098000LL); return v; }(); EXPECT_EQ(*outcome, expected); @@ -232,13 +232,13 @@ TEST(PizzaAdminServiceResponseTest, OpenUnionsUnknownTaggedUnionCase) { const OpenUnionsOutput expected = [] { OpenUnionsOutput v{}; v.data = OpenUnionsPayload::FromTagged(OpenTaggedUnion::FromOther([] { - smithy::DocumentMap map; + opal::DocumentMap map; map.emplace("whatisthis", [] { - smithy::DocumentMap map; - map.emplace("nested", smithy::Document(std::string("something different"))); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("nested", opal::Document(std::string("something different"))); + return opal::Document(std::move(map)); }()); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); }())); return v; }(); @@ -276,10 +276,10 @@ TEST(PizzaAdminServiceResponseTest, OpenUnionsUnknownDiscriminatedUnionCase) { const OpenUnionsOutput expected = [] { OpenUnionsOutput v{}; v.data = OpenUnionsPayload::FromDiscriminated(OpenDiscriminatedUnion::FromOther([] { - smithy::DocumentMap map; - map.emplace("key", smithy::Document(std::string("mysterious_and_important"))); - map.emplace("extras", smithy::Document(std::int64_t{42})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("key", opal::Document(std::string("mysterious_and_important"))); + map.emplace("extras", opal::Document(std::int64_t{42})); + return opal::Document(std::move(map)); }())); return v; }(); @@ -296,15 +296,15 @@ TEST(PizzaAdminServiceResponseTest, PreserveKeyOrderResponse) { PreserveOrderOutput v{}; v.map = std::map{{"a", 1}, {"d", 2}, {"e", 3}, {"b", 4}}; v.document = [] { - smithy::DocumentMap map; - map.emplace("foo", smithy::Document(std::int64_t{1})); - map.emplace("a", smithy::Document(std::string("b"))); + opal::DocumentMap map; + map.emplace("foo", opal::Document(std::int64_t{1})); + map.emplace("a", opal::Document(std::string("b"))); map.emplace("c", [] { - smithy::DocumentList list; - return smithy::Document(std::move(list)); + opal::DocumentList list; + return opal::Document(std::move(list)); }()); - map.emplace("bar", smithy::Document(nullptr)); - return smithy::Document(std::move(map)); + map.emplace("bar", opal::Document(nullptr)); + return opal::Document(std::move(map)); }(); return v; }(); @@ -383,4 +383,4 @@ TEST(PizzaAdminServiceErrorTest, PriceErrorTest) { EXPECT_EQ(*detail, expected); } -} // namespace smithy::protocoltests::simplerestjson +} // namespace opal::protocoltests::simplerestjson diff --git a/protocol-tests/simplerestjson/generated/tests/server_request_tests.cc b/protocol-tests/simplerestjson/generated/tests/server_request_tests.cc index d992b1ab..00220bb6 100644 --- a/protocol-tests/simplerestjson/generated/tests/server_request_tests.cc +++ b/protocol-tests/simplerestjson/generated/tests/server_request_tests.cc @@ -8,11 +8,11 @@ #include #include -#include "smithy/protocoltests/simplerestjson/client.h" -#include "smithy/protocoltests/simplerestjson/server.h" +#include "opal/protocoltests/simplerestjson/client.h" +#include "opal/protocoltests/simplerestjson/server.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::simplerestjson { +namespace opal::protocoltests::simplerestjson { // Generated from smithy.test#httpRequestTests (server cases): the wire // request is routed into the generated server and the parsed input is @@ -114,67 +114,67 @@ VersionOutput MinimalVersionOutput() { class RecordingHandler : public PizzaAdminServiceHandler { public: - smithy::Outcome AddMenuItem(const AddMenuItemInput& input, const smithy::server::RequestContext&) override { + opal::Outcome AddMenuItem(const AddMenuItemInput& input, const opal::server::RequestContext&) override { lastAddMenuItem = input; return MinimalAddMenuItemOutput(); } std::optional lastAddMenuItem; - smithy::Outcome CustomCode(const CustomCodeInput& input, const smithy::server::RequestContext&) override { + opal::Outcome CustomCode(const CustomCodeInput& input, const opal::server::RequestContext&) override { lastCustomCode = input; return MinimalCustomCodeOutput(); } std::optional lastCustomCode; - smithy::Outcome GetEnum(const GetEnumInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetEnum(const GetEnumInput& input, const opal::server::RequestContext&) override { lastGetEnum = input; return MinimalGetEnumOutput(); } std::optional lastGetEnum; - smithy::Outcome GetIntEnum(const GetIntEnumInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetIntEnum(const GetIntEnumInput& input, const opal::server::RequestContext&) override { lastGetIntEnum = input; return MinimalGetIntEnumOutput(); } std::optional lastGetIntEnum; - smithy::Outcome GetMenu(const GetMenuInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetMenu(const GetMenuInput& input, const opal::server::RequestContext&) override { lastGetMenu = input; return MinimalGetMenuOutput(); } std::optional lastGetMenu; - smithy::Outcome HeaderEndpoint(const HeaderEndpointInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HeaderEndpoint(const HeaderEndpointInput& input, const opal::server::RequestContext&) override { lastHeaderEndpoint = input; return MinimalHeaderEndpointOutput(); } std::optional lastHeaderEndpoint; - smithy::Outcome Health(const HealthInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Health(const HealthInput& input, const opal::server::RequestContext&) override { lastHealth = input; return MinimalHealthOutput(); } std::optional lastHealth; - smithy::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const opal::server::RequestContext&) override { lastHttpPayloadRequiredWithDefault = input; return MinimalHttpPayloadRequiredWithDefaultOutput(); } std::optional lastHttpPayloadRequiredWithDefault; - smithy::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const opal::server::RequestContext&) override { lastHttpPayloadWithDefault = input; return MinimalHttpPayloadWithDefaultOutput(); } std::optional lastHttpPayloadWithDefault; - smithy::Outcome OpenUnions(const OpenUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OpenUnions(const OpenUnionsInput& input, const opal::server::RequestContext&) override { lastOpenUnions = input; return MinimalOpenUnionsOutput(); } std::optional lastOpenUnions; - smithy::Outcome PreserveOrder(const PreserveOrderInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PreserveOrder(const PreserveOrderInput& input, const opal::server::RequestContext&) override { lastPreserveOrder = input; return MinimalPreserveOrderOutput(); } std::optional lastPreserveOrder; - smithy::Outcome RoundTrip(const RoundTripInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RoundTrip(const RoundTripInput& input, const opal::server::RequestContext&) override { lastRoundTrip = input; return MinimalRoundTripOutput(); } std::optional lastRoundTrip; - smithy::Outcome Version(const VersionInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Version(const VersionInput& input, const opal::server::RequestContext&) override { lastVersion = input; return MinimalVersionOutput(); } @@ -187,12 +187,12 @@ class RecordingHandler : public PizzaAdminServiceHandler { TEST(PizzaAdminServiceServerRequestTest, AddMenuItem) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/restaurant/bobs/menu/item"; request.headers.Set("Content-Type", "application/json"); request.body = "{\"food\":{\"pizza\":{\"name\":\"margharita\",\"base\":\"T\",\"toppings\":[\"MUSHROOM\",\"TOMATO\"]}},\"price\":9.0}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastAddMenuItem.has_value()) << response.status << " " << response.body; const AddMenuItemInput expected = [] { AddMenuItemInput v{}; @@ -218,10 +218,10 @@ TEST(PizzaAdminServiceServerRequestTest, AddMenuItem) { TEST(PizzaAdminServiceServerRequestTest, CustomCodeInput) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/custom-code/399"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastCustomCode.has_value()) << response.status << " " << response.body; const CustomCodeInput expected = [] { CustomCodeInput v{}; @@ -234,10 +234,10 @@ TEST(PizzaAdminServiceServerRequestTest, CustomCodeInput) { TEST(PizzaAdminServiceServerRequestTest, GetEnumInput) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/get-enum/v1"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastGetEnum.has_value()) << response.status << " " << response.body; const GetEnumInput expected = [] { GetEnumInput v{}; @@ -250,10 +250,10 @@ TEST(PizzaAdminServiceServerRequestTest, GetEnumInput) { TEST(PizzaAdminServiceServerRequestTest, GetIntEnumInput) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/get-int-enum/1"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastGetIntEnum.has_value()) << response.status << " " << response.body; const GetIntEnumInput expected = [] { GetIntEnumInput v{}; @@ -266,10 +266,10 @@ TEST(PizzaAdminServiceServerRequestTest, GetIntEnumInput) { TEST(PizzaAdminServiceServerRequestTest, GetMenuRequest) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/restaurant/uncle%3Amikes/menu"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastGetMenu.has_value()) << response.status << " " << response.body; const GetMenuInput expected = [] { GetMenuInput v{}; @@ -283,14 +283,14 @@ TEST(PizzaAdminServiceServerRequestTest, GetMenuRequest) { TEST(PizzaAdminServiceServerRequestTest, HeaderEndpointInput) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/headers"; request.headers.Set("X-Capitalized-Header", "Capitalized_value"); request.headers.Set("X-UPPERCASE-HEADER", "UPPERCASE_VALUE"); request.headers.Set("x-MiXeD-hEaDEr", "aLLMiXedUP"); request.headers.Set("x-lowercase-header", "lowercase_value"); - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastHeaderEndpoint.has_value()) << response.status << " " << response.body; const HeaderEndpointInput expected = [] { HeaderEndpointInput v{}; @@ -307,10 +307,10 @@ TEST(PizzaAdminServiceServerRequestTest, HeaderEndpointInput) { TEST(PizzaAdminServiceServerRequestTest, HealthGet) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/health?query=hello"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastHealth.has_value()) << response.status << " " << response.body; const HealthInput expected = [] { HealthInput v{}; @@ -324,12 +324,12 @@ TEST(PizzaAdminServiceServerRequestTest, HealthGet) { TEST(PizzaAdminServiceServerRequestTest, SimpleRestJsonSomeRequiredHttpPayloadWithDefault) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = "/httpPayloadRequiredWithDefault"; request.headers.Set("Content-Type", "application/json"); request.body = "\"custom value\""; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastHttpPayloadRequiredWithDefault.has_value()) << response.status << " " << response.body; const HttpPayloadRequiredWithDefaultInput expected = [] { HttpPayloadRequiredWithDefaultInput v{}; @@ -343,10 +343,10 @@ TEST(PizzaAdminServiceServerRequestTest, SimpleRestJsonSomeRequiredHttpPayloadWi TEST(PizzaAdminServiceServerRequestTest, SimpleRestJsonNoneRequiredHttpPayloadWithDefault) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = "/httpPayloadRequiredWithDefault"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastHttpPayloadRequiredWithDefault.has_value()) << response.status << " " << response.body; const HttpPayloadRequiredWithDefaultInput expected = [] { HttpPayloadRequiredWithDefaultInput v{}; @@ -360,12 +360,12 @@ TEST(PizzaAdminServiceServerRequestTest, SimpleRestJsonNoneRequiredHttpPayloadWi TEST(PizzaAdminServiceServerRequestTest, SimpleRestJsonSomeHttpPayloadWithDefault) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = "/httpPayloadWithDefault"; request.headers.Set("Content-Type", "application/json"); request.body = "\"custom value\""; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastHttpPayloadWithDefault.has_value()) << response.status << " " << response.body; const HttpPayloadWithDefaultInput expected = [] { HttpPayloadWithDefaultInput v{}; @@ -379,10 +379,10 @@ TEST(PizzaAdminServiceServerRequestTest, SimpleRestJsonSomeHttpPayloadWithDefaul TEST(PizzaAdminServiceServerRequestTest, SimpleRestJsonNoneHttpPayloadWithDefault) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = "/httpPayloadWithDefault"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastHttpPayloadWithDefault.has_value()) << response.status << " " << response.body; const HttpPayloadWithDefaultInput expected = [] { HttpPayloadWithDefaultInput v{}; @@ -396,12 +396,12 @@ TEST(PizzaAdminServiceServerRequestTest, SimpleRestJsonNoneHttpPayloadWithDefaul TEST(PizzaAdminServiceServerRequestTest, OpenUnionsKnownTaggedUnionCase) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = "/openUnions"; request.headers.Set("Content-Type", "application/json"); request.body = "{\"tagged\": {\"str\": \"string value\"}}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastOpenUnions.has_value()) << response.status << " " << response.body; const OpenUnionsInput expected = [] { OpenUnionsInput v{}; @@ -415,23 +415,23 @@ TEST(PizzaAdminServiceServerRequestTest, OpenUnionsKnownTaggedUnionCase) { TEST(PizzaAdminServiceServerRequestTest, OpenUnionsUnknownTaggedUnionCase) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = "/openUnions"; request.headers.Set("Content-Type", "application/json"); request.body = "{\"tagged\": {\"whatisthis\": {\"nested\": \"something different\"}}}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastOpenUnions.has_value()) << response.status << " " << response.body; const OpenUnionsInput expected = [] { OpenUnionsInput v{}; v.data = OpenUnionsPayload::FromTagged(OpenTaggedUnion::FromOther([] { - smithy::DocumentMap map; + opal::DocumentMap map; map.emplace("whatisthis", [] { - smithy::DocumentMap map; - map.emplace("nested", smithy::Document(std::string("something different"))); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("nested", opal::Document(std::string("something different"))); + return opal::Document(std::move(map)); }()); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); }())); return v; }(); @@ -442,12 +442,12 @@ TEST(PizzaAdminServiceServerRequestTest, OpenUnionsUnknownTaggedUnionCase) { TEST(PizzaAdminServiceServerRequestTest, OpenUnionsKnownDiscriminatedUnionCase) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = "/openUnions"; request.headers.Set("Content-Type", "application/json"); request.body = "{\"discriminated\": {\"key\": \"smol\", \"content\": \"some string\"}}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastOpenUnions.has_value()) << response.status << " " << response.body; const OpenUnionsInput expected = [] { OpenUnionsInput v{}; @@ -465,20 +465,20 @@ TEST(PizzaAdminServiceServerRequestTest, OpenUnionsKnownDiscriminatedUnionCase) TEST(PizzaAdminServiceServerRequestTest, OpenUnionsUnknownDiscriminatedUnionCase) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; request.target = "/openUnions"; request.headers.Set("Content-Type", "application/json"); request.body = "{\"discriminated\": {\"key\": \"mysterious_and_important\", \"extras\": 42}}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastOpenUnions.has_value()) << response.status << " " << response.body; const OpenUnionsInput expected = [] { OpenUnionsInput v{}; v.data = OpenUnionsPayload::FromDiscriminated(OpenDiscriminatedUnion::FromOther([] { - smithy::DocumentMap map; - map.emplace("key", smithy::Document(std::string("mysterious_and_important"))); - map.emplace("extras", smithy::Document(std::int64_t{42})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("key", opal::Document(std::string("mysterious_and_important"))); + map.emplace("extras", opal::Document(std::int64_t{42})); + return opal::Document(std::move(map)); }())); return v; }(); @@ -488,25 +488,25 @@ TEST(PizzaAdminServiceServerRequestTest, OpenUnionsUnknownDiscriminatedUnionCase TEST(PizzaAdminServiceServerRequestTest, PreserveKeyOrderRequest) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/preserveKeyOrder"; request.body = "{\"map\":{\"a\":1,\"d\":2,\"e\":3,\"b\":4},\"document\":{\"foo\":1,\"a\":\"b\",\"c\":[],\"bar\":null}}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastPreserveOrder.has_value()) << response.status << " " << response.body; const PreserveOrderInput expected = [] { PreserveOrderInput v{}; v.map = std::map{{"a", 1}, {"d", 2}, {"e", 3}, {"b", 4}}; v.document = [] { - smithy::DocumentMap map; - map.emplace("foo", smithy::Document(std::int64_t{1})); - map.emplace("a", smithy::Document(std::string("b"))); + opal::DocumentMap map; + map.emplace("foo", opal::Document(std::int64_t{1})); + map.emplace("a", opal::Document(std::string("b"))); map.emplace("c", [] { - smithy::DocumentList list; - return smithy::Document(std::move(list)); + opal::DocumentList list; + return opal::Document(std::move(list)); }()); - map.emplace("bar", smithy::Document(nullptr)); - return smithy::Document(std::move(map)); + map.emplace("bar", opal::Document(nullptr)); + return opal::Document(std::move(map)); }(); return v; }(); @@ -516,12 +516,12 @@ TEST(PizzaAdminServiceServerRequestTest, PreserveKeyOrderRequest) { TEST(PizzaAdminServiceServerRequestTest, RoundTripRequest) { auto handler = std::make_shared(); PizzaAdminServiceServer server(handler); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/roundTrip/thelabel?query=the query"; request.headers.Set("HEADER", "the header"); request.body = "{\"body\":\"the body\"}"; - const smithy::http::HttpResponse response = server.Handler()(request); + const opal::http::HttpResponse response = server.Handler()(request); ASSERT_TRUE(handler->lastRoundTrip.has_value()) << response.status << " " << response.body; const RoundTripInput expected = [] { RoundTripInput v{}; @@ -534,4 +534,4 @@ TEST(PizzaAdminServiceServerRequestTest, RoundTripRequest) { EXPECT_EQ(*handler->lastRoundTrip, expected); } -} // namespace smithy::protocoltests::simplerestjson +} // namespace opal::protocoltests::simplerestjson diff --git a/protocol-tests/simplerestjson/generated/tests/server_response_tests.cc b/protocol-tests/simplerestjson/generated/tests/server_response_tests.cc index 83d9b87b..b9f1dcb9 100644 --- a/protocol-tests/simplerestjson/generated/tests/server_response_tests.cc +++ b/protocol-tests/simplerestjson/generated/tests/server_response_tests.cc @@ -8,11 +8,11 @@ #include #include -#include "smithy/protocoltests/simplerestjson/client.h" -#include "smithy/protocoltests/simplerestjson/server.h" +#include "opal/protocoltests/simplerestjson/client.h" +#include "opal/protocoltests/simplerestjson/server.h" #include "smithy/testing/protocol_test.h" -namespace smithy::protocoltests::simplerestjson { +namespace opal::protocoltests::simplerestjson { // Generated from smithy.test#httpResponseTests (server cases): a stub // handler returns the expected params and the wire response the server @@ -114,76 +114,76 @@ VersionOutput MinimalVersionOutput() { class RecordingHandler : public PizzaAdminServiceHandler { public: - smithy::Outcome AddMenuItem(const AddMenuItemInput& input, const smithy::server::RequestContext&) override { + opal::Outcome AddMenuItem(const AddMenuItemInput& input, const opal::server::RequestContext&) override { lastAddMenuItem = input; return MinimalAddMenuItemOutput(); } std::optional lastAddMenuItem; - smithy::Outcome CustomCode(const CustomCodeInput& input, const smithy::server::RequestContext&) override { + opal::Outcome CustomCode(const CustomCodeInput& input, const opal::server::RequestContext&) override { lastCustomCode = input; return MinimalCustomCodeOutput(); } std::optional lastCustomCode; - smithy::Outcome GetEnum(const GetEnumInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetEnum(const GetEnumInput& input, const opal::server::RequestContext&) override { lastGetEnum = input; return MinimalGetEnumOutput(); } std::optional lastGetEnum; - smithy::Outcome GetIntEnum(const GetIntEnumInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetIntEnum(const GetIntEnumInput& input, const opal::server::RequestContext&) override { lastGetIntEnum = input; return MinimalGetIntEnumOutput(); } std::optional lastGetIntEnum; - smithy::Outcome GetMenu(const GetMenuInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetMenu(const GetMenuInput& input, const opal::server::RequestContext&) override { lastGetMenu = input; return MinimalGetMenuOutput(); } std::optional lastGetMenu; - smithy::Outcome HeaderEndpoint(const HeaderEndpointInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HeaderEndpoint(const HeaderEndpointInput& input, const opal::server::RequestContext&) override { lastHeaderEndpoint = input; return MinimalHeaderEndpointOutput(); } std::optional lastHeaderEndpoint; - smithy::Outcome Health(const HealthInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Health(const HealthInput& input, const opal::server::RequestContext&) override { lastHealth = input; return MinimalHealthOutput(); } std::optional lastHealth; - smithy::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const opal::server::RequestContext&) override { lastHttpPayloadRequiredWithDefault = input; return MinimalHttpPayloadRequiredWithDefaultOutput(); } std::optional lastHttpPayloadRequiredWithDefault; - smithy::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const opal::server::RequestContext&) override { lastHttpPayloadWithDefault = input; return MinimalHttpPayloadWithDefaultOutput(); } std::optional lastHttpPayloadWithDefault; - smithy::Outcome OpenUnions(const OpenUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OpenUnions(const OpenUnionsInput& input, const opal::server::RequestContext&) override { lastOpenUnions = input; return MinimalOpenUnionsOutput(); } std::optional lastOpenUnions; - smithy::Outcome PreserveOrder(const PreserveOrderInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PreserveOrder(const PreserveOrderInput& input, const opal::server::RequestContext&) override { lastPreserveOrder = input; return MinimalPreserveOrderOutput(); } std::optional lastPreserveOrder; - smithy::Outcome RoundTrip(const RoundTripInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RoundTrip(const RoundTripInput& input, const opal::server::RequestContext&) override { lastRoundTrip = input; return MinimalRoundTripOutput(); } std::optional lastRoundTrip; - smithy::Outcome Version(const VersionInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Version(const VersionInput& input, const opal::server::RequestContext&) override { lastVersion = input; return MinimalVersionOutput(); } std::optional lastVersion; }; -smithy::http::HttpRequest MinimalRequestForAddMenuItem() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForAddMenuItem() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -205,9 +205,9 @@ smithy::http::HttpRequest MinimalRequestForAddMenuItem() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForCustomCode() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForCustomCode() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -219,9 +219,9 @@ smithy::http::HttpRequest MinimalRequestForCustomCode() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForGetEnum() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForGetEnum() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -234,9 +234,9 @@ smithy::http::HttpRequest MinimalRequestForGetEnum() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForGetIntEnum() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForGetIntEnum() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -249,9 +249,9 @@ smithy::http::HttpRequest MinimalRequestForGetIntEnum() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForGetMenu() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForGetMenu() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -264,9 +264,9 @@ smithy::http::HttpRequest MinimalRequestForGetMenu() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForHeaderEndpoint() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForHeaderEndpoint() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -278,9 +278,9 @@ smithy::http::HttpRequest MinimalRequestForHeaderEndpoint() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForHttpPayloadRequiredWithDefault() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForHttpPayloadRequiredWithDefault() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -292,9 +292,9 @@ smithy::http::HttpRequest MinimalRequestForHttpPayloadRequiredWithDefault() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForHttpPayloadWithDefault() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForHttpPayloadWithDefault() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -306,9 +306,9 @@ smithy::http::HttpRequest MinimalRequestForHttpPayloadWithDefault() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForOpenUnions() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForOpenUnions() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -321,9 +321,9 @@ smithy::http::HttpRequest MinimalRequestForOpenUnions() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForPreserveOrder() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForPreserveOrder() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -335,9 +335,9 @@ smithy::http::HttpRequest MinimalRequestForPreserveOrder() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForRoundTrip() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForRoundTrip() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -350,9 +350,9 @@ smithy::http::HttpRequest MinimalRequestForRoundTrip() { return transport->last_request; } -smithy::http::HttpRequest MinimalRequestForVersion() { - auto transport = std::make_shared(); - smithy::ClientConfig config; +opal::http::HttpRequest MinimalRequestForVersion() { + auto transport = std::make_shared(); + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = transport; auto client = *PizzaAdminServiceClient::Create(std::move(config)); @@ -370,29 +370,29 @@ smithy::http::HttpRequest MinimalRequestForVersion() { TEST(PizzaAdminServiceServerResponseTest, AddMenuItemResult) { class Handler final : public RecordingHandler { public: - smithy::Outcome AddMenuItem(const AddMenuItemInput& input, const smithy::server::RequestContext&) override { + opal::Outcome AddMenuItem(const AddMenuItemInput& input, const opal::server::RequestContext&) override { (void)input; return [] { AddMenuItemOutput v{}; v.itemId = "1"; - v.added = smithy::Timestamp::FromEpochMilliseconds(1576540098000LL); + v.added = opal::Timestamp::FromEpochMilliseconds(1576540098000LL); return v; }(); } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForAddMenuItem()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForAddMenuItem()); EXPECT_EQ(response.status, 201); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/json"); EXPECT_EQ(response.headers.Get("X-ADDED-AT").value_or(""), "1576540098"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("\"1\"", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("\"1\"", response.body)); } // respect the httpResponseCode trait TEST(PizzaAdminServiceServerResponseTest, CustomCodeOutput) { class Handler final : public RecordingHandler { public: - smithy::Outcome CustomCode(const CustomCodeInput& input, const smithy::server::RequestContext&) override { + opal::Outcome CustomCode(const CustomCodeInput& input, const opal::server::RequestContext&) override { (void)input; return [] { CustomCodeOutput v{}; @@ -402,15 +402,15 @@ TEST(PizzaAdminServiceServerResponseTest, CustomCodeOutput) { } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForCustomCode()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForCustomCode()); EXPECT_EQ(response.status, 399); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{}", response.body)); } TEST(PizzaAdminServiceServerResponseTest, GetEnumOutput) { class Handler final : public RecordingHandler { public: - smithy::Outcome GetEnum(const GetEnumInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetEnum(const GetEnumInput& input, const opal::server::RequestContext&) override { (void)input; return [] { GetEnumOutput v{}; @@ -420,15 +420,15 @@ TEST(PizzaAdminServiceServerResponseTest, GetEnumOutput) { } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForGetEnum()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForGetEnum()); EXPECT_EQ(response.status, 200); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"result\":\"v1\"}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"result\":\"v1\"}", response.body)); } TEST(PizzaAdminServiceServerResponseTest, GetIntEnumOutput) { class Handler final : public RecordingHandler { public: - smithy::Outcome GetIntEnum(const GetIntEnumInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetIntEnum(const GetIntEnumInput& input, const opal::server::RequestContext&) override { (void)input; return [] { GetIntEnumOutput v{}; @@ -438,15 +438,15 @@ TEST(PizzaAdminServiceServerResponseTest, GetIntEnumOutput) { } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForGetIntEnum()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForGetIntEnum()); EXPECT_EQ(response.status, 200); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"result\":1}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"result\":1}", response.body)); } TEST(PizzaAdminServiceServerResponseTest, GetMenuResponse) { class Handler final : public RecordingHandler { public: - smithy::Outcome GetMenu(const GetMenuInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetMenu(const GetMenuInput& input, const opal::server::RequestContext&) override { (void)input; return [] { GetMenuOutput v{}; @@ -467,16 +467,16 @@ TEST(PizzaAdminServiceServerResponseTest, GetMenuResponse) { } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForGetMenu()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForGetMenu()); EXPECT_EQ(response.status, 200); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"a0b0f3a9-81d3-4bf3-8897-a76423116403\" :{\"food\":{\"pizza\": {\"name\":\"margharita\",\"base\":\"T\",\"toppings\":[\"MUSHROOM\", \"TOMATO\"]}},\"price\":9.0}}\n", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"a0b0f3a9-81d3-4bf3-8897-a76423116403\" :{\"food\":{\"pizza\": {\"name\":\"margharita\",\"base\":\"T\",\"toppings\":[\"MUSHROOM\", \"TOMATO\"]}},\"price\":9.0}}\n", response.body)); } // tests variety of casing scenarios for reading http headers TEST(PizzaAdminServiceServerResponseTest, headerEndpointResponse) { class Handler final : public RecordingHandler { public: - smithy::Outcome HeaderEndpoint(const HeaderEndpointInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HeaderEndpoint(const HeaderEndpointInput& input, const opal::server::RequestContext&) override { (void)input; return [] { HeaderEndpointOutput v{}; @@ -489,7 +489,7 @@ TEST(PizzaAdminServiceServerResponseTest, headerEndpointResponse) { } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForHeaderEndpoint()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForHeaderEndpoint()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("X-Capitalized-Header").value_or(""), "Capitalized_value"); EXPECT_EQ(response.headers.Get("X-UPPERCASE-HEADER").value_or(""), "UPPERCASE_VALUE"); @@ -501,7 +501,7 @@ TEST(PizzaAdminServiceServerResponseTest, headerEndpointResponse) { TEST(PizzaAdminServiceServerResponseTest, SimpleRestJsonSomeRequiredHttpPayloadWithDefault) { class Handler final : public RecordingHandler { public: - smithy::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const opal::server::RequestContext&) override { (void)input; return [] { HttpPayloadRequiredWithDefaultOutput v{}; @@ -511,17 +511,17 @@ TEST(PizzaAdminServiceServerResponseTest, SimpleRestJsonSomeRequiredHttpPayloadW } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForHttpPayloadRequiredWithDefault()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForHttpPayloadRequiredWithDefault()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("\"custom value\"", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("\"custom value\"", response.body)); } // Use default value when there is no payload TEST(PizzaAdminServiceServerResponseTest, SimpleRestJsonNoneRequiredHttpPayloadWithDefault) { class Handler final : public RecordingHandler { public: - smithy::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const opal::server::RequestContext&) override { (void)input; return [] { HttpPayloadRequiredWithDefaultOutput v{}; @@ -531,7 +531,7 @@ TEST(PizzaAdminServiceServerResponseTest, SimpleRestJsonNoneRequiredHttpPayloadW } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForHttpPayloadRequiredWithDefault()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForHttpPayloadRequiredWithDefault()); EXPECT_EQ(response.status, 200); } @@ -539,7 +539,7 @@ TEST(PizzaAdminServiceServerResponseTest, SimpleRestJsonNoneRequiredHttpPayloadW TEST(PizzaAdminServiceServerResponseTest, SimpleRestJsonSomeHttpPayloadWithDefault) { class Handler final : public RecordingHandler { public: - smithy::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const opal::server::RequestContext&) override { (void)input; return [] { HttpPayloadWithDefaultOutput v{}; @@ -549,17 +549,17 @@ TEST(PizzaAdminServiceServerResponseTest, SimpleRestJsonSomeHttpPayloadWithDefau } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForHttpPayloadWithDefault()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForHttpPayloadWithDefault()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("\"custom value\"", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("\"custom value\"", response.body)); } // Use default value when there is no payload TEST(PizzaAdminServiceServerResponseTest, SimpleRestJsonNoneHttpPayloadWithDefault) { class Handler final : public RecordingHandler { public: - smithy::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const opal::server::RequestContext&) override { (void)input; return [] { HttpPayloadWithDefaultOutput v{}; @@ -569,7 +569,7 @@ TEST(PizzaAdminServiceServerResponseTest, SimpleRestJsonNoneHttpPayloadWithDefau } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForHttpPayloadWithDefault()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForHttpPayloadWithDefault()); EXPECT_EQ(response.status, 200); } @@ -577,7 +577,7 @@ TEST(PizzaAdminServiceServerResponseTest, SimpleRestJsonNoneHttpPayloadWithDefau TEST(PizzaAdminServiceServerResponseTest, OpenUnionsKnownTaggedUnionCase) { class Handler final : public RecordingHandler { public: - smithy::Outcome OpenUnions(const OpenUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OpenUnions(const OpenUnionsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { OpenUnionsOutput v{}; @@ -587,45 +587,45 @@ TEST(PizzaAdminServiceServerResponseTest, OpenUnionsKnownTaggedUnionCase) { } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForOpenUnions()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForOpenUnions()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"tagged\": {\"str\": \"string value\"}}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"tagged\": {\"str\": \"string value\"}}", response.body)); } // Return an unknown tagged union value in an open union TEST(PizzaAdminServiceServerResponseTest, OpenUnionsUnknownTaggedUnionCase) { class Handler final : public RecordingHandler { public: - smithy::Outcome OpenUnions(const OpenUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OpenUnions(const OpenUnionsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { OpenUnionsOutput v{}; v.data = OpenUnionsPayload::FromTagged(OpenTaggedUnion::FromOther([] { - smithy::DocumentMap map; + opal::DocumentMap map; map.emplace("whatisthis", [] { - smithy::DocumentMap map; - map.emplace("nested", smithy::Document(std::string("something different"))); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("nested", opal::Document(std::string("something different"))); + return opal::Document(std::move(map)); }()); - return smithy::Document(std::move(map)); + return opal::Document(std::move(map)); }())); return v; }(); } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForOpenUnions()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForOpenUnions()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"tagged\": {\"whatisthis\": {\"nested\": \"something different\"}}}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"tagged\": {\"whatisthis\": {\"nested\": \"something different\"}}}", response.body)); } // Return a known discriminated union value in an open union TEST(PizzaAdminServiceServerResponseTest, OpenUnionsKnownDiscriminatedUnionCase) { class Handler final : public RecordingHandler { public: - smithy::Outcome OpenUnions(const OpenUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OpenUnions(const OpenUnionsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { OpenUnionsOutput v{}; @@ -639,70 +639,70 @@ TEST(PizzaAdminServiceServerResponseTest, OpenUnionsKnownDiscriminatedUnionCase) } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForOpenUnions()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForOpenUnions()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"discriminated\": {\"key\": \"smol\", \"content\": \"some string\"}}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"discriminated\": {\"key\": \"smol\", \"content\": \"some string\"}}", response.body)); } // Return an unknown discriminated union value in an open union TEST(PizzaAdminServiceServerResponseTest, OpenUnionsUnknownDiscriminatedUnionCase) { class Handler final : public RecordingHandler { public: - smithy::Outcome OpenUnions(const OpenUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OpenUnions(const OpenUnionsInput& input, const opal::server::RequestContext&) override { (void)input; return [] { OpenUnionsOutput v{}; v.data = OpenUnionsPayload::FromDiscriminated(OpenDiscriminatedUnion::FromOther([] { - smithy::DocumentMap map; - map.emplace("key", smithy::Document(std::string("mysterious_and_important"))); - map.emplace("extras", smithy::Document(std::int64_t{42})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("key", opal::Document(std::string("mysterious_and_important"))); + map.emplace("extras", opal::Document(std::int64_t{42})); + return opal::Document(std::move(map)); }())); return v; }(); } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForOpenUnions()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForOpenUnions()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/json"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"discriminated\": {\"key\": \"mysterious_and_important\", \"extras\": 42}}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"discriminated\": {\"key\": \"mysterious_and_important\", \"extras\": 42}}", response.body)); } TEST(PizzaAdminServiceServerResponseTest, PreserveKeyOrderResponse) { class Handler final : public RecordingHandler { public: - smithy::Outcome PreserveOrder(const PreserveOrderInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PreserveOrder(const PreserveOrderInput& input, const opal::server::RequestContext&) override { (void)input; return [] { PreserveOrderOutput v{}; v.map = std::map{{"a", 1}, {"d", 2}, {"e", 3}, {"b", 4}}; v.document = [] { - smithy::DocumentMap map; - map.emplace("foo", smithy::Document(std::int64_t{1})); - map.emplace("a", smithy::Document(std::string("b"))); + opal::DocumentMap map; + map.emplace("foo", opal::Document(std::int64_t{1})); + map.emplace("a", opal::Document(std::string("b"))); map.emplace("c", [] { - smithy::DocumentList list; - return smithy::Document(std::move(list)); + opal::DocumentList list; + return opal::Document(std::move(list)); }()); - map.emplace("bar", smithy::Document(nullptr)); - return smithy::Document(std::move(map)); + map.emplace("bar", opal::Document(nullptr)); + return opal::Document(std::move(map)); }(); return v; }(); } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForPreserveOrder()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForPreserveOrder()); EXPECT_EQ(response.status, 200); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"map\":{\"a\":1,\"d\":2,\"e\":3,\"b\":4},\"document\":{\"foo\":1,\"a\":\"b\",\"c\":[],\"bar\":null}}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"map\":{\"a\":1,\"d\":2,\"e\":3,\"b\":4},\"document\":{\"foo\":1,\"a\":\"b\",\"c\":[],\"bar\":null}}", response.body)); } TEST(PizzaAdminServiceServerResponseTest, RoundTripDataResponse) { class Handler final : public RecordingHandler { public: - smithy::Outcome RoundTrip(const RoundTripInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RoundTrip(const RoundTripInput& input, const opal::server::RequestContext&) override { (void)input; return [] { RoundTripOutput v{}; @@ -715,16 +715,16 @@ TEST(PizzaAdminServiceServerResponseTest, RoundTripDataResponse) { } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForRoundTrip()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForRoundTrip()); EXPECT_EQ(response.status, 200); EXPECT_EQ(response.headers.Get("HEADER").value_or(""), "the header"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"label\":\"thelabel\",\"query\":\"the query\",\"body\":\"the body\"}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"label\":\"thelabel\",\"query\":\"the query\",\"body\":\"the body\"}", response.body)); } TEST(PizzaAdminServiceServerResponseTest, VersionOutput) { class Handler final : public RecordingHandler { public: - smithy::Outcome Version(const VersionInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Version(const VersionInput& input, const opal::server::RequestContext&) override { (void)input; return [] { VersionOutput v{}; @@ -734,17 +734,17 @@ TEST(PizzaAdminServiceServerResponseTest, VersionOutput) { } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForVersion()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForVersion()); EXPECT_EQ(response.status, 200); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("\"1.0\"", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("\"1.0\"", response.body)); } TEST(PizzaAdminServiceServerErrorTest, NotFoundError) { class Handler final : public RecordingHandler { public: - smithy::Outcome GetMenu(const GetMenuInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetMenu(const GetMenuInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("NotFoundError", ""); + opal::Error error = opal::Error::Modeled("NotFoundError", ""); error.set_detail([] { NotFoundError v{}; v.name = "unknown"; @@ -754,20 +754,20 @@ TEST(PizzaAdminServiceServerErrorTest, NotFoundError) { } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForGetMenu()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForGetMenu()); EXPECT_EQ(response.status, 404); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/json"); EXPECT_EQ(response.headers.Get("X-Error-Type").value_or(""), "NotFoundError"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"name\":\"unknown\"}\n", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"name\":\"unknown\"}\n", response.body)); } // the payload produced on price error TEST(PizzaAdminServiceServerErrorTest, PriceErrorTest) { class Handler final : public RecordingHandler { public: - smithy::Outcome AddMenuItem(const AddMenuItemInput& input, const smithy::server::RequestContext&) override { + opal::Outcome AddMenuItem(const AddMenuItemInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("PriceError", ""); + opal::Error error = opal::Error::Modeled("PriceError", ""); error.set_detail([] { PriceError v{}; v.message = "Price must be greater than 0"; @@ -778,11 +778,11 @@ TEST(PizzaAdminServiceServerErrorTest, PriceErrorTest) { } }; PizzaAdminServiceServer server(std::make_shared()); - const smithy::http::HttpResponse response = server.Handler()(MinimalRequestForAddMenuItem()); + const opal::http::HttpResponse response = server.Handler()(MinimalRequestForAddMenuItem()); EXPECT_EQ(response.status, 400); EXPECT_EQ(response.headers.Get("Content-Type").value_or(""), "application/json"); EXPECT_EQ(response.headers.Get("X-CODE").value_or(""), "400"); - EXPECT_TRUE(smithy::testing::JsonBodyEquals("{\"message\":\"Price must be greater than 0\"}", response.body)); + EXPECT_TRUE(opal::testing::JsonBodyEquals("{\"message\":\"Price must be greater than 0\"}", response.body)); } -} // namespace smithy::protocoltests::simplerestjson +} // namespace opal::protocoltests::simplerestjson diff --git a/protocol-tests/simplerestjson/generated/tests/smoke_test.cc b/protocol-tests/simplerestjson/generated/tests/smoke_test.cc index 93640b10..0b93633d 100644 --- a/protocol-tests/simplerestjson/generated/tests/smoke_test.cc +++ b/protocol-tests/simplerestjson/generated/tests/smoke_test.cc @@ -4,12 +4,12 @@ #include #include +#include "opal/protocoltests/simplerestjson/client.h" +#include "opal/protocoltests/simplerestjson/server.h" #include "smithy/client/config.h" #include "smithy/http/loopback.h" -#include "smithy/protocoltests/simplerestjson/client.h" -#include "smithy/protocoltests/simplerestjson/server.h" -namespace smithy::protocoltests::simplerestjson { +namespace opal::protocoltests::simplerestjson { // Smoke tests for the generated PizzaAdminService service: the generated client calls the // generated server over the in-memory loopback transport. A passing suite @@ -116,55 +116,55 @@ VersionOutput MinimalVersionOutput() { class SmokeHandler : public PizzaAdminServiceHandler { public: - smithy::Outcome AddMenuItem(const AddMenuItemInput& input, const smithy::server::RequestContext&) override { + opal::Outcome AddMenuItem(const AddMenuItemInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalAddMenuItemOutput(); } - smithy::Outcome CustomCode(const CustomCodeInput& input, const smithy::server::RequestContext&) override { + opal::Outcome CustomCode(const CustomCodeInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalCustomCodeOutput(); } - smithy::Outcome GetEnum(const GetEnumInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetEnum(const GetEnumInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalGetEnumOutput(); } - smithy::Outcome GetIntEnum(const GetIntEnumInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetIntEnum(const GetIntEnumInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalGetIntEnumOutput(); } - smithy::Outcome GetMenu(const GetMenuInput& input, const smithy::server::RequestContext&) override { + opal::Outcome GetMenu(const GetMenuInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalGetMenuOutput(); } - smithy::Outcome HeaderEndpoint(const HeaderEndpointInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HeaderEndpoint(const HeaderEndpointInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalHeaderEndpointOutput(); } - smithy::Outcome Health(const HealthInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Health(const HealthInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalHealthOutput(); } - smithy::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadRequiredWithDefault(const HttpPayloadRequiredWithDefaultInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalHttpPayloadRequiredWithDefaultOutput(); } - smithy::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadWithDefault(const HttpPayloadWithDefaultInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalHttpPayloadWithDefaultOutput(); } - smithy::Outcome OpenUnions(const OpenUnionsInput& input, const smithy::server::RequestContext&) override { + opal::Outcome OpenUnions(const OpenUnionsInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalOpenUnionsOutput(); } - smithy::Outcome PreserveOrder(const PreserveOrderInput& input, const smithy::server::RequestContext&) override { + opal::Outcome PreserveOrder(const PreserveOrderInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalPreserveOrderOutput(); } - smithy::Outcome RoundTrip(const RoundTripInput& input, const smithy::server::RequestContext&) override { + opal::Outcome RoundTrip(const RoundTripInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalRoundTripOutput(); } - smithy::Outcome Version(const VersionInput& input, const smithy::server::RequestContext&) override { + opal::Outcome Version(const VersionInput& input, const opal::server::RequestContext&) override { (void)input; return MinimalVersionOutput(); } @@ -172,9 +172,9 @@ class SmokeHandler : public PizzaAdminServiceHandler { PizzaAdminServiceClient MakeClient(std::shared_ptr handler) { PizzaAdminServiceServer server(std::move(handler)); - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); (void)loopback->Start(server.Handler()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; // wire-exact tests: no retries config.http_client = loopback; // Create cannot fail when a transport is injected. @@ -347,9 +347,9 @@ TEST(PizzaAdminServiceSmokeTest, VersionRoundTrips) { TEST(PizzaAdminServiceSmokeTest, ModeledErrorsMapAcrossTheWire) { class FailingHandler final : public SmokeHandler { public: - smithy::Outcome AddMenuItem(const AddMenuItemInput& input, const smithy::server::RequestContext&) override { + opal::Outcome AddMenuItem(const AddMenuItemInput& input, const opal::server::RequestContext&) override { (void)input; - smithy::Error error = smithy::Error::Modeled("GenericServerError", "smoke"); + opal::Error error = opal::Error::Modeled("GenericServerError", "smoke"); auto detail = [] { GenericServerError v{}; return v; @@ -378,10 +378,10 @@ TEST(PizzaAdminServiceSmokeTest, ModeledErrorsMapAcrossTheWire) { input.restaurant = "smoke"; const auto outcome = client.AddMenuItem(input); ASSERT_FALSE(outcome.ok()); - EXPECT_EQ(outcome.error().kind(), smithy::ErrorKind::kModeled); + EXPECT_EQ(outcome.error().kind(), opal::ErrorKind::kModeled); EXPECT_EQ(outcome.error().code(), "GenericServerError"); EXPECT_EQ(outcome.error().message(), "smoke"); EXPECT_NE(outcome.error().detail(), nullptr); } -} // namespace smithy::protocoltests::simplerestjson +} // namespace opal::protocoltests::simplerestjson diff --git a/protocol-tests/simplerestjson/malformed/pattern_violation_test.cc b/protocol-tests/simplerestjson/malformed/pattern_violation_test.cc index eb29bd96..db07cb21 100644 --- a/protocol-tests/simplerestjson/malformed/pattern_violation_test.cc +++ b/protocol-tests/simplerestjson/malformed/pattern_violation_test.cc @@ -18,18 +18,18 @@ namespace { class RecordingHandler : public RoundTripRestHandler { public: - smithy::Outcome DescribeSink(const DescribeSinkInput&, - const smithy::server::RequestContext&) override { + opal::Outcome DescribeSink(const DescribeSinkInput&, + const opal::server::RequestContext&) override { ++calls; return DescribeSinkOutput{}; } - smithy::Outcome PutSink(const PutSinkInput&, - const smithy::server::RequestContext&) override { + opal::Outcome PutSink(const PutSinkInput&, + const opal::server::RequestContext&) override { ++calls; return PutSinkOutput{}; } - smithy::Outcome UploadAttachment( - const UploadAttachmentInput&, const smithy::server::RequestContext&) override { + opal::Outcome UploadAttachment( + const UploadAttachmentInput&, const opal::server::RequestContext&) override { ++calls; return UploadAttachmentOutput{}; } @@ -39,17 +39,17 @@ class RecordingHandler : public RoundTripRestHandler { class PatternViolationTest : public testing::Test { protected: // Returns the single fieldList entry of a 400 ValidationException. - smithy::Document Reject(const std::string& target) { - smithy::http::HttpRequest request; + opal::Document Reject(const std::string& target) { + opal::http::HttpRequest request; request.method = "GET"; request.target = target; - const smithy::http::HttpResponse response = server_.Handler()(request); + const opal::http::HttpResponse response = server_.Handler()(request); EXPECT_EQ(response.status, 400) << response.body; EXPECT_EQ(response.headers.Get("x-error-type").value_or(""), "ValidationException"); EXPECT_EQ(handler_->calls, 0); - auto body = smithy::json::Decode(response.body); + auto body = opal::json::Decode(response.body); EXPECT_TRUE(body.ok()) << response.body; - const smithy::Document* field_list = body->Find("fieldList"); + const opal::Document* field_list = body->Find("fieldList"); EXPECT_NE(field_list, nullptr) << response.body; EXPECT_EQ(field_list->as_list().size(), 1u) << response.body; return field_list->as_list()[0]; @@ -60,7 +60,7 @@ class PatternViolationTest : public testing::Test { }; TEST_F(PatternViolationTest, PatternViolationReportsTheExactMessage) { - const smithy::Document failure = Reject("/sinks/bad!id"); + const opal::Document failure = Reject("/sinks/bad!id"); EXPECT_EQ(failure.Find("path")->as_string(), "/sinkId"); EXPECT_EQ(failure.Find("message")->as_string(), "Value at '/sinkId' failed to satisfy constraint: Member must satisfy regular " @@ -68,7 +68,7 @@ TEST_F(PatternViolationTest, PatternViolationReportsTheExactMessage) { } TEST_F(PatternViolationTest, LengthViolationReportsTheExactMessage) { - const smithy::Document failure = Reject("/sinks/" + std::string(33, 'a')); + const opal::Document failure = Reject("/sinks/" + std::string(33, 'a')); EXPECT_EQ(failure.Find("path")->as_string(), "/sinkId"); EXPECT_EQ(failure.Find("message")->as_string(), "Value with length 33 at '/sinkId' failed to satisfy constraint: Member must have " diff --git a/protocol-tests/simplerestjson/malformed/server_malformed_test.cc b/protocol-tests/simplerestjson/malformed/server_malformed_test.cc index ffd185de..5b077ad8 100644 --- a/protocol-tests/simplerestjson/malformed/server_malformed_test.cc +++ b/protocol-tests/simplerestjson/malformed/server_malformed_test.cc @@ -11,78 +11,78 @@ #include #include +#include "opal/protocoltests/simplerestjson/server.h" #include "smithy/json/json.h" -#include "smithy/protocoltests/simplerestjson/server.h" -namespace smithy::protocoltests::simplerestjson { +namespace opal::protocoltests::simplerestjson { namespace { // Counts invocations; a malformed request must be rejected before any // operation runs, so every test asserts calls stays 0. class RecordingHandler : public PizzaAdminServiceHandler { public: - smithy::Outcome AddMenuItem(const AddMenuItemInput&, - const smithy::server::RequestContext&) override { + opal::Outcome AddMenuItem(const AddMenuItemInput&, + const opal::server::RequestContext&) override { ++calls; return AddMenuItemOutput{}; } - smithy::Outcome CustomCode(const CustomCodeInput&, - const smithy::server::RequestContext&) override { + opal::Outcome CustomCode(const CustomCodeInput&, + const opal::server::RequestContext&) override { ++calls; return CustomCodeOutput{}; } - smithy::Outcome GetEnum(const GetEnumInput&, - const smithy::server::RequestContext&) override { + opal::Outcome GetEnum(const GetEnumInput&, + const opal::server::RequestContext&) override { ++calls; return GetEnumOutput{}; } - smithy::Outcome GetIntEnum(const GetIntEnumInput&, - const smithy::server::RequestContext&) override { + opal::Outcome GetIntEnum(const GetIntEnumInput&, + const opal::server::RequestContext&) override { ++calls; return GetIntEnumOutput{}; } - smithy::Outcome GetMenu(const GetMenuInput&, - const smithy::server::RequestContext&) override { + opal::Outcome GetMenu(const GetMenuInput&, + const opal::server::RequestContext&) override { ++calls; return GetMenuOutput{}; } - smithy::Outcome HeaderEndpoint( - const HeaderEndpointInput&, const smithy::server::RequestContext&) override { + opal::Outcome HeaderEndpoint(const HeaderEndpointInput&, + const opal::server::RequestContext&) override { ++calls; return HeaderEndpointOutput{}; } - smithy::Outcome Health(const HealthInput&, - const smithy::server::RequestContext&) override { + opal::Outcome Health(const HealthInput&, + const opal::server::RequestContext&) override { ++calls; return HealthOutput{}; } - smithy::Outcome HttpPayloadRequiredWithDefault( - const HttpPayloadRequiredWithDefaultInput&, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadRequiredWithDefault( + const HttpPayloadRequiredWithDefaultInput&, const opal::server::RequestContext&) override { ++calls; return HttpPayloadRequiredWithDefaultOutput{}; } - smithy::Outcome HttpPayloadWithDefault( - const HttpPayloadWithDefaultInput&, const smithy::server::RequestContext&) override { + opal::Outcome HttpPayloadWithDefault( + const HttpPayloadWithDefaultInput&, const opal::server::RequestContext&) override { ++calls; return HttpPayloadWithDefaultOutput{}; } - smithy::Outcome OpenUnions(const OpenUnionsInput&, - const smithy::server::RequestContext&) override { + opal::Outcome OpenUnions(const OpenUnionsInput&, + const opal::server::RequestContext&) override { ++calls; return OpenUnionsOutput{}; } - smithy::Outcome PreserveOrder( - const PreserveOrderInput&, const smithy::server::RequestContext&) override { + opal::Outcome PreserveOrder(const PreserveOrderInput&, + const opal::server::RequestContext&) override { ++calls; return PreserveOrderOutput{}; } - smithy::Outcome RoundTrip(const RoundTripInput&, - const smithy::server::RequestContext&) override { + opal::Outcome RoundTrip(const RoundTripInput&, + const opal::server::RequestContext&) override { ++calls; return RoundTripOutput{}; } - smithy::Outcome Version(const VersionInput&, - const smithy::server::RequestContext&) override { + opal::Outcome Version(const VersionInput&, + const opal::server::RequestContext&) override { ++calls; return VersionOutput{}; } @@ -91,7 +91,7 @@ class RecordingHandler : public PizzaAdminServiceHandler { class SimpleRestJsonMalformedTest : public testing::Test { protected: - smithy::http::HttpResponse Send(smithy::http::HttpRequest request) { + opal::http::HttpResponse Send(opal::http::HttpRequest request) { return server_.Handler()(request); } @@ -100,7 +100,7 @@ class SimpleRestJsonMalformedTest : public testing::Test { }; TEST_F(SimpleRestJsonMalformedTest, UnknownRouteIs404) { - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/no-such-route"; EXPECT_EQ(Send(request).status, 404); @@ -108,7 +108,7 @@ TEST_F(SimpleRestJsonMalformedTest, UnknownRouteIs404) { } TEST_F(SimpleRestJsonMalformedTest, WrongMethodIs405) { - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/health"; EXPECT_EQ(Send(request).status, 405); @@ -116,7 +116,7 @@ TEST_F(SimpleRestJsonMalformedTest, WrongMethodIs405) { } TEST_F(SimpleRestJsonMalformedTest, UnparseableJsonBodyIsSerializationException) { - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/restaurant/r1/menu/item"; request.headers.Set("content-type", "application/json"); @@ -128,7 +128,7 @@ TEST_F(SimpleRestJsonMalformedTest, UnparseableJsonBodyIsSerializationException) } TEST_F(SimpleRestJsonMalformedTest, WrongContentTypeIs415) { - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/restaurant/r1/menu/item"; request.headers.Set("content-type", "text/plain"); @@ -141,7 +141,7 @@ TEST_F(SimpleRestJsonMalformedTest, WrongContentTypeIs415) { TEST_F(SimpleRestJsonMalformedTest, IntEnumLabelBeyondInt32IsRejectedBeforeTheHandler) { // The label parser bounds intEnum at int32 like Integer (issue #109's // serde-side fix pins the body path; this pins the text path). - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/get-int-enum/99999999999"; const auto response = Send(request); @@ -154,7 +154,7 @@ TEST_F(SimpleRestJsonMalformedTest, IntEnumLabelOutsideTheValueSetFailsValidatio // In-range but unknown values fail membership validation with the // string-enum suite message, ints spelled the way smithy-rs emits them // (issue #109). - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/get-int-enum/3"; const auto response = Send(request); @@ -162,9 +162,9 @@ TEST_F(SimpleRestJsonMalformedTest, IntEnumLabelOutsideTheValueSetFailsValidatio EXPECT_EQ(response.headers.Get("x-error-type").value_or(""), "ValidationException"); EXPECT_EQ(handler_->calls, 0); - const auto body = smithy::json::Decode(response.body); + const auto body = opal::json::Decode(response.body); ASSERT_TRUE(body.ok()) << response.body; - const smithy::Document* field_list = body->Find("fieldList"); + const opal::Document* field_list = body->Find("fieldList"); ASSERT_NE(field_list, nullptr) << response.body; ASSERT_EQ(field_list->as_list().size(), 1u) << response.body; const auto& failure = field_list->as_list()[0]; @@ -175,7 +175,7 @@ TEST_F(SimpleRestJsonMalformedTest, IntEnumLabelOutsideTheValueSetFailsValidatio } TEST_F(SimpleRestJsonMalformedTest, EnumLabelViolationReportsTheSuiteExactMessage) { - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "GET"; request.target = "/get-enum/bogus"; const auto response = Send(request); @@ -183,9 +183,9 @@ TEST_F(SimpleRestJsonMalformedTest, EnumLabelViolationReportsTheSuiteExactMessag EXPECT_EQ(response.headers.Get("x-error-type").value_or(""), "ValidationException"); EXPECT_EQ(handler_->calls, 0); - const auto body = smithy::json::Decode(response.body); + const auto body = opal::json::Decode(response.body); ASSERT_TRUE(body.ok()) << response.body; - const smithy::Document* field_list = body->Find("fieldList"); + const opal::Document* field_list = body->Find("fieldList"); ASSERT_NE(field_list, nullptr) << response.body; ASSERT_EQ(field_list->as_list().size(), 1u) << response.body; const auto& failure = field_list->as_list()[0]; @@ -196,4 +196,4 @@ TEST_F(SimpleRestJsonMalformedTest, EnumLabelViolationReportsTheSuiteExactMessag } } // namespace -} // namespace smithy::protocoltests::simplerestjson +} // namespace opal::protocoltests::simplerestjson diff --git a/protocol-tests/unions/union_accessor_test.cc b/protocol-tests/unions/union_accessor_test.cc index 2c3408ec..ab89ae90 100644 --- a/protocol-tests/unions/union_accessor_test.cc +++ b/protocol-tests/unions/union_accessor_test.cc @@ -42,7 +42,7 @@ TEST(UnionAccessorTest, CaseNameTracksTheEngagedMember) { } TEST(UnionAccessorTest, VisitDispatchesOverMembersAndEmptyState) { - const auto describe = smithy::Overloaded{ + const auto describe = opal::Overloaded{ [](const PendingStatus& p) { return "pending:" + std::to_string(p.position); }, [](const ReadyStatus&) { return std::string("ready"); }, [](const CancelledStatus&) { return std::string("cancelled"); }, diff --git a/protocol-tests/unions/union_cbor_test.cc b/protocol-tests/unions/union_cbor_test.cc index 62aeb81e..ef6944e3 100644 --- a/protocol-tests/unions/union_cbor_test.cc +++ b/protocol-tests/unions/union_cbor_test.cc @@ -25,36 +25,36 @@ namespace example::roundtrip::rpc { namespace { -smithy::Document TextChoiceDoc(const std::string& text) { - smithy::DocumentMap map; - map.emplace("text", smithy::Document(text)); - return smithy::Document(std::move(map)); +opal::Document TextChoiceDoc(const std::string& text) { + opal::DocumentMap map; + map.emplace("text", opal::Document(text)); + return opal::Document(std::move(map)); } -smithy::Document CountChoiceDoc(std::int64_t count) { - smithy::DocumentMap map; - map.emplace("count", smithy::Document(count)); - return smithy::Document(std::move(map)); +opal::Document CountChoiceDoc(std::int64_t count) { + opal::DocumentMap map; + map.emplace("count", opal::Document(count)); + return opal::Document(std::move(map)); } -smithy::Document NestedChoiceDoc(const std::string& label, std::int64_t depth) { - smithy::DocumentMap nested; - nested.emplace("label", smithy::Document(label)); - nested.emplace("depth", smithy::Document(depth)); - smithy::DocumentMap map; - map.emplace("nested", smithy::Document(std::move(nested))); - return smithy::Document(std::move(map)); +opal::Document NestedChoiceDoc(const std::string& label, std::int64_t depth) { + opal::DocumentMap nested; + nested.emplace("label", opal::Document(label)); + nested.emplace("depth", opal::Document(depth)); + opal::DocumentMap map; + map.emplace("nested", opal::Document(std::move(nested))); + return opal::Document(std::move(map)); } // A wire body for PutSinkRpc carrying only the members the union cell needs. -std::string BodyWithChoice(const smithy::Document& choice) { - smithy::DocumentMap sink; - sink.emplace("name", smithy::Document("n")); +std::string BodyWithChoice(const opal::Document& choice) { + opal::DocumentMap sink; + sink.emplace("name", opal::Document("n")); sink.emplace("choice", choice); - smithy::DocumentMap body; - body.emplace("sinkId", smithy::Document("s1")); - body.emplace("sink", smithy::Document(std::move(sink))); - return smithy::cbor::Encode(smithy::Document(std::move(body))).ToString(); + opal::DocumentMap body; + body.emplace("sinkId", opal::Document("s1")); + body.emplace("sink", opal::Document(std::move(sink))); + return opal::cbor::Encode(opal::Document(std::move(body))).ToString(); } PutSinkRpcInput InputWithChoice(SinkChoice choice) { @@ -68,27 +68,27 @@ PutSinkRpcInput InputWithChoice(SinkChoice choice) { } // The choice subdocument of a captured PutSinkRpc request body. -smithy::Document ChoiceOf(const std::string& wire_body) { - auto doc = smithy::cbor::Decode(smithy::Blob::FromString(wire_body)); +opal::Document ChoiceOf(const std::string& wire_body) { + auto doc = opal::cbor::Decode(opal::Blob::FromString(wire_body)); EXPECT_TRUE(doc.ok()); - if (!doc.ok()) return smithy::Document(nullptr); - const smithy::Document* sink = doc->Find("sink"); + if (!doc.ok()) return opal::Document(nullptr); + const opal::Document* sink = doc->Find("sink"); EXPECT_NE(sink, nullptr); - if (sink == nullptr) return smithy::Document(nullptr); - const smithy::Document* choice = sink->Find("choice"); + if (sink == nullptr) return opal::Document(nullptr); + const opal::Document* choice = sink->Find("choice"); EXPECT_NE(choice, nullptr); - return choice == nullptr ? smithy::Document(nullptr) : *choice; + return choice == nullptr ? opal::Document(nullptr) : *choice; } class UnionCborClientTest : public testing::Test { protected: void SetUp() override { - transport_ = std::make_shared(); - smithy::DocumentMap ok_body; - ok_body.emplace("sinkId", smithy::Document("s1")); - transport_->next_response = smithy::http::HttpResponse{ - 200, {}, smithy::cbor::Encode(smithy::Document(std::move(ok_body))).ToString()}; - smithy::ClientConfig config; + transport_ = std::make_shared(); + opal::DocumentMap ok_body; + ok_body.emplace("sinkId", opal::Document("s1")); + transport_->next_response = opal::http::HttpResponse{ + 200, {}, opal::cbor::Encode(opal::Document(std::move(ok_body))).ToString()}; + opal::ClientConfig config; config.retry.max_attempts = 1; config.http_client = transport_; auto client = RoundTripRpcClient::Create(std::move(config)); @@ -96,14 +96,14 @@ class UnionCborClientTest : public testing::Test { client_ = std::make_unique(std::move(*client)); } - std::shared_ptr transport_; + std::shared_ptr transport_; std::unique_ptr client_; }; TEST_F(UnionCborClientTest, EncodesEachVariantAsASingleMemberMap) { const struct { SinkChoice choice; - smithy::Document expected; + opal::Document expected; } cells[] = { {SinkChoice::FromText("wire text"), TextChoiceDoc("wire text")}, {SinkChoice::FromCount(-7), CountChoiceDoc(-7)}, @@ -117,7 +117,7 @@ TEST_F(UnionCborClientTest, EncodesEachVariantAsASingleMemberMap) { }; for (const auto& cell : cells) { ASSERT_TRUE(client_->PutSinkRpc(InputWithChoice(cell.choice)).ok()); - const smithy::Document choice = ChoiceOf(transport_->last_request.body); + const opal::Document choice = ChoiceOf(transport_->last_request.body); ASSERT_TRUE(choice.is_map()); EXPECT_EQ(choice.as_map().size(), 1u) << "a union must serialize exactly one member"; EXPECT_EQ(choice, cell.expected); @@ -127,7 +127,7 @@ TEST_F(UnionCborClientTest, EncodesEachVariantAsASingleMemberMap) { TEST_F(UnionCborClientTest, DecodesEachVariantFromAResponse) { const struct { - smithy::Document wire; + opal::Document wire; SinkChoice expected; } cells[] = { {TextChoiceDoc("from server"), SinkChoice::FromText("from server")}, @@ -140,7 +140,7 @@ TEST_F(UnionCborClientTest, DecodesEachVariantFromAResponse) { }())}, }; for (const auto& cell : cells) { - transport_->next_response = smithy::http::HttpResponse{200, {}, BodyWithChoice(cell.wire)}; + transport_->next_response = opal::http::HttpResponse{200, {}, BodyWithChoice(cell.wire)}; const auto outcome = client_->PutSinkRpc(InputWithChoice(SinkChoice::FromCount(0))); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); ASSERT_TRUE(outcome->sink.has_value()); @@ -154,34 +154,34 @@ TEST_F(UnionCborClientTest, RejectsInvalidUnionsInResponses) { // for the wrong reason (a generic parse failure, a missing-field error) // would mask the exactly-one-member rule this test defends. const struct { - smithy::Document wire; + opal::Document wire; const char* why; const char* diagnosis; } cells[] = { - {smithy::Document(smithy::DocumentMap{}), "empty union", "expected exactly one union member"}, + {opal::Document(opal::DocumentMap{}), "empty union", "expected exactly one union member"}, {[] { - smithy::DocumentMap map; - map.emplace("text", smithy::Document("a")); - map.emplace("count", smithy::Document(std::int64_t{1})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("text", opal::Document("a")); + map.emplace("count", opal::Document(std::int64_t{1})); + return opal::Document(std::move(map)); }(), "two members set", "expected exactly one union member"}, {[] { - smithy::DocumentMap map; - map.emplace("futureMember", smithy::Document(std::int64_t{1})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("futureMember", opal::Document(std::int64_t{1})); + return opal::Document(std::move(map)); }(), "unknown member", "unknown or missing union member"}, {[] { - smithy::DocumentMap map; - map.emplace("text", smithy::Document(nullptr)); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("text", opal::Document(nullptr)); + return opal::Document(std::move(map)); }(), "null member", "unknown or missing union member"}, - {smithy::Document("not a map"), "non-map union", "expected a map on the wire"}, + {opal::Document("not a map"), "non-map union", "expected a map on the wire"}, }; for (const auto& cell : cells) { - transport_->next_response = smithy::http::HttpResponse{200, {}, BodyWithChoice(cell.wire)}; + transport_->next_response = opal::http::HttpResponse{200, {}, BodyWithChoice(cell.wire)}; const auto outcome = client_->PutSinkRpc(InputWithChoice(SinkChoice::FromCount(0))); ASSERT_FALSE(outcome.ok()) << cell.why; EXPECT_NE(outcome.error().message().find(cell.diagnosis), std::string::npos) @@ -190,11 +190,11 @@ TEST_F(UnionCborClientTest, RejectsInvalidUnionsInResponses) { } TEST_F(UnionCborClientTest, ToleratesATypeDiscriminatorNextToTheMember) { - smithy::DocumentMap map; - map.emplace("__type", smithy::Document("example.roundtrip#SinkChoice")); - map.emplace("text", smithy::Document("discriminated")); + opal::DocumentMap map; + map.emplace("__type", opal::Document("example.roundtrip#SinkChoice")); + map.emplace("text", opal::Document("discriminated")); transport_->next_response = - smithy::http::HttpResponse{200, {}, BodyWithChoice(smithy::Document(std::move(map)))}; + opal::http::HttpResponse{200, {}, BodyWithChoice(opal::Document(std::move(map)))}; const auto outcome = client_->PutSinkRpc(InputWithChoice(SinkChoice::FromCount(0))); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); EXPECT_EQ(*outcome->sink->choice, SinkChoice::FromText("discriminated")); @@ -204,16 +204,15 @@ TEST_F(UnionCborClientTest, ToleratesATypeDiscriminatorNextToTheMember) { class RecordingHandler : public RoundTripRpcHandler { public: - smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome PutSinkRpc(const PutSinkRpcInput& input, + const opal::server::RequestContext&) override { last = input; PutSinkRpcOutput output; output.sinkId = input.sinkId; output.sink = input.sink; // echo, so the response leg is exercised too return output; } - smithy::Outcome Ping(const PingInput&, - const smithy::server::RequestContext&) override { + opal::Outcome Ping(const PingInput&, const opal::server::RequestContext&) override { return PingOutput{}; } std::optional last; @@ -221,8 +220,8 @@ class RecordingHandler : public RoundTripRpcHandler { class UnionCborServerTest : public testing::Test { protected: - smithy::http::HttpResponse Send(const std::string& body) { - return server_.Handler()(smithy::testing::Rpcv2CborRequest("RoundTripRpc", "PutSinkRpc", body)); + opal::http::HttpResponse Send(const std::string& body) { + return server_.Handler()(opal::testing::Rpcv2CborRequest("RoundTripRpc", "PutSinkRpc", body)); } std::shared_ptr handler_ = std::make_shared(); @@ -231,7 +230,7 @@ class UnionCborServerTest : public testing::Test { TEST_F(UnionCborServerTest, DecodesEachVariantAndEchoesItBack) { const struct { - smithy::Document wire; + opal::Document wire; SinkChoice expected; } cells[] = { {TextChoiceDoc("to server"), SinkChoice::FromText("to server")}, @@ -258,21 +257,21 @@ TEST_F(UnionCborServerTest, DecodesEachVariantAndEchoesItBack) { TEST_F(UnionCborServerTest, RejectsInvalidUnionsBeforeTheHandler) { const struct { - smithy::Document wire; + opal::Document wire; const char* diagnosis; } cells[] = { - {smithy::Document(smithy::DocumentMap{}), "expected exactly one union member"}, + {opal::Document(opal::DocumentMap{}), "expected exactly one union member"}, {[] { - smithy::DocumentMap map; - map.emplace("text", smithy::Document("a")); - map.emplace("count", smithy::Document(std::int64_t{1})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("text", opal::Document("a")); + map.emplace("count", opal::Document(std::int64_t{1})); + return opal::Document(std::move(map)); }(), "expected exactly one union member"}, {[] { - smithy::DocumentMap map; - map.emplace("futureMember", smithy::Document(std::int64_t{1})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("futureMember", opal::Document(std::int64_t{1})); + return opal::Document(std::move(map)); }(), "unknown or missing union member"}, }; @@ -281,9 +280,9 @@ TEST_F(UnionCborServerTest, RejectsInvalidUnionsBeforeTheHandler) { EXPECT_EQ(response.status, 400) << response.body; EXPECT_FALSE(handler_->last.has_value()); // The 400's error body names the union rule that was violated. - auto body = smithy::cbor::Decode(smithy::Blob::FromString(response.body)); + auto body = opal::cbor::Decode(opal::Blob::FromString(response.body)); ASSERT_TRUE(body.ok()); - const smithy::Document* message = body->Find("message"); + const opal::Document* message = body->Find("message"); ASSERT_NE(message, nullptr); EXPECT_NE(message->as_string().find(cell.diagnosis), std::string::npos) << message->as_string(); } diff --git a/protocol-tests/unions/union_gauntlet_cbor_test.cc b/protocol-tests/unions/union_gauntlet_cbor_test.cc index 8a909219..d2300d5b 100644 --- a/protocol-tests/unions/union_gauntlet_cbor_test.cc +++ b/protocol-tests/unions/union_gauntlet_cbor_test.cc @@ -29,66 +29,66 @@ namespace compile::unions::cbor { namespace { -smithy::Document Doc(smithy::DocumentMap map) { return smithy::Document(std::move(map)); } +opal::Document Doc(opal::DocumentMap map) { return opal::Document(std::move(map)); } -smithy::Document OneMember(const std::string& name, smithy::Document value) { - smithy::DocumentMap map; +opal::Document OneMember(const std::string& name, opal::Document value) { + opal::DocumentMap map; map.emplace(name, std::move(value)); return Doc(std::move(map)); } -std::string RequestBody(const smithy::Document& choice) { - smithy::DocumentMap body; - body.emplace("id", smithy::Document("a")); +std::string RequestBody(const opal::Document& choice) { + opal::DocumentMap body; + body.emplace("id", opal::Document("a")); body.emplace("choice", choice); - return smithy::cbor::Encode(Doc(std::move(body))).ToString(); + return opal::cbor::Encode(Doc(std::move(body))).ToString(); } // One row per member kind: the typed value and its wire subdocument. struct Cell { const char* name; BigUnion typed; - smithy::Document wire; + opal::Document wire; }; std::vector MemberCells() { - const auto timestamp = smithy::Timestamp::FromEpochMilliseconds(1515531081000); - smithy::DocumentList names; + const auto timestamp = opal::Timestamp::FromEpochMilliseconds(1515531081000); + opal::DocumentList names; names.emplace_back("x"); names.emplace_back("y"); - smithy::DocumentMap attributes; - attributes.emplace("k", smithy::Document("v")); - smithy::DocumentMap node; - node.emplace("label", smithy::Document("outer")); - node.emplace("next", OneMember("label", smithy::Document("inner"))); + opal::DocumentMap attributes; + attributes.emplace("k", opal::Document("v")); + opal::DocumentMap node; + node.emplace("label", opal::Document("outer")); + node.emplace("next", OneMember("label", opal::Document("inner"))); Node inner; inner.label = "inner"; Node outer; outer.label = "outer"; - outer.next = smithy::Boxed(inner); + outer.next = opal::Boxed(inner); std::vector cells; - cells.push_back({"text", BigUnion::FromText("t"), OneMember("text", smithy::Document("t"))}); - cells.push_back({"flag", BigUnion::FromFlag(true), OneMember("flag", smithy::Document(true))}); + cells.push_back({"text", BigUnion::FromText("t"), OneMember("text", opal::Document("t"))}); + cells.push_back({"flag", BigUnion::FromFlag(true), OneMember("flag", opal::Document(true))}); cells.push_back( - {"small", BigUnion::FromSmall(-3), OneMember("small", smithy::Document(std::int64_t{-3}))}); + {"small", BigUnion::FromSmall(-3), OneMember("small", opal::Document(std::int64_t{-3}))}); cells.push_back({"big", BigUnion::FromBig(std::int64_t{1} << 40), - OneMember("big", smithy::Document(std::int64_t{1} << 40))}); - cells.push_back({"ratio", BigUnion::FromRatio(1.5), OneMember("ratio", smithy::Document(1.5))}); - cells.push_back({"data", BigUnion::FromData(smithy::Blob::FromString("\x01\x02")), - OneMember("data", smithy::Document(smithy::Blob::FromString("\x01\x02")))}); + OneMember("big", opal::Document(std::int64_t{1} << 40))}); + cells.push_back({"ratio", BigUnion::FromRatio(1.5), OneMember("ratio", opal::Document(1.5))}); + cells.push_back({"data", BigUnion::FromData(opal::Blob::FromString("\x01\x02")), + OneMember("data", opal::Document(opal::Blob::FromString("\x01\x02")))}); cells.push_back({"when", BigUnion::FromWhen(timestamp), - OneMember("when", smithy::Document::FromTimestamp( - timestamp, smithy::TimestampFormat::kEpochSeconds))}); + OneMember("when", opal::Document::FromTimestamp( + timestamp, opal::TimestampFormat::kEpochSeconds))}); cells.push_back({"names", BigUnion::FromNames({"x", "y"}), - OneMember("names", smithy::Document(std::move(names)))}); + OneMember("names", opal::Document(std::move(names)))}); cells.push_back({"attributes", BigUnion::FromAttributes({{"k", "v"}}), OneMember("attributes", Doc(std::move(attributes)))}); cells.push_back({"grade", BigUnion::FromGrade(Grade::Value::kPass), - OneMember("grade", smithy::Document("pass"))}); + OneMember("grade", opal::Document("pass"))}); cells.push_back({"rank", BigUnion::FromRank(Rank::kFirst), - OneMember("rank", smithy::Document(std::int64_t{1}))}); + OneMember("rank", opal::Document(std::int64_t{1}))}); cells.push_back({"node", BigUnion::FromNode(outer), OneMember("node", Doc(std::move(node)))}); return cells; } @@ -97,11 +97,11 @@ std::vector MemberCells() { // server encode with the client's two directions anchoring the ends. class EchoHandler : public UnionGauntletHandler { public: - smithy::Outcome EchoChoice(const EchoChoiceInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome EchoChoice(const EchoChoiceInput& input, + const opal::server::RequestContext&) override { last = input; if (reject) { - smithy::Error error = smithy::Error::Modeled("ChoiceRejected", "no thanks"); + opal::Error error = opal::Error::Modeled("ChoiceRejected", "no thanks"); ChoiceRejected detail; detail.message = "no thanks"; detail.offending = input.choice; @@ -122,14 +122,14 @@ class UnionGauntletCborTest : public testing::Test { void SetUp() override { handler_ = std::make_shared(); server_ = std::make_unique(handler_); - transport_ = std::make_shared(); + transport_ = std::make_shared(); } // A client whose requests go to the real generated server. UnionGauntletClient LiveClient() { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); EXPECT_TRUE(loopback->Start(server_->Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; config.http_client = loopback; auto client = UnionGauntletClient::Create(std::move(config)); @@ -139,7 +139,7 @@ class UnionGauntletCborTest : public testing::Test { // A client whose requests are captured and answered with a canned body. UnionGauntletClient CapturedClient() { - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; config.http_client = transport_; auto client = UnionGauntletClient::Create(std::move(config)); @@ -149,21 +149,21 @@ class UnionGauntletCborTest : public testing::Test { std::shared_ptr handler_; std::unique_ptr server_; - std::shared_ptr transport_; + std::shared_ptr transport_; }; TEST_F(UnionGauntletCborTest, EveryMemberKindEncodesToItsWireSubdocument) { auto client = CapturedClient(); - transport_->next_response = smithy::http::HttpResponse{ - 200, {}, smithy::cbor::Encode(OneMember("id", smithy::Document("a"))).ToString()}; + transport_->next_response = opal::http::HttpResponse{ + 200, {}, opal::cbor::Encode(OneMember("id", opal::Document("a"))).ToString()}; for (const Cell& cell : MemberCells()) { EchoChoiceInput input; input.id = "a"; input.choice = cell.typed; ASSERT_TRUE(client.EchoChoice(input).ok()) << cell.name; - auto body = smithy::cbor::Decode(smithy::Blob::FromString(transport_->last_request.body)); + auto body = opal::cbor::Decode(opal::Blob::FromString(transport_->last_request.body)); ASSERT_TRUE(body.ok()) << cell.name; - const smithy::Document* choice = body->Find("choice"); + const opal::Document* choice = body->Find("choice"); ASSERT_NE(choice, nullptr) << cell.name; ASSERT_TRUE(choice->is_map()) << cell.name; EXPECT_EQ(choice->as_map().size(), 1u) << cell.name; @@ -195,8 +195,8 @@ TEST_F(UnionGauntletCborTest, EveryMemberKindSurvivesTheFullClientServerLoop) { // level pin that Document-equality checks cannot provide. TEST_F(UnionGauntletCborTest, RequestBodyIsByteExact) { auto client = CapturedClient(); - transport_->next_response = smithy::http::HttpResponse{ - 200, {}, smithy::cbor::Encode(OneMember("id", smithy::Document("a"))).ToString()}; + transport_->next_response = opal::http::HttpResponse{ + 200, {}, opal::cbor::Encode(OneMember("id", opal::Document("a"))).ToString()}; EchoChoiceInput input; input.id = "a"; input.choice = BigUnion::FromText("hi"); @@ -222,20 +222,20 @@ TEST_F(UnionGauntletCborTest, ModeledErrorCarriesAUnionNextToItsTypeDiscriminato // Server side: the error body carries __type AND the union member — the // wire shape whose deserialization the exactly-one arithmetic tolerates. - const auto response = server_->Handler()(smithy::testing::Rpcv2CborRequest( - "UnionGauntlet", "EchoChoice", RequestBody(OneMember("grade", smithy::Document("fail"))))); + const auto response = server_->Handler()(opal::testing::Rpcv2CborRequest( + "UnionGauntlet", "EchoChoice", RequestBody(OneMember("grade", opal::Document("fail"))))); EXPECT_EQ(response.status, 400) << response.body; - auto body = smithy::cbor::Decode(smithy::Blob::FromString(response.body)); + auto body = opal::cbor::Decode(opal::Blob::FromString(response.body)); ASSERT_TRUE(body.ok()); ASSERT_NE(body->Find("__type"), nullptr); - const smithy::Document* offending = body->Find("offending"); + const opal::Document* offending = body->Find("offending"); ASSERT_NE(offending, nullptr) << "error payload lost its union member"; - EXPECT_EQ(*offending, OneMember("grade", smithy::Document("fail"))); + EXPECT_EQ(*offending, OneMember("grade", opal::Document("fail"))); // Client side: the same wire shape deserializes into the typed error // detail with the union preserved. auto client = CapturedClient(); - transport_->next_response = smithy::http::HttpResponse{400, response.headers, response.body}; + transport_->next_response = opal::http::HttpResponse{400, response.headers, response.body}; EchoChoiceInput input; input.id = "a"; input.choice = BigUnion::FromGrade(Grade::Value::kFail); diff --git a/protocol-tests/unions/union_gauntlet_jsonrpc2_test.cc b/protocol-tests/unions/union_gauntlet_jsonrpc2_test.cc index 71491bb7..36cf0cf5 100644 --- a/protocol-tests/unions/union_gauntlet_jsonrpc2_test.cc +++ b/protocol-tests/unions/union_gauntlet_jsonrpc2_test.cc @@ -25,79 +25,79 @@ namespace compile::unions::jsonrpc { namespace { -smithy::Document Doc(smithy::DocumentMap map) { return smithy::Document(std::move(map)); } +opal::Document Doc(opal::DocumentMap map) { return opal::Document(std::move(map)); } -smithy::Document OneMember(const std::string& name, smithy::Document value) { - smithy::DocumentMap map; +opal::Document OneMember(const std::string& name, opal::Document value) { + opal::DocumentMap map; map.emplace(name, std::move(value)); return Doc(std::move(map)); } // A success envelope answering the client's fixed request id 1. -std::string ResultEnvelope(smithy::Document result) { - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("id", smithy::Document(std::int64_t{1})); +std::string ResultEnvelope(opal::Document result) { + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("id", opal::Document(std::int64_t{1})); envelope.emplace("result", std::move(result)); - return smithy::json::Encode(Doc(std::move(envelope))); + return opal::json::Encode(Doc(std::move(envelope))); } struct Cell { const char* name; BigUnion typed; - smithy::Document wire; + opal::Document wire; }; std::vector MemberCells() { - const auto timestamp = smithy::Timestamp::FromEpochMilliseconds(1515531081000); - smithy::DocumentList names; + const auto timestamp = opal::Timestamp::FromEpochMilliseconds(1515531081000); + opal::DocumentList names; names.emplace_back("x"); names.emplace_back("y"); - smithy::DocumentMap attributes; - attributes.emplace("k", smithy::Document("v")); - smithy::DocumentMap node; - node.emplace("label", smithy::Document("outer")); - node.emplace("next", OneMember("label", smithy::Document("inner"))); + opal::DocumentMap attributes; + attributes.emplace("k", opal::Document("v")); + opal::DocumentMap node; + node.emplace("label", opal::Document("outer")); + node.emplace("next", OneMember("label", opal::Document("inner"))); Node inner; inner.label = "inner"; Node outer; outer.label = "outer"; - outer.next = smithy::Boxed(inner); + outer.next = opal::Boxed(inner); std::vector cells; - cells.push_back({"text", BigUnion::FromText("t"), OneMember("text", smithy::Document("t"))}); - cells.push_back({"flag", BigUnion::FromFlag(true), OneMember("flag", smithy::Document(true))}); + cells.push_back({"text", BigUnion::FromText("t"), OneMember("text", opal::Document("t"))}); + cells.push_back({"flag", BigUnion::FromFlag(true), OneMember("flag", opal::Document(true))}); cells.push_back( - {"small", BigUnion::FromSmall(-3), OneMember("small", smithy::Document(std::int64_t{-3}))}); + {"small", BigUnion::FromSmall(-3), OneMember("small", opal::Document(std::int64_t{-3}))}); cells.push_back({"big", BigUnion::FromBig(std::int64_t{1} << 40), - OneMember("big", smithy::Document(std::int64_t{1} << 40))}); - cells.push_back({"ratio", BigUnion::FromRatio(1.5), OneMember("ratio", smithy::Document(1.5))}); + OneMember("big", opal::Document(std::int64_t{1} << 40))}); + cells.push_back({"ratio", BigUnion::FromRatio(1.5), OneMember("ratio", opal::Document(1.5))}); // JSON has no binary type: blobs ride as base64 text on the wire. - cells.push_back({"data", BigUnion::FromData(smithy::Blob::FromString("\x01\x02")), - OneMember("data", smithy::Document("AQI="))}); + cells.push_back({"data", BigUnion::FromData(opal::Blob::FromString("\x01\x02")), + OneMember("data", opal::Document("AQI="))}); // Timestamps default to epoch-seconds numbers. cells.push_back({"when", BigUnion::FromWhen(timestamp), - OneMember("when", smithy::Document(std::int64_t{1515531081}))}); + OneMember("when", opal::Document(std::int64_t{1515531081}))}); cells.push_back({"names", BigUnion::FromNames({"x", "y"}), - OneMember("names", smithy::Document(std::move(names)))}); + OneMember("names", opal::Document(std::move(names)))}); cells.push_back({"attributes", BigUnion::FromAttributes({{"k", "v"}}), OneMember("attributes", Doc(std::move(attributes)))}); cells.push_back({"grade", BigUnion::FromGrade(Grade::Value::kPass), - OneMember("grade", smithy::Document("pass"))}); + OneMember("grade", opal::Document("pass"))}); cells.push_back({"rank", BigUnion::FromRank(Rank::kFirst), - OneMember("rank", smithy::Document(std::int64_t{1}))}); + OneMember("rank", opal::Document(std::int64_t{1}))}); cells.push_back({"node", BigUnion::FromNode(outer), OneMember("node", Doc(std::move(node)))}); return cells; } class EchoHandler : public UnionGauntletHandler { public: - smithy::Outcome EchoChoice(const EchoChoiceInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome EchoChoice(const EchoChoiceInput& input, + const opal::server::RequestContext&) override { last = input; if (reject) { - smithy::Error error = smithy::Error::Modeled("ChoiceRejected", "no thanks"); + opal::Error error = opal::Error::Modeled("ChoiceRejected", "no thanks"); ChoiceRejected detail; detail.message = "no thanks"; detail.offending = input.choice; @@ -118,13 +118,13 @@ class UnionGauntletJsonRpc2Test : public testing::Test { void SetUp() override { handler_ = std::make_shared(); server_ = std::make_unique(handler_); - transport_ = std::make_shared(); + transport_ = std::make_shared(); } UnionGauntletClient LiveClient() { - auto loopback = std::make_shared(); + auto loopback = std::make_shared(); EXPECT_TRUE(loopback->Start(server_->Handler()).ok()); - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; config.http_client = loopback; auto client = UnionGauntletClient::Create(std::move(config)); @@ -133,7 +133,7 @@ class UnionGauntletJsonRpc2Test : public testing::Test { } UnionGauntletClient CapturedClient() { - smithy::ClientConfig config; + opal::ClientConfig config; config.retry.max_attempts = 1; config.http_client = transport_; auto client = UnionGauntletClient::Create(std::move(config)); @@ -143,23 +143,23 @@ class UnionGauntletJsonRpc2Test : public testing::Test { std::shared_ptr handler_; std::unique_ptr server_; - std::shared_ptr transport_; + std::shared_ptr transport_; }; TEST_F(UnionGauntletJsonRpc2Test, EveryMemberKindEncodesToItsWireSubdocument) { auto client = CapturedClient(); transport_->next_response = - smithy::http::HttpResponse{200, {}, ResultEnvelope(OneMember("id", smithy::Document("a")))}; + opal::http::HttpResponse{200, {}, ResultEnvelope(OneMember("id", opal::Document("a")))}; for (const Cell& cell : MemberCells()) { EchoChoiceInput input; input.id = "a"; input.choice = cell.typed; ASSERT_TRUE(client.EchoChoice(input).ok()) << cell.name; - auto body = smithy::json::Decode(transport_->last_request.body); + auto body = opal::json::Decode(transport_->last_request.body); ASSERT_TRUE(body.ok()) << cell.name; - const smithy::Document* params = body->Find("params"); + const opal::Document* params = body->Find("params"); ASSERT_NE(params, nullptr) << cell.name; - const smithy::Document* choice = params->Find("choice"); + const opal::Document* choice = params->Find("choice"); ASSERT_NE(choice, nullptr) << cell.name; ASSERT_TRUE(choice->is_map()) << cell.name; EXPECT_EQ(choice->as_map().size(), 1u) << cell.name; @@ -190,7 +190,7 @@ TEST_F(UnionGauntletJsonRpc2Test, EveryMemberKindSurvivesTheFullClientServerLoop TEST_F(UnionGauntletJsonRpc2Test, RequestBodyIsByteExact) { auto client = CapturedClient(); transport_->next_response = - smithy::http::HttpResponse{200, {}, ResultEnvelope(OneMember("id", smithy::Document("a")))}; + opal::http::HttpResponse{200, {}, ResultEnvelope(OneMember("id", opal::Document("a")))}; EchoChoiceInput input; input.id = "a"; input.choice = BigUnion::FromText("hi"); @@ -205,36 +205,36 @@ TEST_F(UnionGauntletJsonRpc2Test, ModeledErrorCarriesAUnionNextToItsTypeDiscrimi // Server side: the error envelope's data member carries __type AND the // union member. - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("method", smithy::Document("EchoChoice")); - envelope.emplace("id", smithy::Document(std::int64_t{7})); - smithy::DocumentMap params; - params.emplace("id", smithy::Document("a")); - params.emplace("choice", OneMember("grade", smithy::Document("fail"))); + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("method", opal::Document("EchoChoice")); + envelope.emplace("id", opal::Document(std::int64_t{7})); + opal::DocumentMap params; + params.emplace("id", opal::Document("a")); + params.emplace("choice", OneMember("grade", opal::Document("fail"))); envelope.emplace("params", Doc(std::move(params))); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); - request.body = smithy::json::Encode(Doc(std::move(envelope))); + request.body = opal::json::Encode(Doc(std::move(envelope))); const auto response = server_->Handler()(request); EXPECT_EQ(response.status, 200) << response.body; - auto body = smithy::json::Decode(response.body); + auto body = opal::json::Decode(response.body); ASSERT_TRUE(body.ok()) << response.body; - const smithy::Document* error = body->Find("error"); + const opal::Document* error = body->Find("error"); ASSERT_NE(error, nullptr) << response.body; - const smithy::Document* data = error->Find("data"); + const opal::Document* data = error->Find("data"); ASSERT_NE(data, nullptr) << response.body; ASSERT_NE(data->Find("__type"), nullptr) << response.body; - const smithy::Document* offending = data->Find("offending"); + const opal::Document* offending = data->Find("offending"); ASSERT_NE(offending, nullptr) << "error payload lost its union member: " << response.body; - EXPECT_EQ(*offending, OneMember("grade", smithy::Document("fail"))); + EXPECT_EQ(*offending, OneMember("grade", opal::Document("fail"))); // Client side: the same envelope deserializes into the typed error detail // with the union preserved. auto client = CapturedClient(); - transport_->next_response = smithy::http::HttpResponse{response.status, {}, response.body}; + transport_->next_response = opal::http::HttpResponse{response.status, {}, response.body}; EchoChoiceInput input; input.id = "a"; input.choice = BigUnion::FromGrade(Grade::Value::kFail); diff --git a/protocol-tests/unions/union_jsonrpc2_test.cc b/protocol-tests/unions/union_jsonrpc2_test.cc index cc530496..e8a14cb2 100644 --- a/protocol-tests/unions/union_jsonrpc2_test.cc +++ b/protocol-tests/unions/union_jsonrpc2_test.cc @@ -21,44 +21,44 @@ namespace example::roundtrip::jsonrpc { namespace { -smithy::Document TextChoiceDoc(const std::string& text) { - smithy::DocumentMap map; - map.emplace("text", smithy::Document(text)); - return smithy::Document(std::move(map)); +opal::Document TextChoiceDoc(const std::string& text) { + opal::DocumentMap map; + map.emplace("text", opal::Document(text)); + return opal::Document(std::move(map)); } -smithy::Document CountChoiceDoc(std::int64_t count) { - smithy::DocumentMap map; - map.emplace("count", smithy::Document(count)); - return smithy::Document(std::move(map)); +opal::Document CountChoiceDoc(std::int64_t count) { + opal::DocumentMap map; + map.emplace("count", opal::Document(count)); + return opal::Document(std::move(map)); } -smithy::Document NestedChoiceDoc(const std::string& label, std::int64_t depth) { - smithy::DocumentMap nested; - nested.emplace("label", smithy::Document(label)); - nested.emplace("depth", smithy::Document(depth)); - smithy::DocumentMap map; - map.emplace("nested", smithy::Document(std::move(nested))); - return smithy::Document(std::move(map)); +opal::Document NestedChoiceDoc(const std::string& label, std::int64_t depth) { + opal::DocumentMap nested; + nested.emplace("label", opal::Document(label)); + nested.emplace("depth", opal::Document(depth)); + opal::DocumentMap map; + map.emplace("nested", opal::Document(std::move(nested))); + return opal::Document(std::move(map)); } -smithy::Document PayloadWithChoice(const smithy::Document& choice) { - smithy::DocumentMap sink; - sink.emplace("name", smithy::Document("n")); +opal::Document PayloadWithChoice(const opal::Document& choice) { + opal::DocumentMap sink; + sink.emplace("name", opal::Document("n")); sink.emplace("choice", choice); - smithy::DocumentMap payload; - payload.emplace("sinkId", smithy::Document("s1")); - payload.emplace("sink", smithy::Document(std::move(sink))); - return smithy::Document(std::move(payload)); + opal::DocumentMap payload; + payload.emplace("sinkId", opal::Document("s1")); + payload.emplace("sink", opal::Document(std::move(sink))); + return opal::Document(std::move(payload)); } // A success envelope answering the client's fixed request id 1. -std::string ResultEnvelope(const smithy::Document& result) { - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("id", smithy::Document(std::int64_t{1})); +std::string ResultEnvelope(const opal::Document& result) { + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("id", opal::Document(std::int64_t{1})); envelope.emplace("result", result); - return smithy::json::Encode(smithy::Document(std::move(envelope))); + return opal::json::Encode(opal::Document(std::move(envelope))); } PutSinkRpcInput InputWithChoice(SinkChoice choice) { @@ -72,30 +72,30 @@ PutSinkRpcInput InputWithChoice(SinkChoice choice) { } // The params.sink.choice subdocument of a captured JSON-RPC request. -smithy::Document RequestChoiceOf(const std::string& wire_body) { - auto doc = smithy::json::Decode(wire_body); +opal::Document RequestChoiceOf(const std::string& wire_body) { + auto doc = opal::json::Decode(wire_body); EXPECT_TRUE(doc.ok()); - if (!doc.ok()) return smithy::Document(nullptr); - const smithy::Document* params = doc->Find("params"); + if (!doc.ok()) return opal::Document(nullptr); + const opal::Document* params = doc->Find("params"); EXPECT_NE(params, nullptr) << wire_body; - if (params == nullptr) return smithy::Document(nullptr); - const smithy::Document* sink = params->Find("sink"); + if (params == nullptr) return opal::Document(nullptr); + const opal::Document* sink = params->Find("sink"); EXPECT_NE(sink, nullptr) << wire_body; - if (sink == nullptr) return smithy::Document(nullptr); - const smithy::Document* choice = sink->Find("choice"); + if (sink == nullptr) return opal::Document(nullptr); + const opal::Document* choice = sink->Find("choice"); EXPECT_NE(choice, nullptr) << wire_body; - return choice == nullptr ? smithy::Document(nullptr) : *choice; + return choice == nullptr ? opal::Document(nullptr) : *choice; } class UnionJsonRpc2ClientTest : public testing::Test { protected: void SetUp() override { - transport_ = std::make_shared(); - smithy::DocumentMap ok_result; - ok_result.emplace("sinkId", smithy::Document("s1")); + transport_ = std::make_shared(); + opal::DocumentMap ok_result; + ok_result.emplace("sinkId", opal::Document("s1")); transport_->next_response = - smithy::http::HttpResponse{200, {}, ResultEnvelope(smithy::Document(std::move(ok_result)))}; - smithy::ClientConfig config; + opal::http::HttpResponse{200, {}, ResultEnvelope(opal::Document(std::move(ok_result)))}; + opal::ClientConfig config; config.retry.max_attempts = 1; config.http_client = transport_; auto client = RoundTripJsonRpcClient::Create(std::move(config)); @@ -103,14 +103,14 @@ class UnionJsonRpc2ClientTest : public testing::Test { client_ = std::make_unique(std::move(*client)); } - std::shared_ptr transport_; + std::shared_ptr transport_; std::unique_ptr client_; }; TEST_F(UnionJsonRpc2ClientTest, EncodesEachVariantInsideTheEnvelopeParams) { const struct { SinkChoice choice; - smithy::Document expected; + opal::Document expected; } cells[] = { {SinkChoice::FromText("wire text"), TextChoiceDoc("wire text")}, {SinkChoice::FromCount(-7), CountChoiceDoc(-7)}, @@ -124,7 +124,7 @@ TEST_F(UnionJsonRpc2ClientTest, EncodesEachVariantInsideTheEnvelopeParams) { }; for (const auto& cell : cells) { ASSERT_TRUE(client_->PutSinkRpc(InputWithChoice(cell.choice)).ok()); - const smithy::Document choice = RequestChoiceOf(transport_->last_request.body); + const opal::Document choice = RequestChoiceOf(transport_->last_request.body); ASSERT_TRUE(choice.is_map()); EXPECT_EQ(choice.as_map().size(), 1u) << "a union must serialize exactly one member"; EXPECT_EQ(choice, cell.expected); @@ -133,7 +133,7 @@ TEST_F(UnionJsonRpc2ClientTest, EncodesEachVariantInsideTheEnvelopeParams) { TEST_F(UnionJsonRpc2ClientTest, DecodesEachVariantFromAResultEnvelope) { const struct { - smithy::Document wire; + opal::Document wire; SinkChoice expected; } cells[] = { {TextChoiceDoc("from server"), SinkChoice::FromText("from server")}, @@ -147,7 +147,7 @@ TEST_F(UnionJsonRpc2ClientTest, DecodesEachVariantFromAResultEnvelope) { }; for (const auto& cell : cells) { transport_->next_response = - smithy::http::HttpResponse{200, {}, ResultEnvelope(PayloadWithChoice(cell.wire))}; + opal::http::HttpResponse{200, {}, ResultEnvelope(PayloadWithChoice(cell.wire))}; const auto outcome = client_->PutSinkRpc(InputWithChoice(SinkChoice::FromCount(0))); ASSERT_TRUE(outcome.ok()) << outcome.error().message(); ASSERT_TRUE(outcome->sink.has_value()); @@ -160,29 +160,29 @@ TEST_F(UnionJsonRpc2ClientTest, RejectsInvalidUnionsInResultEnvelopes) { // Each cell pins its diagnosis, not just the rejection: a union declined // for the wrong reason would mask the exactly-one-member rule. const struct { - smithy::Document wire; + opal::Document wire; const char* why; const char* diagnosis; } cells[] = { - {smithy::Document(smithy::DocumentMap{}), "empty union", "expected exactly one union member"}, + {opal::Document(opal::DocumentMap{}), "empty union", "expected exactly one union member"}, {[] { - smithy::DocumentMap map; - map.emplace("text", smithy::Document("a")); - map.emplace("count", smithy::Document(std::int64_t{1})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("text", opal::Document("a")); + map.emplace("count", opal::Document(std::int64_t{1})); + return opal::Document(std::move(map)); }(), "two members set", "expected exactly one union member"}, {[] { - smithy::DocumentMap map; - map.emplace("futureMember", smithy::Document(std::int64_t{1})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("futureMember", opal::Document(std::int64_t{1})); + return opal::Document(std::move(map)); }(), "unknown member", "unknown or missing union member"}, - {smithy::Document("not a map"), "non-map union", "expected a map on the wire"}, + {opal::Document("not a map"), "non-map union", "expected a map on the wire"}, }; for (const auto& cell : cells) { transport_->next_response = - smithy::http::HttpResponse{200, {}, ResultEnvelope(PayloadWithChoice(cell.wire))}; + opal::http::HttpResponse{200, {}, ResultEnvelope(PayloadWithChoice(cell.wire))}; const auto outcome = client_->PutSinkRpc(InputWithChoice(SinkChoice::FromCount(0))); ASSERT_FALSE(outcome.ok()) << cell.why; EXPECT_NE(outcome.error().message().find(cell.diagnosis), std::string::npos) @@ -194,8 +194,8 @@ TEST_F(UnionJsonRpc2ClientTest, RejectsInvalidUnionsInResultEnvelopes) { class RecordingHandler : public RoundTripJsonRpcHandler { public: - smithy::Outcome PutSinkRpc(const PutSinkRpcInput& input, - const smithy::server::RequestContext&) override { + opal::Outcome PutSinkRpc(const PutSinkRpcInput& input, + const opal::server::RequestContext&) override { last = input; PutSinkRpcOutput output; output.sinkId = input.sinkId; @@ -207,17 +207,17 @@ class RecordingHandler : public RoundTripJsonRpcHandler { class UnionJsonRpc2ServerTest : public testing::Test { protected: - smithy::http::HttpResponse Send(const smithy::Document& params) { - smithy::DocumentMap envelope; - envelope.emplace("jsonrpc", smithy::Document("2.0")); - envelope.emplace("method", smithy::Document("PutSinkRpc")); - envelope.emplace("id", smithy::Document(std::int64_t{7})); + opal::http::HttpResponse Send(const opal::Document& params) { + opal::DocumentMap envelope; + envelope.emplace("jsonrpc", opal::Document("2.0")); + envelope.emplace("method", opal::Document("PutSinkRpc")); + envelope.emplace("id", opal::Document(std::int64_t{7})); envelope.emplace("params", params); - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "POST"; request.target = "/"; request.headers.Set("content-type", "application/json"); - request.body = smithy::json::Encode(smithy::Document(std::move(envelope))); + request.body = opal::json::Encode(opal::Document(std::move(envelope))); return server_.Handler()(request); } @@ -227,7 +227,7 @@ class UnionJsonRpc2ServerTest : public testing::Test { TEST_F(UnionJsonRpc2ServerTest, DecodesEachVariantAndEchoesItBack) { const struct { - smithy::Document wire; + opal::Document wire; SinkChoice expected; } cells[] = { {TextChoiceDoc("to server"), SinkChoice::FromText("to server")}, @@ -248,10 +248,10 @@ TEST_F(UnionJsonRpc2ServerTest, DecodesEachVariantAndEchoesItBack) { // The echoed result carries the identical union subdocument, under the // envelope's result member and answering the request id. - auto body = smithy::json::Decode(response.body); + auto body = opal::json::Decode(response.body); ASSERT_TRUE(body.ok()) << response.body; EXPECT_EQ(body->Find("id")->as_int(), 7); - const smithy::Document* result = body->Find("result"); + const opal::Document* result = body->Find("result"); ASSERT_NE(result, nullptr) << response.body; EXPECT_EQ(*result->Find("sink")->Find("choice"), cell.wire); handler_->last.reset(); @@ -259,27 +259,27 @@ TEST_F(UnionJsonRpc2ServerTest, DecodesEachVariantAndEchoesItBack) { } TEST_F(UnionJsonRpc2ServerTest, RejectsInvalidUnionsBeforeTheHandler) { - const smithy::Document invalid[] = { - smithy::Document(smithy::DocumentMap{}), + const opal::Document invalid[] = { + opal::Document(opal::DocumentMap{}), [] { - smithy::DocumentMap map; - map.emplace("text", smithy::Document("a")); - map.emplace("count", smithy::Document(std::int64_t{1})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("text", opal::Document("a")); + map.emplace("count", opal::Document(std::int64_t{1})); + return opal::Document(std::move(map)); }(), [] { - smithy::DocumentMap map; - map.emplace("futureMember", smithy::Document(std::int64_t{1})); - return smithy::Document(std::move(map)); + opal::DocumentMap map; + map.emplace("futureMember", opal::Document(std::int64_t{1})); + return opal::Document(std::move(map)); }(), }; for (const auto& wire : invalid) { const auto response = Send(PayloadWithChoice(wire)); // jsonRpc2 answers protocol-layer failures as an error envelope on 200. EXPECT_EQ(response.status, 200) << response.body; - auto body = smithy::json::Decode(response.body); + auto body = opal::json::Decode(response.body); ASSERT_TRUE(body.ok()) << response.body; - const smithy::Document* error = body->Find("error"); + const opal::Document* error = body->Find("error"); ASSERT_NE(error, nullptr) << response.body; // The envelope names the union rule that was violated, so a rejection // for the wrong reason cannot hide behind the error member's presence. diff --git a/runtime/BUILD.bazel b/runtime/BUILD.bazel index 5fc1bb19..ab91e1b0 100644 --- a/runtime/BUILD.bazel +++ b/runtime/BUILD.bazel @@ -3,7 +3,7 @@ load("//bazel:copts.bzl", COPTS = "SMITHY_COPTS") package(default_visibility = ["//visibility:public"]) -# Read by //tools:release_test, which pins the User-Agent to smithy::Version(). +# Read by //tools:release_test, which pins the User-Agent to opal::Version(). exports_files([ "src/core/version.cc", "include/smithy/client/config.h", @@ -752,13 +752,13 @@ genrule( "{", " echo '#include '", " echo '#include '", - " echo 'namespace smithy::json {'", + " echo 'namespace opal::json {'", " echo 'std::vector CorpusFiles() {'", " echo ' return {'", " for f in $(SRCS); do echo \" \\\"$$(basename $$f)\\\",\"; done", " echo ' };'", " echo '}'", - " echo '} // namespace smithy::json'", + " echo '} // namespace opal::json'", "} > $@", ]), ) diff --git a/runtime/include/smithy/cbor/cbor.h b/runtime/include/smithy/cbor/cbor.h index 75cdf2b2..4a5f617f 100644 --- a/runtime/include/smithy/cbor/cbor.h +++ b/runtime/include/smithy/cbor/cbor.h @@ -5,7 +5,7 @@ #include "smithy/core/document.h" #include "smithy/core/outcome.h" -namespace smithy::cbor { +namespace opal::cbor { // Encodes a Document as deterministic CBOR (RFC 8949): smallest-width // integers, definite lengths only, sorted map keys (inherent to DocumentMap), @@ -19,6 +19,6 @@ Blob Encode(const Document& doc); // integers outside int64 range, truncated or trailing input. Outcome Decode(const Blob& bytes); -} // namespace smithy::cbor +} // namespace opal::cbor #endif // SMITHY_CBOR_CBOR_H_ diff --git a/runtime/include/smithy/client/config.h b/runtime/include/smithy/client/config.h index 25604a67..cd457246 100644 --- a/runtime/include/smithy/client/config.h +++ b/runtime/include/smithy/client/config.h @@ -12,11 +12,11 @@ #include "smithy/http/transport.h" #include "smithy/http/websocket.h" -namespace smithy { +namespace opal { // Configuration shared by every generated client. // -// smithy::ClientConfig cfg; +// opal::ClientConfig cfg; // cfg.endpoint = "http://localhost:8080"; // WeatherClient client(cfg); // @@ -25,7 +25,7 @@ namespace smithy { struct ClientConfig { std::string endpoint; int request_timeout_ms = 30000; - // Mirrors smithy::Version() (runtime/src/core/version.cc), the single source + // Mirrors opal::Version() (runtime/src/core/version.cc), the single source // of truth for the product version. std::string user_agent = "smithy-cpp/0.3.0-dev"; @@ -69,11 +69,11 @@ struct ClientConfig { // Optional WebSocket dialer override for event-stream operations // (ADR-0016), injected the way http_client injects the unary transport — // which is also how tests run streams without Beast. When unset, generated - // streaming clients dial with smithy::http::BeastWebSocketClient::Dialer() + // streaming clients dial with opal::http::BeastWebSocketClient::Dialer() // from this config's endpoint and TLS options. http::WebSocketDialer websocket_dialer; }; -} // namespace smithy +} // namespace opal #endif // SMITHY_CLIENT_CONFIG_H_ diff --git a/runtime/include/smithy/client/interceptor.h b/runtime/include/smithy/client/interceptor.h index e81d8e8f..bc357d8b 100644 --- a/runtime/include/smithy/client/interceptor.h +++ b/runtime/include/smithy/client/interceptor.h @@ -4,7 +4,7 @@ #include "smithy/core/outcome.h" #include "smithy/http/message.h" -namespace smithy { +namespace opal { // User-supplied hooks around every HTTP attempt a generated client makes // (smithy-rs prior art: client interceptors). Register on @@ -33,6 +33,6 @@ class Interceptor { } }; -} // namespace smithy +} // namespace opal #endif // SMITHY_CLIENT_INTERCEPTOR_H_ diff --git a/runtime/include/smithy/client/observability.h b/runtime/include/smithy/client/observability.h index 64c7a9eb..7df414a3 100644 --- a/runtime/include/smithy/client/observability.h +++ b/runtime/include/smithy/client/observability.h @@ -9,7 +9,7 @@ #include "smithy/client/interceptor.h" #include "smithy/http/trace_context.h" -namespace smithy { +namespace opal { // One HTTP attempt made by a generated client, as seen by ObserveAttempts. struct AttemptObservation { @@ -32,10 +32,10 @@ std::shared_ptr ObserveAttempts( // context is generated per attempt. Register alongside your other // interceptors: // -// config.interceptors.push_back(smithy::PropagateTraceContext()); +// config.interceptors.push_back(opal::PropagateTraceContext()); std::shared_ptr PropagateTraceContext( std::function()> current = nullptr); -} // namespace smithy +} // namespace opal #endif // SMITHY_CLIENT_OBSERVABILITY_H_ diff --git a/runtime/include/smithy/client/pagination.h b/runtime/include/smithy/client/pagination.h index 81a77160..0b26ffe6 100644 --- a/runtime/include/smithy/client/pagination.h +++ b/runtime/include/smithy/client/pagination.h @@ -8,7 +8,7 @@ #include "smithy/core/outcome.h" -namespace smithy { +namespace opal { // Single-pass input iterator over a generated paginator, surfaced through // the paginator's begin()/end() so range-for works (issue #49): @@ -77,6 +77,6 @@ class PageIterator { std::optional> current_; }; -} // namespace smithy +} // namespace opal #endif // SMITHY_CLIENT_PAGINATION_H_ diff --git a/runtime/include/smithy/client/retry.h b/runtime/include/smithy/client/retry.h index 41be564f..99470654 100644 --- a/runtime/include/smithy/client/retry.h +++ b/runtime/include/smithy/client/retry.h @@ -11,7 +11,7 @@ #include "smithy/http/message.h" #include "smithy/http/transport.h" -namespace smithy { +namespace opal { // Retry configuration for generated clients: full-jitter exponential backoff // (retry n waits uniform(0, min(max_backoff, initial_backoff * 2^(n-1)))). @@ -50,6 +50,6 @@ inline Outcome SendWithRetries(http::HttpClient& transport, return SendWithRetries(transport, request, policy, {}); } -} // namespace smithy +} // namespace opal #endif // SMITHY_CLIENT_RETRY_H_ diff --git a/runtime/include/smithy/compression/gzip.h b/runtime/include/smithy/compression/gzip.h index ec82bd04..96313181 100644 --- a/runtime/include/smithy/compression/gzip.h +++ b/runtime/include/smithy/compression/gzip.h @@ -7,7 +7,7 @@ #include "smithy/core/outcome.h" -namespace smithy { +namespace opal { // Gzip-compresses data (@requestCompression request bodies). Inputs of any // size: bytes reach zlib's 32-bit counters in bounded slices, never through @@ -20,6 +20,6 @@ Outcome GzipCompress(std::string_view data); Outcome GzipDecompress(std::string_view data, std::size_t max_output = std::size_t{64} * 1024 * 1024); -} // namespace smithy +} // namespace opal #endif // SMITHY_COMPRESSION_GZIP_H_ diff --git a/runtime/include/smithy/compression/gzip_test_peer.h b/runtime/include/smithy/compression/gzip_test_peer.h index dbad6b0c..59fbfa3d 100644 --- a/runtime/include/smithy/compression/gzip_test_peer.h +++ b/runtime/include/smithy/compression/gzip_test_peer.h @@ -14,7 +14,7 @@ // to include this header — the public entry points already pass the one // correct bound. -namespace smithy::internal { +namespace opal::internal { // Preconditions (ADR-0009, enforced fatally): 0 < max_feed <= the largest // value zlib's 32-bit avail_in can carry. Zero cannot make progress and a @@ -24,6 +24,6 @@ Outcome GzipCompressChunked(std::string_view data, std::size_t max_ Outcome GzipDecompressChunked(std::string_view data, std::size_t max_output, std::size_t max_feed); -} // namespace smithy::internal +} // namespace opal::internal #endif // SMITHY_COMPRESSION_GZIP_TEST_PEER_H_ diff --git a/runtime/include/smithy/core/base64.h b/runtime/include/smithy/core/base64.h index 6b97db93..b88f28b7 100644 --- a/runtime/include/smithy/core/base64.h +++ b/runtime/include/smithy/core/base64.h @@ -7,7 +7,7 @@ #include "smithy/core/blob.h" #include "smithy/core/outcome.h" -namespace smithy { +namespace opal { // Standard base64 (RFC 4648 §4, with padding), as required for blob shapes in // JSON-based protocols. @@ -16,6 +16,6 @@ std::string Base64Encode(const Blob& blob); // Rejects non-alphabet characters, bad padding, and non-canonical trailing bits. Outcome Base64Decode(std::string_view text); -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_BASE64_H_ diff --git a/runtime/include/smithy/core/blob.h b/runtime/include/smithy/core/blob.h index 30fd7710..b9db1484 100644 --- a/runtime/include/smithy/core/blob.h +++ b/runtime/include/smithy/core/blob.h @@ -10,7 +10,7 @@ #include #include -namespace smithy { +namespace opal { // Owning byte buffer for Smithy blob shapes. Distinct from std::string to keep // binary payloads and text from mixing accidentally. @@ -61,13 +61,13 @@ class Blob { std::vector bytes_; }; -} // namespace smithy +} // namespace opal // Hashes by byte content, so blob-bearing generated structs can key unordered // containers (issue #49). Process-local: never persist hash values. template <> -struct std::hash { - std::size_t operator()(const smithy::Blob& blob) const noexcept { +struct std::hash { + std::size_t operator()(const opal::Blob& blob) const noexcept { return std::hash{}( std::string_view(reinterpret_cast(blob.data()), blob.size())); } diff --git a/runtime/include/smithy/core/boxed.h b/runtime/include/smithy/core/boxed.h index 2ae9a294..3d2959ad 100644 --- a/runtime/include/smithy/core/boxed.h +++ b/runtime/include/smithy/core/boxed.h @@ -7,7 +7,7 @@ #include "smithy/core/print.h" -namespace smithy { +namespace opal { // Value-semantic heap indirection for recursive generated members (a // structure member whose target refers back to its container). Copy is a @@ -58,6 +58,6 @@ class Boxed { std::unique_ptr value_; }; -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_BOXED_H_ diff --git a/runtime/include/smithy/core/container_traits.h b/runtime/include/smithy/core/container_traits.h index e9b8621c..ac0930dc 100644 --- a/runtime/include/smithy/core/container_traits.h +++ b/runtime/include/smithy/core/container_traits.h @@ -6,7 +6,7 @@ #include #include -namespace smithy::internal { +namespace opal::internal { // Detection for the containers generated members use — shared by the // element-wise dispatchers in hash.h (HashValue) and print.h (DebugAppend). @@ -26,6 +26,6 @@ struct IsOptional : std::false_type {}; template struct IsOptional> : std::true_type {}; -} // namespace smithy::internal +} // namespace opal::internal #endif // SMITHY_CORE_CONTAINER_TRAITS_H_ diff --git a/runtime/include/smithy/core/document.h b/runtime/include/smithy/core/document.h index 1e9c4d93..3cce6eaa 100644 --- a/runtime/include/smithy/core/document.h +++ b/runtime/include/smithy/core/document.h @@ -14,7 +14,7 @@ #include "smithy/core/print.h" #include "smithy/core/timestamp.h" -namespace smithy { +namespace opal { class Document; using DocumentList = std::vector; @@ -117,6 +117,6 @@ class Document { Value value_; }; -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_DOCUMENT_H_ diff --git a/runtime/include/smithy/core/document_serde.h b/runtime/include/smithy/core/document_serde.h index 5afa1395..69c4f7a0 100644 --- a/runtime/include/smithy/core/document_serde.h +++ b/runtime/include/smithy/core/document_serde.h @@ -6,7 +6,7 @@ #include "smithy/core/outcome.h" #include "smithy/core/timestamp.h" -namespace smithy { +namespace opal { // Helpers used by generated deserializers to read protocol-shaped Document // nodes back into typed values. They are wire-format tolerant: a JSON decode @@ -35,6 +35,6 @@ Outcome FloatFromDouble(double value); std::string FormatDouble(double value); std::string FormatFloat(float value); -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_DOCUMENT_SERDE_H_ diff --git a/runtime/include/smithy/core/error.h b/runtime/include/smithy/core/error.h index 33f4370b..153ed7d6 100644 --- a/runtime/include/smithy/core/error.h +++ b/runtime/include/smithy/core/error.h @@ -5,7 +5,7 @@ #include #include -namespace smithy { +namespace opal { // Broad classification of a failure, used for retry and reporting decisions. enum class ErrorKind { @@ -85,6 +85,6 @@ class Error { std::any detail_; }; -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_ERROR_H_ diff --git a/runtime/include/smithy/core/exception_guard.h b/runtime/include/smithy/core/exception_guard.h index 42c0db59..35e625b2 100644 --- a/runtime/include/smithy/core/exception_guard.h +++ b/runtime/include/smithy/core/exception_guard.h @@ -7,7 +7,7 @@ #include #endif -namespace smithy::internal { +namespace opal::internal { // Runs `body()` and returns its result. If `body` throws, `on_throw` is // invoked with the exception's what() message — or nullptr for a non-std @@ -43,6 +43,6 @@ auto Contain(Body&& body, OnThrow&& on_throw) -> decltype(std::forward(bod #endif } -} // namespace smithy::internal +} // namespace opal::internal #endif // SMITHY_CORE_EXCEPTION_GUARD_H_ diff --git a/runtime/include/smithy/core/fatal.h b/runtime/include/smithy/core/fatal.h index 21d1245e..ab86bcff 100644 --- a/runtime/include/smithy/core/fatal.h +++ b/runtime/include/smithy/core/fatal.h @@ -6,7 +6,7 @@ #include #include -namespace smithy::internal { +namespace opal::internal { // Terminates the process after printing `message` to stderr — the one abort // primitive behind every contract violation (ADR-0009): exceptions never @@ -40,6 +40,6 @@ namespace smithy::internal { Fatal(text); } -} // namespace smithy::internal +} // namespace opal::internal #endif // SMITHY_CORE_FATAL_H_ diff --git a/runtime/include/smithy/core/hash.h b/runtime/include/smithy/core/hash.h index 03c1ee3e..3954a56d 100644 --- a/runtime/include/smithy/core/hash.h +++ b/runtime/include/smithy/core/hash.h @@ -11,7 +11,7 @@ #include "smithy/core/container_traits.h" -namespace smithy { +namespace opal { // Hashing support for generated types (issue #49): a generated type // specializes std::hash exactly when it defaults operator<=>, so it keys @@ -59,6 +59,6 @@ std::size_t HashValue(const T& value) noexcept { } } -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_HASH_H_ diff --git a/runtime/include/smithy/core/outcome.h b/runtime/include/smithy/core/outcome.h index 3c656836..347757fb 100644 --- a/runtime/include/smithy/core/outcome.h +++ b/runtime/include/smithy/core/outcome.h @@ -12,7 +12,7 @@ #include "smithy/core/error.h" #include "smithy/core/fatal.h" -namespace smithy { +namespace opal { // Marker value for operations that succeed without producing anything. struct Unit { @@ -117,13 +117,13 @@ class Outcome { std::variant storage_; }; -} // namespace smithy +} // namespace opal // One value, one hash — so Unit union members don't block a generated type's // std::hash, mirroring Unit's trivial operator<=> (issue #49). template <> -struct std::hash { - std::size_t operator()(smithy::Unit /*unit*/) const noexcept { return 0; } +struct std::hash { + std::size_t operator()(opal::Unit /*unit*/) const noexcept { return 0; } }; #endif // SMITHY_CORE_OUTCOME_H_ diff --git a/runtime/include/smithy/core/overloaded.h b/runtime/include/smithy/core/overloaded.h index c771a9d6..7f671517 100644 --- a/runtime/include/smithy/core/overloaded.h +++ b/runtime/include/smithy/core/overloaded.h @@ -1,11 +1,11 @@ #ifndef SMITHY_CORE_OVERLOADED_H_ #define SMITHY_CORE_OVERLOADED_H_ -namespace smithy { +namespace opal { // Overload-set builder for visiting generated unions (or any std::variant): // -// status.visit(smithy::Overloaded{ +// status.visit(opal::Overloaded{ // [](const PendingStatus& p) { ... }, // [](const ReadyStatus& r) { ... }, // [](const CancelledStatus&) { ... }, @@ -18,6 +18,6 @@ struct Overloaded : Fs... { template Overloaded(Fs...) -> Overloaded; -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_OVERLOADED_H_ diff --git a/runtime/include/smithy/core/print.h b/runtime/include/smithy/core/print.h index b830aaa9..eca9635e 100644 --- a/runtime/include/smithy/core/print.h +++ b/runtime/include/smithy/core/print.h @@ -14,7 +14,7 @@ #include "smithy/core/container_traits.h" -namespace smithy { +namespace opal { // Debug printing for generated types (issue #85): every generated type // carries `AppendDebugTo(std::string&)` (the one primitive), with @@ -128,6 +128,6 @@ std::string DebugString(const T& value) { return out; } -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_PRINT_H_ diff --git a/runtime/include/smithy/core/regex.h b/runtime/include/smithy/core/regex.h index f88f874d..f6eed02b 100644 --- a/runtime/include/smithy/core/regex.h +++ b/runtime/include/smithy/core/regex.h @@ -8,7 +8,7 @@ #include "smithy/core/outcome.h" -namespace smithy { +namespace opal { // Linear-time regular expressions for generated @pattern validation. The // pattern compiles to a Thompson NFA that Search() simulates breadth-first @@ -83,6 +83,6 @@ class Regex { friend class RegexCompiler; }; -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_REGEX_H_ diff --git a/runtime/include/smithy/core/text.h b/runtime/include/smithy/core/text.h index 4d4ddb8b..1ed91923 100644 --- a/runtime/include/smithy/core/text.h +++ b/runtime/include/smithy/core/text.h @@ -4,12 +4,12 @@ #include #include -namespace smithy { +namespace opal { // Number of Unicode code points in UTF-8 text (Smithy @length counts code // points for strings, not bytes). Invalid bytes count as one code point each. std::size_t Utf8CodePointCount(std::string_view text); -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_TEXT_H_ diff --git a/runtime/include/smithy/core/timestamp.h b/runtime/include/smithy/core/timestamp.h index 5c6ccd6e..34a10e5e 100644 --- a/runtime/include/smithy/core/timestamp.h +++ b/runtime/include/smithy/core/timestamp.h @@ -10,7 +10,7 @@ #include "smithy/core/outcome.h" -namespace smithy { +namespace opal { // The three timestamp serializations defined by the Smithy spec. Which one a // member uses is decided by the protocol and the @timestampFormat trait. @@ -68,14 +68,14 @@ class Timestamp { std::int64_t ms_ = 0; // Milliseconds since 1970-01-01T00:00:00Z. }; -} // namespace smithy +} // namespace opal // Hashes by the instant (epoch milliseconds), matching operator==, so // timestamp-bearing generated structs can key unordered containers // (issue #49). Process-local: never persist hash values. template <> -struct std::hash { - std::size_t operator()(smithy::Timestamp timestamp) const noexcept { +struct std::hash { + std::size_t operator()(opal::Timestamp timestamp) const noexcept { return std::hash{}(timestamp.epoch_milliseconds()); } }; diff --git a/runtime/include/smithy/core/uuid.h b/runtime/include/smithy/core/uuid.h index a909b49e..9c164c96 100644 --- a/runtime/include/smithy/core/uuid.h +++ b/runtime/include/smithy/core/uuid.h @@ -3,12 +3,12 @@ #include -namespace smithy { +namespace opal { // Random (version 4) UUID in canonical 8-4-4-4-12 hex form. Used by generated // clients to fill unset @idempotencyToken members. Not for cryptographic use. std::string GenerateUuidV4(); -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_UUID_H_ diff --git a/runtime/include/smithy/core/version.h b/runtime/include/smithy/core/version.h index e6eef1b5..2c073bc2 100644 --- a/runtime/include/smithy/core/version.h +++ b/runtime/include/smithy/core/version.h @@ -3,11 +3,11 @@ #include -namespace smithy { +namespace opal { // Returns the smithy-cpp runtime version as a semantic version string. std::string_view Version(); -} // namespace smithy +} // namespace opal #endif // SMITHY_CORE_VERSION_H_ diff --git a/runtime/include/smithy/eventstream/async_event_stream.h b/runtime/include/smithy/eventstream/async_event_stream.h index c5698540..a9751a8d 100644 --- a/runtime/include/smithy/eventstream/async_event_stream.h +++ b/runtime/include/smithy/eventstream/async_event_stream.h @@ -18,7 +18,7 @@ #include "smithy/eventstream/frame.h" #include "smithy/http/websocket.h" -namespace smithy::eventstream { +namespace opal::eventstream { // The session-loop coroutine type (ADR-0019): fire and forget. A Detached // coroutine starts eagerly, owns nothing after launch (its frame frees @@ -61,7 +61,7 @@ struct Detached { // symmetric transfer, and a handler that throws completes with // Error::Unknown instead of terminating (the containment posture, since // completion contexts have no caller to rethrow to). Every path must -// co_return an Outcome — `smithy::Unit{}` is the clean close (a bare +// co_return an Outcome — `opal::Unit{}` is the clean close (a bare // co_return does not compile). Handlers may factor their logic into // StreamTask-returning sub-coroutines and co_await each exactly once; // sub-results beyond the Outcome travel by out-parameter (the result @@ -230,7 +230,7 @@ inline ReceiveMessageAwaitable ReceiveMessage(std::shared_ptr s // the frame of the Detached loop serving it, so the session ends when the // loop does. // -// smithy::eventstream::Detached Serve(AsyncEventStream stream) { +// opal::eventstream::Detached Serve(AsyncEventStream stream) { // while (true) { // auto event = co_await stream.Receive(); // if (!event.ok() || !event->has_value()) break; @@ -413,6 +413,6 @@ class AsyncEventStream { internal::SharedViewOwner view_; }; -} // namespace smithy::eventstream +} // namespace opal::eventstream #endif // SMITHY_EVENTSTREAM_ASYNC_EVENT_STREAM_H_ diff --git a/runtime/include/smithy/eventstream/envelope.h b/runtime/include/smithy/eventstream/envelope.h index e0805a00..0e3d70bc 100644 --- a/runtime/include/smithy/eventstream/envelope.h +++ b/runtime/include/smithy/eventstream/envelope.h @@ -9,7 +9,7 @@ #include "smithy/core/print.h" #include "smithy/eventstream/frame.h" -namespace smithy::eventstream { +namespace opal::eventstream { // The event envelope (ADR-0016): the ONE place the header convention that // puts typed events and exceptions onto event-stream messages lives. @@ -74,6 +74,6 @@ Message MakeExceptionMessage(std::string_view exception_type, std::string_view c // wrong wire type is an error. Outcome ParseEnvelope(const Message& message); -} // namespace smithy::eventstream +} // namespace opal::eventstream #endif // SMITHY_EVENTSTREAM_ENVELOPE_H_ diff --git a/runtime/include/smithy/eventstream/event_stream.h b/runtime/include/smithy/eventstream/event_stream.h index 31d980a1..64b46012 100644 --- a/runtime/include/smithy/eventstream/event_stream.h +++ b/runtime/include/smithy/eventstream/event_stream.h @@ -14,7 +14,7 @@ #include "smithy/eventstream/frame.h" #include "smithy/http/websocket.h" -namespace smithy::eventstream { +namespace opal::eventstream { // The vacant direction of a one-directional stream (ADR-0016): when an // operation models no event union for a direction, generated code @@ -312,7 +312,7 @@ class EventStream { // A handle safe to hold beyond this stream's lifetime (issue #112) — the // hub seam: a handler passes Share() to a registry - // (smithy::server::SessionRegistry) instead of parking its borrowed + // (opal::server::SessionRegistry) instead of parking its borrowed // `stream&` in one. A cheap-copy value: all of a stream's handles (and // their copies) see one revocable view of the session; destroying the // stream closes the session and leaves them failing softly with @@ -346,6 +346,6 @@ class EventStream { internal::SharedViewOwner view_; }; -} // namespace smithy::eventstream +} // namespace opal::eventstream #endif // SMITHY_EVENTSTREAM_EVENT_STREAM_H_ diff --git a/runtime/include/smithy/eventstream/frame.h b/runtime/include/smithy/eventstream/frame.h index 4ecef865..0bc93d95 100644 --- a/runtime/include/smithy/eventstream/frame.h +++ b/runtime/include/smithy/eventstream/frame.h @@ -15,7 +15,7 @@ #include "smithy/core/print.h" #include "smithy/core/timestamp.h" -namespace smithy::eventstream { +namespace opal::eventstream { // The event-stream message framing the protocol specs define event streams // against (ADR-0014): a CRC-guarded prelude, a typed header block, and an @@ -28,7 +28,7 @@ namespace smithy::eventstream { // Timestamps and UUIDs are distinct value types rather than aliases of // long/byte-array, so a decoded header can never be confused across wire // types that share a C++ representation. The timestamp is the runtime's -// one `smithy::Timestamp`, so headers and generated code trade timestamps +// one `opal::Timestamp`, so headers and generated code trade timestamps // without a conversion; core has no UUID value type, so Uuid lives here. struct Uuid { std::array bytes{}; @@ -141,6 +141,6 @@ struct DecodedFrame { // unchecked optional dereference. Outcome> DecodeMessage(std::string_view buffer); -} // namespace smithy::eventstream +} // namespace opal::eventstream #endif // SMITHY_EVENTSTREAM_FRAME_H_ diff --git a/runtime/include/smithy/eventstream/json_frame.h b/runtime/include/smithy/eventstream/json_frame.h index 677eb8a0..08442422 100644 --- a/runtime/include/smithy/eventstream/json_frame.h +++ b/runtime/include/smithy/eventstream/json_frame.h @@ -7,7 +7,7 @@ #include "smithy/core/outcome.h" #include "smithy/eventstream/frame.h" -namespace smithy::eventstream { +namespace opal::eventstream { // The negotiated JSON-text wire encoding (ADR-0018): the frame a browser // can speak with JSON.parse alone. A client offering this subprotocol on @@ -48,6 +48,6 @@ Outcome EncodeJsonFrame(const Message& message); // binary mode. Outcome DecodeJsonFrame(std::string_view text); -} // namespace smithy::eventstream +} // namespace opal::eventstream #endif // SMITHY_EVENTSTREAM_JSON_FRAME_H_ diff --git a/runtime/include/smithy/eventstream/jsonrpc_frame.h b/runtime/include/smithy/eventstream/jsonrpc_frame.h index a251385f..25253f74 100644 --- a/runtime/include/smithy/eventstream/jsonrpc_frame.h +++ b/runtime/include/smithy/eventstream/jsonrpc_frame.h @@ -8,7 +8,7 @@ #include "smithy/core/outcome.h" #include "smithy/eventstream/frame.h" -namespace smithy::eventstream { +namespace opal::eventstream { // The jsonRpc2 stream wire (ADR-0023): text JSON-RPC 2.0 envelopes end to // end, no smithy-specific framing. After the opening request envelope @@ -79,6 +79,6 @@ JsonRpcStreamFrame DecodeJsonRpcStreamFrame(std::string_view text, const Documen // "message":},"id":,"jsonrpc":"2.0"} (sorted, compact). std::string EncodeJsonRpcViolationResponse(int code, std::string_view reason, const Document& id); -} // namespace smithy::eventstream +} // namespace opal::eventstream #endif // SMITHY_EVENTSTREAM_JSONRPC_FRAME_H_ diff --git a/runtime/include/smithy/eventstream/jsonrpc_stream_socket.h b/runtime/include/smithy/eventstream/jsonrpc_stream_socket.h index ae1cb79c..4b532f3a 100644 --- a/runtime/include/smithy/eventstream/jsonrpc_stream_socket.h +++ b/runtime/include/smithy/eventstream/jsonrpc_stream_socket.h @@ -10,7 +10,7 @@ #include "smithy/eventstream/frame.h" #include "smithy/http/websocket.h" -namespace smithy::eventstream { +namespace opal::eventstream { // The jsonRpc2 stream translation (ADR-0023), worn as a delegating // WebSocket: above it, EventStream/AsyncEventStream and generated code @@ -101,6 +101,6 @@ class JsonRpcStreamSocket final : public http::WebSocket { Role role_; }; -} // namespace smithy::eventstream +} // namespace opal::eventstream #endif // SMITHY_EVENTSTREAM_JSONRPC_STREAM_SOCKET_H_ diff --git a/runtime/include/smithy/http/beast_transport.h b/runtime/include/smithy/http/beast_transport.h index e5dfe9ad..cc7fa6c5 100644 --- a/runtime/include/smithy/http/beast_transport.h +++ b/runtime/include/smithy/http/beast_transport.h @@ -13,15 +13,15 @@ #include "smithy/http/transport.h" #include "smithy/http/websocket.h" -namespace smithy { +namespace opal { // smithy/client/config.h — forward-declared so this header stays includable // without the client headers. The library dependency is deliberate: // FromConfig is the ClientConfig→transport bridge, and it lives here because // only this side can construct a Beast client while :client stays Boost-free. struct ClientConfig; -} // namespace smithy +} // namespace opal -namespace smithy::http { +namespace opal::http { // Production HTTP/1.1 server transport on Boost.Beast/asio (ADR-0006): // concurrent connections on an asio thread pool (bounded by @@ -32,7 +32,7 @@ namespace smithy::http { // This is what generated services should run on; WebSocket upgrades // (Phase 8) extend this transport. // -// smithy::http::BeastServerTransport server({.port = 8080}); +// opal::http::BeastServerTransport server({.port = 8080}); // server.Start(service.Handler()); // ... // server.Stop(); @@ -133,7 +133,7 @@ class BeastServerTransport : public HttpServerTransport { // RejectedRequest, before the rejection response is written). Runs on an // io thread, concurrently across connections — keep it cheap and // thread-safe; a throwing callback is contained and logged. Wire it to - // the same sink as smithy::server::Observe so over-limit abuse is + // the same sink as opal::server::Observe so over-limit abuse is // visible in the same metrics. std::function on_rejected{}; // Observation hook for connections the transport terminated without a @@ -236,10 +236,10 @@ class BeastServerTransport : public HttpServerTransport { // verification on by default. Thread-safe: concurrent Send() calls use // distinct connections. // -// smithy::ClientConfig config; +// opal::ClientConfig config; // config.endpoint = "https://api.example.com"; // config.tls.ca_pem = corp_ca_pem; // when not publicly trusted -// auto transport = smithy::http::BeastHttpClient::FromConfig(config); +// auto transport = opal::http::BeastHttpClient::FromConfig(config); // if (!transport) { /* bad endpoint */ } // config.http_client = *transport; // the wire // auto client = MyServiceClient::Create(std::move(config)); @@ -282,6 +282,6 @@ class BeastHttpClient : public HttpClient { std::shared_ptr state_; }; -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_BEAST_TRANSPORT_H_ diff --git a/runtime/include/smithy/http/forwarded.h b/runtime/include/smithy/http/forwarded.h index fc081bc4..5cd0b1c0 100644 --- a/runtime/include/smithy/http/forwarded.h +++ b/runtime/include/smithy/http/forwarded.h @@ -11,7 +11,7 @@ #include "smithy/core/outcome.h" #include "smithy/http/message.h" -namespace smithy::http { +namespace opal::http { struct DerivedClient; @@ -102,6 +102,6 @@ DerivedClient DeriveClient(const HttpRequest& request, const TrustedProxies& tru // The simple form: DeriveClient's address alone. std::string ClientAddress(const HttpRequest& request, const TrustedProxies& trusted); -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_FORWARDED_H_ diff --git a/runtime/include/smithy/http/headers.h b/runtime/include/smithy/http/headers.h index 8307d438..4be123b3 100644 --- a/runtime/include/smithy/http/headers.h +++ b/runtime/include/smithy/http/headers.h @@ -7,7 +7,7 @@ #include #include -namespace smithy::http { +namespace opal::http { // HTTP header collection: case-insensitive names, repeated names preserved in // insertion order (as list-valued headers require). @@ -88,6 +88,6 @@ std::optional FindUnsafeHeader(const Headers& headers); // the transports default to "/"). bool ValidRequestLineField(std::string_view field); -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_HEADERS_H_ diff --git a/runtime/include/smithy/http/http1.h b/runtime/include/smithy/http/http1.h index a721a0fb..aefc23e6 100644 --- a/runtime/include/smithy/http/http1.h +++ b/runtime/include/smithy/http/http1.h @@ -9,7 +9,7 @@ #include "smithy/core/outcome.h" #include "smithy/http/headers.h" -namespace smithy::http { +namespace opal::http { // The HTTP/1.1 message reader behind SocketHttpClient/SocketHttpServer, // factored out of the socket layer so hostile-input tests and the fuzz @@ -50,6 +50,6 @@ bool ParseRequestLine(std::string_view line, std::string* method, std::string* t // when the line is not HTTP-shaped or the status is implausible. Outcome ParseStatusLine(std::string_view line); -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_HTTP1_H_ diff --git a/runtime/include/smithy/http/loopback.h b/runtime/include/smithy/http/loopback.h index 80db8e9f..62aa7a33 100644 --- a/runtime/include/smithy/http/loopback.h +++ b/runtime/include/smithy/http/loopback.h @@ -6,7 +6,7 @@ #include "smithy/http/server_dispatch.h" #include "smithy/http/transport.h" -namespace smithy::http { +namespace opal::http { // In-memory transport: an HttpClient wired directly to a request handler with // no sockets, serialization of the connection, or threads. The backbone of @@ -33,6 +33,6 @@ class Loopback : public HttpClient, public HttpServerTransport { RequestHandler handler_; }; -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_LOOPBACK_H_ diff --git a/runtime/include/smithy/http/message.h b/runtime/include/smithy/http/message.h index d8820aba..952c62b2 100644 --- a/runtime/include/smithy/http/message.h +++ b/runtime/include/smithy/http/message.h @@ -5,7 +5,7 @@ #include "smithy/http/headers.h" -namespace smithy::http { +namespace opal::http { // Request/response bodies are byte strings for now. The alias exists so the // representation can grow into a stream-shaped type for Phase 8 (event @@ -44,6 +44,6 @@ struct HttpResponse { std::string operation{}; }; -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_MESSAGE_H_ diff --git a/runtime/include/smithy/http/server_dispatch.h b/runtime/include/smithy/http/server_dispatch.h index 14f83091..c1bbdcee 100644 --- a/runtime/include/smithy/http/server_dispatch.h +++ b/runtime/include/smithy/http/server_dispatch.h @@ -8,7 +8,7 @@ #include "smithy/http/message.h" #include "smithy/http/transport.h" -namespace smithy::http { +namespace opal::http { // Renders a peer's sockaddr as HttpRequest::peer_address ("ip:port", v6 // bracketed) — the one definition of the format, shared by every server @@ -40,6 +40,6 @@ std::string FormatPeerAddress(const sockaddr* address, socklen_t length); // empty — that yields a 503 (no correlation id: nothing ran). HttpResponse InvokeHandlerGuarded(const RequestHandler& handler, HttpRequest request); -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_SERVER_DISPATCH_H_ diff --git a/runtime/include/smithy/http/socket_transport.h b/runtime/include/smithy/http/socket_transport.h index caa5b3db..879eeb73 100644 --- a/runtime/include/smithy/http/socket_transport.h +++ b/runtime/include/smithy/http/socket_transport.h @@ -9,7 +9,7 @@ #include "smithy/http/transport.h" -namespace smithy::http { +namespace opal::http { // Built-in dependency-free HTTP/1.1 client over TCP (ADR-0005; demoted to a // test/reference transport by ADR-0006). One connection per request, @@ -60,6 +60,6 @@ class SocketHttpServer : public HttpServerTransport { std::thread accept_thread_; }; -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_SOCKET_TRANSPORT_H_ diff --git a/runtime/include/smithy/http/trace_context.h b/runtime/include/smithy/http/trace_context.h index 8b24e2dc..09b52c3b 100644 --- a/runtime/include/smithy/http/trace_context.h +++ b/runtime/include/smithy/http/trace_context.h @@ -5,7 +5,7 @@ #include #include -namespace smithy::http { +namespace opal::http { // W3C Trace Context (https://www.w3.org/TR/trace-context/): the traceparent // header's fields, SDK-free. Backend integration (OpenTelemetry etc.) builds @@ -29,6 +29,6 @@ TraceContext GenerateTraceContext(); // A fresh random 16-hex-digit span id (for deriving child contexts). std::string GenerateSpanId(); -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_TRACE_CONTEXT_H_ diff --git a/runtime/include/smithy/http/transport.h b/runtime/include/smithy/http/transport.h index 9f7ba140..7c8fd648 100644 --- a/runtime/include/smithy/http/transport.h +++ b/runtime/include/smithy/http/transport.h @@ -8,10 +8,10 @@ #include "smithy/core/outcome.h" #include "smithy/http/message.h" -namespace smithy::http { +namespace opal::http { // TLS verification knobs, defined once for both sides of the handoff: -// smithy::ClientConfig carries one (the knob consumers set) and TLS-capable +// opal::ClientConfig carries one (the knob consumers set) and TLS-capable // client transports embed the same struct (BeastHttpClient::Options), so the // shape, defaults, and semantics can't drift apart. Certificate + hostname // verification is on by default. `ca_pem` replaces the system trust roots @@ -54,6 +54,6 @@ class HttpServerTransport { virtual void Stop() = 0; }; -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_TRANSPORT_H_ diff --git a/runtime/include/smithy/http/uri.h b/runtime/include/smithy/http/uri.h index 7942f58a..b5fb2187 100644 --- a/runtime/include/smithy/http/uri.h +++ b/runtime/include/smithy/http/uri.h @@ -8,7 +8,7 @@ #include "smithy/core/outcome.h" -namespace smithy::http { +namespace opal::http { // Percent-encodes for a single path segment (httpLabel): every byte outside // RFC 3986 "unreserved" is escaped, including '/'. @@ -68,6 +68,6 @@ struct Endpoint { }; Outcome ParseEndpoint(std::string_view url); -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_URI_H_ diff --git a/runtime/include/smithy/http/websocket.h b/runtime/include/smithy/http/websocket.h index 5ac4a19b..ec68b6ee 100644 --- a/runtime/include/smithy/http/websocket.h +++ b/runtime/include/smithy/http/websocket.h @@ -11,7 +11,7 @@ #include "smithy/http/headers.h" #include "smithy/http/transport.h" -namespace smithy::http { +namespace opal::http { // A blocking, full-duplex event-stream session over one WebSocket // connection (ADR-0015). What travels is eventstream::Message — exactly one @@ -283,7 +283,7 @@ using WebSocketDialer = // the handle only after every Send/Receive has returned — Close() is the // cancellation path, destruction is not. // -// auto socket = smithy::http::BeastWebSocketClient::Dial({ +// auto socket = opal::http::BeastWebSocketClient::Dial({ // .host = "stream.example.com", .port = 443, .tls = true, // .target = "/events", // }); @@ -336,6 +336,6 @@ class BeastWebSocketClient { static WebSocketDialer Dialer(); }; -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_WEBSOCKET_H_ diff --git a/runtime/include/smithy/http/websocket_pair.h b/runtime/include/smithy/http/websocket_pair.h index 71274067..b0abef56 100644 --- a/runtime/include/smithy/http/websocket_pair.h +++ b/runtime/include/smithy/http/websocket_pair.h @@ -7,7 +7,7 @@ #include "smithy/http/websocket.h" -namespace smithy::http { +namespace opal::http { // In-memory WebSocket session: two connected WebSocket ends sharing bounded // queues, with no sockets or io threads — the Loopback analog for event @@ -46,6 +46,6 @@ class InMemoryWebSocketPair { static std::pair, std::shared_ptr> Create(); }; -} // namespace smithy::http +} // namespace opal::http #endif // SMITHY_HTTP_WEBSOCKET_PAIR_H_ diff --git a/runtime/include/smithy/json/json.h b/runtime/include/smithy/json/json.h index 908d9f3d..6439d764 100644 --- a/runtime/include/smithy/json/json.h +++ b/runtime/include/smithy/json/json.h @@ -7,7 +7,7 @@ #include "smithy/core/document.h" #include "smithy/core/outcome.h" -namespace smithy::json { +namespace opal::json { // Renders a Document as compact JSON text with Smithy JSON conventions: // blob nodes become base64 strings; timestamp nodes follow their stored @@ -21,6 +21,6 @@ std::string Encode(const Document& doc); // which re-types members via Base64Decode / Timestamp::Parse. Outcome Decode(std::string_view text); -} // namespace smithy::json +} // namespace opal::json #endif // SMITHY_JSON_JSON_H_ diff --git a/runtime/include/smithy/server/access_log.h b/runtime/include/smithy/server/access_log.h index b783eabf..d8385e78 100644 --- a/runtime/include/smithy/server/access_log.h +++ b/runtime/include/smithy/server/access_log.h @@ -7,7 +7,7 @@ #include "smithy/server/middleware.h" -namespace smithy::server { +namespace opal::server { // The structured access log (issue #203): one RequestObservation in, one // line of JSON out. A pure function — no I/O, no sink, no configuration, no @@ -82,6 +82,6 @@ using AccessLogFields = std::vector>; std::string FormatAccessLog(const RequestObservation& observation, const AccessLogFields& extra = {}); -} // namespace smithy::server +} // namespace opal::server #endif // SMITHY_SERVER_ACCESS_LOG_H_ diff --git a/runtime/include/smithy/server/metrics.h b/runtime/include/smithy/server/metrics.h index adae722c..fc87f070 100644 --- a/runtime/include/smithy/server/metrics.h +++ b/runtime/include/smithy/server/metrics.h @@ -15,7 +15,7 @@ #include "smithy/core/fatal.h" #include "smithy/server/middleware.h" -namespace smithy::server { +namespace opal::server { // A dependency-free Prometheus backend for the server hooks (issue #91). // @@ -26,10 +26,10 @@ namespace smithy::server { // the same Observe hook everything else uses, and MetricsEndpoint serves what // the registry holds. // -// auto metrics = std::make_shared( -// smithy::server::MetricsOptions{.enabled = true, +// auto metrics = std::make_shared( +// opal::server::MetricsOptions{.enabled = true, // .service_name = "todo-service"}); -// transport.Start(smithy::server::Chain({MetricsEndpoint(metrics), +// transport.Start(opal::server::Chain({MetricsEndpoint(metrics), // RecordMetrics(metrics), // HealthEndpoint()}, // server.Handler())); @@ -152,8 +152,8 @@ class Counter { // and deliberately BEFORE the disabled-registry check: enabling metrics // in production must never be the first time this runs. if (amount < 0) { - smithy::internal::Fatal( - "smithy::server::Counter: a counter may not be incremented by a negative amount"); + opal::internal::Fatal( + "opal::server::Counter: a counter may not be incremented by a negative amount"); } // A handle from a disabled registry holds no family. The branch is what // makes an always-compiled call site free when metrics are off; the @@ -452,14 +452,14 @@ Middleware RecordMetrics(std::shared_ptr registry); // A ready-made sink for `BeastServerTransport::Options::on_rejected`: // -// options.on_rejected = smithy::server::RecordRejections(metrics); +// options.on_rejected = opal::server::RecordRejections(metrics); // // Generic in the rejection type so this header — and `:server` with it — // keeps no dependency on the Beast transport that defines it. A null // registry aborts (ADR-0009). inline auto RecordRejections(std::shared_ptr registry) { if (registry == nullptr) { - smithy::internal::Fatal("smithy::server::RecordRejections: registry may not be null"); + opal::internal::Fatal("opal::server::RecordRejections: registry may not be null"); } return [registry = std::move(registry)](const auto& rejected) { registry->RecordRejection(rejected.method, rejected.status); @@ -488,6 +488,6 @@ inline auto RecordRejections(std::shared_ptr registry) { Middleware MetricsEndpoint(std::shared_ptr registry, std::string path = "/metrics"); -} // namespace smithy::server +} // namespace opal::server #endif // SMITHY_SERVER_METRICS_H_ diff --git a/runtime/include/smithy/server/middleware.h b/runtime/include/smithy/server/middleware.h index 80fa903e..6e1cc8c4 100644 --- a/runtime/include/smithy/server/middleware.h +++ b/runtime/include/smithy/server/middleware.h @@ -12,7 +12,7 @@ #include "smithy/http/forwarded.h" #include "smithy/http/transport.h" -namespace smithy::server { +namespace opal::server { // User-supplied middleware wraps the transport-facing handler a generated // server exposes: inspect or reject requests before dispatch, observe or @@ -20,7 +20,7 @@ namespace smithy::server { // so it works with any HttpServerTransport: // // WeatherServer server(handler); -// transport.Start(smithy::server::Chain({AuthCheck(), Observe(log)}, +// transport.Start(opal::server::Chain({AuthCheck(), Observe(log)}, // server.Handler())); using Middleware = std::function; @@ -203,6 +203,6 @@ Middleware RequireBearerAuth(std::function validator); Middleware RequireApiKeyHeader(std::string header_name, std::string scheme, std::function validator); -} // namespace smithy::server +} // namespace opal::server #endif // SMITHY_SERVER_MIDDLEWARE_H_ diff --git a/runtime/include/smithy/server/origin_gate.h b/runtime/include/smithy/server/origin_gate.h index f3ef7fdc..61debdeb 100644 --- a/runtime/include/smithy/server/origin_gate.h +++ b/runtime/include/smithy/server/origin_gate.h @@ -8,7 +8,7 @@ #include "smithy/http/message.h" -namespace smithy::server { +namespace opal::server { // An Origin allowlist as a websocket_gate (ADR-0018, issue #113): the // dozen lines every browser-facing WebSocket endpoint rebuilds, built @@ -34,10 +34,10 @@ namespace smithy::server { // Composes by chaining, like every gate — run it first, then defer: // // options.websocket_gate = -// [origin = smithy::server::RequireOrigin({"https://muchq.com"}), +// [origin = opal::server::RequireOrigin({"https://muchq.com"}), // auth = MyAuthGate(), router = server.StreamRouter()->Gate()]( -// const smithy::http::HttpRequest& request) -// -> std::optional { +// const opal::http::HttpRequest& request) +// -> std::optional { // if (auto refusal = origin(request)) return refusal; // if (auto refusal = auth(request)) return refusal; // return router(request); @@ -45,6 +45,6 @@ namespace smithy::server { std::function(const http::HttpRequest&)> RequireOrigin( const std::vector& allowed_origins); -} // namespace smithy::server +} // namespace opal::server #endif // SMITHY_SERVER_ORIGIN_GATE_H_ diff --git a/runtime/include/smithy/server/router.h b/runtime/include/smithy/server/router.h index dd9386b6..83a79c54 100644 --- a/runtime/include/smithy/server/router.h +++ b/runtime/include/smithy/server/router.h @@ -11,7 +11,7 @@ #include "smithy/http/message.h" #include "smithy/http/uri.h" -namespace smithy::server { +namespace opal::server { // Values captured from URI labels during route matching, keyed by label name. // Greedy label values keep their embedded slashes (decoded). @@ -122,6 +122,6 @@ struct ValidationFailure { std::string message; }; -} // namespace smithy::server +} // namespace opal::server #endif // SMITHY_SERVER_ROUTER_H_ diff --git a/runtime/include/smithy/server/session_registry.h b/runtime/include/smithy/server/session_registry.h index 70611029..f90a9ce3 100644 --- a/runtime/include/smithy/server/session_registry.h +++ b/runtime/include/smithy/server/session_registry.h @@ -19,7 +19,7 @@ #include "smithy/eventstream/event_stream.h" -namespace smithy::server { +namespace opal::server { // The multi-client fan-out helper (issue #112): a thread-safe map of owning // session handles (EventStream::Share) with a bounded outbound queue per @@ -28,7 +28,7 @@ namespace smithy::server { // send loops per consumer. Tx is the event union the sessions transmit; Id // is the application's session key (player id, connection id). // -// smithy::server::SessionRegistry registry; +// opal::server::SessionRegistry registry; // registry.Add(player_id, stream.Share()); // handler entry // registry.SendTo(player_id, event); // queued, non-blocking // registry.Broadcast(ids, [&](const Id& id) { return RedactFor(id); }); @@ -831,6 +831,6 @@ class SessionRegistry { bool expiry_stop_ = false; }; -} // namespace smithy::server +} // namespace opal::server #endif // SMITHY_SERVER_SESSION_REGISTRY_H_ diff --git a/runtime/include/smithy/server/websocket_router.h b/runtime/include/smithy/server/websocket_router.h index 9c8707cc..2141ac8e 100644 --- a/runtime/include/smithy/server/websocket_router.h +++ b/runtime/include/smithy/server/websocket_router.h @@ -14,7 +14,7 @@ #include "smithy/http/websocket.h" #include "smithy/server/router.h" -namespace smithy::server { +namespace opal::server { // A streaming operation's serve callback: the upgrade request, the routing // context built from it (labels + query + the request pointer — exactly @@ -143,6 +143,6 @@ class WebSocketRouter { Seam seam_ = Seam::kNone; }; -} // namespace smithy::server +} // namespace opal::server #endif // SMITHY_SERVER_WEBSOCKET_ROUTER_H_ diff --git a/runtime/src/cbor/cbor.cc b/runtime/src/cbor/cbor.cc index 95c8d2cf..8b322f3a 100644 --- a/runtime/src/cbor/cbor.cc +++ b/runtime/src/cbor/cbor.cc @@ -7,7 +7,7 @@ #include #include -namespace smithy::cbor { +namespace opal::cbor { namespace { // --- Encoding --------------------------------------------------------------- @@ -345,4 +345,4 @@ Outcome Decode(const Blob& bytes) { return Decoder(bytes.data(), bytes.size()).DecodeDocument(); } -} // namespace smithy::cbor +} // namespace opal::cbor diff --git a/runtime/src/client/observability.cc b/runtime/src/client/observability.cc index e5262066..a3060526 100644 --- a/runtime/src/client/observability.cc +++ b/runtime/src/client/observability.cc @@ -2,7 +2,7 @@ #include -namespace smithy { +namespace opal { namespace { class AttemptObserver final : public Interceptor { @@ -65,4 +65,4 @@ std::shared_ptr PropagateTraceContext( return std::make_shared(std::move(current)); } -} // namespace smithy +} // namespace opal diff --git a/runtime/src/client/retry.cc b/runtime/src/client/retry.cc index 35222792..5ff7deab 100644 --- a/runtime/src/client/retry.cc +++ b/runtime/src/client/retry.cc @@ -4,7 +4,7 @@ #include #include -namespace smithy { +namespace opal { namespace { double UniformJitter() { @@ -67,4 +67,4 @@ Outcome SendWithRetries( return outcome; } -} // namespace smithy +} // namespace opal diff --git a/runtime/src/compression/gzip.cc b/runtime/src/compression/gzip.cc index 9718a45c..5375544d 100644 --- a/runtime/src/compression/gzip.cc +++ b/runtime/src/compression/gzip.cc @@ -13,7 +13,7 @@ #include #include -namespace smithy { +namespace opal { namespace { constexpr int kGzipWindowBits = 15 + 16; // 32KB window, gzip wrapper @@ -157,4 +157,4 @@ Outcome GzipDecompress(std::string_view data, std::size_t max_outpu return internal::GzipDecompressChunked(data, max_output, kMaxFeed); } -} // namespace smithy +} // namespace opal diff --git a/runtime/src/core/base64.cc b/runtime/src/core/base64.cc index d1d6c73f..a15e848c 100644 --- a/runtime/src/core/base64.cc +++ b/runtime/src/core/base64.cc @@ -4,7 +4,7 @@ #include #include -namespace smithy { +namespace opal { namespace { constexpr std::string_view kAlphabet = @@ -88,4 +88,4 @@ Outcome Base64Decode(std::string_view text) { return Blob(std::move(out)); } -} // namespace smithy +} // namespace opal diff --git a/runtime/src/core/document_serde.cc b/runtime/src/core/document_serde.cc index ab29539f..cccd8a81 100644 --- a/runtime/src/core/document_serde.cc +++ b/runtime/src/core/document_serde.cc @@ -9,7 +9,7 @@ #include "smithy/core/base64.h" -namespace smithy { +namespace opal { Outcome TimestampFromDocument(const Document& doc, TimestampFormat format) { if (doc.is_timestamp()) { @@ -89,4 +89,4 @@ std::string FormatFloating(T value) { std::string FormatDouble(double value) { return FormatFloating(value); } std::string FormatFloat(float value) { return FormatFloating(value); } -} // namespace smithy +} // namespace opal diff --git a/runtime/src/core/regex.cc b/runtime/src/core/regex.cc index e2817ebd..7987b9f5 100644 --- a/runtime/src/core/regex.cc +++ b/runtime/src/core/regex.cc @@ -6,7 +6,7 @@ #include "smithy/core/error.h" -namespace smithy { +namespace opal { namespace { // Compiled programs are bounded so counted repetition ({n,m} expands by @@ -666,4 +666,4 @@ bool Regex::Search(std::string_view text, std::size_t* steps) const { return false; } -} // namespace smithy +} // namespace opal diff --git a/runtime/src/core/text.cc b/runtime/src/core/text.cc index 6f515d87..33081ba1 100644 --- a/runtime/src/core/text.cc +++ b/runtime/src/core/text.cc @@ -1,6 +1,6 @@ #include "smithy/core/text.h" -namespace smithy { +namespace opal { std::size_t Utf8CodePointCount(std::string_view text) { std::size_t count = 0; @@ -11,4 +11,4 @@ std::size_t Utf8CodePointCount(std::string_view text) { return count; } -} // namespace smithy +} // namespace opal diff --git a/runtime/src/core/timestamp.cc b/runtime/src/core/timestamp.cc index 0d0ca6a4..b2a8bedf 100644 --- a/runtime/src/core/timestamp.cc +++ b/runtime/src/core/timestamp.cc @@ -13,7 +13,7 @@ // std::chrono::parse for chrono types are not available across gcc 11 / clang 14 // / MSVC 19.30. -namespace smithy { +namespace opal { namespace { constexpr std::int64_t kMsPerSecond = 1000; @@ -313,4 +313,4 @@ Outcome Timestamp::Parse(std::string_view text, TimestampFormat forma return Error::Serialization("timestamp: unknown format"); } -} // namespace smithy +} // namespace opal diff --git a/runtime/src/core/uuid.cc b/runtime/src/core/uuid.cc index 086b574d..cd3b1819 100644 --- a/runtime/src/core/uuid.cc +++ b/runtime/src/core/uuid.cc @@ -5,7 +5,7 @@ #include #include -namespace smithy { +namespace opal { std::string GenerateUuidV4() { thread_local std::mt19937_64 generator = [] { @@ -39,4 +39,4 @@ std::string GenerateUuidV4() { return out; } -} // namespace smithy +} // namespace opal diff --git a/runtime/src/core/version.cc b/runtime/src/core/version.cc index 09f4efa1..4390fc85 100644 --- a/runtime/src/core/version.cc +++ b/runtime/src/core/version.cc @@ -1,9 +1,9 @@ #include "smithy/core/version.h" -namespace smithy { +namespace opal { // The one source of truth for the product version (see docs/versioning.md); // the client User-Agent mirrors it. std::string_view Version() { return "0.3.0-dev"; } -} // namespace smithy +} // namespace opal diff --git a/runtime/src/eventstream/envelope.cc b/runtime/src/eventstream/envelope.cc index e0bdffe0..62f3d4e7 100644 --- a/runtime/src/eventstream/envelope.cc +++ b/runtime/src/eventstream/envelope.cc @@ -5,7 +5,7 @@ #include "smithy/core/error.h" -namespace smithy::eventstream { +namespace opal::eventstream { namespace { constexpr std::string_view kMessageTypeHeader = ":message-type"; @@ -91,4 +91,4 @@ Outcome ParseEnvelope(const Message& message) { return envelope; } -} // namespace smithy::eventstream +} // namespace opal::eventstream diff --git a/runtime/src/eventstream/frame.cc b/runtime/src/eventstream/frame.cc index b6b4cd74..4b745a0f 100644 --- a/runtime/src/eventstream/frame.cc +++ b/runtime/src/eventstream/frame.cc @@ -5,7 +5,7 @@ #include "smithy/core/error.h" #include "smithy/core/overloaded.h" -namespace smithy::eventstream { +namespace opal::eventstream { namespace { // The format's header wire-type tags. The two boolean tags map onto the @@ -292,4 +292,4 @@ Outcome> DecodeMessage(std::string_view buffer) { return std::optional(DecodedFrame{std::move(message), total}); } -} // namespace smithy::eventstream +} // namespace opal::eventstream diff --git a/runtime/src/eventstream/json_frame.cc b/runtime/src/eventstream/json_frame.cc index 9799bff3..5b349769 100644 --- a/runtime/src/eventstream/json_frame.cc +++ b/runtime/src/eventstream/json_frame.cc @@ -10,7 +10,7 @@ #include "smithy/eventstream/envelope.h" #include "smithy/json/json.h" -namespace smithy::eventstream { +namespace opal::eventstream { namespace { constexpr std::string_view kEventMember = "event"; @@ -134,4 +134,4 @@ Outcome DecodeJsonFrame(std::string_view text) { : MakeExceptionMessage(type.as_string(), kJsonContentType, std::move(payload_bytes)); } -} // namespace smithy::eventstream +} // namespace opal::eventstream diff --git a/runtime/src/eventstream/jsonrpc_frame.cc b/runtime/src/eventstream/jsonrpc_frame.cc index bc067de6..86678ceb 100644 --- a/runtime/src/eventstream/jsonrpc_frame.cc +++ b/runtime/src/eventstream/jsonrpc_frame.cc @@ -9,7 +9,7 @@ #include "smithy/eventstream/envelope.h" #include "smithy/json/json.h" -namespace smithy::eventstream { +namespace opal::eventstream { namespace { constexpr std::string_view kVersionMember = "jsonrpc"; @@ -263,4 +263,4 @@ std::string EncodeJsonRpcViolationResponse(int code, std::string_view reason, co return json::Encode(Document(std::move(envelope))); } -} // namespace smithy::eventstream +} // namespace opal::eventstream diff --git a/runtime/src/eventstream/jsonrpc_stream_socket.cc b/runtime/src/eventstream/jsonrpc_stream_socket.cc index f908feb9..3ca8c705 100644 --- a/runtime/src/eventstream/jsonrpc_stream_socket.cc +++ b/runtime/src/eventstream/jsonrpc_stream_socket.cc @@ -10,7 +10,7 @@ #include "smithy/core/error.h" #include "smithy/eventstream/jsonrpc_frame.h" -namespace smithy::eventstream { +namespace opal::eventstream { namespace { using Role = JsonRpcStreamSocket::Role; @@ -184,4 +184,4 @@ void JsonRpcStreamSocket::SendAsync(const Message& message, SendCallback callbac bool JsonRpcStreamSocket::SupportsAsync() const { return inner_->SupportsAsync(); } -} // namespace smithy::eventstream +} // namespace opal::eventstream diff --git a/runtime/src/http/beast_transport.cc b/runtime/src/http/beast_transport.cc index f2ff9bc3..ab14b017 100644 --- a/runtime/src/http/beast_transport.cc +++ b/runtime/src/http/beast_transport.cc @@ -42,7 +42,7 @@ #include "smithy/http/server_dispatch.h" #include "smithy/http/uri.h" -namespace smithy::http { +namespace opal::http { namespace { namespace asio = boost::asio; @@ -1714,7 +1714,7 @@ Outcome BeastServerTransport::Start(RequestHandler handler) { // load, a bad_alloc — which Contain turns into a transport Error rather // than unwinding into the caller. The destructor's Shutdown() joins any // threads that did start. - return smithy::internal::Contain( + return opal::internal::Contain( [&]() -> Outcome { return StartContained(std::move(handler)); }, [](const char* what) -> Outcome { return Error::Transport(std::string("beast: start failed: ") + @@ -2178,7 +2178,7 @@ Outcome> BeastHttpClient::FromConfig(const Clie // The make_shared (State ctor allocates the io_context) is the throw // vector; contain it so no exception crosses the Outcome boundary // (ADR-0003). - return smithy::internal::Contain( + return opal::internal::Contain( [&]() -> Outcome> { auto endpoint = ParseEndpoint(config.endpoint); if (!endpoint) { @@ -2204,7 +2204,7 @@ Outcome BeastHttpClient::Send(const HttpRequest& request) { // all error_code-based, so the residual throw vector is a std::bad_alloc // from the sync drive under memory pressure; Contain turns it into a // transport Error instead of unwinding into the caller. - return smithy::internal::Contain( + return opal::internal::Contain( [&]() -> Outcome { return SendContained(request); }, [](const char* what) -> Outcome { return Error::Transport(std::string("beast client: send failed: ") + @@ -2574,4 +2574,4 @@ WebSocketDialer BeastWebSocketClient::Dialer() { }; } -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/src/http/forwarded.cc b/runtime/src/http/forwarded.cc index 43b5f497..fe3271d6 100644 --- a/runtime/src/http/forwarded.cc +++ b/runtime/src/http/forwarded.cc @@ -8,7 +8,7 @@ #include "smithy/http/headers.h" -namespace smithy::http { +namespace opal::http { namespace { // A parsed numeric address: 4 (AF_INET) or 16 (AF_INET6) significant bytes. @@ -245,4 +245,4 @@ std::string ClientAddress(const HttpRequest& request, const TrustedProxies& trus return DeriveClient(request, trusted).address; } -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/src/http/headers.cc b/runtime/src/http/headers.cc index bf6d3fa6..55134700 100644 --- a/runtime/src/http/headers.cc +++ b/runtime/src/http/headers.cc @@ -3,7 +3,7 @@ #include #include -namespace smithy::http { +namespace opal::http { namespace { char AsciiLower(char c) { return (c >= 'A' && c <= 'Z') ? static_cast(c - 'A' + 'a') : c; } @@ -168,4 +168,4 @@ std::vector SplitHttpDateHeaderValues(std::string_view value) { return out; } -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/src/http/http1.cc b/runtime/src/http/http1.cc index 51aec6d3..3890f33f 100644 --- a/runtime/src/http/http1.cc +++ b/runtime/src/http/http1.cc @@ -7,7 +7,7 @@ #include "smithy/core/error.h" -namespace smithy::http { +namespace opal::http { namespace { constexpr std::size_t kMaxHeaderBytes = std::size_t{64} * 1024; @@ -126,4 +126,4 @@ Outcome ParseStatusLine(std::string_view line) { return status; } -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/src/http/server_dispatch.cc b/runtime/src/http/server_dispatch.cc index 93775f3f..e746b084 100644 --- a/runtime/src/http/server_dispatch.cc +++ b/runtime/src/http/server_dispatch.cc @@ -9,7 +9,7 @@ #include "smithy/core/exception_guard.h" #include "smithy/http/trace_context.h" -namespace smithy::http { +namespace opal::http { namespace { // The mint half of the guard's contract (server_dispatch.h, ADR-0011). @@ -50,7 +50,7 @@ HttpResponse InternalError(const HttpRequest& request, const std::string& what) } // A 5xx that leaves the handler chain without a correlation id gets the -// request's trace id (issue #46) — a returned smithy::Error mapped to a 500 +// request's trace id (issue #46) — a returned opal::Error mapped to a 500 // by a generated server then correlates exactly like a thrown one, across // every protocol, with no generated code involved. A handler-set id wins. void CorrelateServerError(const HttpRequest& request, HttpResponse& response) { @@ -82,7 +82,7 @@ HttpResponse InvokeHandlerGuarded(const RequestHandler& handler, HttpRequest req // out of the transport executor and terminates the process, dropping every // in-flight request (ADR-0003). Under -fno-exceptions the handler cannot // throw, so this compiles to a direct call. - return smithy::internal::Contain( + return opal::internal::Contain( [&] { HttpResponse response = handler(request); CorrelateServerError(request, response); @@ -93,4 +93,4 @@ HttpResponse InvokeHandlerGuarded(const RequestHandler& handler, HttpRequest req }); } -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/src/http/socket_transport.cc b/runtime/src/http/socket_transport.cc index c2bff6e1..704300cb 100644 --- a/runtime/src/http/socket_transport.cc +++ b/runtime/src/http/socket_transport.cc @@ -16,7 +16,7 @@ #include "smithy/http/http1.h" #include "smithy/http/server_dispatch.h" -namespace smithy::http { +namespace opal::http { namespace { using SocketFd = int; @@ -268,7 +268,7 @@ void SocketHttpServer::Shutdown() noexcept { stopping_ = true; // Teardown must not propagate out of a destructor; Contain swallows any // throw (and is a no-op wrapper under -fno-exceptions). - smithy::internal::Contain( + opal::internal::Contain( [&] { // Nudge the accept loop awake with a throwaway connection, then close. { @@ -286,4 +286,4 @@ void SocketHttpServer::Shutdown() noexcept { handler_ = nullptr; } -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/src/http/trace_context.cc b/runtime/src/http/trace_context.cc index ae2ced13..0bd094e5 100644 --- a/runtime/src/http/trace_context.cc +++ b/runtime/src/http/trace_context.cc @@ -5,7 +5,7 @@ #include #include -namespace smithy::http { +namespace opal::http { namespace { bool IsLowerHex(std::string_view text) { @@ -84,4 +84,4 @@ std::string GenerateSpanId() { return id; } -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/src/http/uri.cc b/runtime/src/http/uri.cc index 84e3e27a..14b89036 100644 --- a/runtime/src/http/uri.cc +++ b/runtime/src/http/uri.cc @@ -3,7 +3,7 @@ #include #include -namespace smithy::http { +namespace opal::http { namespace { constexpr std::string_view kHex = "0123456789ABCDEF"; @@ -181,4 +181,4 @@ Outcome ParseEndpoint(std::string_view url) { return endpoint; } -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/src/http/websocket_pair.cc b/runtime/src/http/websocket_pair.cc index ab72de58..11f1769f 100644 --- a/runtime/src/http/websocket_pair.cc +++ b/runtime/src/http/websocket_pair.cc @@ -14,7 +14,7 @@ #include "smithy/eventstream/frame.h" -namespace smithy::http { +namespace opal::http { namespace { // The Beast session's receive-side buffer bound (beast_transport.cc), @@ -377,4 +377,4 @@ std::pair, std::shared_ptr> InMemoryWebSoc return {std::make_shared(state, 0), std::make_shared(state, 1)}; } -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/src/json/json.cc b/runtime/src/json/json.cc index 246a40a3..90c0a1f4 100644 --- a/runtime/src/json/json.cc +++ b/runtime/src/json/json.cc @@ -7,7 +7,7 @@ #include "smithy/core/base64.h" -namespace smithy::json { +namespace opal::json { namespace { nlohmann::json ToBackend(const Document& doc) { @@ -151,4 +151,4 @@ Outcome Decode(std::string_view text) { return FromBackend(parsed); } -} // namespace smithy::json +} // namespace opal::json diff --git a/runtime/src/server/access_log.cc b/runtime/src/server/access_log.cc index d5eec67a..6a91d57e 100644 --- a/runtime/src/server/access_log.cc +++ b/runtime/src/server/access_log.cc @@ -10,7 +10,7 @@ #include "smithy/http/forwarded.h" #include "smithy/http/trace_context.h" -namespace smithy::server { +namespace opal::server { namespace { @@ -173,7 +173,7 @@ void CheckExtraKeys(const AccessLogFields& extra) { for (std::size_t i = 0; i < extra.size(); ++i) { const std::string& key = extra[i].first; if (key.empty()) { - smithy::internal::Fatal("smithy::server::FormatAccessLog: extra field key is empty"); + opal::internal::Fatal("opal::server::FormatAccessLog: extra field key is empty"); } for (std::size_t k = 0; k < key.size();) { if (static_cast(key[k]) < 0x80) { @@ -182,21 +182,21 @@ void CheckExtraKeys(const AccessLogFields& extra) { } const std::size_t length = Utf8SequenceLength(key, k); if (length == 0) { - smithy::internal::Fatal("smithy::server::FormatAccessLog: extra field key '" + key + - "' is not well-formed UTF-8"); + opal::internal::Fatal("opal::server::FormatAccessLog: extra field key '" + key + + "' is not well-formed UTF-8"); } k += length; } for (const std::string_view built_in : kBuiltInKeys) { if (key == built_in) { - smithy::internal::Fatal("smithy::server::FormatAccessLog: extra field '" + key + - "' shadows a built-in field"); + opal::internal::Fatal("opal::server::FormatAccessLog: extra field '" + key + + "' shadows a built-in field"); } } for (std::size_t j = 0; j < i; ++j) { if (extra[j].first == key) { - smithy::internal::Fatal("smithy::server::FormatAccessLog: extra field '" + key + - "' is given twice"); + opal::internal::Fatal("opal::server::FormatAccessLog: extra field '" + key + + "' is given twice"); } } } @@ -229,4 +229,4 @@ std::string FormatAccessLog(const RequestObservation& o, const AccessLogFields& return out; } -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/src/server/metrics.cc b/runtime/src/server/metrics.cc index c8ada23c..ce9541c8 100644 --- a/runtime/src/server/metrics.cc +++ b/runtime/src/server/metrics.cc @@ -11,7 +11,7 @@ #include "smithy/core/fatal.h" -namespace smithy::server { +namespace opal::server { namespace { // The exposition format's own escaping for label values: backslash, double @@ -154,7 +154,7 @@ std::string RenderLabels(const MetricLabels& labels, bool histogram) { for (std::size_t i = 0; i < sorted.size(); ++i) { const auto& [name, value] = sorted[i]; if (!ValidName(name, /*allow_colon=*/false)) { - smithy::internal::Fatal("smithy::server::MetricsRegistry: invalid label name '" + name + "'"); + opal::internal::Fatal("opal::server::MetricsRegistry: invalid label name '" + name + "'"); } // Both of these render a scrape Prometheus rejects whole, with no // in-process consumer to notice — the same class the invalid-name abort @@ -162,12 +162,11 @@ std::string RenderLabels(const MetricLabels& labels, bool histogram) { // `le` is the label the histogram exposition appends itself, so a user // copy would put it on every bucket line twice. if (i > 0 && name == sorted[i - 1].first) { - smithy::internal::Fatal("smithy::server::MetricsRegistry: duplicate label name '" + name + - "'"); + opal::internal::Fatal("opal::server::MetricsRegistry: duplicate label name '" + name + "'"); } if (histogram && name == "le") { - smithy::internal::Fatal( - "smithy::server::MetricsRegistry: 'le' is reserved on a histogram's series"); + opal::internal::Fatal( + "opal::server::MetricsRegistry: 'le' is reserved on a histogram's series"); } if (!out.empty()) out += ','; out += name; @@ -299,8 +298,8 @@ MetricsRegistry::MetricsRegistry(MetricsOptions options) : options_(std::move(op // failure mode worth aborting for: it looks like success everywhere except // the panel nobody is watching yet. if (options_.enabled && options_.service_name.empty()) { - smithy::internal::Fatal( - "smithy::server::MetricsRegistry: service_name is required when metrics are enabled"); + opal::internal::Fatal( + "opal::server::MetricsRegistry: service_name is required when metrics are enabled"); } } @@ -433,7 +432,7 @@ std::shared_ptr MetricsRegistry::Register(std::string na internal::MetricFamily::Kind kind, std::vector buckets) { if (!ValidName(name, /*allow_colon=*/true)) { - smithy::internal::Fatal("smithy::server::MetricsRegistry: invalid metric name '" + name + "'"); + opal::internal::Fatal("opal::server::MetricsRegistry: invalid metric name '" + name + "'"); } // The built-ins are emitted unconditionally, so a family under one of their // names would appear twice with two TYPE lines — a scrape Prometheus @@ -443,8 +442,8 @@ std::shared_ptr MetricsRegistry::Register(std::string na {kRequestsTotal, kRequestsSuccess, kRequestsFailure, kRequestsActive, kRequestDuration, kObservationsDropped}) { if (name == reserved) { - smithy::internal::Fatal("smithy::server::MetricsRegistry: '" + name + - "' is one of the built-in families"); + opal::internal::Fatal("opal::server::MetricsRegistry: '" + name + + "' is one of the built-in families"); } } const std::lock_guard lock(mutex_); @@ -453,9 +452,9 @@ std::shared_ptr MetricsRegistry::Register(std::string na // that would corrupt the scrape, so it aborts rather than picking one. const internal::MetricFamily& existing = *found->second; if (existing.kind != kind || existing.help != help || existing.buckets != buckets) { - smithy::internal::Fatal("smithy::server::MetricsRegistry: '" + name + - "' is already registered with a different type, help text, or " - "bucket ladder"); + opal::internal::Fatal("opal::server::MetricsRegistry: '" + name + + "' is already registered with a different type, help text, or " + "bucket ladder"); } return found->second; } @@ -492,17 +491,17 @@ Histogram MetricsRegistry::NewHistogram(std::string name, std::string help, // silently produces cumulative buckets that disagree with themselves, // which a dashboard renders as plausible nonsense (ADR-0009). if (buckets.empty()) { - smithy::internal::Fatal("smithy::server::MetricsRegistry: histogram '" + name + - "' needs at least one bucket (the +Inf bucket is implicit)"); + opal::internal::Fatal("opal::server::MetricsRegistry: histogram '" + name + + "' needs at least one bucket (the +Inf bucket is implicit)"); } for (std::size_t i = 0; i < buckets.size(); ++i) { if (!std::isfinite(buckets[i])) { - smithy::internal::Fatal("smithy::server::MetricsRegistry: histogram '" + name + - "' buckets must all be finite (the +Inf bucket is implicit)"); + opal::internal::Fatal("opal::server::MetricsRegistry: histogram '" + name + + "' buckets must all be finite (the +Inf bucket is implicit)"); } if (i > 0 && buckets[i] <= buckets[i - 1]) { - smithy::internal::Fatal("smithy::server::MetricsRegistry: histogram '" + name + - "' buckets must be strictly ascending"); + opal::internal::Fatal("opal::server::MetricsRegistry: histogram '" + name + + "' buckets must be strictly ascending"); } } auto family = Register(std::move(name), std::move(help), internal::MetricFamily::Kind::kHistogram, @@ -625,7 +624,7 @@ std::string MetricsRegistry::Expose() const { Middleware RecordMetrics(std::shared_ptr registry) { if (registry == nullptr) { - smithy::internal::Fatal("smithy::server::RecordMetrics: registry may not be null"); + opal::internal::Fatal("opal::server::RecordMetrics: registry may not be null"); } // Disabled: compose to the identity. Not a wrapper that checks a flag per // request — no wrapper at all, so the composed chain is byte-for-byte the @@ -652,7 +651,7 @@ Middleware RecordMetrics(std::shared_ptr registry) { Middleware MetricsEndpoint(std::shared_ptr registry, std::string path) { if (registry == nullptr) { - smithy::internal::Fatal("smithy::server::MetricsEndpoint: registry may not be null"); + opal::internal::Fatal("opal::server::MetricsEndpoint: registry may not be null"); } // Disabled: the path is not served at all, so it reaches the router like // any other unmodeled path. An empty 200 would read to Prometheus as a @@ -684,4 +683,4 @@ Middleware MetricsEndpoint(std::shared_ptr registry, std::strin }; } -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/src/server/middleware.cc b/runtime/src/server/middleware.cc index 2c17bfd5..3c9c19dc 100644 --- a/runtime/src/server/middleware.cc +++ b/runtime/src/server/middleware.cc @@ -12,7 +12,7 @@ #include "smithy/core/exception_guard.h" #include "smithy/core/fatal.h" -namespace smithy::server { +namespace opal::server { http::RequestHandler Chain(std::vector middleware, http::RequestHandler handler) { // Wrap inside-out so the first middleware ends up outermost. @@ -54,7 +54,7 @@ Middleware PerClientRateLimit(std::function all if (allow == nullptr) { // A null policy would throw std::bad_function_call per request — fail // fast at composition like HealthEndpoint and Observe do (ADR-0009). - smithy::internal::Fatal("smithy::server::PerClientRateLimit: allow must not be null"); + opal::internal::Fatal("opal::server::PerClientRateLimit: allow must not be null"); } return Guard( [allow = std::move(allow), trusted = std::move(trusted)](const http::HttpRequest& request) { @@ -72,7 +72,7 @@ namespace { // -fno-exceptions, where the sink cannot throw. template void CallContained(const Callback& callback, const Observation& observation, const char* which) { - smithy::internal::Contain( + opal::internal::Contain( [&] { callback(observation); }, [&](const char* what) { if (what != nullptr) { @@ -88,7 +88,7 @@ void CallContained(const Callback& callback, const Observation& observation, con // message is the one clue to why /readyz is flapping, so keep the log // trail. bool ProbeContained(const ReadinessCheck& check) { - return smithy::internal::Contain( + return opal::internal::Contain( [&] { return check.probe(); }, [&](const char* what) -> bool { if (what != nullptr) { @@ -109,13 +109,13 @@ Middleware HealthEndpoint(std::string path, std::vector checks) // monitoring is parsing it. for (const ReadinessCheck& check : checks) { if (check.probe == nullptr) { - smithy::internal::Fatal("smithy::server::HealthEndpoint: check '" + check.name + - "' has a null probe"); + opal::internal::Fatal("opal::server::HealthEndpoint: check '" + check.name + + "' has a null probe"); } for (const char c : check.name) { if (c == '"' || c == '\\' || static_cast(c) < 0x20) { - smithy::internal::Fatal("smithy::server::HealthEndpoint: check name '" + check.name + - "' contains a quote, backslash, or control character"); + opal::internal::Fatal("opal::server::HealthEndpoint: check name '" + check.name + + "' contains a quote, backslash, or control character"); } } } @@ -164,7 +164,7 @@ Middleware Observe(std::function on_complete, std::function now, std::optional trusted) { if (on_complete == nullptr) { - smithy::internal::Fatal("smithy::server::Observe: on_complete may not be null"); + opal::internal::Fatal("opal::server::Observe: on_complete may not be null"); } if (now == nullptr) { now = [] { return std::chrono::steady_clock::now(); }; @@ -268,4 +268,4 @@ Middleware RequireApiKeyHeader(std::string header_name, std::string scheme, }; } -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/src/server/origin_gate.cc b/runtime/src/server/origin_gate.cc index c3dc0cfd..516d6b44 100644 --- a/runtime/src/server/origin_gate.cc +++ b/runtime/src/server/origin_gate.cc @@ -11,7 +11,7 @@ #include "smithy/http/uri.h" #include "smithy/server/router.h" -namespace smithy::server { +namespace opal::server { namespace { // The canonical form origins are compared in: lowercased scheme://host @@ -47,7 +47,7 @@ std::function(const http::HttpRequest&)> Requi if (!normalized.has_value()) { // A malformed allowlist is a programming error that would silently // refuse every browser — fail fast at construction (ADR-0009). - smithy::internal::Fatal("RequireOrigin: not an http(s) origin or \"null\": " + entry); + opal::internal::Fatal("RequireOrigin: not an http(s) origin or \"null\": " + entry); } allowed.insert(std::move(*normalized)); } @@ -69,4 +69,4 @@ std::function(const http::HttpRequest&)> Requi }; } -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/src/server/router.cc b/runtime/src/server/router.cc index e00b2ff6..b275f9ca 100644 --- a/runtime/src/server/router.cc +++ b/runtime/src/server/router.cc @@ -5,7 +5,7 @@ #include "smithy/http/uri.h" -namespace smithy::server { +namespace opal::server { http::HttpResponse MakeErrorResponse(int status, std::string_view code, std::string_view message) { http::HttpResponse response; @@ -199,4 +199,4 @@ http::HttpResponse Router::Route(const http::HttpRequest& request) const { return response; } -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/src/server/websocket_router.cc b/runtime/src/server/websocket_router.cc index 3d54d869..5397175a 100644 --- a/runtime/src/server/websocket_router.cc +++ b/runtime/src/server/websocket_router.cc @@ -7,7 +7,7 @@ #include "smithy/http/uri.h" -namespace smithy::server { +namespace opal::server { namespace { @@ -168,4 +168,4 @@ WebSocketRouter::ServeSession() const { }; } -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/testing/include/smithy/testing/connection_event_recorder.h b/runtime/testing/include/smithy/testing/connection_event_recorder.h index bb3583bd..f04ff672 100644 --- a/runtime/testing/include/smithy/testing/connection_event_recorder.h +++ b/runtime/testing/include/smithy/testing/connection_event_recorder.h @@ -10,7 +10,7 @@ #include "smithy/http/beast_transport.h" -namespace smithy::testing { +namespace opal::testing { // One copy of the ADR-0013 test recorder for the runtime suites and the // consumer module's tests (the tls_test_identity pattern): a mutex-guarded @@ -43,6 +43,6 @@ struct ConnectionEventRecorder { } }; -} // namespace smithy::testing +} // namespace opal::testing #endif // SMITHY_TESTING_CONNECTION_EVENT_RECORDER_H_ diff --git a/runtime/testing/include/smithy/testing/protocol_test.h b/runtime/testing/include/smithy/testing/protocol_test.h index 031275ad..1341aba4 100644 --- a/runtime/testing/include/smithy/testing/protocol_test.h +++ b/runtime/testing/include/smithy/testing/protocol_test.h @@ -25,30 +25,29 @@ #include "smithy/http/uri.h" #include "smithy/json/json.h" -namespace smithy::testing { +namespace opal::testing { // Records the request and answers with a canned response, so generated tests // can assert the exact wire shape a client produced or feed it a response. -class CapturingTransport final : public smithy::http::HttpClient { +class CapturingTransport final : public opal::http::HttpClient { public: - smithy::Outcome Send( - const smithy::http::HttpRequest& request) override { + opal::Outcome Send(const opal::http::HttpRequest& request) override { last_request = request; return next_response; } - smithy::http::HttpRequest last_request; - smithy::http::HttpResponse next_response{200, {}, ""}; + opal::http::HttpRequest last_request; + opal::http::HttpResponse next_response{200, {}, ""}; }; // The rpcv2Cbor request preamble every hand-written server-side wire test // builds: POST /service//operation/ plus the protocol // and content-type headers. One home instead of a copy per test file — the // generated conformance tests regenerate their own copies, these don't. -inline smithy::http::HttpRequest Rpcv2CborRequest(const std::string& service, - const std::string& operation, - std::string body = "") { - smithy::http::HttpRequest request; +inline opal::http::HttpRequest Rpcv2CborRequest(const std::string& service, + const std::string& operation, + std::string body = "") { + opal::http::HttpRequest request; request.method = "POST"; request.target = "/service/" + service + "/operation/" + operation; request.headers.Set("smithy-protocol", "rpc-v2-cbor"); @@ -59,22 +58,21 @@ inline smithy::http::HttpRequest Rpcv2CborRequest(const std::string& service, // Wraps a transport and mutates successful responses in flight — e.g. the // integration tests inject unknown body members that clients must ignore. -class MutatingTransport final : public smithy::http::HttpClient { +class MutatingTransport final : public opal::http::HttpClient { public: - using Mutator = std::function; + using Mutator = std::function; - MutatingTransport(std::shared_ptr inner, Mutator mutate) + MutatingTransport(std::shared_ptr inner, Mutator mutate) : inner_(std::move(inner)), mutate_(std::move(mutate)) {} - smithy::Outcome Send( - const smithy::http::HttpRequest& request) override { + opal::Outcome Send(const opal::http::HttpRequest& request) override { auto response = inner_->Send(request); if (response.ok()) mutate_(*response); return response; } private: - std::shared_ptr inner_; + std::shared_ptr inner_; Mutator mutate_; }; @@ -104,7 +102,7 @@ inline std::string QueryKey(std::string_view entry) { // definition may write "query=the query" while the wire (correctly) carries // "query=the%20query". Falls back to the raw text if the escapes are malformed. inline std::string DecodeQueryEntry(const std::string& entry) { - auto decoded = smithy::http::PercentDecode(entry); + auto decoded = opal::http::PercentDecode(entry); return decoded.ok() ? *decoded : entry; } @@ -193,12 +191,12 @@ inline bool ProtocolDocumentEquals(const Document& a, const Document& b) { inline ::testing::AssertionResult JsonBodyEquals(const std::string& expected, const std::string& actual) { - auto expected_doc = smithy::json::Decode(expected); + auto expected_doc = opal::json::Decode(expected); if (!expected_doc.ok()) { return ::testing::AssertionFailure() << "expected body is not valid JSON: " << expected_doc.error().message(); } - auto actual_doc = smithy::json::Decode(actual); + auto actual_doc = opal::json::Decode(actual); if (!actual_doc.ok()) { return ::testing::AssertionFailure() << "actual body is not valid JSON: " << actual_doc.error().message() << "\nbody: <<" @@ -215,7 +213,7 @@ inline ::testing::AssertionResult JsonBodyEquals(const std::string& expected, // "message" member of the (JSON) error body. inline ::testing::AssertionResult BodyMessageMatches(const std::string& pattern, const std::string& body) { - auto doc = smithy::json::Decode(body); + auto doc = opal::json::Decode(body); if (!doc.ok() || !doc->is_map()) { return ::testing::AssertionFailure() << "body is not a JSON object: <<" << body << ">>"; } @@ -232,22 +230,22 @@ inline ::testing::AssertionResult BodyMessageMatches(const std::string& pattern, // Decodes a base64 body (how binary bodies appear in test definitions). inline std::string FromBase64(const std::string& text) { - auto blob = smithy::Base64Decode(text); + auto blob = opal::Base64Decode(text); return blob.ok() ? blob->ToString() : std::string(); } inline ::testing::AssertionResult CborBodyEqualsBase64(const std::string& expected_base64, const std::string& actual) { - auto expected_bytes = smithy::Base64Decode(expected_base64); + auto expected_bytes = opal::Base64Decode(expected_base64); if (!expected_bytes.ok()) { return ::testing::AssertionFailure() << "expected body is not valid base64"; } - auto expected_doc = smithy::cbor::Decode(*expected_bytes); + auto expected_doc = opal::cbor::Decode(*expected_bytes); if (!expected_doc.ok()) { return ::testing::AssertionFailure() << "expected body is not valid CBOR: " << expected_doc.error().message(); } - auto actual_doc = smithy::cbor::Decode(smithy::Blob::FromString(actual)); + auto actual_doc = opal::cbor::Decode(opal::Blob::FromString(actual)); if (!actual_doc.ok()) { return ::testing::AssertionFailure() << "actual body is not valid CBOR: " << actual_doc.error().message(); @@ -255,11 +253,11 @@ inline ::testing::AssertionResult CborBodyEqualsBase64(const std::string& expect if (!ProtocolDocumentEquals(*expected_doc, *actual_doc)) { return ::testing::AssertionFailure() << "CBOR bodies differ.\nexpected (b64): " << expected_base64 - << "\nactual (b64): " << smithy::Base64Encode(smithy::Blob::FromString(actual)); + << "\nactual (b64): " << opal::Base64Encode(opal::Blob::FromString(actual)); } return ::testing::AssertionSuccess(); } -} // namespace smithy::testing +} // namespace opal::testing #endif // SMITHY_TESTING_PROTOCOL_TEST_H_ diff --git a/runtime/testing/include/smithy/testing/tls_test_identity.h b/runtime/testing/include/smithy/testing/tls_test_identity.h index 0b339e60..d0f712d7 100644 --- a/runtime/testing/include/smithy/testing/tls_test_identity.h +++ b/runtime/testing/include/smithy/testing/tls_test_identity.h @@ -27,7 +27,7 @@ // -subj "/CN=other.example.com" // -addext "subjectAltName=DNS:other.example.com" -namespace smithy::testing { +namespace opal::testing { inline constexpr char kTestCertificatePem[] = R"pem(-----BEGIN CERTIFICATE----- MIIBmTCCAT+gAwIBAgIUV9JEHAQKR6U3ipSZd7B2JYm3AhYwCgYIKoZIzj0EAwIw @@ -72,6 +72,6 @@ sjQDqORDjHUlEMiiDXgz4ZtY2GKhRANCAATaUMXuCmSupqLVRIfYNg2LwAq9GNyY -----END PRIVATE KEY----- )pem"; -} // namespace smithy::testing +} // namespace opal::testing #endif // SMITHY_TESTING_TLS_TEST_IDENTITY_H_ diff --git a/runtime/testing/include/smithy/testing/websocket_contract_test.h b/runtime/testing/include/smithy/testing/websocket_contract_test.h index 210f8596..171b2148 100644 --- a/runtime/testing/include/smithy/testing/websocket_contract_test.h +++ b/runtime/testing/include/smithy/testing/websocket_contract_test.h @@ -24,11 +24,11 @@ // struct Driver { // // The implementation under test. Called once, may block until the // // session exists. -// std::shared_ptr Socket(); +// std::shared_ptr Socket(); // // // Payload for wedge attempt `n` — sized so at most kWedgeAttempts of // // them back the wire up. -// smithy::eventstream::Message BulkMessage(int n); +// opal::eventstream::Message BulkMessage(int n); // static constexpr int kWedgeAttempts = ...; // // // Drives a terminal transition from the far side (a peer close, a @@ -56,7 +56,7 @@ #include "smithy/eventstream/frame.h" #include "smithy/http/websocket.h" -namespace smithy::testing { +namespace opal::testing { // A one-shot deadlined handoff. Deadlined rather than infinite because the // regressions these tests catch are deadlocks: a plain wait would hang out @@ -466,6 +466,6 @@ REGISTER_TYPED_TEST_SUITE_P(WebSocketContractTest, ASecondReceiveRefusesWhileATimedOneIsParked, ASecondReceiveClassOperationRefusesWhileOneIsParked); -} // namespace smithy::testing +} // namespace opal::testing #endif // SMITHY_TESTING_WEBSOCKET_CONTRACT_TEST_H_ diff --git a/runtime/tests/cbor/cbor_hostile_test.cc b/runtime/tests/cbor/cbor_hostile_test.cc index 73140a11..ace979db 100644 --- a/runtime/tests/cbor/cbor_hostile_test.cc +++ b/runtime/tests/cbor/cbor_hostile_test.cc @@ -19,7 +19,7 @@ #include "smithy/cbor/cbor.h" -namespace smithy::cbor { +namespace opal::cbor { namespace { Blob FromHex(std::string_view hex) { @@ -257,4 +257,4 @@ TEST(CborHostileTest, EveryStrictPrefixOfAValidDocumentIsRejected) { } } // namespace -} // namespace smithy::cbor +} // namespace opal::cbor diff --git a/runtime/tests/cbor/cbor_property_test.cc b/runtime/tests/cbor/cbor_property_test.cc index 69021bc4..9257b271 100644 --- a/runtime/tests/cbor/cbor_property_test.cc +++ b/runtime/tests/cbor/cbor_property_test.cc @@ -9,11 +9,11 @@ #include "smithy/cbor/cbor.h" #include "tests/testing/random_document.h" -namespace smithy::cbor { +namespace opal::cbor { namespace { TEST(CborPropertyTest, RandomDocumentsRoundTrip) { - smithy::testing::RandomDocumentGenerator generator(/*seed=*/20260706); + opal::testing::RandomDocumentGenerator generator(/*seed=*/20260706); for (int i = 0; i < 500; ++i) { const Document original = generator.Next(); const Blob encoded = Encode(original); @@ -24,7 +24,7 @@ TEST(CborPropertyTest, RandomDocumentsRoundTrip) { } TEST(CborPropertyTest, EncodingIsDeterministic) { - smithy::testing::RandomDocumentGenerator generator(/*seed=*/777); + opal::testing::RandomDocumentGenerator generator(/*seed=*/777); for (int i = 0; i < 50; ++i) { const Document doc = generator.Next(); ASSERT_TRUE(Encode(doc) == Encode(doc)) << "iteration " << i; @@ -34,7 +34,7 @@ TEST(CborPropertyTest, EncodingIsDeterministic) { // Decoding corrupted bytes must fail cleanly (an Error) or succeed with some // value — never crash, hang, or trip a sanitizer. TEST(CborPropertyTest, CorruptedInputNeverCrashes) { - smithy::testing::RandomDocumentGenerator generator(/*seed=*/424242); + opal::testing::RandomDocumentGenerator generator(/*seed=*/424242); std::mt19937_64 rng(31337); for (int i = 0; i < 300; ++i) { Blob encoded = Encode(generator.Next()); @@ -65,4 +65,4 @@ TEST(CborPropertyTest, RandomGarbageNeverCrashes) { } } // namespace -} // namespace smithy::cbor +} // namespace opal::cbor diff --git a/runtime/tests/cbor/cbor_test.cc b/runtime/tests/cbor/cbor_test.cc index 455c0e12..81b1305b 100644 --- a/runtime/tests/cbor/cbor_test.cc +++ b/runtime/tests/cbor/cbor_test.cc @@ -4,7 +4,7 @@ #include -namespace smithy::cbor { +namespace opal::cbor { namespace { std::string ToHex(const Blob& blob) { @@ -208,4 +208,4 @@ TEST(CborTest, RejectsExcessiveNesting) { } } // namespace -} // namespace smithy::cbor +} // namespace opal::cbor diff --git a/runtime/tests/client/observability_test.cc b/runtime/tests/client/observability_test.cc index b74bdd8f..389d778c 100644 --- a/runtime/tests/client/observability_test.cc +++ b/runtime/tests/client/observability_test.cc @@ -13,22 +13,22 @@ namespace { -smithy::http::HttpRequest MakeRequest() { - smithy::http::HttpRequest request; +opal::http::HttpRequest MakeRequest() { + opal::http::HttpRequest request; request.method = "POST"; request.target = "/books?pageSize=10"; return request; } TEST(ObserveAttemptsTest, ReportsSuccessfulAttempts) { - std::vector seen; - const auto interceptor = smithy::ObserveAttempts( - [&seen](const smithy::AttemptObservation& obs) { seen.push_back(obs); }); + std::vector seen; + const auto interceptor = + opal::ObserveAttempts([&seen](const opal::AttemptObservation& obs) { seen.push_back(obs); }); - smithy::http::HttpResponse response; + opal::http::HttpResponse response; response.status = 201; - interceptor->ReadAfterTransmit(MakeRequest(), - smithy::Outcome(response), 1); + interceptor->ReadAfterTransmit(MakeRequest(), opal::Outcome(response), + 1); ASSERT_EQ(seen.size(), 1u); EXPECT_EQ(seen[0].method, "POST"); @@ -39,14 +39,13 @@ TEST(ObserveAttemptsTest, ReportsSuccessfulAttempts) { } TEST(ObserveAttemptsTest, ReportsTransportErrorsAsStatusMinusOne) { - std::vector seen; - const auto interceptor = smithy::ObserveAttempts( - [&seen](const smithy::AttemptObservation& obs) { seen.push_back(obs); }); + std::vector seen; + const auto interceptor = + opal::ObserveAttempts([&seen](const opal::AttemptObservation& obs) { seen.push_back(obs); }); interceptor->ReadAfterTransmit( MakeRequest(), - smithy::Outcome(smithy::Error::Transport("connection refused")), - 3); + opal::Outcome(opal::Error::Transport("connection refused")), 3); ASSERT_EQ(seen.size(), 1u); EXPECT_EQ(seen[0].attempt, 3); @@ -57,30 +56,30 @@ TEST(ObserveAttemptsTest, ReportsTransportErrorsAsStatusMinusOne) { TEST(ObserveAttemptsTest, ObservesEveryAttemptOfARetryLoop) { int calls = 0; const auto interceptor = - smithy::ObserveAttempts([&calls](const smithy::AttemptObservation&) { ++calls; }); - smithy::http::HttpResponse throttled; + opal::ObserveAttempts([&calls](const opal::AttemptObservation&) { ++calls; }); + opal::http::HttpResponse throttled; throttled.status = 429; for (int attempt = 1; attempt <= 3; ++attempt) { interceptor->ReadAfterTransmit(MakeRequest(), - smithy::Outcome(throttled), attempt); + opal::Outcome(throttled), attempt); } EXPECT_EQ(calls, 3); } TEST(PropagateTraceContextTest, StampsAWellFormedTraceparent) { - const auto interceptor = smithy::PropagateTraceContext(); + const auto interceptor = opal::PropagateTraceContext(); auto request = MakeRequest(); interceptor->ModifyBeforeTransmit(request, 1); const auto header = request.headers.Get("traceparent"); ASSERT_TRUE(header.has_value()); - const auto parsed = smithy::http::ParseTraceparent(*header); + const auto parsed = opal::http::ParseTraceparent(*header); ASSERT_TRUE(parsed.has_value()) << *header; EXPECT_TRUE(parsed->sampled); } TEST(PropagateTraceContextTest, RespectsAnExistingTraceparent) { - const auto interceptor = smithy::PropagateTraceContext(); + const auto interceptor = opal::PropagateTraceContext(); auto request = MakeRequest(); const std::string preset = "00-0123456789abcdef0123456789abcdef-0123456789abcdef-01"; request.headers.Set("traceparent", preset); @@ -89,12 +88,12 @@ TEST(PropagateTraceContextTest, RespectsAnExistingTraceparent) { } TEST(PropagateTraceContextTest, UsesTheApplicationsCurrentContext) { - smithy::http::TraceContext context; + opal::http::TraceContext context; context.trace_id = "0af7651916cd43dd8448eb211c80319c"; context.parent_id = "b7ad6b7169203331"; context.sampled = true; - const auto interceptor = smithy::PropagateTraceContext( - [context]() -> std::optional { return context; }); + const auto interceptor = opal::PropagateTraceContext( + [context]() -> std::optional { return context; }); auto request = MakeRequest(); interceptor->ModifyBeforeTransmit(request, 1); @@ -103,14 +102,14 @@ TEST(PropagateTraceContextTest, UsesTheApplicationsCurrentContext) { } TEST(PropagateTraceContextTest, FallsBackToAFreshRootWhenTheCallbackHasNoContext) { - const auto interceptor = smithy::PropagateTraceContext( - []() -> std::optional { return std::nullopt; }); + const auto interceptor = opal::PropagateTraceContext( + []() -> std::optional { return std::nullopt; }); auto request = MakeRequest(); interceptor->ModifyBeforeTransmit(request, 1); const auto header = request.headers.Get("traceparent"); ASSERT_TRUE(header.has_value()); - EXPECT_TRUE(smithy::http::ParseTraceparent(*header).has_value()) << *header; + EXPECT_TRUE(opal::http::ParseTraceparent(*header).has_value()) << *header; // Each attempt without an application context gets its own root. auto second = MakeRequest(); diff --git a/runtime/tests/client/pagination_test.cc b/runtime/tests/client/pagination_test.cc index 888dfe37..c05ada4b 100644 --- a/runtime/tests/client/pagination_test.cc +++ b/runtime/tests/client/pagination_test.cc @@ -1,4 +1,4 @@ -// smithy::PageIterator (smithy/client/pagination.h): the single-pass range +// opal::PageIterator (smithy/client/pagination.h): the single-pass range // adapter generated paginators surface through begin()/end() (issue #49), so // `for (auto& page : client.PaginateX(input))` works. Iteration yields // Outcome&; a failed call is yielded exactly once and then the range @@ -18,7 +18,7 @@ #include "smithy/core/error.h" #include "smithy/core/outcome.h" -namespace smithy { +namespace opal { namespace { // Scripted stand-in for a generated paginator: the same Next() contract, @@ -80,4 +80,4 @@ TEST(PageIteratorTest, ErrorIsYieldedOnceThenTheRangeEnds) { } } // namespace -} // namespace smithy +} // namespace opal diff --git a/runtime/tests/client/retry_test.cc b/runtime/tests/client/retry_test.cc index 847c7a76..e5cf5e8b 100644 --- a/runtime/tests/client/retry_test.cc +++ b/runtime/tests/client/retry_test.cc @@ -10,7 +10,7 @@ #include "smithy/core/error.h" -namespace smithy { +namespace opal { namespace { using std::chrono::milliseconds; @@ -188,4 +188,4 @@ TEST(SendWithRetriesTest, MaxAttemptsOneDisablesRetries) { } } // namespace -} // namespace smithy +} // namespace opal diff --git a/runtime/tests/compression/gzip_test.cc b/runtime/tests/compression/gzip_test.cc index ab1aa51d..1679803a 100644 --- a/runtime/tests/compression/gzip_test.cc +++ b/runtime/tests/compression/gzip_test.cc @@ -7,7 +7,7 @@ #include "smithy/compression/gzip_test_peer.h" -namespace smithy { +namespace opal { namespace { // A body that compresses but not trivially, so slice boundaries land on @@ -138,4 +138,4 @@ TEST(GzipChunkedFeedTest, GarbageUnderSlicedFeedsIsMalformedNotAHang) { } } // namespace -} // namespace smithy +} // namespace opal diff --git a/runtime/tests/core/boxed_test.cc b/runtime/tests/core/boxed_test.cc index 9fa61c48..e446c0f9 100644 --- a/runtime/tests/core/boxed_test.cc +++ b/runtime/tests/core/boxed_test.cc @@ -1,4 +1,4 @@ -// smithy::Boxed: value-semantic heap indirection for recursive generated +// opal::Boxed: value-semantic heap indirection for recursive generated // members — deep copy, deep equality, and compilability with the mutually // recursive struct shapes the generator emits. @@ -12,7 +12,7 @@ #include #include -namespace smithy { +namespace opal { namespace { // The shape the generator emits for mutual recursion: forward-declared @@ -94,4 +94,4 @@ TEST(BoxedTest, ListRecursionComparesStructurally) { } } // namespace -} // namespace smithy +} // namespace opal diff --git a/runtime/tests/core/core_test.cc b/runtime/tests/core/core_test.cc index 200633c6..e63d5ea3 100644 --- a/runtime/tests/core/core_test.cc +++ b/runtime/tests/core/core_test.cc @@ -11,7 +11,7 @@ #include "smithy/core/outcome.h" #include "smithy/core/text.h" -namespace smithy { +namespace opal { namespace { TEST(OutcomeTest, HoldsValue) { @@ -227,4 +227,4 @@ TEST(DocumentTest, ListAccess) { } } // namespace -} // namespace smithy +} // namespace opal diff --git a/runtime/tests/core/document_serde_test.cc b/runtime/tests/core/document_serde_test.cc index 52915e58..0e90c8da 100644 --- a/runtime/tests/core/document_serde_test.cc +++ b/runtime/tests/core/document_serde_test.cc @@ -9,7 +9,7 @@ #include "smithy/core/uuid.h" -namespace smithy { +namespace opal { namespace { TEST(DocumentSerdeTest, TimestampFromAllWireShapes) { @@ -146,4 +146,4 @@ TEST(DocumentSerdeTest, FormatFloatingPoint) { EXPECT_EQ(FormatFloat(-std::numeric_limits::infinity()), "-Infinity"); } -} // namespace smithy +} // namespace opal diff --git a/runtime/tests/core/exception_guard_test.cc b/runtime/tests/core/exception_guard_test.cc index 4aac4b4d..66ae6d19 100644 --- a/runtime/tests/core/exception_guard_test.cc +++ b/runtime/tests/core/exception_guard_test.cc @@ -5,7 +5,7 @@ #include "gtest/gtest.h" -namespace smithy::internal { +namespace opal::internal { namespace { TEST(ContainTest, ReturnsBodyResultWhenNothingThrows) { @@ -60,4 +60,4 @@ TEST(ContainTest, HandlerFallbackValueIsReturnedOnThrow) { #endif } // namespace -} // namespace smithy::internal +} // namespace opal::internal diff --git a/runtime/tests/core/hash_test.cc b/runtime/tests/core/hash_test.cc index f92130ac..b3726e1f 100644 --- a/runtime/tests/core/hash_test.cc +++ b/runtime/tests/core/hash_test.cc @@ -21,7 +21,7 @@ #include "smithy/core/outcome.h" #include "smithy/core/timestamp.h" -namespace smithy { +namespace opal { namespace { template @@ -99,4 +99,4 @@ TEST(StdHashTest, UnitHashesConsistently) { } } // namespace -} // namespace smithy +} // namespace opal diff --git a/runtime/tests/core/print_test.cc b/runtime/tests/core/print_test.cc index d17ba338..d03621d4 100644 --- a/runtime/tests/core/print_test.cc +++ b/runtime/tests/core/print_test.cc @@ -22,7 +22,7 @@ #include "smithy/core/outcome.h" #include "smithy/core/timestamp.h" -namespace smithy { +namespace opal { namespace { template @@ -98,4 +98,4 @@ TEST(RuntimeTypePrintingTest, DocumentRendersJsonish) { } } // namespace -} // namespace smithy +} // namespace opal diff --git a/runtime/tests/core/regex_test.cc b/runtime/tests/core/regex_test.cc index dd6964f9..c18c1b0e 100644 --- a/runtime/tests/core/regex_test.cc +++ b/runtime/tests/core/regex_test.cc @@ -10,12 +10,12 @@ namespace { bool Search(const std::string& pattern, const std::string& text) { - auto re = smithy::Regex::Compile(pattern); + auto re = opal::Regex::Compile(pattern); EXPECT_TRUE(re.ok()) << pattern << ": " << (re.ok() ? "" : re.error().message()); return re.ok() && re->Search(text); } -bool Compiles(const std::string& pattern) { return smithy::Regex::Compile(pattern).ok(); } +bool Compiles(const std::string& pattern) { return opal::Regex::Compile(pattern).ok(); } TEST(RegexTest, LiteralsUsePartialMatchSemantics) { EXPECT_TRUE(Search("bc", "abcd")); // regex_search, not regex_match @@ -133,7 +133,7 @@ TEST(RegexTest, UnsupportedConstructsFailAtCompileTime) { // bound deterministic — a loaded CI runner can't flake it the way a // wall-clock limit could. TEST(RegexTest, CatastrophicPatternIsLinear) { - auto re = smithy::Regex::Compile("^([0-9]+)+$"); + auto re = opal::Regex::Compile("^([0-9]+)+$"); ASSERT_TRUE(re.ok()); std::string evil(100000, '1'); evil.push_back('!'); @@ -148,7 +148,7 @@ TEST(RegexTest, MoreNestedQuantifierBombs) { std::string as(50000, 'a'); const std::string bomb = as + "b"; for (const char* pattern : {"^(a+)+$", "^(a|a)+$", "^(a*)*$"}) { - auto re = smithy::Regex::Compile(pattern); + auto re = opal::Regex::Compile(pattern); ASSERT_TRUE(re.ok()) << pattern; std::size_t steps = 0; EXPECT_FALSE(re->Search(bomb, &steps)) << pattern; @@ -171,7 +171,7 @@ TEST(RegexTest, AgreesWithStdRegexOnRandomInputs) { const std::string alphabet = "abcdexy01239. -_"; std::uniform_int_distribution pick(0, alphabet.size() - 1); for (const char* pattern : patterns) { - auto mine = smithy::Regex::Compile(pattern); + auto mine = opal::Regex::Compile(pattern); ASSERT_TRUE(mine.ok()) << pattern; const std::regex theirs(pattern, std::regex::ECMAScript); for (int i = 0; i < 500; ++i) { diff --git a/runtime/tests/core/timestamp_differential_test.cc b/runtime/tests/core/timestamp_differential_test.cc index b6edbf44..80cf15cb 100644 --- a/runtime/tests/core/timestamp_differential_test.cc +++ b/runtime/tests/core/timestamp_differential_test.cc @@ -13,7 +13,7 @@ #include "smithy/core/timestamp.h" -namespace smithy { +namespace opal { namespace { bool GmTime(std::int64_t epoch_seconds, std::tm* out) { @@ -135,4 +135,4 @@ TEST(TimestampDifferentialTest, EpochSecondsReconstructsFromItsOwnTextOverRandom } } // namespace -} // namespace smithy +} // namespace opal diff --git a/runtime/tests/core/timestamp_test.cc b/runtime/tests/core/timestamp_test.cc index d522c100..8b375ae9 100644 --- a/runtime/tests/core/timestamp_test.cc +++ b/runtime/tests/core/timestamp_test.cc @@ -9,7 +9,7 @@ #include #include -namespace smithy { +namespace opal { namespace { TEST(TimestampOrderingTest, ProvidesTheFullComparisonSet) { @@ -24,8 +24,8 @@ TEST(TimestampOrderingTest, ProvidesTheFullComparisonSet) { } TEST(TimestampParseTest, EpochSecondsIsStrict) { - using smithy::Timestamp; - using smithy::TimestampFormat; + using opal::Timestamp; + using opal::TimestampFormat; EXPECT_TRUE(Timestamp::Parse("1515531081", TimestampFormat::kEpochSeconds).ok()); EXPECT_TRUE(Timestamp::Parse("1515531081.123", TimestampFormat::kEpochSeconds).ok()); EXPECT_TRUE(Timestamp::Parse("-5", TimestampFormat::kEpochSeconds).ok()); @@ -276,4 +276,4 @@ TEST(TimestampTest, RejectsInvalidEpochSeconds) { } } // namespace -} // namespace smithy +} // namespace opal diff --git a/runtime/tests/core/uuid_test.cc b/runtime/tests/core/uuid_test.cc index 25f28158..8bc8c7fe 100644 --- a/runtime/tests/core/uuid_test.cc +++ b/runtime/tests/core/uuid_test.cc @@ -11,7 +11,7 @@ namespace { TEST(UuidTest, CanonicalForm) { - const std::string uuid = smithy::GenerateUuidV4(); + const std::string uuid = opal::GenerateUuidV4(); ASSERT_EQ(uuid.size(), 36u); for (std::size_t i = 0; i < uuid.size(); ++i) { if (i == 8 || i == 13 || i == 18 || i == 23) { @@ -27,7 +27,7 @@ TEST(UuidTest, VersionAndVariantBits) { // RFC 4122: the version nibble is always 4, the variant nibble 10xx — // stable across every generated value, not just one sample. for (int i = 0; i < 256; ++i) { - const std::string uuid = smithy::GenerateUuidV4(); + const std::string uuid = opal::GenerateUuidV4(); EXPECT_EQ(uuid[14], '4') << uuid; EXPECT_TRUE(uuid[19] == '8' || uuid[19] == '9' || uuid[19] == 'a' || uuid[19] == 'b') << uuid; } @@ -36,7 +36,7 @@ TEST(UuidTest, VersionAndVariantBits) { TEST(UuidTest, ValuesDoNotRepeat) { std::set seen; for (int i = 0; i < 1000; ++i) { - EXPECT_TRUE(seen.insert(smithy::GenerateUuidV4()).second) << "duplicate uuid"; + EXPECT_TRUE(seen.insert(opal::GenerateUuidV4()).second) << "duplicate uuid"; } } @@ -51,7 +51,7 @@ TEST(UuidTest, ThreadLocalGeneratorsProduceDistinctStreams) { for (int t = 0; t < kThreads; ++t) { threads.emplace_back([&results, t] { results[t].reserve(kPerThread); - for (int i = 0; i < kPerThread; ++i) results[t].push_back(smithy::GenerateUuidV4()); + for (int i = 0; i < kPerThread; ++i) results[t].push_back(opal::GenerateUuidV4()); }); } for (auto& thread : threads) thread.join(); diff --git a/runtime/tests/core/version_test.cc b/runtime/tests/core/version_test.cc index bb0e2cd1..06f5b80a 100644 --- a/runtime/tests/core/version_test.cc +++ b/runtime/tests/core/version_test.cc @@ -2,7 +2,7 @@ #include -namespace smithy { +namespace opal { namespace { TEST(VersionTest, ReturnsSemanticVersion) { @@ -11,4 +11,4 @@ TEST(VersionTest, ReturnsSemanticVersion) { } } // namespace -} // namespace smithy +} // namespace opal diff --git a/runtime/tests/eventstream/async_event_stream_test.cc b/runtime/tests/eventstream/async_event_stream_test.cc index fb2fb99d..7c885943 100644 --- a/runtime/tests/eventstream/async_event_stream_test.cc +++ b/runtime/tests/eventstream/async_event_stream_test.cc @@ -29,7 +29,7 @@ #include "smithy/http/websocket_pair.h" #include "smithy/testing/websocket_contract_test.h" -namespace smithy::eventstream { +namespace opal::eventstream { namespace { constexpr std::size_t kWireDepth = http::InMemoryWebSocketPair::kQueueDepth; @@ -896,12 +896,12 @@ struct PairContractDriver { }; } // namespace -} // namespace smithy::eventstream +} // namespace opal::eventstream // The instantiation lives where the suite was registered: gtest builds the // registration symbols from the bare suite name, so a qualified one does // not resolve. -namespace smithy::testing { +namespace opal::testing { INSTANTIATE_TYPED_TEST_SUITE_P(InMemoryPair, WebSocketContractTest, eventstream::PairContractDriver); -} // namespace smithy::testing +} // namespace opal::testing diff --git a/runtime/tests/eventstream/envelope_test.cc b/runtime/tests/eventstream/envelope_test.cc index b4041e7a..1d6b8525 100644 --- a/runtime/tests/eventstream/envelope_test.cc +++ b/runtime/tests/eventstream/envelope_test.cc @@ -14,7 +14,7 @@ #include "smithy/eventstream/frame.h" -namespace smithy::eventstream { +namespace opal::eventstream { namespace { EventEnvelope ParseOrDie(const Message& message) { @@ -173,4 +173,4 @@ TEST(EnvelopeTest, EnvelopesRenderThroughTheDebugPrinter) { } } // namespace -} // namespace smithy::eventstream +} // namespace opal::eventstream diff --git a/runtime/tests/eventstream/event_stream_test.cc b/runtime/tests/eventstream/event_stream_test.cc index 5fd7c11c..e3da98b7 100644 --- a/runtime/tests/eventstream/event_stream_test.cc +++ b/runtime/tests/eventstream/event_stream_test.cc @@ -24,7 +24,7 @@ #include "smithy/http/websocket.h" #include "smithy/http/websocket_pair.h" -namespace smithy::eventstream { +namespace opal::eventstream { namespace { // Distinct client-to-server and server-to-client types, so a swapped @@ -417,4 +417,4 @@ TEST(EventStreamHandleTest, AReceiveOnlyStreamStillSharesForClose) { } } // namespace -} // namespace smithy::eventstream +} // namespace opal::eventstream diff --git a/runtime/tests/eventstream/frame_test.cc b/runtime/tests/eventstream/frame_test.cc index 84469fe2..4b8dcc50 100644 --- a/runtime/tests/eventstream/frame_test.cc +++ b/runtime/tests/eventstream/frame_test.cc @@ -17,7 +17,7 @@ #include #include -namespace smithy::eventstream { +namespace opal::eventstream { namespace { std::string EncodeOrDie(const Message& message) { @@ -663,4 +663,4 @@ TEST(EventStreamFrameTest, RandomMessagesRoundTripByteExactly) { } } // namespace -} // namespace smithy::eventstream +} // namespace opal::eventstream diff --git a/runtime/tests/eventstream/json_frame_test.cc b/runtime/tests/eventstream/json_frame_test.cc index 824f8bf6..962230ff 100644 --- a/runtime/tests/eventstream/json_frame_test.cc +++ b/runtime/tests/eventstream/json_frame_test.cc @@ -14,7 +14,7 @@ #include "smithy/eventstream/envelope.h" #include "smithy/eventstream/frame.h" -namespace smithy::eventstream { +namespace opal::eventstream { namespace { std::string EncodeOrDie(const Message& message) { @@ -231,4 +231,4 @@ TEST(JsonFrameTest, AFrameExactlyAtTheCeilingIsLegal) { } } // namespace -} // namespace smithy::eventstream +} // namespace opal::eventstream diff --git a/runtime/tests/eventstream/jsonrpc_frame_test.cc b/runtime/tests/eventstream/jsonrpc_frame_test.cc index bc424bca..d77503de 100644 --- a/runtime/tests/eventstream/jsonrpc_frame_test.cc +++ b/runtime/tests/eventstream/jsonrpc_frame_test.cc @@ -16,7 +16,7 @@ #include "smithy/eventstream/envelope.h" #include "smithy/eventstream/frame.h" -namespace smithy::eventstream { +namespace opal::eventstream { namespace { const Document kId(1); @@ -254,4 +254,4 @@ TEST(JsonRpcFrameTest, TheViolationResponseRendersThePinnedRefusalShape) { } } // namespace -} // namespace smithy::eventstream +} // namespace opal::eventstream diff --git a/runtime/tests/eventstream/jsonrpc_stream_socket_test.cc b/runtime/tests/eventstream/jsonrpc_stream_socket_test.cc index 35fcd743..cd778a75 100644 --- a/runtime/tests/eventstream/jsonrpc_stream_socket_test.cc +++ b/runtime/tests/eventstream/jsonrpc_stream_socket_test.cc @@ -25,7 +25,7 @@ #include "smithy/http/websocket_pair.h" #include "smithy/testing/websocket_contract_test.h" -namespace smithy::eventstream { +namespace opal::eventstream { namespace { // A headerless raw-text message: what the wire (and the unwrapped pair @@ -399,11 +399,11 @@ struct JsonRpcContractDriver { }; } // namespace -} // namespace smithy::eventstream +} // namespace opal::eventstream // gtest builds the registration symbols from the bare suite name, so the // instantiation lives in the namespace the suite was registered in. -namespace smithy::testing { +namespace opal::testing { INSTANTIATE_TYPED_TEST_SUITE_P(JsonRpcStreamSocket, WebSocketContractTest, eventstream::JsonRpcContractDriver); -} // namespace smithy::testing +} // namespace opal::testing diff --git a/runtime/tests/http/beast_client_test.cc b/runtime/tests/http/beast_client_test.cc index e718289f..da983cab 100644 --- a/runtime/tests/http/beast_client_test.cc +++ b/runtime/tests/http/beast_client_test.cc @@ -35,13 +35,13 @@ #include "smithy/testing/connection_event_recorder.h" #include "smithy/testing/tls_test_identity.h" -namespace smithy::http { +namespace opal::http { namespace { -using smithy::testing::kMismatchedNameCertificatePem; -using smithy::testing::kMismatchedNamePrivateKeyPem; -using smithy::testing::kTestCertificatePem; -using smithy::testing::kTestPrivateKeyPem; +using opal::testing::kMismatchedNameCertificatePem; +using opal::testing::kMismatchedNamePrivateKeyPem; +using opal::testing::kTestCertificatePem; +using opal::testing::kTestPrivateKeyPem; RequestHandler EchoHandler() { return [](const HttpRequest& request) { @@ -229,7 +229,7 @@ TEST(BeastClientTest, PlaintextToTheTlsPortIsObservedAsAHandshakeFailure) { // The "LB is misrouting" alarm (ADR-0013): a client speaking plain HTTP // to the TLS port fails the handshake, and the event carries the peer — // known before TLS ever ran. - smithy::testing::ConnectionEventRecorder recorder; + opal::testing::ConnectionEventRecorder recorder; auto options = TlsServerOptions(); options.on_connection_event = recorder.Hook(); BeastServerTransport server(options); @@ -257,7 +257,7 @@ TEST(BeastClientTest, TlsLifecycleAndProbesStaySilent) { // (stream_truncated at the server's next read — a healthy close, not a // drop), and (b) TCP health probes connect and leave, or idle into the // deadline, without ever really starting a handshake. All silent. - smithy::testing::ConnectionEventRecorder recorder; + opal::testing::ConnectionEventRecorder recorder; auto options = TlsServerOptions(); options.request_timeout_seconds = 1; options.on_connection_event = recorder.Hook(); @@ -545,7 +545,7 @@ TEST(BeastClientTest, ATlsPeerVanishingMidRequestIsObservedAsDropped) { // The mid-message side of the stream_truncated split (ADR-0013): a TLS // client that dies after starting a request — TCP close, no close_notify // — is a drop, not a clean close. - smithy::testing::ConnectionEventRecorder recorder; + opal::testing::ConnectionEventRecorder recorder; auto options = TlsServerOptions(); options.on_connection_event = recorder.Hook(); BeastServerTransport server(options); @@ -750,4 +750,4 @@ TEST(BeastClientTest, TlsClientReachesATls13OnlyServer) { } } // namespace -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/tests/http/beast_transport_test.cc b/runtime/tests/http/beast_transport_test.cc index b261d2fd..8ffbd18f 100644 --- a/runtime/tests/http/beast_transport_test.cc +++ b/runtime/tests/http/beast_transport_test.cc @@ -24,10 +24,10 @@ #include "smithy/server/middleware.h" #include "smithy/testing/connection_event_recorder.h" -namespace smithy::http { +namespace opal::http { namespace { -using smithy::testing::ConnectionEventRecorder; +using opal::testing::ConnectionEventRecorder; // Opens a loopback connection to `port` with a bounded receive timeout (and // SIGPIPE disarmed where SO_NOSIGPIPE exists); returns the fd, or -1. @@ -1272,19 +1272,19 @@ TEST(BeastTransportTest, TheMetricsEndpointScrapesOverTheRealTransport) { // proves is that a scrape survives the transport — the exposition's own // content type reaches the client, and the traffic counted is the traffic // the transport actually served. - auto metrics = std::make_shared( - smithy::server::MetricsOptions{.enabled = true, .service_name = "todo-service"}); + auto metrics = std::make_shared( + opal::server::MetricsOptions{.enabled = true, .service_name = "todo-service"}); BeastServerTransport server; ASSERT_TRUE(server - .Start(smithy::server::Chain({smithy::server::MetricsEndpoint(metrics), - smithy::server::RecordMetrics(metrics)}, - [](const HttpRequest&) { - HttpResponse response; - response.status = 200; - response.operation = "GetThing"; - response.body = "ok"; - return response; - })) + .Start(opal::server::Chain({opal::server::MetricsEndpoint(metrics), + opal::server::RecordMetrics(metrics)}, + [](const HttpRequest&) { + HttpResponse response; + response.status = 200; + response.operation = "GetThing"; + response.body = "ok"; + return response; + })) .ok()); ASSERT_FALSE( @@ -1321,19 +1321,19 @@ TEST(BeastTransportTest, AnOverLimitRejectionReachesTheMetricsScrape) { // over-limit flood would be invisible in the request counters. Wiring // on_rejected is what makes it visible, and only a real transport proves // the wiring — the rejection has no in-process caller to fake. - auto metrics = std::make_shared( - smithy::server::MetricsOptions{.enabled = true, .service_name = "todo-service"}); + auto metrics = std::make_shared( + opal::server::MetricsOptions{.enabled = true, .service_name = "todo-service"}); BeastServerTransport server(BeastServerTransport::Options{ - .max_body_bytes = 1024, .on_rejected = smithy::server::RecordRejections(metrics)}); + .max_body_bytes = 1024, .on_rejected = opal::server::RecordRejections(metrics)}); ASSERT_TRUE(server - .Start(smithy::server::Chain({smithy::server::MetricsEndpoint(metrics), - smithy::server::RecordMetrics(metrics)}, - [](const HttpRequest&) { - HttpResponse response; - response.status = 200; - response.operation = "GetThing"; - return response; - })) + .Start(opal::server::Chain({opal::server::MetricsEndpoint(metrics), + opal::server::RecordMetrics(metrics)}, + [](const HttpRequest&) { + HttpResponse response; + response.status = 200; + response.operation = "GetThing"; + return response; + })) .ok()); SocketHttpClient client("127.0.0.1", server.port()); @@ -1371,17 +1371,17 @@ TEST(BeastTransportTest, TheMetricsEndpointsHeadReportsTheGetsLength) { // Same framing hazard as the health endpoint below: MetricsEndpoint answers // HEAD itself, so it is on the handler to hand the transport a full body // and let the transport withhold the octets while keeping the length. - auto metrics = std::make_shared( - smithy::server::MetricsOptions{.enabled = true, .service_name = "todo-service"}); + auto metrics = std::make_shared( + opal::server::MetricsOptions{.enabled = true, .service_name = "todo-service"}); BeastServerTransport server; ASSERT_TRUE(server - .Start(smithy::server::Chain({smithy::server::MetricsEndpoint(metrics)}, - [](const HttpRequest&) { - HttpResponse response; - response.status = 404; - response.body = "no route"; - return response; - })) + .Start(opal::server::Chain({opal::server::MetricsEndpoint(metrics)}, + [](const HttpRequest&) { + HttpResponse response; + response.status = 404; + response.body = "no route"; + return response; + })) .ok()); const std::string head = @@ -1409,13 +1409,13 @@ TEST(BeastTransportTest, TheHealthEndpointsHeadReportsTheGetsLength) { // to the only question a HEAD asks. BeastServerTransport server; ASSERT_TRUE(server - .Start(smithy::server::Chain({smithy::server::HealthEndpoint("/livez")}, - [](const HttpRequest&) { - HttpResponse response; - response.status = 404; - response.body = "no route"; - return response; - })) + .Start(opal::server::Chain({opal::server::HealthEndpoint("/livez")}, + [](const HttpRequest&) { + HttpResponse response; + response.status = 404; + response.body = "no route"; + return response; + })) .ok()); const std::string head = @@ -1521,4 +1521,4 @@ TEST(BeastTransportTest, OptionalFieldsCanBeOmittedFromDesignatedInitializers) { } } // namespace -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/tests/http/beast_websocket_test.cc b/runtime/tests/http/beast_websocket_test.cc index 19ffa5b1..c1866b58 100644 --- a/runtime/tests/http/beast_websocket_test.cc +++ b/runtime/tests/http/beast_websocket_test.cc @@ -38,11 +38,11 @@ #include "smithy/testing/tls_test_identity.h" #include "smithy/testing/websocket_contract_test.h" -namespace smithy::http { +namespace opal::http { namespace { using eventstream::Message; -using smithy::testing::ConnectionEventRecorder; +using opal::testing::ConnectionEventRecorder; Message Text(const std::string& kind, const std::string& body) { return Message{.headers = {{":event-type", kind}}, .payload = Blob::FromString(body)}; @@ -1110,8 +1110,8 @@ TEST(BeastWebSocketTest, StopUnblocksAServeCallbackMidReceive) { TEST(BeastWebSocketTest, TlsStreamsCarryMessagesEndToEnd) { BeastServerTransport::Options options = EchoOptions(); - options.tls_certificate_chain_pem = smithy::testing::kTestCertificatePem; - options.tls_private_key_pem = smithy::testing::kTestPrivateKeyPem; + options.tls_certificate_chain_pem = opal::testing::kTestCertificatePem; + options.tls_private_key_pem = opal::testing::kTestPrivateKeyPem; BeastServerTransport server(options); ASSERT_TRUE(server.Start(NotFoundHandler()).ok()); @@ -1119,7 +1119,7 @@ TEST(BeastWebSocketTest, TlsStreamsCarryMessagesEndToEnd) { dial.host = "127.0.0.1"; dial.port = server.port(); dial.tls = true; - dial.tls_options.ca_pem = smithy::testing::kTestCertificatePem; + dial.tls_options.ca_pem = opal::testing::kTestCertificatePem; auto dialed = BeastWebSocketClient::Dial(dial); ASSERT_TRUE(dialed.ok()) << dialed.error().message(); @@ -1293,8 +1293,8 @@ TEST(BeastWebSocketTest, TlsDialAgainstAnUntrustedCertificateFailsFastAndNonRetr // with verification disabled) — only dialing an UNTRUSTED cert with // default options can catch it. BeastServerTransport::Options options = EchoOptions(); - options.tls_certificate_chain_pem = smithy::testing::kTestCertificatePem; - options.tls_private_key_pem = smithy::testing::kTestPrivateKeyPem; + options.tls_certificate_chain_pem = opal::testing::kTestCertificatePem; + options.tls_private_key_pem = opal::testing::kTestPrivateKeyPem; BeastServerTransport server(options); ASSERT_TRUE(server.Start(NotFoundHandler()).ok()); @@ -1635,8 +1635,8 @@ TEST(BeastWebSocketTest, ALargeButLegalMessageRoundTrips) { TEST(BeastWebSocketTest, TheGateRefusesOverTlsToo) { // The refusal Respond arm on the TLS template instantiation. BeastServerTransport::Options options = EchoOptions(); - options.tls_certificate_chain_pem = smithy::testing::kTestCertificatePem; - options.tls_private_key_pem = smithy::testing::kTestPrivateKeyPem; + options.tls_certificate_chain_pem = opal::testing::kTestCertificatePem; + options.tls_private_key_pem = opal::testing::kTestPrivateKeyPem; options.websocket_gate = [](const HttpRequest& request) -> std::optional { if (request.headers.Get("authorization").value_or("") != "Bearer let-me-in") { return PlainResponse(401, "who are you?"); @@ -1650,7 +1650,7 @@ TEST(BeastWebSocketTest, TheGateRefusesOverTlsToo) { dial.host = "127.0.0.1"; dial.port = server.port(); dial.tls = true; - dial.tls_options.ca_pem = smithy::testing::kTestCertificatePem; + dial.tls_options.ca_pem = opal::testing::kTestCertificatePem; auto refused = BeastWebSocketClient::Dial(dial); EXPECT_FALSE(refused.ok()); @@ -2012,11 +2012,11 @@ struct BeastContractDriver { }; } // namespace -} // namespace smithy::http +} // namespace opal::http // The instantiation lives where the suite was registered: gtest builds the // registration symbols from the bare suite name, so a qualified one does // not resolve. -namespace smithy::testing { +namespace opal::testing { INSTANTIATE_TYPED_TEST_SUITE_P(Beast, WebSocketContractTest, http::BeastContractDriver); -} // namespace smithy::testing +} // namespace opal::testing diff --git a/runtime/tests/http/forwarded_test.cc b/runtime/tests/http/forwarded_test.cc index fc61717a..9aed4826 100644 --- a/runtime/tests/http/forwarded_test.cc +++ b/runtime/tests/http/forwarded_test.cc @@ -10,7 +10,7 @@ #include #include -namespace smithy::http { +namespace opal::http { namespace { // A valid trust boundary or a fatal test failure: the parse-error path is @@ -355,4 +355,4 @@ TEST(ClientAddressTest, AnEmptyPeerDerivesEmpty) { } } // namespace -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/tests/http/http1_hostile_test.cc b/runtime/tests/http/http1_hostile_test.cc index 0099d368..657601d8 100644 --- a/runtime/tests/http/http1_hostile_test.cc +++ b/runtime/tests/http/http1_hostile_test.cc @@ -14,7 +14,7 @@ #include "smithy/http/http1.h" -namespace smithy::http { +namespace opal::http { namespace { // Reads from an in-memory wire capture, `chunk` bytes per call, EOF after. @@ -176,4 +176,4 @@ TEST(Http1HostileTest, StartLineHelpersMatchTheTransports) { } } // namespace -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/tests/http/http_test.cc b/runtime/tests/http/http_test.cc index 3a556bcc..d5d5b5d8 100644 --- a/runtime/tests/http/http_test.cc +++ b/runtime/tests/http/http_test.cc @@ -5,11 +5,11 @@ #include "smithy/http/message.h" #include "smithy/http/uri.h" -namespace smithy::http { +namespace opal::http { namespace { TEST(HeadersTest, AcceptMatches) { - using smithy::http::AcceptMatches; + using opal::http::AcceptMatches; EXPECT_TRUE(AcceptMatches("application/json", "application/json")); EXPECT_TRUE(AcceptMatches("Application/JSON", "application/json")); EXPECT_TRUE(AcceptMatches("*/*", "image/jpeg")); @@ -21,7 +21,7 @@ TEST(HeadersTest, AcceptMatches) { } TEST(HeadersTest, HeaderNameStartsWith) { - using smithy::http::HeaderNameStartsWith; + using opal::http::HeaderNameStartsWith; EXPECT_TRUE(HeaderNameStartsWith("x-foo-abc", "x-foo-")); EXPECT_TRUE(HeaderNameStartsWith("X-Foo-Abc", "x-foo-")); EXPECT_TRUE(HeaderNameStartsWith("anything", "")); @@ -288,4 +288,4 @@ TEST(HeadersTest, RequestLineFieldPredicateRejectsSpaceAndControls) { } } // namespace -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/tests/http/server_dispatch_test.cc b/runtime/tests/http/server_dispatch_test.cc index d182fa2a..284c1575 100644 --- a/runtime/tests/http/server_dispatch_test.cc +++ b/runtime/tests/http/server_dispatch_test.cc @@ -9,7 +9,7 @@ #include "smithy/http/trace_context.h" #include "smithy/http/transport.h" -namespace smithy::http { +namespace opal::http { namespace { HttpRequest SampleRequest() { @@ -210,4 +210,4 @@ TEST(ServerDispatchTest, EmptyHandlerIsA503NotACrash) { } } // namespace -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/tests/http/socket_transport_hostile_test.cc b/runtime/tests/http/socket_transport_hostile_test.cc index 8e8a1db5..2edd2915 100644 --- a/runtime/tests/http/socket_transport_hostile_test.cc +++ b/runtime/tests/http/socket_transport_hostile_test.cc @@ -16,7 +16,7 @@ #include "smithy/http/socket_transport.h" -namespace smithy::http { +namespace opal::http { namespace { // Sends raw bytes to 127.0.0.1:port, half-closes so the server sees EOF (no @@ -176,4 +176,4 @@ TEST(HostileFramingResponseTest, ServerEmitsExactlyOneContentLength) { } } // namespace -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/tests/http/socket_transport_test.cc b/runtime/tests/http/socket_transport_test.cc index 6ea18b1e..4de5f902 100644 --- a/runtime/tests/http/socket_transport_test.cc +++ b/runtime/tests/http/socket_transport_test.cc @@ -16,7 +16,7 @@ #include "smithy/http/trace_context.h" -namespace smithy::http { +namespace opal::http { namespace { // Sends raw bytes to the loopback server and returns the raw response, so an @@ -496,4 +496,4 @@ TEST(SocketTransportTest, TheClientReadsAHeadResponseAsHeadersWhateverFollowsThe } } // namespace -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/tests/http/trace_context_test.cc b/runtime/tests/http/trace_context_test.cc index d9ad3023..fa9477ba 100644 --- a/runtime/tests/http/trace_context_test.cc +++ b/runtime/tests/http/trace_context_test.cc @@ -4,7 +4,7 @@ #include -namespace smithy::http { +namespace opal::http { namespace { constexpr char kTrace[] = "0af7651916cd43dd8448eb211c80319c"; @@ -67,4 +67,4 @@ TEST(TraceContextTest, GeneratedContextsAreValidAndDistinct) { } } // namespace -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/tests/http/uri_property_test.cc b/runtime/tests/http/uri_property_test.cc index 717f529f..0eb3900a 100644 --- a/runtime/tests/http/uri_property_test.cc +++ b/runtime/tests/http/uri_property_test.cc @@ -8,7 +8,7 @@ #include "smithy/http/uri.h" -namespace smithy::http { +namespace opal::http { namespace { std::string RandomBytes(std::mt19937_64& rng, int max_length) { @@ -72,4 +72,4 @@ TEST(UriPropertyTest, GreedyEncodingPreservesSlashesOnly) { } } // namespace -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/tests/http/websocket_pair_test.cc b/runtime/tests/http/websocket_pair_test.cc index cafd0436..934c422a 100644 --- a/runtime/tests/http/websocket_pair_test.cc +++ b/runtime/tests/http/websocket_pair_test.cc @@ -21,7 +21,7 @@ #include "smithy/eventstream/frame.h" #include "smithy/http/websocket.h" -namespace smithy::http { +namespace opal::http { namespace { using eventstream::Message; @@ -371,4 +371,4 @@ TEST(WebSocketPairTimeoutTest, EveryImplementorAnswersTheDeadlineItself) { } } // namespace -} // namespace smithy::http +} // namespace opal::http diff --git a/runtime/tests/json/json_conformance_test.cc b/runtime/tests/json/json_conformance_test.cc index 32f3180a..12386e91 100644 --- a/runtime/tests/json/json_conformance_test.cc +++ b/runtime/tests/json/json_conformance_test.cc @@ -1,5 +1,5 @@ // Runs the vendored JSONTestSuite parsing corpus (nst/JSONTestSuite, see -// tests/json/jsontestsuite/PROVENANCE.md) through smithy::json::Decode. The +// tests/json/jsontestsuite/PROVENANCE.md) through opal::json::Decode. The // suite is the canonical bank for "does the parser agree with RFC 8259 and // never crash on hostile input" — the class of bug that produced the // nesting-depth stack overflow this test was added with. @@ -20,7 +20,7 @@ #include "smithy/json/json.h" #include "tools/cpp/runfiles/runfiles.h" -namespace smithy::json { +namespace opal::json { // Defined in the generated json_conformance_index.cc (a genrule lists the // vendored corpus filenames): runfiles directory enumeration is not portable, @@ -88,4 +88,4 @@ INSTANTIATE_TEST_SUITE_P(JSONTestSuite, JsonConformanceTest, testing::ValuesIn(C }); } // namespace -} // namespace smithy::json +} // namespace opal::json diff --git a/runtime/tests/json/json_property_test.cc b/runtime/tests/json/json_property_test.cc index e80ca71b..b214dad6 100644 --- a/runtime/tests/json/json_property_test.cc +++ b/runtime/tests/json/json_property_test.cc @@ -7,14 +7,14 @@ #include "smithy/json/json.h" #include "tests/testing/random_document.h" -namespace smithy::json { +namespace opal::json { namespace { TEST(JsonPropertyTest, RandomNativeDocumentsRoundTrip) { - smithy::testing::DocumentGeneratorOptions options; + opal::testing::DocumentGeneratorOptions options; options.with_blobs = false; options.with_timestamps = false; - smithy::testing::RandomDocumentGenerator generator(/*seed=*/20260706, options); + opal::testing::RandomDocumentGenerator generator(/*seed=*/20260706, options); for (int i = 0; i < 500; ++i) { const Document original = generator.Next(); const std::string text = Encode(original); @@ -26,10 +26,10 @@ TEST(JsonPropertyTest, RandomNativeDocumentsRoundTrip) { } TEST(JsonPropertyTest, EncodingIsDeterministic) { - smithy::testing::DocumentGeneratorOptions options; + opal::testing::DocumentGeneratorOptions options; options.with_blobs = false; options.with_timestamps = false; - smithy::testing::RandomDocumentGenerator generator(/*seed=*/99, options); + opal::testing::RandomDocumentGenerator generator(/*seed=*/99, options); for (int i = 0; i < 50; ++i) { const Document doc = generator.Next(); ASSERT_EQ(Encode(doc), Encode(doc)) << "iteration " << i; @@ -37,4 +37,4 @@ TEST(JsonPropertyTest, EncodingIsDeterministic) { } } // namespace -} // namespace smithy::json +} // namespace opal::json diff --git a/runtime/tests/json/json_test.cc b/runtime/tests/json/json_test.cc index ee5c0e19..0e2dd98b 100644 --- a/runtime/tests/json/json_test.cc +++ b/runtime/tests/json/json_test.cc @@ -2,7 +2,7 @@ #include -namespace smithy::json { +namespace opal::json { namespace { Document CityDocument() { @@ -117,4 +117,4 @@ TEST(JsonTest, DecodesNestedLists) { } } // namespace -} // namespace smithy::json +} // namespace opal::json diff --git a/runtime/tests/json/jsontestsuite/PROVENANCE.md b/runtime/tests/json/jsontestsuite/PROVENANCE.md index 74e99e49..a37b915d 100644 --- a/runtime/tests/json/jsontestsuite/PROVENANCE.md +++ b/runtime/tests/json/jsontestsuite/PROVENANCE.md @@ -15,7 +15,7 @@ runs the whole corpus in CI. File naming is the suite's own convention: require that these don't crash or hang. The overriding invariant the test enforces for *every* file — `y_`, `n_`, -and `i_` alike — is that `smithy::json::Decode` returns (an ok or an error), +and `i_` alike — is that `opal::json::Decode` returns (an ok or an error), never crashes. That is the property that caught the nesting-depth stack overflow this suite was added alongside. diff --git a/runtime/tests/server/access_log_test.cc b/runtime/tests/server/access_log_test.cc index dd4367ff..8aa48c68 100644 --- a/runtime/tests/server/access_log_test.cc +++ b/runtime/tests/server/access_log_test.cc @@ -22,7 +22,7 @@ #include "smithy/server/metrics.h" #include "smithy/server/middleware.h" -namespace smithy::server { +namespace opal::server { namespace { using nlohmann::json; @@ -280,4 +280,4 @@ TEST(AccessLogTest, FormatsWhatObserveReports) { } } // namespace -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/tests/server/metrics_test.cc b/runtime/tests/server/metrics_test.cc index 78a297e6..26506442 100644 --- a/runtime/tests/server/metrics_test.cc +++ b/runtime/tests/server/metrics_test.cc @@ -23,7 +23,7 @@ #include "smithy/server/middleware.h" -namespace smithy::server { +namespace opal::server { namespace { using std::chrono::microseconds; @@ -1491,4 +1491,4 @@ TEST(MetricsRegistryDeathTest, ANegativeCounterIncrementAborts) { } } // namespace -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/tests/server/middleware_test.cc b/runtime/tests/server/middleware_test.cc index c4f3458d..0cc0c772 100644 --- a/runtime/tests/server/middleware_test.cc +++ b/runtime/tests/server/middleware_test.cc @@ -12,7 +12,7 @@ #include "smithy/http/loopback.h" #include "smithy/http/trace_context.h" -namespace smithy::server { +namespace opal::server { namespace { using std::chrono::milliseconds; @@ -380,7 +380,7 @@ TEST(ObserveTest, CountsEveryRequest) { TEST(ObserveDeathTest, NullOnCompleteAbortsAtComposition) { // A composition-time contract violation fails fast (ADR-0009), so no // exception crosses the boundary and the runtime builds -fno-exceptions. - EXPECT_DEATH(Observe(nullptr), "smithy::server::Observe: on_complete may not be null"); + EXPECT_DEATH(Observe(nullptr), "opal::server::Observe: on_complete may not be null"); } TEST(ObserveTest, ThrowingCallbackDoesNotDiscardResponseOrPropagate) { @@ -528,7 +528,7 @@ TEST(PerClientRateLimitTest, AnUnknownClientIsAdmittedWithoutConsultingAllow) { TEST(PerClientRateLimitDeathTest, ANullPolicyAbortsAtComposition) { EXPECT_DEATH(PerClientRateLimit(nullptr, http::TrustedProxies::None()), - "smithy::server::PerClientRateLimit: allow must not be null"); + "opal::server::PerClientRateLimit: allow must not be null"); } TEST(TooManyRequestsTest, ShapesThe429) { @@ -773,4 +773,4 @@ TEST(HealthEndpointTest, AnswersHeadWithWhatTheGetWouldCarry) { } } // namespace -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/tests/server/origin_gate_test.cc b/runtime/tests/server/origin_gate_test.cc index 90627a7d..f03a9df1 100644 --- a/runtime/tests/server/origin_gate_test.cc +++ b/runtime/tests/server/origin_gate_test.cc @@ -13,7 +13,7 @@ #include "smithy/http/message.h" -namespace smithy::server { +namespace opal::server { namespace { http::HttpRequest UpgradeFrom(const std::string& origin) { @@ -136,4 +136,4 @@ TEST(OriginGateTest, AnEmptyAllowlistRefusesEveryBrowser) { } } // namespace -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/tests/server/router_test.cc b/runtime/tests/server/router_test.cc index ad6b9c19..19f3b1b5 100644 --- a/runtime/tests/server/router_test.cc +++ b/runtime/tests/server/router_test.cc @@ -2,7 +2,7 @@ #include -namespace smithy::server { +namespace opal::server { namespace { http::HttpRequest Request(std::string method, std::string target) { @@ -169,4 +169,4 @@ TEST(MakeErrorResponseTest, ProducesJsonBody) { } } // namespace -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/tests/server/session_registry_test.cc b/runtime/tests/server/session_registry_test.cc index fc93888c..aa65acd9 100644 --- a/runtime/tests/server/session_registry_test.cc +++ b/runtime/tests/server/session_registry_test.cc @@ -36,7 +36,7 @@ #include "smithy/http/websocket.h" #include "smithy/http/websocket_pair.h" -namespace smithy::server { +namespace opal::server { namespace { using eventstream::EventStream; @@ -1434,4 +1434,4 @@ TEST(SessionRegistryGraceTest, RetentionSkipsThePreLossBacklogAndThePolicy) { } } // namespace -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/tests/server/websocket_router_test.cc b/runtime/tests/server/websocket_router_test.cc index ae901e6a..bc53511e 100644 --- a/runtime/tests/server/websocket_router_test.cc +++ b/runtime/tests/server/websocket_router_test.cc @@ -21,7 +21,7 @@ #include "smithy/http/websocket_pair.h" -namespace smithy::server { +namespace opal::server { namespace { http::HttpRequest Request(std::string method, std::string target) { @@ -348,4 +348,4 @@ TEST(WebSocketRouterTest, AddRejectsBadPatternsAndConflictsLikeRouter) { } } // namespace -} // namespace smithy::server +} // namespace opal::server diff --git a/runtime/tests/testing/protocol_test_support_test.cc b/runtime/tests/testing/protocol_test_support_test.cc index 279d62cc..36f3c33a 100644 --- a/runtime/tests/testing/protocol_test_support_test.cc +++ b/runtime/tests/testing/protocol_test_support_test.cc @@ -9,7 +9,7 @@ #include "smithy/testing/protocol_test.h" -namespace smithy::testing { +namespace opal::testing { namespace { TEST(UriPathTest, SplitsTargetAtQuestionMark) { @@ -79,8 +79,8 @@ TEST(JsonBodyEqualsTest, IgnoresFormattingAndKeyOrder) { TEST(CborBodyEqualsTest, ComparesDecodedDocuments) { DocumentMap map; map.emplace("a", Document(std::int64_t{1})); - const std::string bytes = smithy::cbor::Encode(Document(std::move(map))).ToString(); - const std::string b64 = smithy::Base64Encode(smithy::Blob::FromString(bytes)); + const std::string bytes = opal::cbor::Encode(Document(std::move(map))).ToString(); + const std::string b64 = opal::Base64Encode(opal::Blob::FromString(bytes)); EXPECT_TRUE(CborBodyEqualsBase64(b64, bytes)); EXPECT_FALSE(CborBodyEqualsBase64(b64, "junk")); } @@ -96,7 +96,7 @@ TEST(MutatingTransportTest, MutatesSuccessfulResponses) { auto inner = std::make_shared(); inner->next_response = {200, {}, "before"}; MutatingTransport transport(inner, - [](smithy::http::HttpResponse& response) { response.body += "!"; }); + [](opal::http::HttpResponse& response) { response.body += "!"; }); const auto response = transport.Send({}); ASSERT_TRUE(response.ok()); EXPECT_EQ(response->body, "before!"); @@ -105,7 +105,7 @@ TEST(MutatingTransportTest, MutatesSuccessfulResponses) { TEST(CapturingTransportTest, RecordsAndReplays) { CapturingTransport transport; transport.next_response = {418, {}, "teapot"}; - smithy::http::HttpRequest request; + opal::http::HttpRequest request; request.method = "PUT"; const auto response = transport.Send(request); ASSERT_TRUE(response.ok()); @@ -114,4 +114,4 @@ TEST(CapturingTransportTest, RecordsAndReplays) { } } // namespace -} // namespace smithy::testing +} // namespace opal::testing diff --git a/runtime/tests/testing/random_document.h b/runtime/tests/testing/random_document.h index 2a184c47..e7e01139 100644 --- a/runtime/tests/testing/random_document.h +++ b/runtime/tests/testing/random_document.h @@ -12,7 +12,7 @@ #include "smithy/core/document.h" -namespace smithy::testing { +namespace opal::testing { struct DocumentGeneratorOptions { // JSON cannot represent blob/timestamp nodes natively; codecs that re-type @@ -119,6 +119,6 @@ class RandomDocumentGenerator { DocumentGeneratorOptions options_; }; -} // namespace smithy::testing +} // namespace opal::testing #endif // SMITHY_TESTS_TESTING_RANDOM_DOCUMENT_H_ diff --git a/tools/release.sh b/tools/release.sh index c59096f9..0bab6820 100755 --- a/tools/release.sh +++ b/tools/release.sh @@ -24,7 +24,7 @@ die() { exit 1 } -# smithy::Version()'s literal is the single source of truth; the other two +# opal::Version()'s literal is the single source of truth; the other two # files mirror it (docs/versioning.md). read_version() { sed -n 's/^std::string_view Version() { return "\(.*\)"; }$/\1/p' "$VERSION_CC" @@ -119,8 +119,8 @@ current_state_section() { ## Current state: $released released, $dev in development \`v$released\` is the current release; \`main\` develops $dev. The one product version -consumers observe — \`smithy::Version()\` (\`runtime/src/core/version.cc\`) and the -client \`User-Agent\` (\`smithy::ClientConfig::user_agent\`) — reports +consumers observe — \`opal::Version()\` (\`runtime/src/core/version.cc\`) and the +client \`User-Agent\` (\`opal::ClientConfig::user_agent\`) — reports **\`$dev-dev\`** on \`main\` until that tag lands, and the generator's Gradle \`version\` (\`codegen/gradle.properties\`) tracks it, since the two ship under one tag. The bzlmod **module** version in \`MODULE.bazel\` is a separate identifier From 5b9804fdb8ba685c3a1d7b69c0e8f2cb7e8922d6 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 9 Sep 2026 10:38:52 +0000 Subject: [PATCH 2/2] Constrain the namespace migration recipe to the runtime's scopes A blind smithy:: -> opal:: substitution also renames a C++ namespace a consumer derived from a model whose Smithy namespace starts with smithy., which the CHANGELOG told them to leave alone in the next sentence. Spell the recipe with that exclusion and the list of runtime scopes it applies to; same note in ADR-0024's consequences. --- CHANGELOG.md | 17 ++++++++++++----- .../adr/0024-runtime-not-named-after-the-idl.md | 4 +++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd1a8117..2fe4529f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,11 +16,18 @@ policy in [docs/versioning.md](docs/versioning.md). `opal::http::BeastServerTransport` — every `smithy::` scope in the runtime, in generated code, and in the generated protocol-conformance suites (now `opal::protocoltests::…`, whose headers moved to - `include/opal/protocoltests/`). Migration is one substitution over your - tree: `smithy::` → `opal::` and `namespace smithy` → `namespace opal`. - Leave alone anything that names the model rather than the runtime: Smithy - namespaces in `.smithy` files, the `smithy_cpp_*_library` rules, and any - C++ namespace you derived from your own model's Smithy namespace. The + `include/opal/protocoltests/`). Migration: `smithy::` → `opal::` and + `namespace smithy` → `namespace opal` over your tree, with one exclusion. + A C++ namespace you derived from your own model's Smithy namespace is + yours, not the runtime's, and when that model namespace starts with + `smithy.` a blind substitution would rename it too (this repo's rules-test + fixture, `smithy.cpp.ruletest` → `smithy::cpp::ruletest`, is one). Keep + it, and constrain the substitution to the runtime's scopes: + `smithy::http::`, `smithy::json::`, `smithy::cbor::`, + `smithy::eventstream::`, `smithy::server::`, `smithy::testing::`, + `smithy::protocoltests::`, and the top-level runtime types such as + `smithy::Outcome`. Smithy namespaces in `.smithy` files and the + `smithy_cpp_*_library` rules name the model and are unchanged. The include root (`smithy/http/transport.h`) and the Bazel module (`@smithy_cpp`) are unchanged here and move in the two PRs that follow. diff --git a/docs/adr/0024-runtime-not-named-after-the-idl.md b/docs/adr/0024-runtime-not-named-after-the-idl.md index 6922711a..dcda2634 100644 --- a/docs/adr/0024-runtime-not-named-after-the-idl.md +++ b/docs/adr/0024-runtime-not-named-after-the-idl.md @@ -81,7 +81,9 @@ and the goldens regenerate from them. - Breaking, on a minor bump, called out in the CHANGELOG with the one-line migration each surface needs (a `sed` over the consumer's - tree). Consumers migrate once per surface, or once at the release that + tree, constrained to the runtime's scopes where the consumer's own model + namespace starts with `smithy.`, as this repo's rules-test fixture + does). Consumers migrate once per surface, or once at the release that carries all three. - The rename is mechanical and verified by the existing suites: the goldens must regenerate byte-identically from the emitters (the codegen