Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add service and operation names to HandlerExecutionContext #934

Merged
merged 2 commits into from
Sep 15, 2023

Conversation

syall
Copy link
Contributor

@syall syall commented Sep 13, 2023

Issue #, if available:

Resolves #933

Description of changes:

Add service and operation names to HandlerExecutionContext

Dependent on: #927

Testing:

Smithy context service and operation population

smithy-typescript-codegen-test: for the Weather service's CreateCity command, the following codegen diff is produced:

diff --color -Nur smithy-typescript-codegen-test/build_old/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/commands/CreateCityCommand.ts smithy-typescript-codegen-test/build/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/commands/CreateCityCommand.ts
--- smithy-typescript-codegen-test/build_old/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/commands/CreateCityCommand.ts	2023-09-13 16:03:06
+++ smithy-typescript-codegen-test/build/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/commands/CreateCityCommand.ts	2023-09-13 16:03:21
@@ -23,6 +23,7 @@
   Handler,
   HandlerExecutionContext,
   MiddlewareStack,
+  SMITHY_CONTEXT_KEY,
   HttpHandlerOptions as __HttpHandlerOptions,
   MetadataBearer as __MetadataBearer,
   SerdeContext as __SerdeContext,
@@ -81,6 +82,10 @@
         (_: any) => _,
       outputFilterSensitiveLog:
         (_: any) => _,
+      [SMITHY_CONTEXT_KEY]: {
+        service: "Weather",
+        operation: "CreateCity",
+      },
     }
     const { requestHandler } = configuration;
     return stack.resolve(

experimentalIdentityAndAuth: HttpAuthSchemeParametersProvider update

diff --color -Nur /Users/yuasteve/development/ts-ia/smithy-typescript/smithy-typescript-codegen-test/build_old/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/auth/httpAuthSchemeProvider.ts /Users/yuasteve/development/ts-ia/smithy-typescript/smithy-typescript-codegen-test/build/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/auth/httpAuthSchemeProvider.ts
--- /Users/yuasteve/development/ts-ia/smithy-typescript/smithy-typescript-codegen-test/build_old/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/auth/httpAuthSchemeProvider.ts	2023-09-14 14:43:01
+++ /Users/yuasteve/development/ts-ia/smithy-typescript/smithy-typescript-codegen-test/build/smithyprojections/smithy-typescript-codegen-test/client-experimental-identity-and-auth/typescript-codegen/src/auth/httpAuthSchemeProvider.ts	2023-09-14 14:43:33
@@ -7,7 +7,10 @@
   HttpAuthSchemeParametersProvider,
   HttpAuthSchemeProvider,
 } from "@smithy/experimental-identity-and-auth";
-import { normalizeProvider } from "@smithy/util-middleware";
+import {
+  getSmithyContext,
+  normalizeProvider,
+} from "@smithy/util-middleware";
 
 /**
  * @internal
@@ -21,7 +24,7 @@
  */
 export const defaultWeatherHttpAuthSchemeParametersProvider: HttpAuthSchemeParametersProvider<WeatherClientResolvedConfig, WeatherHttpAuthSchemeParameters> = async (config, context) => {
   return {
-    operation: context.commandName,
+    operation: getSmithyContext(context).operation as string,
     region: await normalizeProvider(config.region)() || (() => {
       throw new Error("expected `region` to be configured for `aws.auth#sigv4`");
     })(),

If one or more of the packages in the /packages directory has been modified, be sure yarn changeset add has been run and its output has
been committed and included in this pull request. See CONTRIBUTING.md.


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@syall syall force-pushed the add-service-and-operation-names branch from 0864127 to 0359819 Compare September 14, 2023 21:30
@syall syall force-pushed the add-service-and-operation-names branch from 356b7bc to f3c0bfc Compare September 15, 2023 18:19
@syall syall force-pushed the add-service-and-operation-names branch from f3c0bfc to 4dbdcb1 Compare September 15, 2023 19:06
@syall syall marked this pull request as ready for review September 15, 2023 19:06
@syall syall requested review from a team as code owners September 15, 2023 19:06
@syall syall merged commit 94f2e72 into smithy-lang:main Sep 15, 2023
@syall syall deleted the add-service-and-operation-names branch September 15, 2023 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add service and operation names to middleware context
3 participants