...
 
Commits (5)
  • Andreas Mieke's avatar
    Adding GET endpoints for crashes, reports and symfiles · 0afd8895
    Andreas Mieke authored
    Filtering is possible with filter_field=fieldname and filter_value=value
    It is also possible to AND-combine multiple filters by setting the query-parameters
    multiple times.
    
    Ordering is possible with order_field=fieldname and order_direction=desc (the default
    ordering direction is asc so there is no parameter needed). If direction is something other
    than `desc` it will also be ordered ascending.
    
    Pagination is possible with limit=numer and offset=number. If nothing is specified limit
    will be 50 and offset 0.
    0afd8895
  • Andreas Mieke's avatar
    Adapted API · 0eb210da
    Andreas Mieke authored
    Filtering now works with <field>=<value> syntax. Ordering is possible with o_<field>,
    o_<field>= (which will order ASCending) or o_<field>=desc which will order in DESCending
    mode.
    0eb210da
  • Andreas Mieke's avatar
    Added all GET endpoints · 62e834ff
    Andreas Mieke authored
    62e834ff
  • Andreas Mieke's avatar
    Adding/Changing post/put/delete endpoints · a4d759bc
    Andreas Mieke authored
    a4d759bc
  • Andreas Mieke's avatar
    Adding API · 47473205
    Andreas Mieke authored
    Fixes #35
    47473205
