Documentation
¶
Index ¶
- type AuthenticationManager
- func (auth *AuthenticationManager) AuthAPI() *authentication.Authentication
- func (auth *AuthenticationManager) AuthenticateUser(username string, password string) (*oauth.TokenSet, error)
- func (auth *AuthenticationManager) DeactivateUser(auth0Id string) error
- func (auth *AuthenticationManager) GetEmailFromToken(token string) (string, error)
- func (auth *AuthenticationManager) ManagementAPI() *management.Management
- func (auth *AuthenticationManager) RegisterUser(username string, email string, password string) (*database.SignupResponse, error)
- func (auth *AuthenticationManager) ResetUserPassword(email string) error
- func (auth *AuthenticationManager) SetScope(scope string)
- type Database
- func (database *Database) AppendField(collection string, query bson.M, fields bson.M) (*mongo.UpdateResult, bool)
- func (database *Database) Client() *mongo.Client
- func (database *Database) Connect() error
- func (database *Database) Database() *mongo.Database
- func (database *Database) Delete(collection string, query bson.M) (*mongo.DeleteResult, bool)
- func (database *Database) Disconnect() error
- func (database *Database) Exists(collection string, query bson.M) (bool, error)
- func (database *Database) Find(collection string, query bson.M, model interface{}) bool
- func (database *Database) FindMultiple(collection string, key string, value []string, model interface{}) bool
- func (database *Database) IncrementField(collection string, query bson.M, fields bson.M) (*mongo.UpdateResult, bool)
- func (database *Database) Index(collection string, limit int64, model interface{}) bool
- func (database *Database) Insert(collection string, model interface{}) (*mongo.InsertOneResult, bool)
- func (database *Database) PullField(collection string, query bson.M, fields bson.M) (*mongo.UpdateResult, bool)
- func (database *Database) Replace(collection string, query bson.M, model interface{}) (*mongo.UpdateResult, bool)
- func (database *Database) SetField(collection string, query bson.M, fields bson.M) (*mongo.UpdateResult, bool)
- func (database *Database) SetSCRAMAuthentication(username string, password string)
- type Log
- type Server
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthenticationManager ¶ added in v1.4.0
type AuthenticationManager struct {
// contains filtered or unexported fields
}
func NewAuthenticationManager ¶ added in v1.4.0
func NewAuthenticationManager(domain string, audience string, clientId string, clientSecret string) (*AuthenticationManager, error)
NewAuthenticationManager - Instantiates a new AuthenticationManager structure
func NewAuthenticationManagerFromConfig ¶ added in v1.4.0
func NewAuthenticationManagerFromConfig() (*AuthenticationManager, error)
NewAuthenticationManagerFromConfig - Instantiates a new AuthenticationManager using values provided in viper
func (*AuthenticationManager) AuthAPI ¶ added in v1.4.1
func (auth *AuthenticationManager) AuthAPI() *authentication.Authentication
AuthAPI - Returns a pointer to the Auth0 Authentication API struct
func (*AuthenticationManager) AuthenticateUser ¶ added in v1.4.0
func (auth *AuthenticationManager) AuthenticateUser(username string, password string) (*oauth.TokenSet, error)
AuthenticateUser - Fetch a token on the users behalf using there credentials
func (*AuthenticationManager) DeactivateUser ¶ added in v1.4.0
func (auth *AuthenticationManager) DeactivateUser(auth0Id string) error
DeactivateUser - Delete a user from Auth0. This does not remove the user from mtgjson-api, only Auth0
func (*AuthenticationManager) GetEmailFromToken ¶ added in v1.4.0
func (auth *AuthenticationManager) GetEmailFromToken(token string) (string, error)
GetEmailFromToken - Calls the /userinfo OIDC endpoint and return the users email address
func (*AuthenticationManager) ManagementAPI ¶ added in v1.4.1
func (auth *AuthenticationManager) ManagementAPI() *management.Management
ManagementAPI - Returns a pointer to the Auth0 Management API struct
func (*AuthenticationManager) RegisterUser ¶ added in v1.4.0
func (auth *AuthenticationManager) RegisterUser(username string, email string, password string) (*database.SignupResponse, error)
RegisterUser - Register a user with Auth0. This does not create a mtgjson-api user, only a user within MTGJSON. You should configure an Auth0 auth flow for automatically assigning users a role
func (*AuthenticationManager) ResetUserPassword ¶ added in v1.4.0
func (auth *AuthenticationManager) ResetUserPassword(email string) error
ResetUserPassword - Trigger a reset password email to be sent to the users account
func (*AuthenticationManager) SetScope ¶ added in v1.4.0
func (auth *AuthenticationManager) SetScope(scope string)
SetScope - Set the scopes that the API should recognize
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
Database An abstraction of an active mongodb database connection. The same connection is re-used across all SDK operations to ensure that we don't exceed the connection pool limit
func NewDatabase ¶ added in v1.3.2
NewDatabase - Instantiate a new database object. Does not connect automatically, this needs to be done with Database.Connect()
func NewDatabaseFromConfig ¶ added in v1.4.0
func NewDatabaseFromConfig() *Database
NewDatabaseFromConfig - Instantiate a new database from viper config values
func (*Database) AppendField ¶ added in v1.3.0
func (database *Database) AppendField(collection string, query bson.M, fields bson.M) (*mongo.UpdateResult, bool)
AppendField Append an item to a field in a single document in the Mongo Database
func (*Database) Disconnect ¶
Disconnect Gracefully disconnect from your active MongoDB connection
func (*Database) Exists ¶ added in v1.4.8
Exists - Runs a light weight FindOne query on a collection and returns true or false if the document exists.
func (*Database) Find ¶
Find a single document from the MongoDB instance and unmarshal it into the interface passed in the 'model' parameter
func (*Database) FindMultiple ¶ added in v1.1.8
func (database *Database) FindMultiple(collection string, key string, value []string, model interface{}) bool
FindMultiple - Find multiple documents from within a collection
func (*Database) IncrementField ¶ added in v1.3.0
func (database *Database) IncrementField(collection string, query bson.M, fields bson.M) (*mongo.UpdateResult, bool)
IncrementField Increment a single field in a document
func (*Database) Index ¶
Index Return all documents in a collection and unmarshal them into the interface passed in the 'model' parameter
func (*Database) Insert ¶
func (database *Database) Insert(collection string, model interface{}) (*mongo.InsertOneResult, bool)
Insert the interface represented in the 'model' parameter into the MongoDB instance
func (*Database) PullField ¶ added in v1.3.0
func (database *Database) PullField(collection string, query bson.M, fields bson.M) (*mongo.UpdateResult, bool)
PullField Remove all instances of an object from an array in a single document
func (*Database) Replace ¶
func (database *Database) Replace(collection string, query bson.M, model interface{}) (*mongo.UpdateResult, bool)
Replace a single document from the MongoDB instance and unmarshal it into the interface passed in the 'model' parameter
func (*Database) SetField ¶ added in v1.3.0
func (database *Database) SetField(collection string, query bson.M, fields bson.M) (*mongo.UpdateResult, bool)
SetField Update a single field in a requested document in the Mongo Database
func (*Database) SetSCRAMAuthentication ¶ added in v1.4.0
SetSCRAMAuthentication - Set the credentials for the database if they are needed
type Log ¶ added in v1.4.0
type Log struct {
// contains filtered or unexported fields
}
Log - An abstraction of the slog logger used for the SDK
func NewLogger ¶ added in v1.4.0
NewLogger - Instantiate a new logger object. The 'path' parameter should be the UNIX path of where you want logs saved to
func NewLoggerFromConfig ¶ added in v1.4.0
func NewLoggerFromConfig() *Log
NewLoggerFromConfig - Instantiate a new logger using flags from viper
type Server ¶ added in v1.4.0
type Server struct {
// contains filtered or unexported fields
}
Server - An abstraction of the Server running the MTGJSON-API. Includes any components necessary for functionality such as the Database, Logging, etc.
func FromConfig ¶ added in v1.4.0
FromConfig - Initializes a new server object using config values from viper
func New ¶ added in v1.4.0
func New(database *Database, log *Log, authenticationManager *AuthenticationManager) *Server
New - Basic constructor for the Server structure
func (*Server) AuthenticationManager ¶ added in v1.4.0
func (server *Server) AuthenticationManager() *AuthenticationManager
AuthenticationManager - Returns a pointer to the AuthenticationManager for the server
func (*Server) Database ¶ added in v1.4.0
Database - Returns a pointer to the currently used Database object for the server
func (*Server) Log ¶ added in v1.4.0
Log - Returns a pointer to the currently used Log object for the server
func (*Server) SetAuthManager ¶ added in v1.4.0
func (server *Server) SetAuthManager(auth *AuthenticationManager)
SetAuthManager - Set the auth manager for the Server