Argument Annotations

Replace URI Path Variables

class uplink.Path(name=None, type=None)

Substitution of a path variable in a URI template.

URI template parameters are enclosed in braces (e.g., {name}). To map an argument to a declared URI parameter, use the Path annotation:

class TodoService(object):
    @get("todos{/id}")
    def get_todo(self, todo_id: Path("id")): pass

Then, invoking get_todo with a consumer instance:

todo_service.get_todo(100)

creates an HTTP request with a URL ending in todos/100.

Note

When building the consumer instance, uplink.build() will try match unannotated function arguments with URL path parameters. See Implicit Path Annotations for details.

For example, we could rewrite the method from the previous example as:

@get("todos{/id}")
def get_todo(self, id): pass

Append a URL Query Parameter

class uplink.Query(name=None, type=None)
class uplink.QueryMap(type=None)

Set HTTP Header Field

class uplink.Header(name=None, type=None)
class uplink.HeaderMap(type=None)

Add URL-Encoded Form Field

class uplink.Field(name=None, type=None)
class uplink.FieldMap(type=None)

Submit Form Data Part

class uplink.Part(name=None, type=None)
class uplink.PartMap(type=None)

Control the Request Body

class uplink.Body(type=None)

Assign a Url at Runtime

class uplink.Url