2019-01-24 16:26:36 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-12-26 14:00:53 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-01-15 13:03:24 +00:00
|
|
|
package console
|
2018-12-26 14:00:53 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/skyrings/skyring-common/tools/uuid"
|
|
|
|
)
|
|
|
|
|
2018-12-27 15:30:15 +00:00
|
|
|
// APIKeys is interface for working with api keys store
|
2018-12-26 14:00:53 +00:00
|
|
|
type APIKeys interface {
|
|
|
|
// GetByProjectID retrieves list of APIKeys for given projectID
|
2018-12-27 15:30:15 +00:00
|
|
|
GetByProjectID(ctx context.Context, projectID uuid.UUID) ([]APIKeyInfo, error)
|
|
|
|
// Get retrieves APIKeyInfo with given ID
|
|
|
|
Get(ctx context.Context, id uuid.UUID) (*APIKeyInfo, error)
|
2019-05-24 17:51:27 +01:00
|
|
|
// GetByHead retrieves APIKeyInfo for given key head
|
|
|
|
GetByHead(ctx context.Context, head []byte) (*APIKeyInfo, error)
|
2018-12-27 15:30:15 +00:00
|
|
|
// Create creates and stores new APIKeyInfo
|
2019-05-24 17:51:27 +01:00
|
|
|
Create(ctx context.Context, head []byte, info APIKeyInfo) (*APIKeyInfo, error)
|
2018-12-27 15:30:15 +00:00
|
|
|
// Update updates APIKeyInfo in store
|
|
|
|
Update(ctx context.Context, key APIKeyInfo) error
|
|
|
|
// Delete deletes APIKeyInfo from store
|
2018-12-26 14:00:53 +00:00
|
|
|
Delete(ctx context.Context, id uuid.UUID) error
|
|
|
|
}
|
|
|
|
|
2018-12-27 15:30:15 +00:00
|
|
|
// APIKeyInfo describing api key model in the database
|
|
|
|
type APIKeyInfo struct {
|
2019-05-24 17:51:27 +01:00
|
|
|
ID uuid.UUID `json:"id"`
|
2018-12-26 14:00:53 +00:00
|
|
|
ProjectID uuid.UUID `json:"projectId"`
|
2019-07-12 18:59:19 +01:00
|
|
|
PartnerID uuid.UUID `json:"partnerId"`
|
2019-05-24 17:51:27 +01:00
|
|
|
Name string `json:"name"`
|
|
|
|
Secret []byte `json:"-"`
|
2018-12-26 14:00:53 +00:00
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
}
|