Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-05 Thread via GitHub


exceptionfactory commented on PR #8122:
URL: https://github.com/apache/nifi/pull/8122#issuecomment-1841627615

   Merged in 
https://github.com/apache/nifi/commit/b27e0f87818af90d745418530c13b11cc510c56e


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-05 Thread via GitHub


exceptionfactory closed pull request #8122: NIFI-12331: Added PublishSlack 
Processor
URL: https://github.com/apache/nifi/pull/8122


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-05 Thread via GitHub


exceptionfactory closed pull request #8120: NIFI-12331: Added PublishSlack 
Processor
URL: https://github.com/apache/nifi/pull/8120


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-05 Thread via GitHub


markap14 commented on PR #8120:
URL: https://github.com/apache/nifi/pull/8120#issuecomment-1841306234

   That's a good catch @exceptionfactory . Unfortunately most of the 
dependencies are still necessary for the Record Sink stuff. Eventually that 
should be rewritten to use the SDK as well, and then we could eliminate most 
all of the dependencies.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


exceptionfactory commented on code in PR #8122:
URL: https://github.com/apache/nifi/pull/8122#discussion_r1414854636


##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/pom.xml:
##
@@ -26,6 +26,23 @@
 jar
 
 
+
+org.apache.nifi
+nifi-api
+provided
+
+
+com.slack.api
+bolt-socket-mode
+1.32.1

Review Comment:
   The latest version is 1.36.1, can this be updated?



##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/pom.xml:
##
@@ -26,6 +26,23 @@
 jar
 
 
+
+org.apache.nifi
+nifi-api
+provided
+
+
+com.slack.api
+bolt-socket-mode
+1.32.1
+
+
+
+org.glassfish.tyrus.bundles
+tyrus-standalone-client
+1.20

Review Comment:
   The latest version of version 1 is 1.21.



