slack

package
v0.0.0-...-4b9a916 Latest Latest
Warning

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

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

Documentation

Overview

Package slack provides an interface to the Slack REST API for Enterprise Grid

Index

Constants

View Source
const (
	SlackErrorNameAlreadyExists = "name_already_exists"
	SlackErrorNoSuchSubteam     = "no_such_subteam"
	SlackErrorSubteamNotFound   = "subteam_not_found"
	SlackErrorTeamNotFound      = "team_not_found"
	SlackErrorUserNotFound      = "user_not_found"
	SlackErrorUsersNotFound     = "users_not_found"
)

list of error messages returned by the slack api

Variables

View Source
var (
	// ErrBadParameter is returned when bad parameters are passed to a slack request
	ErrBadParameter = errors.New("bad parameters in request")

	// ErrEmptyUserGroupMembers is returned when we try to set an empty user group member list
	ErrEmptyUserGroupMembers = errors.New("user group members cannot be empty list")

	// ErrMissingUserGroupParameter is returned when there are missing user group request parameters
	ErrMissingUserGroupParameter = errors.New("missing required user group parameters in request")

	// ErrSlackGroupAlreadyExists is returned when the slack user group already exists
	ErrSlackGroupAlreadyExists = errors.New("slack user group already exists")

	// ErrSlackGroupNotFound is returned when the slack user group is not found
	ErrSlackGroupNotFound = errors.New("slack user group not found")

	// ErrSlackUserNotFound is returned when the slack user is not found
	ErrSlackUserNotFound = errors.New("slack user not found")

	// ErrSlackWorkspaceNotFound is returned when the slack workspace (team) is not found
	ErrSlackWorkspaceNotFound = errors.New("slack workspace not found")
)

Functions

This section is empty.

Types

type Client

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

Client is a client that can talk to the Slack API

func NewClient

func NewClient(opts ...Option) *Client

NewClient returns a new Slack client

func (*Client) CreateUserGroup

func (c *Client) CreateUserGroup(ctx context.Context, teamID string, userGroup *UserGroupReq) (*slack.UserGroup, error)

CreateUserGroup creates a new user group in a workspace

func (*Client) DisableUserGroup

func (c *Client) DisableUserGroup(ctx context.Context, groupID, teamID string) (*slack.UserGroup, error)

DisableUserGroup disables a user group. Slack does not support deleting a group.

func (*Client) EnableUserGroup

func (c *Client) EnableUserGroup(ctx context.Context, groupID, teamID string) (*slack.UserGroup, error)

EnableUserGroup enables a disabled user group

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context, id string) (*slack.User, error)

GetUser gets information about a slack organization user by id

func (*Client) GetUserByEmail

func (c *Client) GetUserByEmail(ctx context.Context, email string) (*slack.User, error)

GetUserByEmail gets information about a slack organization user by email

func (*Client) GetUserGroupMembers

func (c *Client) GetUserGroupMembers(ctx context.Context, groupID, teamID string, includeDisabled bool) ([]string, error)

GetUserGroupMembers returns the members of a user group

func (*Client) GetUserGroups

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

GetUserGroups gets all user groups in a workspace (given the workspace/team id)

func (*Client) ListWorkspaces

func (c *Client) ListWorkspaces(ctx context.Context) ([]slack.Team, error)

ListWorkspaces returns a list of all workspaces (teams) the token has access to. In the case of Enterprise Grid, this will return a list of all the workspaces in the Slack orgnization. Keep in mind that Slack uses the terms "team" and "workspace" interchangeably in this context. Let's use workspace wherever possible to avoid confusion.

func (*Client) UpdateUserGroup

func (c *Client) UpdateUserGroup(ctx context.Context, groupID, teamID string, userGroup UserGroupReq) (*slack.UserGroup, error)

UpdateUserGroup updates one or more parameters of a user group

func (*Client) UpdateUserGroupMembers

func (c *Client) UpdateUserGroupMembers(ctx context.Context, groupID, teamID string, members []string) (*slack.UserGroup, error)

UpdateUserGroupMembers updates the members of a user group. You cannot pass an empty members list as the Slack API doesn't allow removing all members of a group.

type Option

type Option func(c *Client)

Option is a functional configuration option

func WithLogger

func WithLogger(l *zap.Logger) Option

WithLogger sets logger

func WithToken

func WithToken(t string) Option

WithToken sets the token

type UserGroupReq

type UserGroupReq struct {
	Name        *string
	Handle      *string
	Description *string
}

UserGroupReq is a request to create or update a user group

Jump to

Keyboard shortcuts

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