user

package
v5.0.8 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

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) error
	GetUserByName(ctx context.Context, username string) (*modelv2.UserResp, error)
	GetUserByID(ctx context.Context, id int64) (*modelv2.UserResp, error)
	ListUsers(ctx context.Context) ([]*modelv2.UserResp, error)
	SearchUsers(ctx context.Context, name string) ([]*modelv2.UserSearchRespItem, error)
	GetCurrentUserInfo(ctx context.Context) (*modelv2.UserResp, error)
	GetCurrentUserPermisisons(ctx context.Context, relative bool, scope string) ([]*modelv2.Permission, error)
	SetUserSysAdmin(ctx context.Context, id int64, admin bool) error
	DeleteUser(ctx context.Context, id int64) error
	UpdateUserProfile(ctx context.Context, id int64, profile *modelv2.UserProfile) error
	UpdateUserPassword(ctx context.Context, userID int64, passwordRequest *modelv2.PasswordReq) error
	UserExists(ctx context.Context, idOrName intstr.IntOrString) (bool, error)
}

type RESTClient

type RESTClient struct {
	// The new client of the harbor v2 API
	V2Client *v2client.Harbor

	// Options contains optional configuration when making API calls.
	Options *config.Options

	// 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(v2Client *v2client.Harbor, opts *config.Options, authInfo runtime.ClientAuthInfoWriter) *RESTClient

func (*RESTClient) DeleteUser

func (c *RESTClient) DeleteUser(ctx context.Context, id int64) error

DeleteUser deletes the specified user, first ensuring its existence.

func (*RESTClient) GetCurrentUserInfo

func (c *RESTClient) GetCurrentUserInfo(ctx context.Context) (*modelv2.UserResp, error)

GetCurrentUserInfo returns information of currently active user.

func (*RESTClient) GetCurrentUserPermisisons

func (c *RESTClient) GetCurrentUserPermisisons(ctx context.Context, relative bool, scope string) ([]*modelv2.Permission, error)

GetCurrentUserPermisisons returns the permissions of the currently active user.

func (*RESTClient) GetUserByID

func (c *RESTClient) GetUserByID(ctx context.Context, id int64) (*modelv2.UserResp, error)

GetUserByID returns an existing user identified by ID.

func (*RESTClient) GetUserByName

func (c *RESTClient) GetUserByName(ctx context.Context, username string) (*modelv2.UserResp, error)

GetUserByName returns an existing user identified by name.

func (*RESTClient) ListUsers

func (c *RESTClient) ListUsers(ctx context.Context) ([]*modelv2.UserResp, error)

ListUsers lists and returns all registered Harbor users. The maximum number of users listed is bound to the RESTClient's configured PageSize.

func (*RESTClient) NewUser

func (c *RESTClient) NewUser(ctx context.Context, username, email, realname, password, comments string) 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) SearchUsers

func (c *RESTClient) SearchUsers(ctx context.Context, name string) ([]*modelv2.UserSearchRespItem, error)

SearchUsers searches all existing users by the provided username 'name' and returns matching users.

func (*RESTClient) SetUserSysAdmin

func (c *RESTClient) SetUserSysAdmin(ctx context.Context, id int64, admin bool) error

SetUserSysAdmin updates a user's administrator privileges.

func (*RESTClient) UpdateUserPassword

func (c *RESTClient) UpdateUserPassword(ctx context.Context, userID int64, passwordRequest *modelv2.PasswordReq) error

UpdateUserPassword updates a user's password from 'old' to 'new'. 'old' is an optional parameter when called by an administrator.

func (*RESTClient) UpdateUserProfile

func (c *RESTClient) UpdateUserProfile(ctx context.Context, id int64, profile *modelv2.UserProfile) error

UpdateUserProfile updates a user identified by id with the specified profile data.

func (*RESTClient) UserExists

func (c *RESTClient) UserExists(ctx context.Context, idOrName intstr.IntOrString) (bool, error)

UserExists checks the user with the provided 'idOrName' for existence.

Jump to

Keyboard shortcuts

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