enterprise

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UrlPathGetRoleAssignments  = "/api/admin.roles.listAssignments"
	UrlPathGetTeams            = "/api/admin.teams.list"
	UrlPathGetUserGroupMembers = "/api/usergroups.users.list"
	UrlPathGetUserGroups       = "/api/usergroups.list"
	UrlPathGetUserInfo         = "/api/users.info"
	UrlPathGetUsers            = "/api/users.list"
	UrlPathGetUsersAdmin       = "/api/admin.users.list"
	UrlPathIDPGroup            = "/scim/v2/Groups/%s"
	UrlPathIDPGroups           = "/scim/v2/Groups"
	UrlPathAuthTeamsList       = "/api/auth.teams.list"

	// NOTE: these are only for enterprise grid workspaces
	// docs: https://api.slack.com/methods/admin.users.setRegular
	UrlPathSetRegular = "/api/admin.users.setRegular"
	UrlPathSetAdmin   = "/api/admin.users.setAdmin"
	UrlPathSetOwner   = "/api/admin.users.setOwner"
)

docs: https://api.slack.com/methods

View Source
const (
	PageSizeDefault = 100
)

Variables

This section is empty.

Functions

func WithBearerToken

func WithBearerToken(token string) uhttp.RequestOption

WithBearerToken - TODO(marcos): move this function to `baton-sdk`.

Types

type Address

type Address struct {
	StreetAddress string `json:"streetAddress"`
	Locality      string `json:"locality"`
	Region        string `json:"region"`
	PostalCode    string `json:"postalCode"`
	Country       string `json:"country"`
}

type BaseResponse

