2019-01-24 16:26:36 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-13 08:27:42 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2019-01-15 13:03:24 +00:00
|
|
|
package console
|
2018-11-13 08:27:42 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/skyrings/skyring-common/tools/uuid"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Projects exposes methods to manage Project table in database.
|
|
|
|
type Projects interface {
|
|
|
|
// GetAll is a method for querying all projects from the database.
|
|
|
|
GetAll(ctx context.Context) ([]Project, error)
|
2018-12-06 15:19:47 +00:00
|
|
|
// GetByUserID is a method for querying all projects from the database by userID.
|
|
|
|
GetByUserID(ctx context.Context, userID uuid.UUID) ([]Project, error)
|
2018-11-13 08:27:42 +00:00
|
|
|
// Get is a method for querying project from the database by id.
|
|
|
|
Get(ctx context.Context, id uuid.UUID) (*Project, error)
|
|
|
|
// Insert is a method for inserting project into the database.
|
2018-11-14 12:45:49 +00:00
|
|
|
Insert(ctx context.Context, project *Project) (*Project, error)
|
2018-11-13 08:27:42 +00:00
|
|
|
// Delete is a method for deleting project by Id from the database.
|
|
|
|
Delete(ctx context.Context, id uuid.UUID) error
|
|
|
|
// Update is a method for updating project entity.
|
2018-11-14 12:45:49 +00:00
|
|
|
Update(ctx context.Context, project *Project) error
|
2018-11-13 08:27:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Project is a database object that describes Project entity
|
|
|
|
type Project struct {
|
2018-11-26 10:47:23 +00:00
|
|
|
ID uuid.UUID `json:"id"`
|
2018-11-13 08:27:42 +00:00
|
|
|
|
2018-11-26 10:47:23 +00:00
|
|
|
Name string `json:"name"`
|
|
|
|
Description string `json:"description"`
|
2018-11-13 08:27:42 +00:00
|
|
|
|
2018-11-26 10:47:23 +00:00
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// ProjectInfo holds data needed to create/update Project
|
|
|
|
type ProjectInfo struct {
|
|
|
|
Name string `json:"name"`
|
|
|
|
Description string `json:"description"`
|
2018-11-28 16:20:23 +00:00
|
|
|
|
|
|
|
CreatedAt time.Time `json:"createdAt"`
|
2018-11-13 08:27:42 +00:00
|
|
|
}
|