How to describe an operation authorization in AWS Smithy

22 Views Asked by At

From what I see in some Smithy examples (1, 2, 3) engineers tend to describe operations and input structures without any mentions of who or what performs them.

For example, if I have the following Smithy definition:

@auth([httpBearerAuth])
@http(method: "PUT", uri: "/api/v1/tasks/{id}", code: 200)
operation PutTask {
    input: PutTaskInput
    output: Unit
}

structure PutTaskInput {
    @httpLabel
    @required
    id: TaskId

    @httpPayload
    @required
    body: TaskBody
}

I'll get a generated code something like (imaginary Python HTTP Service codegen):

class TasksService(HttpEndpoint):
    def put_task(id, body):
        raise NotImplementedError("PutTask operation is not implemented")

My question now is how to idiomatically state that code needs to look something like following:

class TasksService(HttpEndpoint):
    # I need to know who the author is
    # Depending on that I can either refuse the creation (authorize) or create the task in some specific way
    def put_task(author, id, body):
        raise NotImplementedError("PutTask operation is not implemented")
0

There are 0 best solutions below