messenger

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestDescriptionId             = "accessRequest"
	IamServicesSelectorActionID      = "awsServicesSelect"
	IamServiceActionSelectorActionID = "awsServiceActionSelector"
	IamResourcesSelectorActionID     = "awsResourcesSelector"
	AccountSelectorActionId          = "awsAccountSelector"
	LoginRoleSelector                = "awsLoginRoleSelector"
	TimeInputID                      = "awsTimeInput"
	ApprovedActionID                 = "approve"
	DenyActionID                     = "deny"
)

Slack Action and block id Constants which can be referenced else where

Variables

This section is empty.

Functions

func GetRequestAccessModal

func GetRequestAccessModal(tmplVals Template) (slack.ModalViewRequest, error)

func GetRequestApprovalBlocks

func GetRequestApprovalBlocks(auditObj internal.AuditObject, gotResponse bool, responseMSG string) ([]slack.Block, error)

func GetValuesFromSelectedOptions

func GetValuesFromSelectedOptions(selectedOptions []slack.OptionBlockObject) []string

Types

type Messenger

type Messenger struct {
	SlackClient slack.Client
}

func NewMessenger

func NewMessenger(Client *slack.Client) *Messenger

func (*Messenger) GenerateModal

func (m *Messenger) GenerateModal(modalType string, Accounts, LoginRoles []string, hasResourceFinder bool, privateMetadata string, selectedService string) (slack.ModalViewRequest, error)

func (*Messenger) GetUserIdsFromGroup

func (m *Messenger) GetUserIdsFromGroup(groups []string) ([]string, error)

func (*Messenger) PostBlockMessage

func (m *Messenger) PostBlockMessage(channelId string, msgContents []slack.Block, requestId string) (string, string, error)

func (*Messenger) PostSimpleMessage

func (m *Messenger) PostSimpleMessage(channelId string, msgText string, requestId string) error

func (*Messenger) UpdateMessageFromMessageObj

func (m *Messenger) UpdateMessageFromMessageObj(requestId string, approvalMsgObj []internal.ApprovalMsgObj, msgContents []slack.Block) error

type Option

type Option struct {
	Text  Text   `json:"text"`
	Value string `json:"value"`
}

type Options

type Options struct {
	Options []Option `json:"options"`
}

Options Slack Options block for rendering dynamic select lists

func MapToOptions

func MapToOptions(slice map[string]string, TextType string) Options

MapToOptions Given a map[string]string will return Options required for a multiselect and other lists Value will be shown within the Text of the option Key will be shown in the Text and as the actual value of the option e.g Key (Value)

func SliceToOptions

func SliceToOptions(slice []string, TextType string) Options

SliceToOptions Given a slice will return Options required for a multiselect and other lists

type Template

type Template struct {
	SelectedService string //This is here to store the selected service into the BlockID as block_suggestion doesn't show the state

	LoginRoles      []string
	Accounts        []string
	PrivateMetadata string

	TimeInputID          string
	RequestDescriptionId string
	LoginRoleSelectorId  string
	AccountSelectorId    string
	ServiceActionId      string
	ActionsActionId      string
	ActionsBlockId       string
	ResourcesActionId    string
	ResourcesBlockId     string

	IsIamService                bool
	IsActionSelector            bool
	IsExternalResourcesSelector bool
	IsResourcesText             bool
}

Template struct for options within Slack Model

type Text

type Text struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

Jump to

Keyboard shortcuts

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