First iteration of selfpass gRPC backend, w/ credentials CRUD functional

This commit is contained in:
mitchell 2019-04-14 20:56:55 -07:00
commit 719a462048
15 changed files with 1610 additions and 0 deletions

View file

@ -0,0 +1,36 @@
package types
import "time"
// Credential TODO
type Credential struct {
Metadata
Username string
Email string
Password string
}
// CredentialInput TODO
type CredentialInput struct {
MetadataInput
Username string
Email string
Password string
}
// Metadata TODO
type Metadata struct {
ID string
CreatedAt time.Time
UpdatedAt time.Time
Primary string
SourceHost string
LoginURL string
}
// MetadataInput TODO
type MetadataInput struct {
Primary string
SourceHost string
LoginURL string
}

View file

@ -0,0 +1,8 @@
package types
// These constants are the prefixes of errors that should be exposed to the client.
// All error encoders should check for them.
const (
NotFound = "not found:"
InvalidArgument = "invalid argument:"
)

View file

@ -0,0 +1,20 @@
package types
import "context"
// Service TODO
type Service interface {
GetAllMetadata(ctx context.Context, sourceService string) (output <-chan Metadata, errch chan error)
Get(ctx context.Context, id string) (output Credential, err error)
Create(ctx context.Context, ci CredentialInput) (output Credential, err error)
Update(ctx context.Context, id string, ci CredentialInput) (output Credential, err error)
Delete(ctx context.Context, id string) (err error)
}
// CredentialRepo TODO
type CredentialRepo interface {
GetAllMetadata(ctx context.Context, sourceService string, errch chan<- error) (output <-chan Metadata)
Get(ctx context.Context, id string) (output Credential, err error)
Put(ctx context.Context, c Credential) (err error)
Delete(ctx context.Context, id string) (err error)
}