Documentation
¶
Overview ¶
Package users provides primitives to interact with the openapi HTTP API.
Code generated by github.com/deepmap/oapi-codegen version v1.11.0 DO NOT EDIT.
Package users provides primitives to interact with the openapi HTTP API.
Code generated by github.com/deepmap/oapi-codegen version v1.11.0 DO NOT EDIT.
Index ¶
- Constants
- Variables
- func GetErrorF(errMsg string, err error) error
- func RegisterHandlers(router EchoRouter, si ServerInterface)
- func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)
- type EchoRouter
- type Error
- type Group
- type GroupCreateJSONBody
- type GroupCreateJSONRequestBody
- type GroupList
- type GroupListParams
- type JwtCustomClaims
- type PGX
- func (db *PGX) Close()
- func (db *PGX) Count() (int32, error)
- func (db *PGX) Create(u User) (*User, error)
- func (db *PGX) CreateGroup(g Group) (*Group, error)
- func (db *PGX) Delete(id int32) error
- func (db *PGX) DeleteGroup(id int32) error
- func (db *PGX) Exist(id int32) bool
- func (db *PGX) FindUsername(username string) (int32, error)
- func (db *PGX) Get(id int32) (*User, error)
- func (db *PGX) GetGroup(id int32) (*Group, error)
- func (db *PGX) GetMaxId() (int32, error)
- func (db *PGX) IsUserActive(idUser int32) bool
- func (db *PGX) IsUserAdmin(idUser int32) bool
- func (db *PGX) List(offset, limit int) ([]*UserList, error)
- func (db *PGX) ListGroup(offset, limit int) ([]*GroupList, error)
- func (db *PGX) ResetPassword(id int32, passwordHash string, idCurrentUser int) error
- func (db *PGX) Update(id int32, user User) (*User, error)
- func (db *PGX) UpdateGroup(id int32, group Group) (*Group, error)
- type ServerInterface
- type ServerInterfaceWrapper
- func (w *ServerInterfaceWrapper) GroupCreate(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GroupDelete(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GroupGet(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GroupList(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) GroupUpdate(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) UserChangePassword(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) UserCreate(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) UserDelete(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) UserGet(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) UserList(ctx echo.Context) error
- func (w *ServerInterfaceWrapper) UserUpdate(ctx echo.Context) error
- type Service
- func (s Service) GetLogin(ctx echo.Context) error
- func (s Service) GetMaxId(ctx echo.Context) error
- func (s Service) GetResetPasswordEmail(ctx echo.Context) error
- func (s Service) GetResetPasswordToken(ctx echo.Context) error
- func (s Service) GetStatus(ctx echo.Context) error
- func (s Service) GroupCreate(ctx echo.Context) error
- func (s Service) GroupDelete(ctx echo.Context, id int32) error
- func (s Service) GroupGet(ctx echo.Context, id int32) error
- func (s Service) GroupList(ctx echo.Context, params GroupListParams) error
- func (s Service) GroupUpdate(ctx echo.Context, id int32) error
- func (s Service) LoginUser(ctx echo.Context) error
- func (s Service) ResetPassword(ctx echo.Context) error
- func (s Service) SendResetPassword(ctx echo.Context) error
- func (s Service) UserChangePassword(ctx echo.Context, userId int32) error
- func (s Service) UserCreate(ctx echo.Context) error
- func (s Service) UserDelete(ctx echo.Context, userId int32) error
- func (s Service) UserGet(ctx echo.Context, userId int32) error
- func (s Service) UserList(ctx echo.Context, params UserListParams) error
- func (s Service) UserUpdate(ctx echo.Context, userId int32) error
- type Storage
- type User
- type UserCreateJSONBody
- type UserCreateJSONRequestBody
- type UserList
- type UserListParams
- type UserLogin
Constants ¶
const (
JWTAuthScopes = "JWTAuth.Scopes"
)
Variables ¶
var ErrUsernameNotFound = errors.New("username does not exist")
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(router EchoRouter, si ServerInterface)
RegisterHandlers adds each server route to the EchoRouter.
func RegisterHandlersWithBaseURL ¶
func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string)
Registers handlers, and prepends BaseURL to the paths, so that the paths can be served under a prefix.
Types ¶
type EchoRouter ¶
type EchoRouter interface {
CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}
This is a simple interface which specifies echo.Route addition functions which are present on both echo.Echo and echo.Group, since we want to allow using either of them for path registration
type Group ¶
type Group struct {
Comment *string `json:"comment,omitempty"`
CreateTime time.Time `json:"create_time"`
Creator int32 `json:"creator"`
Id int32 `json:"id"`
InactivationReason *string `json:"inactivation_reason,omitempty"`
InactivationTime *time.Time `json:"inactivation_time,omitempty"`
IsActive bool `json:"is_active"`
LastModificationTime *time.Time `json:"last_modification_time,omitempty"`
LastModificationUser *int32 `json:"last_modification_user,omitempty"`
Name string `json:"name"`
}
Group defines model for Group.
type GroupCreateJSONBody ¶
type GroupCreateJSONBody = Group
GroupCreateJSONBody defines parameters for GroupCreate.
type GroupCreateJSONRequestBody ¶
type GroupCreateJSONRequestBody = GroupCreateJSONBody
GroupCreateJSONRequestBody defines body for GroupCreate for application/json ContentType.
type GroupList ¶
type GroupList struct {
Id int32 `json:"id"`
IsActive bool `json:"is_active"`
Name string `json:"name"`
}
GroupList defines model for GroupList.
type GroupListParams ¶
type GroupListParams struct {
// maximum number of results to return
Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"`
}
GroupListParams defines parameters for GroupList.
type JwtCustomClaims ¶
type JwtCustomClaims struct {
jwt.RegisteredClaims
Id int32 `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
Username string `json:"username"`
IsAdmin bool `json:"is_admin"`
}
JwtCustomClaims are custom claims extending default ones.
type PGX ¶
func (*PGX) CreateGroup ¶
CreateGroup saves a new group in the storage.
func (*PGX) DeleteGroup ¶
DeleteGroup removes the group with given ID from the storage.
func (*PGX) FindUsername ¶
FindUsername retrieves the user id for the given username or err if not found.
func (*PGX) IsUserActive ¶
IsUserActive returns true if the user with the specified id has the is_active attribute set to true
func (*PGX) IsUserAdmin ¶
IsUserAdmin returns true if the user with the specified id has the is_admin attribute set to true
func (*PGX) ResetPassword ¶
ResetPassword the user password stored in DB for given id
type ServerInterface ¶
type ServerInterface interface {
// GroupList returns a list of groups
// (GET /groups)
GroupList(ctx echo.Context, params GroupListParams) error
// GroupCreate will create a new group
// (POST /groups)
GroupCreate(ctx echo.Context) error
// GroupDelete allows to delete a specific groupId
// (DELETE /groups/{groupId})
GroupDelete(ctx echo.Context, groupId int32) error
// GroupGet will retrieve in backend all information about a specific groupId
// (GET /groups/{groupId})
GroupGet(ctx echo.Context, groupId int32) error
// GroupUpdate allows to modify information about a specific groupId
// (PUT /groups/{groupId})
GroupUpdate(ctx echo.Context, groupId int32) error
// UserList returns a list of users
// (GET /users)
UserList(ctx echo.Context, params UserListParams) error
// UserCreate will create a new user
// (POST /users)
UserCreate(ctx echo.Context) error
// UserDelete allows to delete a specific userId
// (DELETE /users/{userId})
UserDelete(ctx echo.Context, userId int32) error
// UserGet will retrieve in backend all information about a specific userId
// (GET /users/{userId})
UserGet(ctx echo.Context, userId int32) error
// UserUpdate allows to modify information about a specific userId
// (PUT /users/{userId})
UserUpdate(ctx echo.Context, userId int32) error
// UserChangePassword allows a user to change it's own password
// (PUT /users/{userId}/changepassword)
UserChangePassword(ctx echo.Context, userId int32) error
}
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct {
Handler ServerInterface
}
ServerInterfaceWrapper converts echo contexts to parameters.
func (*ServerInterfaceWrapper) GroupCreate ¶
func (w *ServerInterfaceWrapper) GroupCreate(ctx echo.Context) error
GroupCreate converts echo context to params.
func (*ServerInterfaceWrapper) GroupDelete ¶
func (w *ServerInterfaceWrapper) GroupDelete(ctx echo.Context) error
GroupDelete converts echo context to params.
func (*ServerInterfaceWrapper) GroupGet ¶
func (w *ServerInterfaceWrapper) GroupGet(ctx echo.Context) error
GroupGet converts echo context to params.
func (*ServerInterfaceWrapper) GroupList ¶
func (w *ServerInterfaceWrapper) GroupList(ctx echo.Context) error
GroupList converts echo context to params.
func (*ServerInterfaceWrapper) GroupUpdate ¶
func (w *ServerInterfaceWrapper) GroupUpdate(ctx echo.Context) error
GroupUpdate converts echo context to params.
func (*ServerInterfaceWrapper) UserChangePassword ¶
func (w *ServerInterfaceWrapper) UserChangePassword(ctx echo.Context) error
UserChangePassword converts echo context to params.
func (*ServerInterfaceWrapper) UserCreate ¶
func (w *ServerInterfaceWrapper) UserCreate(ctx echo.Context) error
UserCreate converts echo context to params.
func (*ServerInterfaceWrapper) UserDelete ¶
func (w *ServerInterfaceWrapper) UserDelete(ctx echo.Context) error
UserDelete converts echo context to params.
func (*ServerInterfaceWrapper) UserGet ¶
func (w *ServerInterfaceWrapper) UserGet(ctx echo.Context) error
UserGet converts echo context to params.
func (*ServerInterfaceWrapper) UserList ¶
func (w *ServerInterfaceWrapper) UserList(ctx echo.Context) error
UserList converts echo context to params.
func (*ServerInterfaceWrapper) UserUpdate ¶
func (w *ServerInterfaceWrapper) UserUpdate(ctx echo.Context) error
UserUpdate converts echo context to params.
type Service ¶
func (Service) GetMaxId ¶
GetMaxId returns the greatest users id used by now curl -H "Content-Type: application/json" 'http://localhost:8888/users/maxid'
func (Service) GetResetPasswordEmail ¶
func (Service) GetResetPasswordToken ¶
func (Service) GroupCreate ¶
GroupCreate will store a new Group in the store
func (Service) GroupDelete ¶
GroupDelete will remove the given id entry from the store, and if not present will return 400 Bad Request curl -v -XDELETE -H "Content-Type: application/json" -H "Authorization: Bearer $token" 'http://localhost:8888/api/groups/3' -> 204 No Content if present and delete it
func (Service) GroupGet ¶
GroupGet will retrieve the Group in the store and return then to test it with curl you can try : curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $token" 'http://localhost:8888/api/users' |jq
func (Service) GroupList ¶
func (s Service) GroupList(ctx echo.Context, params GroupListParams) error
GroupList will retrieve all Groups in the store and return then
func (Service) GroupUpdate ¶
GroupUpdate will store the modified information in the store for the given id
func (Service) LoginUser ¶
LoginUser allows client to try to authenticate, and then receive a valid JWT curl -X POST -H "Content-Type: application/json" -d '{"username": "go-admin", "password_hash": "your_pwd_hash" }' http://localhost:8888/login with the received token you can try : curl -H "Authorization: Bearer $token " http://localhost:8888/restricted
func (Service) ResetPassword ¶
func (Service) SendResetPassword ¶
func (Service) UserChangePassword ¶
UserChangePassword allows a user to change it's own password (PUT /api/users/{userId}/changepassword)
func (Service) UserCreate ¶
UserCreate will store a new User in the store
to test it with curl you can try :
curl -s -XPOST -H "Content-Type: application/json" -H "Authorization: Bearer $token" \ -d '{"username":"cgil", "name":"Carlos GIL", "email":"c@gil.town", "password_hash":"4acf0b39d9c4766709a3689f553ac01ab550545ffa4544dfc0b2cea82fba02a3"}' 'http://localhost:8888/api/users'
func (Service) UserDelete ¶
UserDelete will remove the given userID entry from the store, and if not present will return 400 Bad Request curl -v -XDELETE -H "Content-Type: application/json" -H "Authorization: Bearer $token" 'http://localhost:8888/api/users/3' -> 204 No Content if present and delete it curl -v -XDELETE -H "Content-Type: application/json" -H "Authorization: Bearer $token" 'http://localhost:8888/users/93333' -> 400 Bad Request
func (Service) UserGet ¶
UserGet will retrieve the User in the store and return then to test it with curl you can try : curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $token" 'http://localhost:8888/api/users' |jq
func (Service) UserList ¶
func (s Service) UserList(ctx echo.Context, params UserListParams) error
UserList will retrieve all Users in the store and return then to test it with curl you can try : curl -s -H "Content-Type: application/json" -H "Authorization: Bearer $token" 'http://localhost:8888/api/users' |jq
func (Service) UserUpdate ¶
UserUpdate will store the modified information in the store for the given userId curl -v -XPUT -H "Content-Type: application/json" -d '{"id": 3, "task":"learn Linux", "completed": true}' 'http://localhost:8888/users/3' curl -v -XPUT -H "Content-Type: application/json" -d '{"id": 3, "task":"learn Linux", "completed": false}' 'http://localhost:8888/users/3'
type Storage ¶
type Storage interface {
// List returns the list of existing users with the given offset and limit.
List(offset, limit int) ([]*UserList, error)
// Get returns the users with the specified users ID.
Get(id int32) (*User, error)
// GetMaxId returns the maximum value of users id existing in store.
GetMaxId() (int32, error)
// Exist returns true only if a users with the specified id exists in store.
Exist(id int32) bool
// Count returns the total number of users.
Count() (int32, error)
// Create saves a new users in the storage.
Create(user User) (*User, error)
// Update updates the users with given ID in the storage.
Update(id int32, user User) (*User, error)
// Delete removes the users with given ID from the storage.
Delete(id int32) error
// FindUsername retrieves the user id for the given username or err if not found
FindUsername(username string) (int32, error)
// Close terminates properly the connection to the backend
Close()
// IsUserAdmin returns true if the user with the specified id has the is_admin attribute set to true
IsUserAdmin(id int32) bool
// IsUserActive returns true if the user with the specified id has the is_active attribute set to true
IsUserActive(id int32) bool
// CreateGroup saves a new group in the storage.
CreateGroup(group Group) (*Group, error)
// UpdateGroup updates the group with given ID in the storage.
UpdateGroup(id int32, group Group) (*Group, error)
// DeleteGroup removes the group with given ID from the storage.
DeleteGroup(id int32) error
// ListGroup returns the list of active groups with the given offset and limit.
ListGroup(offset, limit int) ([]*GroupList, error)
// GetGroup returns the group with the specified users ID.
GetGroup(id int32) (*Group, error)
}
Storage is an interface to different implementation of persistence for Users/Groups
func GetStorageInstance ¶
type User ¶
type User struct {
BadPasswordCount int32 `json:"bad_password_count"`
Comment *string `json:"comment,omitempty"`
CreateTime time.Time `json:"create_time"`
Creator int32 `json:"creator"`
Email openapi_types.Email `json:"email"`
ExternalId *int32 `json:"external_id,omitempty"`
GroupsId *[]int32 `json:"groups_id,omitempty"`
Id int32 `json:"id"`
InactivationReason *string `json:"inactivation_reason,omitempty"`
InactivationTime *time.Time `json:"inactivation_time,omitempty"`
IsActive bool `json:"is_active"`
IsAdmin bool `json:"is_admin"`
IsLocked bool `json:"is_locked"`
LastModificationTime *time.Time `json:"last_modification_time,omitempty"`
LastModificationUser *int32 `json:"last_modification_user,omitempty"`
Name string `json:"name"`
OrgunitId *int32 `json:"orgunit_id,omitempty"`
PasswordHash string `json:"password_hash"`
Phone *string `json:"phone,omitempty"`
Username string `json:"username"`
}
User defines model for User.
type UserCreateJSONBody ¶
type UserCreateJSONBody = User
UserCreateJSONBody defines parameters for UserCreate.
type UserCreateJSONRequestBody ¶
type UserCreateJSONRequestBody = UserCreateJSONBody
UserCreateJSONRequestBody defines body for UserCreate for application/json ContentType.
type UserList ¶
type UserList struct {
CreateTime time.Time `json:"create_time"`
Creator int32 `json:"creator"`
Email openapi_types.Email `json:"email"`
Id int32 `json:"id"`
IsActive bool `json:"is_active"`
IsAdmin bool `json:"is_admin"`
IsLocked bool `json:"is_locked"`
Name string `json:"name"`
Username string `json:"username"`
}
UserList defines model for UserList.
type UserListParams ¶
type UserListParams struct {
// maximum number of results to return
Limit *int32 `form:"limit,omitempty" json:"limit,omitempty"`
}
UserListParams defines parameters for UserList.