server

package
v1.4.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2025 License: Unlicense Imports: 15 Imported by: 0

Documentation

Index

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

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

func NewDatabase(hostname string, port int, defaultDatabase string) *Database

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) Client

func (database *Database) Client() *mongo.Client

Client - Return a pointer to the underlying mongo.Client structure

func (*Database) Connect

func (database *Database) Connect() error

Connect to the MongoDB instance defined in the Database object

func (*Database) Database

func (database *Database) Database() *mongo.Database

Database - Return a pointer to the underlying mongo.Database structure

func (*Database) Delete

func (database *Database) Delete(collection string, query bson.M) (*mongo.DeleteResult, bool)

Delete a single document from the MongoDB instance

func (*Database) Disconnect

func (database *Database) Disconnect() error

Disconnect Gracefully disconnect from your active MongoDB connection

func (*Database) Exists added in v1.4.8

func (database *Database) Exists(collection string, query bson.M) (bool, error)

Exists - Runs a light weight FindOne query on a collection and returns true or false if the document exists.

func (*Database) Find

func (database *Database) Find(collection string, query bson.M, model interface{}) bool

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

func (database *Database) Index(collection string, limit int64, model interface{}) bool

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

func (database *Database) SetSCRAMAuthentication(username string, password string)

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

func NewLogger(path string) *Log

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

func (*Log) CloseFile added in v1.4.0

func (log *Log) CloseFile() error

CloseFile - Close the open log file, if it has been set

func (*Log) Logger added in v1.4.1

func (log *Log) Logger() *slog.Logger

Logger - Returns a pointer to the slog.Logger object stored in Log

func (*Log) Path added in v1.4.0

func (log *Log) Path() string

Path - Return the path that the Log is currently saving files to

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

func FromConfig() (*Server, error)

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

func (server *Server) Database() *Database

Database - Returns a pointer to the currently used Database object for the server

func (*Server) Log added in v1.4.0

func (server *Server) Log() *Log

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL