public class SlackFunctions extends BaseFunctions
Constructor and Description |
---|
SlackFunctions(boolean isExecute,
LogFunctions pFLOG) |
Modifier and Type | Method and Description |
---|---|
void |
cleanup() |
java.lang.String |
getGroovyKey() |
FDUser |
getUserFromSlackId(java.lang.String pSlackId)
Returns the FlexDeploy User corresponding to the given slack user id.
|
FlexSlackMessage |
makePipelineStageCompletedMessage(java.lang.Object pPayload)
Creates a PipelineStageCompleted Event message that can be posted via postMessage.
|
FlexSlackMessage |
makeSnapshotCompleteMessage(java.lang.Object pPayload)
Creates a SnapshotCompleted Event message that can be posted via postMessage.
|
FlexSlackMessage |
makeTaskCreatedMessage(java.lang.Object pPayload,
java.lang.Boolean pAllowInteraction)
Creates a TaskCreated Event message that can be posted via postMessage.
|
FlexSlackMessage |
makeWorkflowCompletedMessage(java.lang.Object pPayload,
java.lang.Boolean pIncludeErrorData)
Creates a WorkflowCompleted Event message that can be posted via postMessage.
|
void |
postAttachment(java.lang.String pSlackAccountCode,
java.lang.String pChannel,
java.io.File pInput,
java.lang.String pMessage,
java.lang.String pParentMessage)
Uploads an attachment to the given slack channel.
|
void |
postAttachment(java.lang.String pSlackAccountCode,
java.lang.String pChannel,
java.io.InputStream pInput,
java.lang.String pMessage,
java.lang.String pParentMessage)
Uploads an attachment to the given slack channel.
|
java.lang.String |
postMessage(java.lang.String pSlackAccountCode,
java.lang.String pChannel,
FlexSlackMessage pMessage)
Posts a slack message using JSON formatted based on Slack API.
|
java.lang.String |
postMessage(java.lang.String pSlackAccountCode,
java.lang.String pChannel,
java.lang.String pJson)
Posts a slack message using JSON formatted based on Slack API.
|
java.lang.String |
postSimpleMessage(java.lang.String pSlackAccountCode,
java.lang.String pChannel,
java.lang.String pMessageText)
Posts a simple slack message to the specified channel.
|
void |
updateTask(java.lang.Object pSlackPayload,
java.lang.Boolean pUpdateInPlace)
Approves or rejects a task from an incoming Slack webhook payload.
|
decryptIntegrationInstance, doSimpleGet, findIntegrationInstanceByCode, getLogFunctions, getServerBaseUrl, setScriptRef
public SlackFunctions(boolean isExecute, LogFunctions pFLOG)
public FDUser getUserFromSlackId(java.lang.String pSlackId) throws FlexCheckedException, FlexNotFoundException
pSlackId
- The Slack user id. This can be found in the Slack payload from incoming webhook messages.FlexNotFoundException
- If no FlexDeploy user was found for the given Slack id.FlexCheckedException
- All other exceptionspublic void updateTask(java.lang.Object pSlackPayload, java.lang.Boolean pUpdateInPlace) throws FlexCheckedException
pSlackPayload
- Slack webhook payload resulting from makeTaskCreatedMessage post message.pUpdateInPlace
- Should the original message be updated with this response.FlexCheckedException
public void postAttachment(java.lang.String pSlackAccountCode, java.lang.String pChannel, java.io.InputStream pInput, java.lang.String pMessage, java.lang.String pParentMessage) throws FlexCheckedException, FlexNotFoundException
pSlackAccountCode
- Messaging account code for Slack account.pChannel
- Name or Id of channel where the attachment will be uploaded. Use user channel Id to send direct messages.pInput
- The input stream to upload.pMessage
- Text to display giving context about the attachmentpParentMessage
- Parent message/ts id if you wish to post attachment as a reply, leave as null otherwiseFlexNotFoundException
- If no account is found for give codeFlexCheckedException
public void postAttachment(java.lang.String pSlackAccountCode, java.lang.String pChannel, java.io.File pInput, java.lang.String pMessage, java.lang.String pParentMessage) throws FlexCheckedException, FlexNotFoundException
pSlackAccountCode
- Messaging account code for Slack account.pChannel
- Name or Id of channel where the attachment will be uploaded. Use user channel Id to send direct messages.pInput
- The file to upload.pMessage
- Text to display giving context about the attachmentpParentMessage
- Parent message/ts id if you wish to post attachment as a reply, leave as null otherwiseFlexNotFoundException
- If no account is found for give codeFlexCheckedException
public FlexSlackMessage makeSnapshotCompleteMessage(java.lang.Object pPayload) throws FlexCheckedException
pPayload
- Payload for the Workflow Completed Event. The EVENT.payload key should be usedFlexCheckedException
public FlexSlackMessage makePipelineStageCompletedMessage(java.lang.Object pPayload) throws FlexCheckedException
pPayload
- Payload for the Pipeline Stage Completed Event. The EVENT.payload key should be usedFlexCheckedException
public FlexSlackMessage makeTaskCreatedMessage(java.lang.Object pPayload, java.lang.Boolean pAllowInteraction) throws FlexCheckedException
pPayload
- Payload for the Task Created Event. The EVENT.payload key should be usedpAllowInteraction
- If true, the message will contain interactive buttons to approve/reject the task via inbound webhooks. See the official Events documentation for more information.FlexCheckedException
public FlexSlackMessage makeWorkflowCompletedMessage(java.lang.Object pPayload, java.lang.Boolean pIncludeErrorData) throws FlexCheckedException
pPayload
- Payload for the Workflow Completed Event. The EVENT.payload key should be usedpIncludeErrorData
- If the workflow is a failure, should error data be included in the message. Setting this to false can improve performance of messaging.FlexCheckedException
public java.lang.String postMessage(java.lang.String pSlackAccountCode, java.lang.String pChannel, FlexSlackMessage pMessage) throws FlexCheckedException
pSlackAccountCode
- Messaging account code for Slack account.pChannel
- Name or Id of channel where the notification will be sent. Use user channel Id to send direct messages.pMessage
- FlexSlackMessage to post. Formatted based on Slack API.FlexCheckedException
public java.lang.String postMessage(java.lang.String pSlackAccountCode, java.lang.String pChannel, java.lang.String pJson) throws FlexCheckedException
pSlackAccountCode
- Messaging account code for Slack account.pChannel
- Name or Id of channel where the notification will be sent. Use user channel Id to send direct messages.pJson
- Json string of your slack message body. Formatted based on Slack API.FlexCheckedException
public java.lang.String postSimpleMessage(java.lang.String pSlackAccountCode, java.lang.String pChannel, java.lang.String pMessageText) throws FlexCheckedException
pSlackAccountCode
- Messaging account code for Slack account.pChannel
- Name or Id of channel where the notification will be sent. Use user channel Id to send direct messages.pMessageText
- Text for the message that will be sent.FlexNotFoundException
FlexCheckedException
public java.lang.String getGroovyKey()
getGroovyKey
in class BaseFunctions
public void cleanup()
cleanup
in class BaseFunctions