Skip to content

Commit 113ebdf

Browse files
authored
Merge pull request #8 from streammachineio/kafka-exporters
Kafka exporters
2 parents 4d43b0b + 21305f8 commit 113ebdf

File tree

3 files changed

+136
-1
lines changed

3 files changed

+136
-1
lines changed

src/main/kotlin/io/streammachine/api/cli/Strm.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class Strm : CliktCommand(
3737
Streams(),
3838
Outputs(),
3939
Exporters(),
40+
KafkaExporters(),
41+
KafkaExportersUsers(),
4042
ConsentLevels(),
4143
Sinks()
4244
)
@@ -47,4 +49,4 @@ class Strm : CliktCommand(
4749
printUpdateMessageIfAvailable()
4850
initializeFuel()
4951
}
50-
}
52+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
package io.streammachine.api.cli.commands
2+
3+
import com.github.ajalt.clikt.core.CliktCommand
4+
import com.github.ajalt.clikt.core.subcommands
5+
import com.github.ajalt.clikt.parameters.arguments.argument
6+
import com.github.ajalt.clikt.parameters.options.option
7+
import com.github.ajalt.clikt.parameters.options.required
8+
import com.github.ajalt.clikt.parameters.types.choice
9+
import com.github.ajalt.clikt.parameters.types.enum
10+
import com.github.ajalt.clikt.parameters.types.int
11+
import com.github.ajalt.clikt.parameters.types.restrictTo
12+
import com.github.kittinunf.fuel.gson.jsonBody
13+
import com.github.kittinunf.fuel.httpDelete
14+
import com.github.kittinunf.fuel.httpGet
15+
import com.github.kittinunf.fuel.httpPut
16+
import io.streammachine.api.cli.common.ExporterCreateRequest
17+
import io.streammachine.api.cli.common.ExporterType
18+
import io.streammachine.api.cli.common.SinkType
19+
import io.streammachine.api.cli.common.printResponse
20+
21+
class KafkaExporters : CliktCommand(
22+
name = "kafka-exporters",
23+
help = "Kafka exporters and details."
24+
) {
25+
init {
26+
subcommands(
27+
KafkaExportersGet(),
28+
KafkaExportersCreate(),
29+
KafkaExportersDelete()
30+
)
31+
}
32+
33+
override fun run() = Unit
34+
}
35+
36+
open class KafkaExportersGet : CliktCommand(
37+
name = "get",
38+
help = "Get a specific exporter by name for a stream"
39+
) {
40+
internal val streamName by argument("stream-name", help = "Name of the stream that is being exporter")
41+
42+
override fun run() {
43+
"/v1/kafka-exporters/$streamName".httpGet().printResponse()
44+
}
45+
}
46+
47+
open class KafkaExportersDelete : CliktCommand(
48+
name = "delete",
49+
help = "Delete a Kafka exporter by stream name"
50+
) {
51+
internal val streamName by argument("stream-name", help = "Name of the stream that is being exported")
52+
override fun run() {
53+
"/v1/kafka-exporters/$streamName".httpDelete().printResponse()
54+
}
55+
}
56+
57+
open class KafkaExportersCreate : CliktCommand(
58+
name = "create",
59+
help = "Create a new Kafka exporter"
60+
) {
61+
internal val streamName by argument("stream-name", help = "Name of the stream that is being exported")
62+
override fun run() {
63+
"/v1/kafka-exporters/$streamName".httpPut().printResponse()
64+
}
65+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package io.streammachine.api.cli.commands
2+
3+
import com.github.ajalt.clikt.core.CliktCommand
4+
import com.github.ajalt.clikt.core.subcommands
5+
import com.github.ajalt.clikt.parameters.arguments.argument
6+
import com.github.kittinunf.fuel.httpDelete
7+
import com.github.kittinunf.fuel.httpGet
8+
import com.github.kittinunf.fuel.httpPost
9+
import io.streammachine.api.cli.common.printResponse
10+
11+
class KafkaExportersUsers : CliktCommand(
12+
name = "kafka-exporters-users",
13+
help = "View users on kafka-exporters and their details."
14+
) {
15+
init {
16+
subcommands(
17+
kafkaExportersUsersList(),
18+
KafkaExportersUsersGetOne(),
19+
KafkaExportersUsersCreate(),
20+
KafkaExportersUsersDelete()
21+
)
22+
}
23+
24+
override fun run() = Unit
25+
}
26+
27+
open class kafkaExportersUsersList : CliktCommand(
28+
name = "list",
29+
help = "Get all users on a certain Kafka exporter"
30+
) {
31+
internal val streamName by argument("stream-name", help = "Name of the stream that is being exporter")
32+
33+
override fun run() {
34+
"/v1/kafka-exporters-users/$streamName".httpGet().printResponse()
35+
}
36+
}
37+
open class KafkaExportersUsersGetOne : CliktCommand(
38+
name = "get",
39+
help = "Get a specific user on a Kafka exporter by stream name"
40+
) {
41+
internal val streamName by argument("stream-name", help = "Name of the stream that is being exported")
42+
internal val clientId by argument("client-id", help = "The client id that identifies the Kafka Consumer")
43+
44+
override fun run() {
45+
"/v1/kafka-exporters-users/$streamName/$clientId".httpGet().printResponse()
46+
}
47+
}
48+
49+
open class KafkaExportersUsersDelete : CliktCommand(
50+
name = "delete",
51+
help = "Delete a specific exporter by name for a stream"
52+
) {
53+
internal val streamName by argument("stream-name", help = "Name of the stream that is being exported")
54+
internal val clientId by argument("client-id", help = "The client id that identifies the Kafka Consumer")
55+
override fun run() {
56+
"/v1/kafka-exporters-users/$streamName/$clientId".httpDelete().printResponse()
57+
}
58+
}
59+
60+
open class KafkaExportersUsersCreate : CliktCommand(
61+
name = "create",
62+
help = "Create a new user on an existing Kafka exporter"
63+
) {
64+
internal val streamName by argument("stream-name", help = "Name of the stream that is being exported")
65+
override fun run() {
66+
"/v1/kafka-exporters-users/$streamName".httpPost().printResponse()
67+
}
68+
}

0 commit comments

Comments
 (0)