Documentation ¶
Overview ¶
Package namespace provides database implementations for the Namespace entity and its related entities.
Index ¶
- Variables
- func CollaboratorModel(cc []*Collaborator) func(int) database.Model
- func CollaboratorSelect(col string, opts ...query.Option) query.Query
- func InitEvent(dis event.Dispatcher) queue.InitFunc
- func InitInviteEvent(db *sqlx.DB, dis event.Dispatcher) queue.InitFunc
- func InviteModel(ii []*Invite) func(int) database.Model
- func LoadInviteRelations(loaders *database.Loaders, ii ...*Invite) error
- func Model(nn []*Namespace) func(int) database.Model
- func SelectRootID(id int64) query.Query
- func SharedWith(u *user.User) query.Option
- func WebhookURL(url *url.URL) hookURL
- func WhereCollaborator(m database.Model) query.Option
- type Collaborator
- func (c *Collaborator) Bind(mm ...database.Model)
- func (c *Collaborator) Endpoint(uri ...string) string
- func (c *Collaborator) IsZero() bool
- func (c *Collaborator) JSON(addr string) map[string]interface{}
- func (c *Collaborator) Primary() (string, int64)
- func (c *Collaborator) SetPrimary(id int64)
- func (c *Collaborator) Values() map[string]interface{}
- type CollaboratorStore
- func (s *CollaboratorStore) All(opts ...query.Option) ([]*Collaborator, error)
- func (s *CollaboratorStore) Bind(mm ...database.Model)
- func (s *CollaboratorStore) Create(cc ...*Collaborator) error
- func (s *CollaboratorStore) Delete(username string, chowns ...func(int64, int64) error) error
- func (s *CollaboratorStore) Get(opts ...query.Option) (*Collaborator, error)
- func (s *CollaboratorStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s *CollaboratorStore) New() *Collaborator
- type Event
- type Form
- type Invite
- func (i *Invite) Bind(mm ...database.Model)
- func (i *Invite) Endpoint(_ ...string) string
- func (i *Invite) IsZero() bool
- func (i *Invite) JSON(addr string) map[string]interface{}
- func (i *Invite) Primary() (string, int64)
- func (i *Invite) SetPrimary(id int64)
- func (i *Invite) Values() map[string]interface{}
- type InviteEvent
- type InviteForm
- type InviteStore
- func (s *InviteStore) Accept(id int64) (*Namespace, *user.User, *user.User, error)
- func (s *InviteStore) All(opts ...query.Option) ([]*Invite, error)
- func (s *InviteStore) Bind(mm ...database.Model)
- func (s *InviteStore) Create(inviterId, inviteeId int64) (*Invite, error)
- func (s *InviteStore) Delete(ii ...*Invite) error
- func (s *InviteStore) Get(opts ...query.Option) (*Invite, error)
- func (s *InviteStore) New() *Invite
- type Namespace
- func (n *Namespace) AccessibleBy(m database.Model) bool
- func (n *Namespace) Bind(mm ...database.Model)
- func (n *Namespace) CanAdd(m database.Model) bool
- func (n *Namespace) Endpoint(uri ...string) string
- func (n *Namespace) IsZero() bool
- func (n *Namespace) JSON(addr string) map[string]interface{}
- func (n *Namespace) LoadCollaborators(cc []*Collaborator)
- func (n *Namespace) Primary() (string, int64)
- func (n *Namespace) SetPrimary(id int64)
- func (n *Namespace) Values() map[string]interface{}
- type Resource
- type Store
- func (s *Store) All(opts ...query.Option) ([]*Namespace, error)
- func (s *Store) Bind(mm ...database.Model)
- func (s *Store) Create(parent, name, description string, visibility Visibility) (*Namespace, error)
- func (s *Store) Delete(ids ...int64) error
- func (s *Store) Get(opts ...query.Option) (*Namespace, error)
- func (s *Store) GetByPath(path string) (*Namespace, error)
- func (s *Store) Index(vals url.Values, opts ...query.Option) ([]*Namespace, database.Paginator, error)
- func (s *Store) Load(key string, vals []interface{}, load database.LoaderFunc) error
- func (s *Store) New() *Namespace
- func (s Store) Paginate(page int64, opts ...query.Option) (database.Paginator, error)
- func (s *Store) Update(id int64, description string, visibility Visibility) error
- type Visibility
- type Webhook
- func (w *Webhook) Bind(mm ...database.Model)
- func (w *Webhook) Endpoint(uri ...string) string
- func (w *Webhook) IsZero() bool
- func (w *Webhook) JSON(addr string) map[string]interface{}
- func (w *Webhook) Primary() (string, int64)
- func (w *Webhook) SetPrimary(id int64)
- func (w *Webhook) Values() map[string]interface{}
- type WebhookDelivery
- type WebhookForm
- type WebhookStore
- func (s *WebhookStore) All(opts ...query.Option) ([]*Webhook, error)
- func (s *WebhookStore) Bind(mm ...database.Model)
- func (s *WebhookStore) Create(authorId int64, payloadUrl *url.URL, secret string, ssl bool, ...) (*Webhook, error)
- func (s *WebhookStore) Delete(id int64) error
- func (s *WebhookStore) Deliveries(id int64) ([]*WebhookDelivery, error)
- func (s *WebhookStore) Delivery(hookId, id int64) (*WebhookDelivery, error)
- func (s *WebhookStore) Dispatch(ev *event.Event) error
- func (s *WebhookStore) Get(opts ...query.Option) (*Webhook, error)
- func (s *WebhookStore) LastDelivery(id int64) (*WebhookDelivery, error)
- func (s *WebhookStore) LoadLastDeliveries(ww ...*Webhook) error
- func (s *WebhookStore) New() *Webhook
- func (s *WebhookStore) Redeliver(id int64, eventId uuid.UUID) error
- func (s *WebhookStore) Update(id int64, payloadUrl *url.URL, secret string, ssl bool, events event.Type, ...) error
Constants ¶
This section is empty.
Variables ¶
var ( MaxDepth int64 = 20 ErrOwner = errors.New("invalid namespace owner") ErrDepth = errors.New("namespace cannot exceed depth of 20") ErrName = errors.New("namespace name can only contain letters and numbers") ErrPermission = errors.New("namespace permissions invalid") ErrDeleteSelf = errors.New("cannot delete self from namespace") )
var (
ErrUnknownWebhook = errors.New("unknown webhook")
)
Functions ¶
func CollaboratorModel ¶
func CollaboratorModel(cc []*Collaborator) func(int) database.Model
CollaboratorModel is called along with database.ModelSlice to convert the given slice of Collaborator models to a slice of database.Model interfaces.
func CollaboratorSelect ¶
CollaboratorSelect returns a query that selects the given column from the namespace_collaborators table, with each given query.Option applied to the returned query.
func InitInviteEvent ¶ added in v1.1.0
func InviteModel ¶
InviteModel is called along with database.ModelSlice to convert the given slice of Invite models to a slice of database.Model interfaces.
func LoadInviteRelations ¶
LoadInviteRelations loads all of the available relations for the given Invite models using the given loaders available.
func Model ¶
Model is called along with database.ModelSlice to convert the given slice of Namespace models to a slice of database.Model interfaces.
func SelectRootID ¶
SelectRootId returns query.Query that will return the root_id of the Namespace by the given id.
func SharedWith ¶
SharedWith expects the given database.Model to be of *user.User. This will apply two WHERE clauses to the query, that will check if the given User database either owns the Namespace, or is a collaborator for the Namespace. If the given database.Model is not of *user.User, then the WHERE clauses are not applied.
func WebhookURL ¶ added in v1.1.0
func WhereCollaborator ¶
WhereCollaborator returns a query.Option that when applied to a query will check to see if the given database.Model (assuming it's of type *user.User), is either a Collaborator, or owner of a Namespace. This would typically be used on resource queries, for example if you want to get a slice of *variable.Variable models for a User.
Types ¶
type Collaborator ¶
type Collaborator struct { ID int64 `db:"id"` NamespaceID int64 `db:"namespace_id"` UserID int64 `db:"user_id"` CreatedAt time.Time `db:"created_at"` User *user.User `db:"-"` Namespace *Namespace `db:"-"` }
Collaborator is the type that represents a collaborator within a namespace.
func (*Collaborator) Bind ¶
func (c *Collaborator) Bind(mm ...database.Model)
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User, or namespace.Namespace models.
func (*Collaborator) Endpoint ¶
func (c *Collaborator) Endpoint(uri ...string) string
Endpoint implements the database.Model interface. This will return an empty string if the bound Namespace, or User models are either nil or zero.
func (*Collaborator) IsZero ¶
func (c *Collaborator) IsZero() bool
IsZero implements the database.Model interface.
func (*Collaborator) JSON ¶
func (c *Collaborator) JSON(addr string) map[string]interface{}
JSON implements the database.Model interface. If the bound User model is nil or zero then an empty map is returned, otherwise this will return the JSON representation of that bound User model, along with the url and created_at fields.
func (*Collaborator) Primary ¶
func (c *Collaborator) Primary() (string, int64)
Primary implements the database.Model interface.
func (*Collaborator) SetPrimary ¶
func (c *Collaborator) SetPrimary(id int64)
SetPrimary implements the database.Model interface.
func (*Collaborator) Values ¶
func (c *Collaborator) Values() map[string]interface{}
Values implements the database.Model interface. This will return a map with the following values, namespace_id and user_id.
type CollaboratorStore ¶
type CollaboratorStore struct { database.Store // User is the bound User model. If not nil this will bind the User model to // any Collaborator models that are created. If not nil this will be passed // to the namespace.WhereCollaborator query option on each SELECT query // performed. User *user.User // Namespace is the bound Namespace model. If not nil this will bind the // Namespace model to any Collaborator models that are created. If not nil // this will append a WHERE clause on the namespace_id column for all SELECT // queries performed. Namespace *Namespace }
CollaboratorStore is the type for creating and modifying Collaborator models in the database.
func NewCollaboratorStore ¶
func NewCollaboratorStore(db *sqlx.DB, mm ...database.Model) *CollaboratorStore
NewCollaboratorStore returns a new Store for querying the namespace_collaborators table. Each database passed to this function will be bound to the returned Store.
func (*CollaboratorStore) All ¶
func (s *CollaboratorStore) All(opts ...query.Option) ([]*Collaborator, error)
All returns a slice of Collaborator models, applying each query.Option that is given. The database.Where option is applied to the bound User database, and the bound Namespace database using the "root_id" column as the value to perform the WHERE clause on.
func (*CollaboratorStore) Bind ¶
func (s *CollaboratorStore) Bind(mm ...database.Model)
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User, or namespace.Namespace models.
func (*CollaboratorStore) Create ¶
func (s *CollaboratorStore) Create(cc ...*Collaborator) error
Create inserts the given Collaborator models into the namespace_collaborators table.
func (*CollaboratorStore) Delete ¶
Delete will remove the collaborator of the given username from the database. The given chown functions will be invoked to change ownership of any resources that user may have created within the namespace to the owner of the namespace. This requires a bound Namespace to execute successfully.
func (*CollaboratorStore) Get ¶
func (s *CollaboratorStore) Get(opts ...query.Option) (*Collaborator, error)
Get returns a single Collaborator database, applying each query.Option that is given. The database.Where option is applied to the bound User database, and the bound Namespace database using the "root_id" column as the value to perform the WHERE clause on.
func (*CollaboratorStore) Load ¶
func (s *CollaboratorStore) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Collaborator models where the given key is in the list of given vals. Each database is loaded individually via a call to the given load callback. This method calls CollaboratorStore.All under the hood, so any bound models will impact the models being loaded.
func (*CollaboratorStore) New ¶
func (s *CollaboratorStore) New() *Collaborator
New returns a new Collaborator binding any non-nil models to it from the current CollaboratorStore.
type Form ¶
type Form struct { Namespaces *Store `schema:"-" json:"-"` Namespace *Namespace `schema:"-" json:"-"` Parent string `schema:"parent" json:"parent"` Name string `schema:"name" json:"name"` Description string `schema:"description" json:"description"` Visibility Visibility `schema:"visibility" json:"visibility"` }
Form is the type that represents input data for creating a new Namespace.
func (Form) Validate ¶
Validate checks to see if the Namespace Name is present, between 3 and 32 characters in length, contains only letters and numbers, and is unique to the current Namespace. This uniqueness check is skipped if a Namespace is set, and the Name field already matches that name (assuming it's being edited). The description field is checked to see if it is less than 255 characters in length, if present.
type Invite ¶
type Invite struct { ID int64 `db:"id"` NamespaceID int64 `db:"namespace_id"` InviteeID int64 `db:"invitee_id"` InviterID int64 `db:"inviter_id"` CreatedAt time.Time `db:"created_at"` Inviter *user.User `db:"-"` Invitee *user.User `db:"-"` Namespace *Namespace `db:"-"` }
Invite is the type that represents an invite sent to a user for a namespace.
func InviteFromContext ¶
InviteFromContext returns the Invite model from the given context, if any.
func (*Invite) Bind ¶
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User, or namespace.Namespace models. The ID of the User model is checked agains the InviterID, and InviteeID of the current invite to determine if the User model should be bound as an Inviter or Invitee.
func (*Invite) Endpoint ¶
Endpoint returns the endpoint for the current Invite. This does not append any of the given URIs.
func (*Invite) JSON ¶
JSON implements the database.Model interface. If the bound User model is present as either invitee, or inviter then the JSON representation of this model will be under the invitee, or inviter keys respectively. If the Namespace bound model is present then the JSON representation of that model will be under the namespace key.
func (*Invite) SetPrimary ¶
SetPrimary implements the database.Model interface.
type InviteEvent ¶ added in v1.1.0
type InviteEvent struct { Action string Namespace *Namespace Invitee *user.User Inviter *user.User // contains filtered or unexported fields }
func (*InviteEvent) Name ¶ added in v1.1.0
func (ev *InviteEvent) Name() string
func (*InviteEvent) Perform ¶ added in v1.1.0
func (ev *InviteEvent) Perform() error
type InviteForm ¶
type InviteForm struct { Namespaces *Store `schema:"-"` Collaborators *CollaboratorStore `schema:"-"` Invites *InviteStore `schema:"-"` Users *user.Store `schema:"-"` // Inviter is the original User who sent the invite. Inviter *user.User `schema:"-"` // Invitee is the User who received the invite. Invitee *user.User `schema:"-"` Owner string `schema:"-" json:"-"` Handle string `schema:"handle" json:"handle"` }
InviteForm is the type that represents input data for sending an Invite.
func (*InviteForm) Fields ¶
func (f *InviteForm) Fields() map[string]string
Fields returns a map of just the Handle field from the current InviteForm.
func (*InviteForm) Validate ¶
func (f *InviteForm) Validate() error
Validate checks to see if the current InviteForm has the handle of the User being invited available, if the User being invited is not the current User, and if that User actually exists, and is not already in the Namespace. If all of these checks pass, then the User being invited is set as the Invitee field on the InviteForm.
type InviteStore ¶
type InviteStore struct { database.Store // User is the bound User model. If not nil this will bind the User model to // any Invite models that are created. If not nil this will be passed to the // namespace.WhereCollaborator query option on each SELECT query performed. User *user.User // Namespace is the bound Namespace model. If not nil this will bind the // Namespace model to any Invite models that are created. If not nil this // will append a WHERE clause on the namespace_id column for all SELECT // queries performed. Namespace *Namespace }
InviteStore is the type for creating and mofiying Invite models in the database.
func NewInviteStore ¶
func NewInviteStore(db *sqlx.DB, mm ...database.Model) *InviteStore
NewInviteStore returns a new Store for querying the namespace_invites table. Each database passed to this function will be bound to the returned Store.
func (*InviteStore) Accept ¶
Accept will delete the invite of the given ID, and create a new collaborator for the invited user. The namespace that the invite was for will be returned upon success.
func (*InviteStore) All ¶
func (s *InviteStore) All(opts ...query.Option) ([]*Invite, error)
All returns a slice of Invite models, applying each query.Option that is given. The database.Where option is applied to the bound User database, and the bound Namespace database.
func (*InviteStore) Bind ¶
func (s *InviteStore) Bind(mm ...database.Model)
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User, or namespace.Namespace models.
func (*InviteStore) Create ¶
func (s *InviteStore) Create(inviterId, inviteeId int64) (*Invite, error)
Create will send an invite to the user specified via inviteeId. It is expected for the inviterId to match the user ID of the namespace's owner. The newly create invite will be returned.
func (*InviteStore) Delete ¶
func (s *InviteStore) Delete(ii ...*Invite) error
Update updates the given Invite models in the namespace_invites table.
func (*InviteStore) Get ¶
func (s *InviteStore) Get(opts ...query.Option) (*Invite, error)
Get returns a single Invite database, applying each query.Option that is given. The database.Where option is applied to the bound User database, and the bound Namespace database.
func (*InviteStore) New ¶
func (s *InviteStore) New() *Invite
New returns a new Invite binding any non-nil models to it from the current Invite.
type Namespace ¶
type Namespace struct { ID int64 `db:"id"` UserID int64 `db:"user_id"` RootID sql.NullInt64 `db:"root_id"` ParentID sql.NullInt64 `db:"parent_id"` Name string `db:"name"` Path string `db:"path"` Description string `db:"description"` Level int64 `db:"level"` Visibility Visibility `db:"visibility"` CreatedAt time.Time `db:"created_at"` User *user.User `db:"-"` Parent *Namespace `db:"-"` Build database.Model `db:"-"` Collaborators map[int64]struct{} `db:"-"` }
Namespace is the type that represents a namespace in the system for grouping related resources together.
func FromContext ¶
FromContext returns the Namespace model from the given context, if any.
func (*Namespace) AccessibleBy ¶
AccessibleBy assumes that the given database.Model is of type *user.User, and checks that the given database.Model has access to the current Namespace, depending on the Namespace's visibility. If the Namespace visibility is Public, then this method will return true. If the Namespace visibility is Private, then it will return true if the given database.Model is not zero. If the visibility is Private, then it will check to see if the primary key of the database.Model exists in the Namespace collaborators (this assumes the collaborators have been previously loaded into the Namespace). If the given database.Model is not of type *user.User then this method returns false.
func (*Namespace) Bind ¶
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User, or namespace.Namespace models.
func (*Namespace) CanAdd ¶
CanAdd assumes that the given database.Model is of type *user.User, and checks to see if that User either owns the Namespace, or is a Collaborator in that Namespace. This assumes that the collaborators have been previously loaded into the Namespace.
func (*Namespace) Endpoint ¶
Endpoint returns the endpoint for the current Namespace, appending the given variadic URIs. The Namespace endpoint will contain the username of the bound User database. If there is no bound User database, or the database IsZero, then an empty string is returned.
func (*Namespace) JSON ¶
JSON implements the database.Model interface. This will return a map with the current Namespace values under each key. This will also include urls to the Namespace's builds, namespaces, images, objects, variables, keys, and collaborators. I any of the User, Parent, or Build models exist on the Namespace then the JSON representation of these models will be in the returned map, under the user, parent, and build keys respectively.
func (*Namespace) LoadCollaborators ¶
func (n *Namespace) LoadCollaborators(cc []*Collaborator)
LoadCollaborators takes the given slice of Collaborator models and adds them to the Collaborators map on the current Namespace, if the Namespace ID for the Collaborator matches the current Namespace ID.
func (*Namespace) SetPrimary ¶
SetPrimary implements the database.Model interface.
type Resource ¶
type Resource struct { Owner *user.User `schema:"-"` // Owner is who the resource belongs to once authored Author *user.User `schema:"-"` // Author is the original author of the resource Namespaces *Store `schema:"-"` Namespace string `schema:"namespace"` }
Resource is the type that represents a model that can exist within a Namespace, such as an object, image, variable, or key.
type Store ¶
type Store struct { database.Store // User is the bound User model. If not nil this will bind the User model to // any Namespace models that are created. User *user.User // Namespace is the bound Namespace model. If not nil this will bind the // Namespace model to any Build models that are created. If not nil this // will append a WHERE clause on the parent_id column for all SELECT // queries performed. Namespace *Namespace }
Store is the type for creating and modifying Namespace models in the database.
func NewStore ¶
NewStore returns a new Store for querying the namespaces table. Each database passed to this function will be bound to the returned Store.
func (*Store) All ¶
All returns a slice of Namespace models, applying each query.Option that is given. The SharedWith option is applied to the bound User database, and the database.Where option to the bound Namespace database on the "parent_id".
func (*Store) Bind ¶
Bind implements the database.Binder interface. This will only bind the model if they are pointers to either user.User, or namespace.Namespace models.
func (*Store) Create ¶
func (s *Store) Create(parent, name, description string, visibility Visibility) (*Namespace, error)
Create creates a new namespace under the given parent, with the given name, description, and visibility. The parent and description variables can be empty.
func (*Store) Get ¶
Get returns a single Namespace database, applying each query.Option that is given. The SharedWith option is applied to the bound User database, and the database.Where option to the bound Namespace database on the "parent_id".
func (*Store) GetByPath ¶
GetByPath returns a Namespace by the given path. If it does not exist then it will be created, including all grandparents up to the maximum possible depth for a Namespace. If any invalid names for a Namespace appear in the path, then the child Namespaces will not be created beyong that point. If a '@' is present in the given path, then the Namespace for that given user will be returned if it exists, if not then nothing will be returned and a Namespace will not be created.
func (*Store) Index ¶
func (s *Store) Index(vals url.Values, opts ...query.Option) ([]*Namespace, database.Paginator, error)
Index returns the paginated results from the namespaces table depending on the values that are present in url.Values. Detailed below are the values that are used from the given url.Values,
path - This applies the database.Search query.Option using the value os path
func (*Store) Load ¶
func (s *Store) Load(key string, vals []interface{}, load database.LoaderFunc) error
Load loads in a slice of Namespace models where the given key is in the list of given vals. Each model is loaded individually via a call to the given load callback. This method calls Store.All under the hood, so any bound models will impact the models being loaded.
func (*Store) New ¶
New returns a new Namespace binding any non-nil models to it from the current Store.
type Visibility ¶
type Visibility uint8
Visibility represents the visibility level of a Namespace, there are three possible values it could be,
Private - only the owner and collaborators can view the Namespace and its
contents
Internal - only authenticated users can view the Namespace and its contents Public - anyone can view the Namespace and its contents, authenticated or
not
const ( Private Visibility = iota // private Internal // internal Public // public )
func (*Visibility) Scan ¶
func (v *Visibility) Scan(val interface{}) error
Scan scans the given interface value into a byte slice and will attempt to turn it into the correct Visibility value. If it succeeds then it set's it on the current Visibility, otherwise an error is returned.
func (Visibility) String ¶
func (i Visibility) String() string
func (*Visibility) UnmarshalJSON ¶
func (v *Visibility) UnmarshalJSON(b []byte) error
UnmarshalJSON takes the given byte slice, and attempts to unmarshal it to a string from its JSON representation. This is then mapped to a known Visibility. This will return webutil.UnmarshalError if any error occurs.
func (*Visibility) UnmarshalText ¶
func (v *Visibility) UnmarshalText(b []byte) error
UnmarshalText takes the given byte slice, and attempts to map it to a known Visibility. If it is a known Visibility, then that the current Visibility is set to that, otherwise webutil.UnmarshalError is returned.
type Webhook ¶ added in v1.1.0
type Webhook struct { ID int64 `db:"id"` UserID int64 `db:"user_id"` AuthorID int64 `db:"author_id"` NamespaceID int64 `db:"namespace_id"` PayloadURL hookURL `db:"payload_url"` Secret []byte `db:"secret"` SSL bool `db:"ssl"` Events event.Type `db:"events"` Active bool `db:"active"` CreatedAt time.Time `db:"created_at"` User *user.User `db:"-"` Namespace *Namespace `db:"-"` LastDelivery *WebhookDelivery `db:"-"` }
func WebhookFromContext ¶ added in v1.1.0
func (*Webhook) SetPrimary ¶ added in v1.1.0
type WebhookDelivery ¶ added in v1.1.0
type WebhookDelivery struct { ID int64 `db:"id"` WebhookID int64 `db:"webhook_id"` EventID uuid.UUID `db:"event_id"` NamespaceID sql.NullInt64 `db:"-"` Error sql.NullString `db:"error"` Event event.Type `db:"event"` Redelivery bool `db:"redelivery"` RequestHeaders sql.NullString `db:"request_headers"` RequestBody sql.NullString `db:"request_body"` ResponseCode sql.NullInt64 `db:"response_code"` ResponseStatus string `db:"-"` ResponseHeaders sql.NullString `db:"response_headers"` ResponseBody sql.NullString `db:"response_body"` Payload map[string]interface{} `db:"-"` Duration time.Duration `db:"duration"` CreatedAt time.Time `db:"created_at"` Webhook *Webhook `db:"-"` }
func (*WebhookDelivery) Endpoint ¶ added in v1.1.0
func (e *WebhookDelivery) Endpoint(_ ...string) string
type WebhookForm ¶ added in v1.1.0
type WebhookForm struct { Webhooks *WebhookStore `schema:"-" json:"-"` Webhook *Webhook `schema:"-" json:"-"` PayloadURL string `schema:"payload_url" json:"payload_url"` Secret string `schema:"secret" json:"secret"` RemoveSecret bool `schema:"remove_secret" json:"remove_secret"` SSL bool `schema:"ssl" json:"ssl"` Active bool `schema:"active" json:"active"` Events []string `schema:"events[]" json:"events"` }
func (WebhookForm) Fields ¶ added in v1.1.0
func (f WebhookForm) Fields() map[string]string
func (WebhookForm) Validate ¶ added in v1.1.0
func (f WebhookForm) Validate() error
type WebhookStore ¶ added in v1.1.0
type WebhookStore struct { database.Store User *user.User Namespace *Namespace // contains filtered or unexported fields }
func NewWebhookStore ¶ added in v1.1.0
func NewWebhookStore(db *sqlx.DB, mm ...database.Model) *WebhookStore
func NewWebhookStoreWithCrypto ¶ added in v1.1.0
func (*WebhookStore) All ¶ added in v1.1.0
func (s *WebhookStore) All(opts ...query.Option) ([]*Webhook, error)
func (*WebhookStore) Bind ¶ added in v1.1.0
func (s *WebhookStore) Bind(mm ...database.Model)
func (*WebhookStore) Delete ¶ added in v1.1.0
func (s *WebhookStore) Delete(id int64) error
func (*WebhookStore) Deliveries ¶ added in v1.1.0
func (s *WebhookStore) Deliveries(id int64) ([]*WebhookDelivery, error)
func (*WebhookStore) Delivery ¶ added in v1.1.0
func (s *WebhookStore) Delivery(hookId, id int64) (*WebhookDelivery, error)
func (*WebhookStore) Dispatch ¶ added in v1.1.0
func (s *WebhookStore) Dispatch(ev *event.Event) error
func (*WebhookStore) Get ¶ added in v1.1.0
func (s *WebhookStore) Get(opts ...query.Option) (*Webhook, error)
func (*WebhookStore) LastDelivery ¶ added in v1.1.0
func (s *WebhookStore) LastDelivery(id int64) (*WebhookDelivery, error)
func (*WebhookStore) LoadLastDeliveries ¶ added in v1.1.0
func (s *WebhookStore) LoadLastDeliveries(ww ...*Webhook) error
func (*WebhookStore) New ¶ added in v1.1.0
func (s *WebhookStore) New() *Webhook