{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Create Event Destination",
  "description": "Add a destination that receives the organization's audit log events that match its filter.",
  "type": "object",
  "required": ["name", "adapter", "config", "filter"],
  "properties": {
    "name": {
      "type": "string",
      "title": "Name",
      "description": "Name of the destination, unique in the organization.",
      "minLength": 1,
      "examples": ["Production deployments"]
    },
    "adapter": {
      "type": "string",
      "x-gql-type": "event_destination_adapter",
      "title": "Adapter",
      "description": "How Massdriver sends events. `eventDestinationAdapters` lists each adapter and the settings it takes.",
      "enum": ["HTTP"]
    },
    "config": {
      "type": "object",
      "x-gql-type": "map",
      "title": "Configuration",
      "description": "Where and how events are sent, in the shape of the adapter's `configSchema` from `eventDestinationAdapters`. The API returns it, so put credentials in `auth`.",
      "examples": [{ "url": "https://hooks.example.com/massdriver", "headers": { "X-Team": "platform" } }]
    },
    "auth": {
      "type": "object",
      "x-gql-type": "map",
      "title": "Credentials",
      "description": "Credentials used to send events, in the shape of the adapter's `authSchema` from `eventDestinationAdapters`. The API never returns them.",
      "examples": [{ "headers": { "Authorization": "Bearer token" } }]
    },
    "filter": {
      "type": "object",
      "x-gql-type": "event_filter_input",
      "title": "Filter",
      "description": "The events the destination receives. An empty filter matches all of the organization's events."
    },
    "condition": {
      "type": "string",
      "title": "Condition",
      "description": "A jq expression run on each CloudEvent that the filter matches. The event is sent only when it outputs `true`. Use it for checks the filter cannot express, such as comparisons, `or`, or values inside `data`. It must finish within the install's timeout (1 second by default) and cannot use `import`, `include`, `module`, `modulemeta`, or `get_search_list`.",
      "examples": [".data.attributes[\"md-environment\"] == \"prod\" or .data.attributes[\"md-environment\"] == \"staging\""]
    }
  }
}
