iam

package
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: MIT Imports: 11 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const UsernameSetSuccessFmt = "Username set to %q"

UsernameSetSuccessFmt is the confirmation format shown after a username is set.

Variables

View Source
var ErrUsernameSetupStopped = errors.New("username setup stopped before the name was sent")

ErrUsernameSetupStopped is HandleUsernameRequiredUnless's answer when the caller was stopped while the prompt waited: the name read after that is not sent.

Functions

func AddMember

func AddMember(ac *client.AlpaconClient, memberRequest MemberAddRequest) error

func CreateGroup

func CreateGroup(ac *client.AlpaconClient, groupRequest GroupCreateRequest) error

func CreateUser

func CreateUser(ac *client.AlpaconClient, userRequest UserCreateRequest) (string, error)

CreateUser returns the password the server generated for the new user, or "" when the response carries none.

func CurrentUsernameUnset added in v1.20.0

func CurrentUsernameUnset(ac *client.AlpaconClient) (bool, error)

CurrentUsernameUnset reports whether the caller's account has a null username. An empty string or a missing field reads as not unset.

func DeleteGroup

func DeleteGroup(ac *client.AlpaconClient, groupName string) error

func DeleteMember

func DeleteMember(ac *client.AlpaconClient, memberDeleteRequest MemberDeleteRequest) error

func DeleteUser

func DeleteUser(ac *client.AlpaconClient, userName string, archiveHome bool) error

func GetGroupDetail

func GetGroupDetail(ac *client.AlpaconClient, groupId string) ([]byte, error)

func GetGroupIDByName

func GetGroupIDByName(ac *client.AlpaconClient, groupName string) (string, error)

func GetUserDetail

func GetUserDetail(ac *client.AlpaconClient, userId string) ([]byte, error)

func GetUserIDByName

func GetUserIDByName(ac *client.AlpaconClient, userName string) (string, error)

func GetUsernamesByID added in v1.12.0

func GetUsernamesByID(ac *client.AlpaconClient) (map[string]string, error)

GetUsernamesByID maps each user's id to the username other commands accept; a role binding embeds only a display name.

func InviteUser added in v1.4.2

func InviteUser(ac *client.AlpaconClient, request UserInviteRequest) error

func PatchUser added in v1.12.0

func PatchUser(ac *client.AlpaconClient, userID string, changes map[string]any) ([]byte, error)

func UpdateGroup added in v1.2.0

func UpdateGroup(ac *client.AlpaconClient, groupName string) ([]byte, error)

func UsernameErrorMessage added in v1.8.0

func UsernameErrorMessage(code string) (string, bool)

UsernameErrorMessage maps a server username error code to a human-readable message, reporting false for an unrecognized code.

Types

type CurrentUserResponse added in v1.4.2

type CurrentUserResponse struct {
	ID            string `json:"id"`
	Username      string `json:"username"`
	Email         string `json:"email"`
	Phone         string `json:"phone"`
	UID           int    `json:"uid"`
	Shell         string `json:"shell"`
	HomeDirectory string `json:"home_directory"`
	IsStaff       bool   `json:"is_staff"`
	IsSuperuser   bool   `json:"is_superuser"`
}

func GetCurrentUser added in v1.4.2

func GetCurrentUser(ac *client.AlpaconClient) (*CurrentUserResponse, error)

func GetCurrentUserWithContext added in v1.20.2

func GetCurrentUserWithContext(ctx context.Context, ac *client.AlpaconClient) (*CurrentUserResponse, error)

GetCurrentUserWithContext is GetCurrentUser ended early by ctx.

type GroupAttributes

type GroupAttributes struct {
	Name        string `json:"name"`
	DisplayName string `json:"display_name" table:"Display Name"`
	Tags        string `json:"tags"`
	Members     int    `json:"members"`
	Servers     int    `json:"servers"`
	GID         int    `json:"gid" table:"GID"`
	LDAPStatus  string `json:"ldap_status" table:"LDAP"`
}

func GetGroupList

func GetGroupList(ac *client.AlpaconClient) ([]GroupAttributes, error)

type GroupCreateRequest

type GroupCreateRequest struct {
	Name        string   `json:"name"`
	DisplayName string   `json:"display_name"`
	Tags        string   `json:"tags"`
	Description string   `json:"description"`
	IsLdapGroup bool     `json:"is_ldap_group"`
	Servers     []string `json:"servers"`
}

type GroupMembership added in v1.4.2

type GroupMembership struct {
	Name string `json:"name"`
	Role string `json:"role"`
}

func GetUserMemberships added in v1.4.2

func GetUserMemberships(ac *client.AlpaconClient, userID string) ([]GroupMembership, error)

type GroupResponse

type GroupResponse struct {
	ID           string                `json:"id"`
	Name         string                `json:"name"`
	DisplayName  string                `json:"display_name"`
	Description  string                `json:"description"`
	Tags         string                `json:"tags"`
	NumMembers   int                   `json:"num_members"`
	MembersNames []string              `json:"members_names"`
	GID          int                   `json:"gid"`
	IsLDAPGroup  bool                  `json:"is_ldap_group"`
	Servers      []types.ServerSummary `json:"servers"`
	AddedAt      time.Time             `json:"added_at"`
	UpdatedAt    time.Time             `json:"updated_at"`
}

