Documentation
¶
Overview ¶
Package service orchestrates components between handlers and other packages (datastore, gateway, domain, etc.)
Index ¶
- func NewCreateAppAPIKeyParams(a app.App, k app.APIKey, adt audit.Audit) appstore.CreateAppAPIKeyParams
- func NewCreateAppParams(a app.App, adt audit.Audit) appstore.CreateAppParams
- func NewCreateOrgParams(o org.Org) orgstore.CreateOrgParams
- type APIKeyResponse
- type AppResponse
- type AuthorizeService
- type Authorizer
- type CreateAppRequest
- type CreateAppService
- type CreateOrgRequest
- type CreateOrgService
- type CryptoRandomGenerator
- type DBTX
- type Datastorer
- type FindAppService
- type FindOrgService
- type FindUserParams
- type FindUserService
- type GoogleOauth2TokenConverter
- type LoggerRequest
- type LoggerResponse
- type LoggerService
- type OrgResponse
- type PingResponse
- type PingService
- type Pinger
- type SeedRequest
- type SeedResponse
- type SeedService
- type UpdateOrgRequest
- type UpdateOrgService
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCreateAppAPIKeyParams ¶ added in v0.39.0
func NewCreateAppAPIKeyParams(a app.App, k app.APIKey, adt audit.Audit) appstore.CreateAppAPIKeyParams
NewCreateAppAPIKeyParams maps an AppAPIKey to appstore.CreateAppAPIKeyParams
func NewCreateAppParams ¶ added in v0.39.0
NewCreateAppParams maps an App to appstore.CreateAppParams
func NewCreateOrgParams ¶ added in v0.39.0
func NewCreateOrgParams(o org.Org) orgstore.CreateOrgParams
NewCreateOrgParams maps an Org to orgstore.CreateOrgParams
Types ¶
type APIKeyResponse ¶ added in v0.39.0
type APIKeyResponse struct {
Key string `json:"key"`
DeactivationDate string `json:"deactivation_date"`
}
APIKeyResponse is the response fields for an API key
type AppResponse ¶ added in v0.39.0
type AppResponse struct {
ExternalID string `json:"external_id"`
Name string `json:"name"`
Description string `json:"description"`
APIKeys []APIKeyResponse `json:"api_keys"`
}
AppResponse is the response struct for an App
type AuthorizeService ¶ added in v0.39.0
type AuthorizeService struct {
Authorizer Authorizer
}
type Authorizer ¶ added in v0.39.0
type CreateAppRequest ¶ added in v0.39.0
CreateAppRequest is the request struct for Creating an App
type CreateAppService ¶ added in v0.39.0
type CreateAppService struct {
Datastorer Datastorer
CryptoRandomGenerator CryptoRandomGenerator
EncryptionKey *[32]byte
}
CreateAppService is a service for creating an App
func (CreateAppService) Create ¶ added in v0.39.0
func (cas CreateAppService) Create(ctx context.Context, r *CreateAppRequest, adt audit.Audit) (AppResponse, error)
Create is used to create an App
type CreateOrgRequest ¶ added in v0.39.0
CreateOrgRequest is the request struct for Creating a Movie
type CreateOrgService ¶ added in v0.39.0
type CreateOrgService struct {
Datastorer Datastorer
}
CreateOrgService is a service for creating an Org
func (CreateOrgService) Create ¶ added in v0.39.0
func (cos CreateOrgService) Create(ctx context.Context, r *CreateOrgRequest, adt audit.Audit) (OrgResponse, error)
Create is used to create an Org
type CryptoRandomGenerator ¶ added in v0.39.0
type CryptoRandomGenerator interface {
RandomBytes(n int) ([]byte, error)
RandomString(n int) (string, error)
}
CryptoRandomGenerator is the interface that generates random data
type DBTX ¶ added in v0.39.0
type DBTX interface {
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
QueryRow(context.Context, string, ...interface{}) pgx.Row
}
DBTX interface mirrors the interface generated by sqlc to allow passing a Pool or a Tx
type Datastorer ¶ added in v0.39.0
type Datastorer interface {
// Pool returns *pgxpool.Pool
Pool() *pgxpool.Pool
// BeginTx starts a pgx.Tx using the input context
BeginTx(ctx context.Context) (pgx.Tx, error)
// RollbackTx rolls back the input pgx.Tx
RollbackTx(ctx context.Context, tx pgx.Tx, err error) error
// CommitTx commits the Tx
CommitTx(ctx context.Context, tx pgx.Tx) error
}
Datastorer is an interface for working with the Database
type FindAppService ¶ added in v0.39.0
type FindAppService struct {
Datastorer Datastorer
EncryptionKey *[32]byte
}
FindAppService is a service for retrieving an App from the datastore
func (FindAppService) FindAppByAPIKey ¶ added in v0.39.0
func (fas FindAppService) FindAppByAPIKey(ctx context.Context, realm, appExtlID, apiKey string) (app.App, error)
FindAppByAPIKey finds an app given its External ID and determines if the given API key is a valid key for it. It is used as part of app authentication
type FindOrgService ¶ added in v0.39.0
type FindOrgService struct {
Datastorer Datastorer
}
FindOrgService interface reads Orgs form the datastore
func (FindOrgService) FindAll ¶ added in v0.39.0
func (fos FindOrgService) FindAll(ctx context.Context) ([]OrgResponse, error)
FindAll is used to list all orgs in the datastore
func (FindOrgService) FindByExternalID ¶ added in v0.39.0
func (fos FindOrgService) FindByExternalID(ctx context.Context, extlID string) (OrgResponse, error)
FindByExternalID is used to find an Org by its External ID
type FindUserParams ¶ added in v0.39.0
FindUserParams is the parameters for the FindUser function
type FindUserService ¶ added in v0.39.0
type FindUserService struct {
GoogleOauth2TokenConverter GoogleOauth2TokenConverter
Datastorer Datastorer
}
FindUserService retrieves a User from the Database
func (FindUserService) FindUserByOauth2Token ¶ added in v0.39.0
func (fus FindUserService) FindUserByOauth2Token(ctx context.Context, params FindUserParams) (user.User, error)
FindUserByOauth2Token retrieves a users' identity from a Provider and then retrieves the associated registered user from the datastore
type GoogleOauth2TokenConverter ¶ added in v0.39.0
type GoogleOauth2TokenConverter interface {
Convert(ctx context.Context, realm string, token oauth2.Token) (authgateway.Userinfo, error)
}
GoogleOauth2TokenConverter converts an oauth2.Token to an authgateway.Userinfo struct
type LoggerRequest ¶
type LoggerRequest struct {
GlobalLogLevel string `json:"global_log_level"`
LogErrorStack string `json:"log_error_stack"`
}
LoggerRequest is the request struct for the app logger
type LoggerResponse ¶
type LoggerResponse struct {
LoggerMinimumLevel string `json:"logger_minimum_level"`
GlobalLogLevel string `json:"global_log_level"`
LogErrorStack bool `json:"log_error_stack"`
}
LoggerResponse is the response struct for the current state of the app logger
type LoggerService ¶
LoggerService reads and updates the logger state
func (LoggerService) Read ¶
func (ls LoggerService) Read() LoggerResponse
ReadLogger handles GET requests for the /logger endpoint
func (LoggerService) Update ¶
func (ls LoggerService) Update(r *LoggerRequest) (LoggerResponse, error)
Update handles PUT requests for the /logger endpoint and updates the logger globals
type OrgResponse ¶ added in v0.39.0
type OrgResponse struct {
ExternalID string `json:"external_id"`
Name string `json:"name"`
Description string `json:"description"`
CreateAudit auditResponse `json:"create_audit"`
UpdateAudit auditResponse `json:"update_audit"`
}
OrgResponse is the response struct for a Movie
type PingResponse ¶
type PingResponse struct {
DBUp bool `json:"db_up"`
}
PingResponse is the response struct for the PingService
type PingService ¶
type PingService struct {
Pinger Pinger
}
PingService pings the database.
func (PingService) Ping ¶
func (p PingService) Ping(ctx context.Context, logger zerolog.Logger) PingResponse
Ping method pings the database
type SeedRequest ¶ added in v0.39.0
type SeedRequest struct {
OrgName string `json:"org_name"`
OrgDescription string `json:"org_description"`
AppName string `json:"app_name"`
AppDescription string `json:"app_description"`
SeedUsername string `json:"seed_username"`
SeedUserFirstName string `json:"seed_user_first_name"`
SeedUserLastName string `json:"seed_user_last_name"`
}
SeedRequest is the request struct for seeding the database
type SeedResponse ¶ added in v0.39.0
type SeedResponse struct {
OrgResponse OrgResponse `json:"org"`
AppResponse AppResponse `json:"app"`
}
SeedResponse is the response struct for seeding the database
type SeedService ¶ added in v0.39.0
type SeedService struct {
Datastorer Datastorer
CryptoRandomGenerator CryptoRandomGenerator
EncryptionKey *[32]byte
}
SeedService seeds the database. It is run only once on initial database setup.
func (SeedService) Seed ¶ added in v0.39.0
func (sr SeedService) Seed(ctx context.Context, r *SeedRequest) (SeedResponse, error)
Seed method seeds the database
type UpdateOrgRequest ¶ added in v0.39.0
type UpdateOrgRequest struct {
ExternalID string
Name string `json:"name"`
Description string `json:"description"`
}
UpdateOrgRequest is the request struct for Updating an Org
type UpdateOrgService ¶ added in v0.39.0
type UpdateOrgService struct {
Datastorer Datastorer
}
UpdateOrgService is a service for updating an Org
func (UpdateOrgService) Update ¶ added in v0.39.0
func (cos UpdateOrgService) Update(ctx context.Context, r *UpdateOrgRequest, adt audit.Audit) (OrgResponse, error)
Update is used to update an Org