WardrikProtocol (wardrik_protocol v0.1.0-rc.1)
Copy MarkdownWardrik's wire format: events as CloudEvents, and operations as OpenAPI.
schema = JSV.build!(WardrikProtocol.schema("run.started"))
{:ok, _data} = JSV.validate(event["data"], schema)
%{method: "post", path: "/v1/agents/{agent}/messages"} = WardrikProtocol.operation("agent.ask")
Summary
Types
An operation from openapi.json.
Functions
Returns the dataschema for an event type.
Returns the directory of the schema files.
Returns true if events of the type are sent as they happen and never stored.
Returns the OpenAPI document, with every $ref to another schema file inlined.
Returns the operation with ID id, like agent.ask, or nil.
Lists every operation, ordered by path.
Returns the schema name with every $ref inlined.
Lists every event type, like wardrik.run.started.
Types
@type operation() :: %{ id: String.t(), summary: String.t(), description: String.t() | nil, method: String.t(), path: String.t(), action: String.t(), effect: String.t(), subject: String.t(), parameters: [%{name: String.t(), in: String.t()}], input: map(), status: pos_integer(), output: map() | nil, stream: boolean() }
An operation from openapi.json.
:id- itsoperationId, as"agent.ask".:summaryand:description- what it does.:methodand:path- its HTTP route.:action- what the caller must be allowed to do.:effect-"read","change"or"destructive".:subject- what it acts on:"agent","agents","deployment","owner"(an org's or person's accounts and servers),"hook"(a request that proves itself with a secret, not a caller) or"channel"(a chat app's request, which its channel verifies).:parameters- which input fields go in the HTTP path or query.:input- one schema for its parameters and body together.:status- the HTTP status it returns on success.:output- its output schema, ornil.:stream-trueif it can stream events.
Functions
Returns the dataschema for an event type.
WardrikProtocol.dataschema("wardrik.run.started")
#=> "urn:wardrik:schema:v1:run.started"Raises FunctionClauseError for an unknown type.
@spec dir() :: Path.t()
Returns the directory of the schema files.
Returns true if events of the type are sent as they happen and never stored.
@spec openapi() :: map()
Returns the OpenAPI document, with every $ref to another schema file inlined.
Returns the operation with ID id, like agent.ask, or nil.
@spec operations() :: [operation()]
Lists every operation, ordered by path.
Returns the schema name with every $ref inlined.
name is a file name in dir/0 without .json, like run.started, cloudevent or defs.
@spec types() :: [String.t()]
Lists every event type, like wardrik.run.started.