type BaseResponse struct {
	Ok       bool   `json:"ok"`
	Error    string `json:"error"`
	Needed   string `json:"needed"`
	Provided string `json:"provided"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(
	httpClient *http.Client,
	token string,
	botToken string,
	enterpriseID string,
	ssoEnabled bool,
) (*Client, error)

func (*Client) AddUserToGroup

func (c *Client) AddUserToGroup(
	ctx context.Context,
	groupID string,
	user string,
) (
	*v2.RateLimitDescription,
	error,
)

AddUserToGroup patches a group by adding a user to it.

func (*Client) GetAuthTeamsList added in v0.0.24

func (c *Client) GetAuthTeamsList(
	ctx context.Context,
	cursor string,
) (
	[]slack.Team,
	string,
	*v2.RateLimitDescription,
	error,
)

GetAuthTeamsList returns the list of teams for which the app is authed.

func (*Client) GetIDPGroup

func (c *Client) GetIDPGroup(
	ctx context.Context,
	groupID string,
) (
	*GroupResource,
	*v2.RateLimitDescription,
	error,
)

GetIDPGroup returns a single IDP group from the SCIM API.

func (*Client) GetRoleAssignments

func (c *Client) GetRoleAssignments(
	ctx context.Context,
	roleID string,
	cursor string,
) (
	[]RoleAssignment,
	string,
	*v2.RateLimitDescription,
	error,
)

GetRoleAssignments returns the role assignments for the given role ID.

func (*Client) GetTeams

func (c *Client) GetTeams(
	ctx context.Context,
	cursor string,
) (
	[]slack.Team,
	string,
	*v2.RateLimitDescription,
	error,
)

GetTeams returns the teams of the given enterprise.

func (*Client) GetUserGroupMembers

func (c *Client) GetUserGroupMembers(
	ctx context.Context,
	userGroupID string,
	teamID string,
) (
	[]string,
	*v2.RateLimitDescription,
	error,
)

GetUserGroupMembers returns the members of the given user group from a given team.

func (*Client) GetUserGroups

func (c *Client) GetUserGroups(
	ctx context.Context,
	teamID string,
) (
	[]slack.UserGroup,
	*v2.RateLimitDescription,
	error,
)

GetUserGroups returns the user groups for the given team.

func (*Client) GetUserInfo

func (c *Client) GetUserInfo(
	ctx context.Context,
	userID string,
) (
	*User,
	*v2.RateLimitDescription,
	error,
)

GetUserInfo returns the user info for the given user ID.

func (*Client) GetUsers

func (c *Client) GetUsers(
	ctx context.Context,
	teamID string,
	cursor string,
) (
	[]User,
	string,
	*v2.RateLimitDescription,
	error,
)

GetUsers returns the users of the given team.

func (*Client) GetUsersAdmin

func (c *Client) GetUsersAdmin(
	ctx context.Context,
	cursor string,
) (
	[]UserAdmin,
	string,
	*v2.RateLimitDescription,
	error,
)

GetUsersAdmin returns all users in Enterprise grid.

func (*Client) ListIDPGroups

func (c *Client) ListIDPGroups(
	ctx context.Context,
	startIndex int,
	count int,
) (
	*SCIMResponse[GroupResource],
	*v2.RateLimitDescription,
	error,
)

ListIDPGroups returns all IDP groups from the SCIM API.

func (*Client) RemoveUserFromGroup

func (c *Client) RemoveUserFromGroup(
	ctx context.Context,
	groupID string,
	user string,
) (
	bool,
	*v2.RateLimitDescription,
	error,
)

RemoveUserFromGroup patches a group by removing a user from it.

func (*Client) SetWorkspaceRole

func (c *Client) SetWorkspaceRole(
	ctx context.Context,
	teamID string,
	userID string,
	roleID string,
) (
	*v2.RateLimitDescription,
	error,
)

SetWorkspaceRole sets the role for the given user in the given team.

type Email

type Email struct {
	Value   string `json:"value"`
	Primary bool   `json:"primary"`
}

type EnterpriseUser

type EnterpriseUser struct {
	ID             string   `json:"id"`
	EnterpriseID   string   `json:"enterprise_id"`
	EnterpriseName string   `json:"enterprise_name"`
	IsAdmin        bool     `json:"is_admin"`
	IsOwner        bool     `json:"is_owner"`
	IsPrimaryOwner bool     `json:"is_primary_owner"`
	Teams          []string `json:"teams"`
}

type Group

type Group struct {
	Display string `json:"display"`
	Value   string `json:"value"`
}

type GroupResource

type GroupResource struct {
	Schemas     []string `json:"schemas"`
	ID          string   `json:"id"`
	Meta        Meta     `json:"meta"`
	DisplayName string   `json:"displayName"`
	Members     []Member `json:"members"`
}

type Manager

type Manager struct {
	ManagerID string `json:"managerId"`
}

type Member

type Member struct {
	Value   string `json:"value"`
	Display string `json:"display"`
}

type Meta

type Meta struct {
	Created  string `json:"created"`
	Location string `json:"location"`
}

type Name

type Name struct {
	GivenName       string `json:"givenName"`
	FamilyName      string `json:"familyName"`
	HonorificPrefix string `json:"honorificPrefix"`
}

type Pagination

type Pagination struct {
	ResponseMetadata struct {
		NextCursor string `json:"next_cursor"`
	} `json:"response_metadata"`
}

type PatchOp

type PatchOp struct {
	Schemas    []string      `json:"schemas"`
	Operations []ScimOperate `json:"Operations"`
}

type PhoneNumber

type PhoneNumber struct {
	Value   string `json:"value"`
	Type    string `json:"type,omitempty"`
	Primary bool   `json:"primary,omitempty"`
}

type RoleAssignment

type RoleAssignment struct {
	RoleID     string `json:"role_id"`
	EntityID   string `json:"entity_id"`
	UserID     string `json:"user_id"`
	DateCreate int    `json:"date_create"`
}

type SCIMResponse

type SCIMResponse[T any] struct {
	Schemas      []string `json:"schemas"`
	Resources    []T      `json:"Resources"`
	TotalResults int      `json:"totalResults"`
	ItemsPerPage int      `json:"itemsPerPage"`
	StartIndex   int      `json:"startIndex"`
}

type ScimOperate

type ScimOperate struct {
	Op    string   `json:"op"`
	Path  string   `json:"path"`
	Value []UserID `json:"value"`
}

type UrnIETFParamsScimSchemasExtensionEnterprise20UserClass

type UrnIETFParamsScimSchemasExtensionEnterprise20UserClass struct {
	EmployeeNumber string  `json:"employeeNumber"`
	CostCenter     string  `json:"costCenter"`
	Organization   string  `json:"organization"`
	Division       string  `json:"division"`
	Department     string  `json:"department"`
	Manager        Manager `json:"manager"`
}

type User

type User struct {
	ID                string            `json:"id"`
	TeamID            string            `json:"team_id"`
	Name              string            `json:"name"`
	Deleted           bool              `json:"deleted"`
	Color             string            `json:"color"`
	RealName          string            `json:"real_name"`
	TZ                string            `json:"tz,omitempty"`
	TZLabel           string            `json:"tz_label"`
	TZOffset          int               `json:"tz_offset"`
	Profile           slack.UserProfile `json:"profile"`
	IsBot             bool              `json:"is_bot"`
	IsAdmin           bool              `json:"is_admin"`
	IsOwner           bool              `json:"is_owner"`
	IsPrimaryOwner    bool              `json:"is_primary_owner"`
	IsRestricted      bool              `json:"is_restricted"`
	IsUltraRestricted bool              `json:"is_ultra_restricted"`
	IsStranger        bool              `json:"is_stranger"`
	IsAppUser         bool              `json:"is_app_user"`
	IsInvitedUser     bool              `json:"is_invited_user"`
	Has2FA            bool              `json:"has_2fa"`
	TwoFactorType     string            `json:"two_factor_type"`
	HasFiles          bool              `json:"has_files"`
	Presence          string            `json:"presence"`
	Locale            string            `json:"locale"`
	Enterprise        EnterpriseUser    `json:"enterprise_user,omitempty"`
}

type UserAdmin

type UserAdmin struct {
	ID                string   `json:"id"`
	Email             string   `json:"email"`
	IsAdmin           bool     `json:"is_admin"`
	IsOwner           bool     `json:"is_owner"`
	IsPrimaryOwner    bool     `json:"is_primary_owner"`
	IsRestricted      bool     `json:"is_restricted"`
	IsUltraRestricted bool     `json:"is_ultra_restricted"`
	IsBot             bool     `json:"is_bot"`
	Username          string   `json:"username"`
	FullName          string   `json:"full_name"`
	IsActive          bool     `json:"is_active"`
	DateCreated       int      `json:"date_created"`
	DeactivatedTs     int      `json:"deactivated_ts"`
	ExpirationTs      int      `json:"expiration_ts"`
	Workspaces        []string `json:"workspaces"`
	Has2Fa            bool     `json:"has_2fa"`
	HasSso            bool     `json:"has_sso"`
}

type UserID

type UserID struct {
	Value string `json:"value"`
}

type UserResource

type UserResource struct {
	Schemas                                           []string                                               `json:"schemas"`
	ID                                                string                                                 `json:"id"`
	ExternalID                                        string                                                 `json:"externalId"`
	Meta                                              Meta                                                   `json:"meta"`
	UserName                                          string                                                 `json:"userName"`
	NickName                                          string                                                 `json:"nickName"`
	Name                                              Name                                                   `json:"name"`
	DisplayName                                       string                                                 `json:"displayName"`
	ProfileURL                                        string                                                 `json:"profileUrl"`
	Title                                             string                                                 `json:"title"`
	Timezone                                          string                                                 `json:"timezone"`
	Active                                            bool                                                   `json:"active"`
	Emails                                            []Email                                                `json:"emails"`
	Addresses                                         []Address                                              `json:"addresses"`
	PhoneNumbers                                      []PhoneNumber                                          `json:"phoneNumbers"`
	UserType                                          string                                                 `json:"userType"`
	Roles                                             []Email                                                `json:"roles"`
	PreferredLanguage                                 string                                                 `json:"preferredLanguage"`
	Locale                                            string                                                 `json:"locale"`
	UrnIETFParamsScimSchemasExtensionEnterprise20User UrnIETFParamsScimSchemasExtensionEnterprise20UserClass `json:"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"`
	Groups                                            []Group                                                `json:"groups"`
}

UserResource SCIM resources.

Jump to

Keyboard shortcuts

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