Documentation ¶
Overview ¶
Package profile contains profile related CRUD functionality.
Index ¶
- Variables
- type Info
- type NewProfile
- type Profile
- func (p Profile) Create(ctx context.Context, traceID string, claims auth.Claims, np NewProfile, ...) (Info, error)
- func (p Profile) Delete(ctx context.Context, traceID string, name string) error
- func (p Profile) Query(ctx context.Context, traceID string, pageNumber int, rowsPerPage int) ([]Info, error)
- func (p Profile) QueryByName(ctx context.Context, traceID string, name string) (Info, error)
- func (p Profile) QueryUserProfile(ctx context.Context, traceID string, userID string) (Info, error)
- func (p Profile) Update(ctx context.Context, traceID string, claims auth.Claims, name string, ...) error
- type Type
- type UpdateProfile
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is used when a specific Profile is requested but does not exist. ErrNotFound = errors.New("not found") // ErrInvalidID occurs when an ID is not in a valid form. ErrInvalidID = errors.New("ID is not in its proper form") // ErrForbidden occurs when a user tries to do something that is forbidden to them according to our access control policies. ErrForbidden = errors.New("attempted action is not allowed") )
Functions ¶
This section is empty.
Types ¶
type Info ¶
type Info struct { Name string `db:"name" json:"name"` // Unique profile name Type Type `db:"type" json:"type"` // Profile type DisplayName string `db:"display_name" json:"display_name"` // Display name of the profile. UserID string `db:"user_id" json:"user_id"` // ID of the user who created the profile. DateCreated time.Time `db:"date_created" json:"date_created"` // When the profile was added. DateUpdated time.Time `db:"date_updated" json:"date_updated"` // When the profile record was last modified. }
Info represents an individual profile.
type NewProfile ¶
type NewProfile struct { Name string `json:"name" validate:"required"` Type string `json:"type" validate:"required"` DisplayName string `json:"display_name" validate:"required"` }
NewProfile is what we require from clients when adding a Profile.
type Profile ¶
type Profile struct {
// contains filtered or unexported fields
}
Profile manages the set of API's for profile access.
func (Profile) Create ¶
func (p Profile) Create(ctx context.Context, traceID string, claims auth.Claims, np NewProfile, now time.Time) (Info, error)
Create adds a Profile to the database. It returns the created Profile with fields like ID and DateCreated populated.
func (Profile) Query ¶
func (p Profile) Query(ctx context.Context, traceID string, pageNumber int, rowsPerPage int) ([]Info, error)
Query gets all Profiles from the database.
func (Profile) QueryByName ¶
QueryByName finds the profile identified by a given name.
func (Profile) QueryUserProfile ¶
QueryUserProfile finds the profile identified by a given user ID.
type Type ¶
type Type string
Type represents a particular type of profile.
func TypeFromString ¶
TypeFromString returns a pointer to type from the provided string or an error when an invalid type string is provided.
type UpdateProfile ¶
UpdateProfile defines what information may be provided to modify an existing Profile. All fields are optional so clients can send just the fields they want changed. It uses pointer fields so we can differentiate between a field that was not provided and a field that was provided as explicitly blank. Normally we do not want to use pointers to basic types but we make exceptions around marshalling/unmarshalling.