type MemberAddRequest

type MemberAddRequest struct {
	Group string `json:"group"`
	User  string `json:"user"`
	Role  string `json:"role"`
}

type MemberDeleteRequest

type MemberDeleteRequest struct {
	Group string `json:"group"`
	User  string `json:"user"`
}

type MemberDetailResponse

type MemberDetailResponse struct {
	ID        string            `json:"id"`
	Group     string            `json:"group"`
	GroupName string            `json:"group_name"`
	User      types.UserSummary `json:"user"`
	Role      string            `json:"role"`
}

type PrivilegeEdit added in v1.12.0

type PrivilegeEdit struct {
	Field  string
	Enable bool
}

type SetUsernameRequest added in v1.0.0

type SetUsernameRequest struct {
	Username string `json:"username"`
}

type SetUsernameResponse added in v1.0.0

type SetUsernameResponse struct {
	ID       string `json:"id"`
	Username string `json:"username"`
}

func HandleUsernameRequired added in v1.0.0

func HandleUsernameRequired(ac *client.AlpaconClient) (*SetUsernameResponse, error)

func HandleUsernameRequiredUnless added in v1.20.0

func HandleUsernameRequiredUnless(ac *client.AlpaconClient, stopped func() bool) (*SetUsernameResponse, error)

HandleUsernameRequiredUnless is HandleUsernameRequired for a caller whose own Ctrl+C handler takes SIGINT, so the prompt keeps reading after it: once stopped reports true, the prompt asks no more and sends nothing, and the next line read, an empty one included, ends it.

func SetUsername added in v1.0.0

func SetUsername(ac *client.AlpaconClient, username string) (*SetUsernameResponse, error)

type UserAttributes

type UserAttributes struct {
	Username   string `json:"username"`
	Name       string `json:"name"`
	Email      string `json:"email"`
	Tags       string `json:"tags"`
	Groups     int    `json:"groups"`
	UID        int    `json:"uid" table:"UID"`
	Status     string `json:"status"`
	LDAPStatus string `json:"ldap_status" table:"LDAP"`
}

func GetUserList

func GetUserList(ac *client.AlpaconClient) ([]UserAttributes, error)

type UserCreateRequest

type UserCreateRequest struct {
	Username    string `json:"username"`
	FirstName   string `json:"first_name"`
	LastName    string `json:"last_name"`
	Email       string `json:"email"`
	Phone       string `json:"phone"`
	Tags        string `json:"tags"`
	Description string `json:"description"`
	Shell       string `json:"shell"`
	IsActive    bool   `json:"is_active"`
	IsStaff     bool   `json:"is_staff"`
	IsSuperuser bool   `json:"is_superuser"`
	IsLdapUser  bool   `json:"is_ldap_user"`
}

type UserDetailAttributes

type UserDetailAttributes struct {
	Username      string   `json:"username"`
	Name          string   `json:"name"`
	Description   string   `json:"description"`
	Email         string   `json:"email"`
	Phone         string   `json:"phone"`
	UID           int      `json:"uid"`
	Shell         string   `json:"shell"`
	HomeDirectory string   `json:"home_directory"`
	NumGroups     int      `json:"num_groups"`
	Groups        []string `json:"groups"`
	Tags          string   `json:"tags"`
	Status        string   `json:"status"`
	LDAPStatus    string   `json:"ldap_status"`
}

type UserEdit added in v1.12.0

type UserEdit struct {
	Changes    map[string]any
	Privileges []PrivilegeEdit
}

UserEdit is not a wire type: nothing marshals it, so it has no JSON tags—only Changes reaches the wire.

func PrepareUserUpdate added in v1.12.0

func PrepareUserUpdate(ac *client.AlpaconClient, userName string) (string, *UserEdit, error)

PrepareUserUpdate opens the user's detail in an editor and reports what changed; it sends nothing. The patch is sparse so untouched fields are not re-submitted: forwarding an unchanged is_ldap_user makes the server run a live LDAP bind.

type UserInviteRequest added in v1.4.2

type UserInviteRequest struct {
	Email string `json:"email"`
}

type UserResponse

type UserResponse struct {
	ID          string    `json:"id"`
	Username    string    `json:"username"`
	FirstName   string    `json:"first_name"`
	LastName    string    `json:"last_name"`
	Email       string    `json:"email"`
	Phone       string    `json:"phone"`
	Tags        string    `json:"tags"`
	NumGroups   int       `json:"num_groups"`
	UID         int       `json:"uid"`
	IsActive    bool      `json:"is_active"`
	IsStaff     bool      `json:"is_staff"`
	IsSuperuser bool      `json:"is_superuser"`
	IsLDAPUser  bool      `json:"is_ldap_user"`
	DateJoined  time.Time `json:"date_joined"`
}

Jump to

Keyboard shortcuts

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