-
Notifications
You must be signed in to change notification settings - Fork 32
/
apitypes.go
119 lines (100 loc) · 3.09 KB
/
apitypes.go
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Package apitypes defines types shared between the daemon and its api client.
package apitypes
import (
"strings"
"github.com/arigatomachine/cli/identity"
"github.com/arigatomachine/cli/primitive"
)
// ErrorType represents the string error types that the daemon and registry can
// return.
type ErrorType string
// These are the possible error types.
const (
BadRequestError = "bad_request"
UnauthorizedError = "unauthorized"
NotFoundError = "not_found"
InternalServerError = "internal_server"
NotImplementedError = "not_implemented"
)
// Error represents standard formatted API errors from the daemon or registry.
type Error struct {
StatusCode int
Type string `json:"type"`
Err []string `json:"error"`
}
// Error implements the error interface for formatted API errors.
func (e *Error) Error() string {
return e.Type + ": " + strings.Join(e.Err, " ")
}
// Version contains the release version of the daemon.
type Version struct {
Version string `json:"version"`
}
// SessionStatus contains details about the user's daemon session.
type SessionStatus struct {
Token bool `json:"token"`
Passphrase bool `json:"passphrase"`
}
// Login contains the required details for logging in to the api and daemon.
type Login struct {
Email string `json:"email"`
Passphrase string `json:"passphrase"`
}
// Profile contains the fields in the response for the profiles endpoint
type Profile struct {
ID *identity.ID `json:"id"`
Body *struct {
Name string `json:"name"`
Username string `json:"username"`
} `json:"body"`
}
// Signup contains information required for registering an account
type Signup struct {
Name string
Username string
Email string
Passphrase string
InviteCode string
OrgName string
OrgInvite bool
}
// OrgInvite contains information for sending an Org invite
type OrgInvite struct {
ID string `json:"id"`
Version int `json:"version"`
Body *primitive.OrgInvite `json:"body"`
}
// Team contains information for creating a new Team object
type Team struct {
ID *identity.ID `json:"id"`
Version int `json:"version"`
Body *primitive.Team `json:"body"`
}
// Service contains information for creating a new Service object
type Service struct {
ID *identity.ID `json:"id"`
Version int `json:"version"`
Body *primitive.Service `json:"body"`
}
// Environment contains information for creating a new Env object
type Environment struct {
ID string `json:"id"`
Version int `json:"version"`
Body *primitive.Environment `json:"body"`
}
// InviteAccept contains data required to accept org invite
type InviteAccept struct {
Org string `json:"org"`
Email string `json:"email"`
Code string `json:"code"`
}
// Membership contains data required to be added to a team
type Membership struct {
ID *identity.ID `json:"id"`
Version int `json:"version"`
Body *primitive.Membership `json:"body"`
}
// VerifyEmail contains email verification code
type VerifyEmail struct {
Code string `json:"code"`
}