user

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ErrUserNotFoundMsg is the error message for ErrUserNotFound error.
	ErrUserNotFoundMsg = "user not found on server side"

	// ErrUserBadRequestMsg is the error message for ErrUserBadRequest error.
	ErrUserBadRequestMsg = "Unsatisfied with constraints of the user creation/modification."

	// ErrUserMismatchMsg is the error message for ErrUserMismatch error.
	ErrUserMismatchMsg = "id/name pair not found on server side"

	// ErrUserAlreadyExistMsg is the error message for ErrUserAlreadyExists error.
	ErrUserAlreadyExistsMsg = "user with this username already exists"

	// ErrUserInvalidIDMsg is the error message for ErrUserInvalidID error.
	ErrUserInvalidIDMsg = "invalid user ID"

	// ErrUserIDNotExistsMsg is the error message for ErrUserIDNotExists error.
	ErrUserIDNotExistsMsg = "user id does not exist"

	// ErrUserPasswordInvalid  is the error message for ErrUserPasswordInvalid error.
	ErrUserPasswordInvalidMsg = "invalid user password"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	NewUser(ctx context.Context, username, email, realname, password,
		comments string) (*model.User, error)
	GetUser(ctx context.Context, username string) (*model.User, error)
	GetUserByID(ctx context.Context, id int64) (*model.User, error)
	DeleteUser(ctx context.Context, u *model.User) error
	UpdateUser(ctx context.Context, u *model.User) error
	UpdateUserPassword(ctx context.Context, id int64, password *model.Password) error
	UserExists(ctx context.Context, u *model.User) (bool, error)
}

type ErrUserAlreadyExists

type ErrUserAlreadyExists struct{}

ErrUserAlreadyExists describes an error indicating that this user already exists.

func (*ErrUserAlreadyExists) Error

func (e *ErrUserAlreadyExists) Error() string

Error returns the error message.

type ErrUserBadRequest

type ErrUserBadRequest struct{}

ErrUserBadRequest describes a formal error when creating or updating a user (such as bad password).

func (*ErrUserBadRequest) Error

func (e *ErrUserBadRequest) Error() string

Error returns the error message.

type ErrUserIDNotExists added in v3.2.2

type ErrUserIDNotExists struct{}

ErrUserIDNotExists describes an error indicating a non existing user id.

func (*ErrUserIDNotExists) Error added in v3.2.2

func (e *ErrUserIDNotExists) Error() string

Error returns the error message.

type ErrUserInvalidID

type ErrUserInvalidID struct{}

ErrUserInvalidID describes an error indicating an invalid user id.

func (*ErrUserInvalidID) Error

func (e *ErrUserInvalidID) Error() string

Error returns the error message.

type ErrUserMismatch

type ErrUserMismatch struct{}

ErrUserMismatch describes an error when the id and name of a user do not match on server side.

func (*ErrUserMismatch) Error

func (e *ErrUserMismatch) Error() string

Error returns the error message.

type ErrUserNotFound

type ErrUserNotFound struct{}

ErrUserNotFound describes an error when a specific user was not found on server side.

func (*ErrUserNotFound) Error

func (e *ErrUserNotFound) Error() string

Error returns the error message.

type ErrUserPasswordInvalid

type ErrUserPasswordInvalid struct{}

ErrUserPasswordInvalid describes an error indicating an invalid password

func (*ErrUserPasswordInvalid) Error

func (e *ErrUserPasswordInvalid) Error() string

Error returns the error message.

type RESTClient

type RESTClient struct {
	// The legacy swagger client
	LegacyClient *client.Harbor

	// The new client of the harbor v2 API
	V2Client *v2client.Harbor

	// AuthInfo contains the auth information that is provided on API calls.
	AuthInfo runtime.ClientAuthInfoWriter
}

RESTClient is a subclient for handling user related actions.

func NewClient

func NewClient(legacyClient *client.Harbor, v2Client *v2client.Harbor, authInfo runtime.ClientAuthInfoWriter) *RESTClient

func (*RESTClient) DeleteUser

func (c *RESTClient) DeleteUser(ctx context.Context, u *model.User) error

DeleteUser deletes the specified user.

func (*RESTClient) GetUser

func (c *RESTClient) GetUser(ctx context.Context, username string) (*model.User, error)

GetUser returns an existing user or an error in case of failure.

func (*RESTClient) GetUserByID added in v3.2.2

func (c *RESTClient) GetUserByID(ctx context.Context, id int64) (*model.User, error)

GetUserByID fetches a registered user by the provided user id. Returns an error if no user could be found, or if the id is '0'.

func (*RESTClient) NewUser

func (c *RESTClient) NewUser(ctx context.Context, username, email, realname, password,
	comments string) (*model.User, error)

NewUser creates and returns a new user, or error in case of failure. Username is a unique username. email is the Email of the user. realname is the fullname of the user. password is the password for this user. comments as a comment attached to the user.

func (*RESTClient) UpdateUser

func (c *RESTClient) UpdateUser(ctx context.Context, u *model.User) error

UpdateUser updates a user with the specified data. Note that only realname, email and comment properties are updateable.

func (*RESTClient) UpdateUserPassword

func (c *RESTClient) UpdateUserPassword(ctx context.Context, id int64, password *model.Password) error

UpdateUserPassword updates a users password

func (*RESTClient) UserExists

func (c *RESTClient) UserExists(ctx context.Context, u *model.User) (bool, error)

Jump to

Keyboard shortcuts

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