-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathpackage.go
More file actions
57 lines (49 loc) · 1.9 KB
/
package.go
File metadata and controls
57 lines (49 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package models
// PackageInfoRequest represents public API request to get package info
type PackageInfoRequest struct {
Component ComponentType `json:"component" validate:"required,valid"`
Version string `json:"version" validate:"required,semver"`
OS OSType `json:"os" validate:"required,valid"`
Arch ArchType `json:"arch" validate:"required,valid"`
}
func (p PackageInfoRequest) Valid() error {
return validate.Struct(p)
}
func (p PackageInfoRequest) Query() map[string]string {
return map[string]string{
"component": p.Component.String(),
"version": p.Version,
"os": p.OS.String(),
"arch": p.Arch.String(),
}
}
// PackageInfoResponse represents response for package info
type PackageInfoResponse struct {
Size int64 `json:"size" validate:"required,min=1"`
Hash string `json:"hash" validate:"required,len=64"`
Version string `json:"version" validate:"required,semver"`
OS OSType `json:"os" validate:"required,valid"`
Arch ArchType `json:"arch" validate:"required,valid"`
Signature SignatureValue `json:"signature,omitempty" validate:"omitempty,valid"`
}
func (p PackageInfoResponse) Valid() error {
return validate.Struct(p)
}
// DownloadPackageRequest represents public API request to download package
type DownloadPackageRequest struct {
Component ComponentType `json:"component" validate:"required,valid"`
Version string `json:"version" validate:"required,semver"`
OS OSType `json:"os" validate:"required,valid"`
Arch ArchType `json:"arch" validate:"required,valid"`
}
func (p DownloadPackageRequest) Valid() error {
return validate.Struct(p)
}
func (p DownloadPackageRequest) Query() map[string]string {
return map[string]string{
"component": p.Component.String(),
"version": p.Version,
"os": p.OS.String(),
"arch": p.Arch.String(),
}
}