Skip to content

Commit 6c61315

Browse files
authored
Merge pull request #41 from ddebrunner/doc_03
Improve docs and update to 0.3.
2 parents 0b29888 + 0d6d708 commit 6c61315

File tree

32 files changed

+1532
-1080
lines changed

32 files changed

+1532
-1080
lines changed

com.ibm.streamsx.slack/com.ibm.streamsx.slack.services/message.spl

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,43 @@ use com.ibm.streamsx.topology::String ;
1313
use com.ibm.streamsx.topology.topic::Subscribe ;
1414

1515
/**
16-
* Microservice sending messages to a Slack incoming webhook.
16+
* Microservice sending messages to a Slack incoming web hook.
1717
*
1818
* Subscribes to `Json` topic and sends each JSON tuple as-is
19-
* as the request body to the webhook. Any application can
20-
* thus send messages to the Slack webhook by publishing a JSON
19+
* as the request body to the web hook. Any application can
20+
* thus send messages to the Slack web hook by publishing a JSON
2121
* message to the topic this microservice is subscribing to.
2222
*
23-
* The JSON can have any properties accepted by the webhook
23+
* The JSON can have any properties accepted by the web hook
2424
* minimally having `text` property defining the text of the message.
2525
*
2626
* Additionally the topic with type `String` is subscribed to allowing
2727
* applications to publish simple text messages using the `String` schema.
28-
* Each tuple is converted to a JSON object for the webhook with
28+
* Each tuple is converted to a JSON object for the web hook with
2929
* a single property `text` with the value of the tuple.
3030
*
31-
* Slack incoming webhooks are described here: [https://api.slack.com/incoming-webhooks]
31+
* Slack incoming web hooks are described here: [https://api.slack.com/incoming-webhooks]
3232
*
3333
* **Microservice topic**
3434
*
3535
* The topic subscribed to is set by the submission time parameter `topic`
36-
* defaulting to `streamsx/slack/messages`.
36+
* defaulting to `streamsx/slack/messages`. The subscribed types are:
37+
* * [Json] - Each JSON object is the message body.
38+
* * [String] - Each string is the message text to send.
3739
*
3840
* **Slack webhook URL**
3941
*
4042
* The Slack incoming webhook is defined by the `slackUrl` property in
4143
* a Streams application configuration. The name of the application
42-
* configuration is set by the submission time parameter `applicationConfigurationName` defaulting to `slackConfiguration`.
44+
* configuration is set by the submission time parameter `slackConfiguration` defaulting to `slack`.
4345
*
44-
* @param slack Name of the application configuration containing the `slackUrl` property. Defaults to the submission time parameter `slack` which in turn defaults to `slack`.
46+
* @param slackConfiguration Name of the application configuration containing the `slackUrl` property. Defaults to the submission time parameter `slackConfiguration` which in turn defaults to `slack`.
4547
* @param topic Topic name service subscribes. Defaults to the submission time parameter `topic` which in turn defaults to `streamsx/slack/messages`.
4648
*/
4749
public composite SlackMessageService
4850
{
4951
param
50-
expression<rstring> $slack : getSubmissionTimeValue("slack", "slack");
52+
expression<rstring> $slackConfiguration : getSubmissionTimeValue("slackConfiguration", "slack");
5153
expression<rstring> $topic : getSubmissionTimeValue("topic", "streamsx/slack/messages");
5254

5355
graph
@@ -79,6 +81,6 @@ public composite SlackMessageService
7981
() as SendMessage = SendSlackMessage(JsonMessages, TextAsJson)
8082
{
8183
param
82-
applicationConfigurationName : $slack ;
84+
slackConfiguration : $slackConfiguration ;
8385
}
8486
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// ****************************************************************************
2+
// * Copyright (C) 2018, International Business Machines Corporation *
3+
// ****************************************************************************
4+
5+
/**
6+
* Slack microservices.
7+
*
8+
* Microservices provide ready to use Streams applications
9+
* that can be comined to build a complete applications.
10+
*
11+
* [SendSlackMessage] supports sending tuples to a Slack channel
12+
* through an incoming web hook.
13+
*/
14+
15+
namespace com.ibm.streamsx.slack.services;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// ****************************************************************************
2+
// * Copyright (C) 2018, International Business Machines Corporation *
3+
// ****************************************************************************
4+
5+
/**
6+
* Interaction with Slack.
7+
*
8+
* [SendSlackMessage] supports sending tuples to a Slack channel
9+
* through an incoming web hook.
10+
*/
11+
12+
namespace com.ibm.streamsx.slack;

com.ibm.streamsx.slack/com.ibm.streamsx.slack/types.spl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@ namespace com.ibm.streamsx.slack;
99
*/
1010
type Message = tuple<rstring text>;
1111

12-
/**
13-
* Slack message with emoji.
14-
* Extends [Message] to add the `icon_emoji` attribute to
15-
* specify the emoji of the message.
16-
*/
17-
type EmojiMessage = Message, tuple<rstring icon_emoji>;
18-
1912
/**
2013
* Standard JSON schema.
2114
*/
2215
type Json = tuple<rstring jsonString>;
16+
17+
/**
18+
* Standard String schema.
19+
*/
20+
type String = tuple<rstring string>;

com.ibm.streamsx.slack/impl/java/src/com/ibm/streamsx/slack/SendSlackMessage.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,18 @@
5050
)
5151
@InputPorts({
5252
@InputPortSet(
53-
description="Each tuple is converted to JSON and sent as a message to the "
54-
+ "Slack incoming Webhook. The schema must include a ",
53+
description="Each tuple is converted to JSON and sent as a message to the "
54+
+ "Slack incoming web hook.\\n\\n"
55+
+ "The port's schema must be one of:\\n"
56+
+ " * [Json] - Streams standard JSON schema. Each tuple represents a JSON object and is used as the message contents. This allows the application to use any field supported by the Slack web hook.\\n"
57+
+ " * A single `rstring` or `ustring` attribute (which includes the default string exchange schema [String]). The value of the string is used as the `text` property in the JSON message object.\\n"
58+
+ " * A schema containing an attribute named `text` with type `rstring` or `ustring`. The value of the `text` attributed is used as the `text` property in the JSON message object. [Message] type may be used to augment other schemas.\\n",
59+
5560
cardinality=1,
5661
optional=false,
5762
windowingMode=WindowMode.NonWindowed,
5863
windowPunctuationInputMode=WindowPunctuationInputMode.Oblivious)})
5964
@Libraries({
60-
// Include javax.mail libraries.
6165
"opt/downloaded/*"
6266
})
6367
public class SendSlackMessage extends TupleConsumer {
@@ -68,10 +72,17 @@ public class SendSlackMessage extends TupleConsumer {
6872
// ------------------------------------------------------------------------
6973

7074
protected static final String DESC_OPERATOR =
71-
"Sends messages to a Slack incoming WebHook."
75+
"Sends messages to a Slack incoming web hook."
7276
+ "\\n"
73-
+ "Each incoming tuple results in a message sent to the incoming Webhook."
74-
+ "The tuple is converted to JSON and sent to the incoming Webhook.";
77+
+ "Each incoming tuple results in a message sent to the incoming web hook."
78+
+ "The tuple is converted to JSON and sent to the incoming web hook."
79+
+ "\\n\\n"
80+
+ "This operator forms the basis for the [SlackMessageService] microservice."
81+
+ "\\n\\n"
82+
+ "Guide on Slack incoming web hooks: [https://api.slack.com/incoming-webhooks]\\n"
83+
84+
85+
;
7586

7687
@ContextCheck(runtime=false)
7788
public static void validateSchema(OperatorContextChecker checker) {
@@ -123,18 +134,17 @@ private static boolean isStringAttribute(StreamSchema schema) {
123134

124135
@Parameter(
125136
optional=true,
126-
description="Specifies the Slack incoming WebHook URL to send messages to."
137+
description="Specifies the Slack incoming web hook URL to send messages to."
127138
)
128139
public void setSlackUrl(String slackUrl) throws IOException {
129140
this.slackUrl = slackUrl;
130141
}
131142

132143
@Parameter(
133144
optional=true,
134-
description="Name of application configuration containing operator parameters. "
135-
+ "Parameters of type Attribute should be specified in the form of a String."
145+
description="Name of application configuration containing operator parameters. The incoming web hook URL can be set in the application configuration by setting the `slackUrl` property. This is more flexible than the operator parameter as the incoming web hook URL can be changed while the application is running."
136146
)
137-
public void setApplicationConfigurationName(String applicationConfigurationName) throws IOException {
147+
public void setSlackConfiguration(String applicationConfigurationName) throws IOException {
138148
if (!applicationConfigurationName.isEmpty()) {
139149
this.applicationConfigurationName = applicationConfigurationName;
140150
}

com.ibm.streamsx.slack/info.xml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,12 @@
33
xmlns:info="http://www.ibm.com/xmlns/prod/streams/spl/toolkitInfo">
44
<info:identity>
55
<info:name>com.ibm.streamsx.slack</info:name>
6-
<info:description></info:description>
7-
<info:version>0.2.0</info:version>
6+
<info:description>Integration with Slack digital workspace.
7+
8+
Typical use is to send alerts or informational messages from
9+
a Streams application to Slack channel using a incoming web hook.
10+
</info:description>
11+
<info:version>0.3.0</info:version>
812
<info:requiredProductVersion>4.2.0.0</info:requiredProductVersion>
913
</info:identity>
1014
<info:dependencies/>

docs/doc/spldoc/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)