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

Rule-Engine: Experimental Context Traits #1248

Merged
merged 1 commit into from
Aug 18, 2022

Conversation

skmcgrail
Copy link
Contributor

@skmcgrail skmcgrail commented Jun 1, 2022

Adds support for new AWS context traits clientContextParams, staticContextParams, and contextParam.

  • smithy.rules#clientContextParams is a trait that may be applied to a Service shape. It is used to indicate that the named context parameters that should be configurable on a top-level API client. The trait is a mapping of the context parameter name to their definition containing the Smithy shape type used to represent it, documentation string for the client, and context usages. Valid usages are endpoint, and valid shape types supported are string and boolean.

  • smithy.rules#staticContextParams is a trait that may be applied to an Operation shape. It is a mapping of context parameter names to their definition containing the static value to be configured for the parameter, and context usages. Valid usages are endpoint.

  • smithy.rules#contextParam is a trait that may be applied to a Member shape. The trait indicates the target context parameter name that the member's value should be bound to as, as well as the context usages. Valid usages are endpoint. Per specification this trait will only be supported on the top-level operation input shape.

  • smithy.rules#endpointRuleSet is a trait that is used to embed a rule-set document.

Example Model

$version: "1.0"

namespace ns.foo

use smithy.rules#clientContextParams
use smithy.rules#staticContextParams
use smithy.rules#contextParam
use smithy.rules#endpointRuleSet

@clientContextParams(
    stringParam: {type: "string", documentation: "a client string parameter"},
    booleanParam: {type: "boolean", documentation: "a client boolean parameter"}
)
service ExampleService {
    version: "2022-01-01",
    operations: [GetThing]
}

apply ExampleService @endpointRuleSet({
    version: "1.0",
    serviceId: "example",
    parameters: {
        stringParam: {type: "string"},
        booleanParam: {type: "boolean"}
    },
    rules: []
})

@readonly
@staticContextParams(
    stringParam: {value: "some value"},
    booleanParam: {value: true}
)
operation GetThing {
    input: GetThingInput
}

@input
structure GetThingInput {
    fizz: String,

    @contextParam(name: "stringParam")
    buzz: String,
}

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mtdowling
Copy link
Member

I’m tempted to make this part of Smithy core rather than something AWS-specific. Seems simple enough so far, but I guess the decision hinges on the associated endpoint rules configuration and whether they can be generic enough too.

@rcoh
Copy link
Contributor

rcoh commented Jun 8, 2022

My recommendation would be to have this be in Smithy core—this would influence code generation of endpoint parameter structures / configuration wiring.

For the rules, I'd put them in something like smithy.experimental.endpoints—I think it's too early to move them into core.

You might imagine that a customer uses the endpoint parameters but than hand-writes a simple endpoint resolver instead of relying on rules.

@skmcgrail skmcgrail changed the title AWS Endpoint Traits AWS Experimental Context Traits Jun 28, 2022
@skmcgrail
Copy link
Contributor Author

skmcgrail commented Jun 28, 2022

Updated this PR with the latest trait designs & feedback. This should be good for another review pass now.

@skmcgrail skmcgrail marked this pull request as ready for review June 28, 2022 16:43
@skmcgrail skmcgrail requested a review from a team as a code owner June 28, 2022 16:43
@skmcgrail skmcgrail force-pushed the endpoints branch 2 times, most recently from 2682d96 to ecd22e8 Compare June 30, 2022 16:40
@skmcgrail
Copy link
Contributor Author

Implemented all feedback, except for the final documentation pieces within the model.

@skmcgrail skmcgrail requested a review from kstich July 15, 2022 01:07
@skmcgrail skmcgrail changed the title AWS Experimental Context Traits Rule-Engine: Experimental Context Traits Jul 15, 2022
@skmcgrail
Copy link
Contributor Author

Rebased commits on top of 1.22.0.

@skmcgrail skmcgrail requested a review from mtdowling August 5, 2022 01:49
@skmcgrail
Copy link
Contributor Author

Good for follow-up review.

@skmcgrail skmcgrail force-pushed the endpoints branch 2 times, most recently from 9687058 to 0d4a5e0 Compare August 12, 2022 01:32
@skmcgrail skmcgrail requested a review from mtdowling August 12, 2022 01:32
@skmcgrail skmcgrail requested a review from kstich August 18, 2022 04:38
@skmcgrail skmcgrail force-pushed the endpoints branch 3 times, most recently from 4fb02d3 to e90daed Compare August 18, 2022 17:11
@kstich kstich merged commit 1c68ab0 into smithy-lang:main Aug 18, 2022
@skmcgrail skmcgrail deleted the endpoints branch August 22, 2022 23:33
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.

4 participants