// Package api holds the JSON contract between mailqueuer, the daemon and // counterctl, plus the request validators (the "fields" step of the HTTP // validation layer). package api // OutRequest is the body of POST /out: one recipient of an authenticated // submission. type OutRequest struct { TraceID string `json:"trace_id"` // mizu's X-Trace-Id; log correlation only AuthUser string `json:"auth_user"` // SMTP AUTH user (mizu's X-Auth-User) MailFrom string `json:"mail_from"` // envelope sender, optional Recipient string `json:"recipient"` } // InRequest is the body of POST /in: one recipient of an inbound message. type InRequest struct { TraceID string `json:"trace_id"` MailFrom string `json:"mail_from"` // "" for a bounce sender <> Recipient string `json:"recipient"` Junk bool `json:"junk"` // mizu's X-Junk: yes } // CountResponse answers /in and /out with 202: the request was validated and // queued; counting happens off the request path. The counted values appear in // the counting log and in GET /counters. type CountResponse struct { Accepted bool `json:"accepted"` } // ErrorResponse is the body of every non-2xx answer. type ErrorResponse struct { Error string `json:"error"` } // CountersLevel is one row of GET /counters. type CountersLevel struct { Level string `json:"level"` ID string `json:"id"` In int64 `json:"in"` InLimit *int64 `json:"in_limit"` // null when unlimited or unmanaged Out int64 `json:"out"` OutLimit *int64 `json:"out_limit"` } // CountersResponse answers GET /counters?address=|domain=[&date=]. type CountersResponse struct { Query string `json:"query"` Mode string `json:"mode"` // address | domain Date string `json:"date"` // UTC day Managed bool `json:"managed"` Exempt bool `json:"exempt"` Domain string `json:"domain,omitempty"` OrgID *int64 `json:"org_id,omitempty"` Levels []CountersLevel `json:"levels"` }