......@@ -14,10 +14,10 @@ import (
// Product defines the structure of a product
type Product struct {
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
CreatedAt time.Time `json:",omitempty"`
UpdatedAt time.Time `json:",omitempty"`
DeletedAt *time.Time `json:",omitempty"`
Name string
Slug string
......@@ -28,20 +28,20 @@ var Products []Product
// Version defines the structure of a product
type Version struct {
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
CreatedAt time.Time `json:",omitempty"`
UpdatedAt time.Time `json:",omitempty"`
DeletedAt *time.Time `json:",omitempty"`
Name string
Slug string
GitRepo string
Ignore bool
ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
Product Product
ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
Product Product `json:"-"`
Crashes []*Crash `gorm:"many2many:crash_versions;"`
Crashes []*Crash `gorm:"many2many:crash_versions;" json:"-"`
}
// Versions contains all currently available versions and is used for the switcher in the header
......@@ -49,69 +49,69 @@ var Versions []Version
// User defines the structure of a user
type User struct {
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
CreatedAt time.Time `json:",omitempty"`
UpdatedAt time.Time `json:",omitempty"`
DeletedAt *time.Time `json:",omitempty"`
Name string
IsAdmin bool
Comments []Comment
Comments []Comment `json:"-"`
}
// Comment defines the structure of a comment
type Comment struct {
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
CreatedAt time.Time `json:",omitempty"`
UpdatedAt time.Time `json:",omitempty"`
DeletedAt *time.Time `json:",omitempty"`
CrashID uuid.UUID `sql:"type:uuid DEFAULT NULL"`
ReportID uuid.UUID `sql:"type:uuid DEFAULT NULL"`
CrashID uuid.UUID `sql:"type:uuid DEFAULT NULL" json:",omitempty"`
ReportID uuid.UUID `sql:"type:uuid DEFAULT NULL" json:",omitempty"`
UserID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
User User
UserID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
User User `json:"-"`
Content template.HTML
}
// Crash database model
type Crash struct {
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
CreatedAt time.Time `json:",omitempty"`
UpdatedAt time.Time `json:",omitempty"`
DeletedAt *time.Time `json:",omitempty"`
Signature string
Module string
AllCrashCount uint `gorm:"-"`
WinCrashCount uint `gorm:"-"`
MacCrashCount uint `gorm:"-"`
AllCrashCount uint `gorm:"-" json:",omitempty"`
WinCrashCount uint `gorm:"-" json:",omitempty"`
MacCrashCount uint `gorm:"-" json:",omitempty"`
Reports []Report
Comments []Comment
Reports []Report `json:",omitempty"`
Comments []Comment `json:",omitempty"`
FirstReported time.Time
LastReported time.Time
ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
Product Product
ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
Product Product `json:"-"`
Versions []*Version `gorm:"many2many:crash_versions;"`
Versions []*Version `gorm:"many2many:crash_versions;" json:",omitempty"`
Fixed *time.Time `sql:"DEFAULT NULL"`
}
// Report database model
type Report struct {
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
CreatedAt time.Time `json:",omitempty"`
UpdatedAt time.Time `json:",omitempty"`
DeletedAt *time.Time `json:",omitempty"`
CrashID uuid.UUID `sql:"type:uuid DEFAULT NULL"`
Crash Crash
CrashID uuid.UUID `sql:"type:uuid DEFAULT NULL" json:",omitempty"`
Crash Crash `json:"-"`
ProcessUptime int
EMail string
......@@ -127,26 +127,26 @@ type Report struct {
CrashPath string
CrashLine int
Comments []Comment
Comments []Comment `json:"-"`
ReportContentJSON string `sql:"type:JSONB NOT NULL DEFAULT '{}'::JSONB" json:"-"`
Report ReportContent `gorm:"-"`
Report ReportContent `gorm:"-" json:",omitempty"`
ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
Product Product
ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
Product Product `json:"-"`
VersionID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
Version Version
VersionID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
Version Version `json:"-"`
ProcessingTime float64
}
// Symfile database model
type Symfile struct {
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt *time.Time
ID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
CreatedAt time.Time `json:",omitempty"`
UpdatedAt time.Time `json:",omitempty"`
DeletedAt *time.Time `json:",omitempty"`
Os string
......@@ -154,11 +154,11 @@ type Symfile struct {
Code string `gorm:"unique;index"`
Name string
ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
Product Product
ProductID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
Product Product `json:"-"`
VersionID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL"`
Version Version
VersionID uuid.UUID `sql:"type:uuid NOT NULL DEFAULT NULL" json:",omitempty"`
Version Version `json:"-"`
}
// ReportContent of a crashreport
......
This diff is collapsed.
......@@ -59,31 +59,36 @@ func initRouter() *gin.Engine {
// Admin JSON endpoints
apiv1 := auth.Group("/api/v1")
apiv1.GET("/products", APIGetProducts)
apiv1.GET("/products/:id", APIGetProduct)
apiv1.POST("/products", APINewProduct)
apiv1.PUT("/products/:id", APIUpdateProduct)
apiv1.DELETE("/products/:id", APIDeleteProduct)
apiv1.GET("/versions", APIGetVersions)
apiv1.GET("/versions/:id", APIGetVersion)
apiv1.POST("/versions", APINewVersion)
apiv1.PUT("/versions/:id", APIUpdateVersion)
apiv1.DELETE("/versions/:id", APIDeleteVersion)
apiv1.GET("/users", APIGetUsers)
apiv1.GET("/users/:id", APIGetUser)
apiv1.POST("/users", APINewUser)
apiv1.PUT("/users/:id", APIUpdateUser)
apiv1.DELETE("/users/:id", APIDeleteUser)
apiv1.GET("/stats", GetIndex)
apiv1.GET("/crashes", GetCrashes)
apiv1.GET("/crashes/:id", GetCrash)
apiv1.GET("/reports", GetReports)
apiv1.GET("/reports/:id", GetReport)
apiv1.GET("/symfiles", GetSymfiles)
apiv1.GET("/symfiles/:id", GetSymfile)
apiv1.GET("/crashes", APIv1GetCrashes)
apiv1.GET("/crashes/:id", APIv1GetCrash)
apiv1.GET("/reports", APIv1GetReports)
apiv1.GET("/reports/:id", APIv1GetReport)
apiv1.GET("/symfiles", APIv1GetSymfiles)
apiv1.GET("/symfiles/:id", APIv1GetSymfile)
apiv1.GET("/products", APIv1GetProducts)
apiv1.GET("/products/:id", APIv1GetProduct)
apiv1.POST("/products", APIv1NewProduct)
apiv1.PUT("/products/:id", APIv1UpdateProduct)
apiv1.DELETE("/products/:id", APIv1DeleteProduct)
apiv1.GET("/versions", APIv1GetVersions)
apiv1.GET("/versions/:id", APIv1GetVersion)
apiv1.POST("/versions", APIv1NewVersion)
apiv1.PUT("/versions/:id", APIv1UpdateVersion)
apiv1.DELETE("/versions/:id", APIv1DeleteVersion)
apiv1.GET("/users", APIv1GetUsers)
apiv1.GET("/users/:id", APIv1GetUser)
apiv1.POST("/users", APIv1NewUser)
apiv1.PUT("/users/:id", APIv1UpdateUser)
apiv1.DELETE("/users/:id", APIv1DeleteUser)
apiv1.GET("/comments", APIv1GetComments)
apiv1.GET("/comments/:id", APIv1GetComment)
apiv1.POST("/comments", APIv1NewComment)
apiv1.PUT("/comments/:id", APIv1UpdateComment)
apiv1.DELETE("/comments/:id", APIv1DeleteComment)
// simple-breakpad endpoints
router.GET("/", GetIndex)
......