API token -> API key rename

This commit is contained in:
Torkel Ödegaard
2015-01-27 08:26:11 +01:00
parent db371d2a5d
commit 951ce0a102
10 changed files with 201 additions and 195 deletions

65
pkg/models/apikey.go Normal file
View File

@ -0,0 +1,65 @@
package models
import (
"errors"
"time"
)
var ErrInvalidApiKey = errors.New("Invalid API Key")
type ApiKey struct {
Id int64
AccountId int64
Name string
Key string
Role RoleType
Created time.Time
Updated time.Time
}
// ---------------------
// COMMANDS
type AddApiKeyCommand struct {
Name string `json:"name" binding:"required"`
Role RoleType `json:"role" binding:"required"`
AccountId int64 `json:"-"`
Key string `json:"-"`
Result *ApiKey `json:"-"`
}
type UpdateApiKeyCommand struct {
Id int64 `json:"id"`
Name string `json:"name"`
Role RoleType `json:"role"`
AccountId int64 `json:"-"`
}
type DeleteApiKeyCommand struct {
Id int64 `json:"id"`
AccountId int64 `json:"-"`
}
// ----------------------
// QUERIES
type GetApiKeysQuery struct {
AccountId int64
Result []*ApiKey
}
type GetApiKeyByKeyQuery struct {
Key string
Result *ApiKey
}
// ------------------------
// DTO & Projections
type ApiKeyDTO struct {
Id int64 `json:"id"`
Name string `json:"name"`
Key string `json:"key"`
Role RoleType `json:"role"`
}