##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/processors/slack/PublishSlack.java:
##
@@ -0,0 +1,489 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.processors.slack;
+
+import com.slack.api.bolt.App;
+import com.slack.api.bolt.AppConfig;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.SlackApiException;
+import com.slack.api.methods.request.chat.ChatPostMessageRequest;
+import com.slack.api.methods.request.files.FilesUploadV2Request;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.files.FilesUploadV2Response;
+import com.slack.api.model.File;
+import com.slack.api.model.File.ShareDetail;
+import com.slack.api.model.File.Shares;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.configuration.DefaultSettings;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.annotation.lifecycle.OnStopped;
+import org.apache.nifi.components.AllowableValue;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.Validator;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.flowfile.attributes.CoreAttributes;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.DataUnit;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.processors.slack.util.ChannelMapper;
+import org.apache.nifi.processors.slack.util.RateLimit;
+import org.apache.nifi.stream.io.StreamUtils;
+import org.apache.nifi.util.FormatUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.time.Duration;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+@InputRequirement(Requirement.INPUT_REQUIRED)
+@CapabilityDescription("Posts a message to the specified Slack channel. The 
content of the message can be either a user-defined message that makes use of 
Expression Language or " +
+"the contents of the FlowFile can be sent as the message. If sending a 
user-defined message, the contents of the FlowFile may also be optionally 
uploaded as " +
+"a file attachment.")
+@Tags({"slack", "conversation", "chat.postMessage", "social media", "team", 
"text", "unstructured", "write", "upload", "send", "publish"})
+@WritesAttributes({
+@WritesAttribute(attribute = "slack.channel.id", description = "The ID of 
the Slack Channel from which 

Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


exceptionfactory commented on code in PR #8120:
URL: https://github.com/apache/nifi/pull/8120#discussion_r1414850950


##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/processors/slack/PublishSlack.java:
##
@@ -0,0 +1,517 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.processors.slack;
+
+import com.slack.api.bolt.App;
+import com.slack.api.bolt.AppConfig;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.request.chat.ChatPostMessageRequest;
+import com.slack.api.methods.request.files.FilesUploadV2Request;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.files.FilesUploadV2Response;
+import com.slack.api.model.File;
+import com.slack.api.model.File.ShareDetail;
+import com.slack.api.model.File.Shares;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.configuration.DefaultSettings;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.MultiProcessorUseCase;
+import org.apache.nifi.annotation.documentation.ProcessorConfiguration;
+import org.apache.nifi.annotation.documentation.SeeAlso;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.documentation.UseCase;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.annotation.lifecycle.OnStopped;
+import org.apache.nifi.components.AllowableValue;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.Validator;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.flowfile.attributes.CoreAttributes;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.DataUnit;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.processors.slack.util.SlackResponseUtil;
+import org.apache.nifi.processors.slack.util.ChannelMapper;
+import org.apache.nifi.processors.slack.util.RateLimit;
+import org.apache.nifi.stream.io.StreamUtils;
+import org.apache.nifi.util.FormatUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+@InputRequirement(Requirement.INPUT_REQUIRED)
+@CapabilityDescription("""
+Posts a message to the specified Slack channel. The content of the message 
can be either a user-defined message that makes use of Expression Language or
+the contents of the FlowFile can be sent as the message. If sending a 
user-defined message, the contents of the FlowFile may also be optionally 
uploaded as
+a file attachment.
+""")
+@SeeAlso({ListenSlack.class, ConsumeSlack.class})
+@Tags({"slack", "conversation", "chat.postMessage", "social media", "team", 
"text", "unstructured", "write", "upload", "send", "publish"})
+@WritesAttributes({
+@WritesAttribute(attribute = "slack.channel.id", description = "The ID of 
the Slack Channel from which the messages were retrieved"),
+@WritesAttribute(attribute = "slack.ts", description = "The timestamp of 
the slack messages that was sent; this is used by Slack as a unique identifier")
+})
+@DefaultSettings(yieldDuration = "3 sec")
+@UseCase(
+description = "Send specific text as a message to Slack, optionally 
including the FlowFile's contents as an attached file.",
+configuration = """
+Set "Access Token" to the value of your Slack OAuth Access Token.
+Set "Channel" to the ID of the channel or the name of the channel 
prefixed with the # symbol. For example, "C0123456789" or 

Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


markap14 commented on PR #8120:
URL: https://github.com/apache/nifi/pull/8120#issuecomment-1839649244

   That's a good call @exceptionfactory! Just pushed a new PR for the 1.x line: 
https://github.com/apache/nifi/pull/8122
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


markap14 opened a new pull request, #8122:
URL: https://github.com/apache/nifi/pull/8122

   
   
   
   
   
   
   
   
   
   
   
   
   
   # Summary
   
   [NIFI-0](https://issues.apache.org/jira/browse/NIFI-0)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue 
created
   
   ### Pull Request Tracking
   
   - [ ] Pull Request title starts with Apache NiFi Jira issue number, such as 
`NIFI-0`
   - [ ] Pull Request commit message starts with Apache NiFi Jira issue number, 
as such `NIFI-0`
   
   ### Pull Request Formatting
   
   - [ ] Pull Request based on current revision of the `main` branch
   - [ ] Pull Request refers to a feature branch with one commit containing 
changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request 
creation.
   
   ### Build
   
   - [ ] Build completed using `mvn clean install -P contrib-check`
 - [ ] JDK 21
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 
2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License 
Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` 
files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


joewitt commented on code in PR #8120:
URL: https://github.com/apache/nifi/pull/8120#discussion_r1414551223


##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/processors/slack/PutSlack.java:
##
@@ -66,6 +67,13 @@
 @DynamicProperty(name = "A JSON object to add to Slack's \"attachments\" JSON 
payload.", value = "JSON-formatted string to add to Slack's payload JSON 
appended to the \"attachments\" JSON array.",
 expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES,
 description = "Converts the contents of each value specified by the 
Dynamic Property's value to JSON and appends it to the payload being sent to 
Slack.")
+@DeprecationNotice(

Review Comment:
   Agreed.  There shouldn't be anything deprecated on 2.x for a while.  But 
another PR should deprecate these for the support branch.  And this PR should 
remove them.  Then the migration guide/component mapping guide for 2.x updated. 
 This is cool though



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


exceptionfactory commented on code in PR #8120:
URL: https://github.com/apache/nifi/pull/8120#discussion_r1414545297


##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/processors/slack/PostSlack.java:
##
@@ -82,6 +83,14 @@
 " The property name will not be used by the processor.",
 expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
 @WritesAttribute(attribute="slack.file.url", description = "The Slack URL of 
the uploaded file. It will be added if 'Upload FlowFile' has been set to 
'Yes'.")
+@DeprecationNotice(
+alternatives = {PublishSlack.class},
+reason = "This Processor is more difficult to configure than necessary, 
and exposes intricate nuances of the Slack API that need not be exposed. " +
+ "Additionally, it lacks some capabilities, such as responding to 
messages in threads. It interacts directly with the Slack API instead of " +
+ "making use of the Slack-provided SDK, which makes the Processor 
much more brittle. Additionally, it does not make clear the differences " +
+ "between PutSlack and PostSlack. Each provides slightly different 
capabilities. " +
+ "PublishSlack combines the capabilities of both Processors in a 
simpler configuration that makes use of Slack's standard REST API."
+)

Review Comment:
   Rather than tag this on deprecated on the main branch, the deprecation 
should be added on the support branch. The removal of these Processors could be 
handled in this pull request, or in a subsequent PR.



##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/pom.xml:
##
@@ -61,10 +61,6 @@
 org.slf4j
 jcl-over-slf4j
 
-
-org.apache.nifi
-nifi-api
-

Review Comment:
   It seems like this should still be declared, perhaps the removal triggered 
the other addition with the compile scope, but this one looks correct.



##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/processors/slack/PutSlack.java:
##
@@ -66,6 +67,13 @@
 @DynamicProperty(name = "A JSON object to add to Slack's \"attachments\" JSON 
payload.", value = "JSON-formatted string to add to Slack's payload JSON 
appended to the \"attachments\" JSON array.",
 expressionLanguageScope = ExpressionLanguageScope.FLOWFILE_ATTRIBUTES,
 description = "Converts the contents of each value specified by the 
Dynamic Property's value to JSON and appends it to the payload being sent to 
Slack.")
+@DeprecationNotice(

Review Comment:
   Same as noted on `PostSlack`, the deprecation should be removed and applied 
to the support branch.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


exceptionfactory commented on code in PR #8120:
URL: https://github.com/apache/nifi/pull/8120#discussion_r1414496998


##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/processors/slack/PublishSlack.java:
##
@@ -0,0 +1,513 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.processors.slack;
+
+import com.slack.api.bolt.App;
+import com.slack.api.bolt.AppConfig;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.request.chat.ChatPostMessageRequest;
+import com.slack.api.methods.request.files.FilesUploadV2Request;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.files.FilesUploadV2Response;
+import com.slack.api.model.File;
+import com.slack.api.model.File.ShareDetail;
+import com.slack.api.model.File.Shares;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.configuration.DefaultSettings;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.MultiProcessorUseCase;
+import org.apache.nifi.annotation.documentation.ProcessorConfiguration;
+import org.apache.nifi.annotation.documentation.SeeAlso;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.documentation.UseCase;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.annotation.lifecycle.OnStopped;
+import org.apache.nifi.components.AllowableValue;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.Validator;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.flowfile.attributes.CoreAttributes;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.DataUnit;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.processors.slack.consume.ConsumeSlackUtil;
+import org.apache.nifi.processors.slack.util.ChannelMapper;
+import org.apache.nifi.processors.slack.util.RateLimit;
+import org.apache.nifi.stream.io.StreamUtils;
+import org.apache.nifi.util.FormatUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+@InputRequirement(Requirement.INPUT_REQUIRED)
+@CapabilityDescription("""
+Posts a message to the specified Slack channel. The content of the message 
can be either a user-defined message that makes use of Expression Language or
+the contents of the FlowFile can be sent as the message. If sending a 
user-defined message, the contents of the FlowFile may also be optionally 
uploaded as
+a file attachment.
+""")
+@SeeAlso({ListenSlack.class, ConsumeSlack.class})
+@Tags({"slack", "conversation", "chat.postMessage", "social media", "team", 
"text", "unstructured", "write", "upload", "send", "publish"})
+@WritesAttributes({
+@WritesAttribute(attribute = "slack.channel.id", description = "The ID of 
the Slack Channel from which the messages were retrieved"),
+@WritesAttribute(attribute = "slack.ts", description = "The timestamp of 
the slack messages that was sent; this is used by Slack as a unique identifier")
+})
+@DefaultSettings(yieldDuration = "3 sec")
+@UseCase(
+description = "Send specific text as a message to Slack, optionally 
including the FlowFile's contents as an attached file.",
+configuration = """
+Set "Access Token" to the value of your Slack OAuth Access Token.
+Set "Channel" to the ID of the channel or the name of the channel 
prefixed with the # symbol. For example, "C0123456789" or "#general".
+

Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


markap14 commented on code in PR #8120:
URL: https://github.com/apache/nifi/pull/8120#discussion_r1414495581


##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/processors/slack/PublishSlack.java:
##
@@ -0,0 +1,513 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.processors.slack;
+
+import com.slack.api.bolt.App;
+import com.slack.api.bolt.AppConfig;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.request.chat.ChatPostMessageRequest;
+import com.slack.api.methods.request.files.FilesUploadV2Request;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.files.FilesUploadV2Response;
+import com.slack.api.model.File;
+import com.slack.api.model.File.ShareDetail;
+import com.slack.api.model.File.Shares;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.configuration.DefaultSettings;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.MultiProcessorUseCase;
+import org.apache.nifi.annotation.documentation.ProcessorConfiguration;
+import org.apache.nifi.annotation.documentation.SeeAlso;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.documentation.UseCase;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.annotation.lifecycle.OnStopped;
+import org.apache.nifi.components.AllowableValue;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.Validator;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.flowfile.attributes.CoreAttributes;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.DataUnit;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.processors.slack.consume.ConsumeSlackUtil;
+import org.apache.nifi.processors.slack.util.ChannelMapper;
+import org.apache.nifi.processors.slack.util.RateLimit;
+import org.apache.nifi.stream.io.StreamUtils;
+import org.apache.nifi.util.FormatUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+@InputRequirement(Requirement.INPUT_REQUIRED)
+@CapabilityDescription("""
+Posts a message to the specified Slack channel. The content of the message 
can be either a user-defined message that makes use of Expression Language or
+the contents of the FlowFile can be sent as the message. If sending a 
user-defined message, the contents of the FlowFile may also be optionally 
uploaded as
+a file attachment.
+""")
+@SeeAlso({ListenSlack.class, ConsumeSlack.class})
+@Tags({"slack", "conversation", "chat.postMessage", "social media", "team", 
"text", "unstructured", "write", "upload", "send", "publish"})
+@WritesAttributes({
+@WritesAttribute(attribute = "slack.channel.id", description = "The ID of 
the Slack Channel from which the messages were retrieved"),
+@WritesAttribute(attribute = "slack.ts", description = "The timestamp of 
the slack messages that was sent; this is used by Slack as a unique identifier")
+})
+@DefaultSettings(yieldDuration = "3 sec")
+@UseCase(
+description = "Send specific text as a message to Slack, optionally 
including the FlowFile's contents as an attached file.",
+configuration = """
+Set "Access Token" to the value of your Slack OAuth Access Token.
+Set "Channel" to the ID of the channel or the name of the channel 
prefixed with the # symbol. For example, "C0123456789" or "#general".
+Set 

Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


markap14 commented on code in PR #8120:
URL: https://github.com/apache/nifi/pull/8120#discussion_r1414488743


##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/processors/slack/util/RateLimit.java:
##
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.processors.slack.util;
+
+import org.apache.nifi.logging.ComponentLog;
+
+import java.util.Date;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class RateLimit {
+private final AtomicLong nextRequestTime = new AtomicLong(0L);
+private final ComponentLog logger;
+
+public RateLimit(final ComponentLog logger) {
+this.logger = logger;
+}
+
+public void retryAfter(final int seconds) {

Review Comment:
   Yeah, good call.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


markap14 commented on code in PR #8120:
URL: https://github.com/apache/nifi/pull/8120#discussion_r1414486316


##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/pom.xml:
##
@@ -146,6 +142,11 @@
 nifi-proxy-configuration-api
 test
 
+
+org.apache.nifi
+nifi-api
+compile

Review Comment:
   Nope, not sure how that happened :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


exceptionfactory commented on code in PR #8120:
URL: https://github.com/apache/nifi/pull/8120#discussion_r1414460826


##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/pom.xml:
##
@@ -146,6 +142,11 @@
 nifi-proxy-configuration-api
 test
 
+
+org.apache.nifi
+nifi-api
+compile

Review Comment:
   Is there a reason for this change? The `nifi-api` should be provided.



##
nifi-nar-bundles/nifi-slack-bundle/nifi-slack-processors/src/main/java/org/apache/nifi/processors/slack/PublishSlack.java:
##
@@ -0,0 +1,513 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.nifi.processors.slack;
+
+import com.slack.api.bolt.App;
+import com.slack.api.bolt.AppConfig;
+import com.slack.api.methods.MethodsClient;
+import com.slack.api.methods.request.chat.ChatPostMessageRequest;
+import com.slack.api.methods.request.files.FilesUploadV2Request;
+import com.slack.api.methods.response.chat.ChatPostMessageResponse;
+import com.slack.api.methods.response.files.FilesUploadV2Response;
+import com.slack.api.model.File;
+import com.slack.api.model.File.ShareDetail;
+import com.slack.api.model.File.Shares;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.InputRequirement.Requirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.configuration.DefaultSettings;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.MultiProcessorUseCase;
+import org.apache.nifi.annotation.documentation.ProcessorConfiguration;
+import org.apache.nifi.annotation.documentation.SeeAlso;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.documentation.UseCase;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.annotation.lifecycle.OnStopped;
+import org.apache.nifi.components.AllowableValue;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.components.Validator;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.flowfile.attributes.CoreAttributes;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.DataUnit;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+import org.apache.nifi.processors.slack.consume.ConsumeSlackUtil;
+import org.apache.nifi.processors.slack.util.ChannelMapper;
+import org.apache.nifi.processors.slack.util.RateLimit;
+import org.apache.nifi.stream.io.StreamUtils;
+import org.apache.nifi.util.FormatUtils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+@InputRequirement(Requirement.INPUT_REQUIRED)
+@CapabilityDescription("""
+Posts a message to the specified Slack channel. The content of the message 
can be either a user-defined message that makes use of Expression Language or
+the contents of the FlowFile can be sent as the message. If sending a 
user-defined message, the contents of the FlowFile may also be optionally 
uploaded as
+a file attachment.
+""")
+@SeeAlso({ListenSlack.class, ConsumeSlack.class})
+@Tags({"slack", "conversation", "chat.postMessage", "social media", "team", 
"text", "unstructured", "write", "upload", "send", "publish"})
+@WritesAttributes({
+@WritesAttribute(attribute = "slack.channel.id", description = "The ID of 
the Slack Channel from which the messages were retrieved"),
+@WritesAttribute(attribute = "slack.ts", description = "The timestamp of 
the slack messages that was sent; this is used by Slack as a unique identifier")
+})
+@DefaultSettings(yieldDuration = "3 sec")
+@UseCase(
+description = "Send specific text as a 

[PR] NIFI-12331: Added PublishSlack Processor [nifi]

2023-12-04 Thread via GitHub


markap14 opened a new pull request, #8120:
URL: https://github.com/apache/nifi/pull/8120

   
   
   
   
   
   
   
   
   
   
   
   
   
   # Summary
   
   [NIFI-0](https://issues.apache.org/jira/browse/NIFI-0)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [ ] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue 
created
   
   ### Pull Request Tracking
   
   - [ ] Pull Request title starts with Apache NiFi Jira issue number, such as 
`NIFI-0`
   - [ ] Pull Request commit message starts with Apache NiFi Jira issue number, 
as such `NIFI-0`
   
   ### Pull Request Formatting
   
   - [ ] Pull Request based on current revision of the `main` branch
   - [ ] Pull Request refers to a feature branch with one commit containing 
changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request 
creation.
   
   ### Build
   
   - [ ] Build completed using `mvn clean install -P contrib-check`
 - [ ] JDK 21
   
   ### Licensing
   
   - [ ] New dependencies are compatible with the [Apache License 
2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License 
Policy](https://www.apache.org/legal/resolved.html)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` 
files
   
   ### Documentation
   
   - [ ] Documentation formatting appears as expected in rendered files
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org