cloudmunda 0.1.0 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0224d338965547c5fb715c3e3b3f6443606fe3688ecf3bef13c7fedd10ded234
4
- data.tar.gz: ba347d1a7aa1624624d30d3459110c81e0a6ff98e9e4d06dfb9c9c08e7d75dd3
3
+ metadata.gz: f7bc11e07d3ec2aa7bd21257979a3fff0e144e5be7dd15bf40a8a56ad319ab37
4
+ data.tar.gz: 2b67cee925aeb9c29cbf1dd7890b388d8a6fc0714307d895e4cf72fb0cd68aeb
5
5
  SHA512:
6
- metadata.gz: 72ce642c5be6dc2a8d12585c88aaa8c89f9ac6a8d89ee7ae83f0dae71788689b6f09cbbce4543582c1f1af734045dc230b44bb33041d7a57cd7e705611df9625
7
- data.tar.gz: 49d5cf58b015e80c233eebb989a0c855fcd59b91a252aaf91e7bf127c068ad027eb119a491284e769b1be04518234c7506f353ddd6e6fb093f84a79c0195a04b
6
+ metadata.gz: 9923bd0036513545ac6fb1348d27acced388c39d158e8650f2c0106812ce689c5bdfc75d47df18e6edaae1142ae15bbb6f05f1e4309b9cf182a859b9885b350b
7
+ data.tar.gz: 1a45f2b528c6ba450467cf4184a2785af77eb0448f583559469c2e5bc78e7d8710120ea22d273b0698213e9f1bb1922d1dc8c74c580546001d261bef20caf370
data/.rubocop.yml CHANGED
@@ -1,13 +1,11 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
1
3
  AllCops:
2
4
  TargetRubyVersion: 2.6
5
+ NewCops: enable
3
6
 
4
- Style/StringLiterals:
5
- Enabled: true
6
- EnforcedStyle: double_quotes
7
-
8
- Style/StringLiteralsInInterpolation:
9
- Enabled: true
10
- EnforcedStyle: double_quotes
7
+ Style/Documentation:
8
+ Enabled: false
11
9
 
12
10
  Layout/LineLength:
13
11
  Max: 120
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,39 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2022-02-25 21:56:34 UTC using RuboCop version 1.23.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 4
10
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
11
+ Metrics/AbcSize:
12
+ Max: 52
13
+
14
+ # Offense count: 1
15
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
16
+ # IgnoredMethods: refine
17
+ Metrics/BlockLength:
18
+ Max: 43
19
+
20
+ # Offense count: 1
21
+ # Configuration parameters: CountComments, CountAsOne.
22
+ Metrics/ClassLength:
23
+ Max: 117
24
+
25
+ # Offense count: 5
26
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
27
+ Metrics/MethodLength:
28
+ Max: 45
29
+
30
+ # Offense count: 8
31
+ Naming/AccessorMethodName:
32
+ Exclude:
33
+ - 'lib/cloudmunda/cli/worker.rb'
34
+ - 'lib/cloudmunda/zeebe/client.rb'
35
+
36
+ # Offense count: 1
37
+ Style/OpenStructUse:
38
+ Exclude:
39
+ - 'lib/cloudmunda/api/o_auth_resource.rb'
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.1.3] - 2021-02-25
4
+ - Fix bug in `Supervisor#start` that would lead to not gracefully shutting down workers.
5
+
6
+ ## [0.1.2] - 2021-02-25
7
+ - Add class method `runs_in_development` to Cloudmunda::Worker. This way you can run only specific jobs in development.
8
+
9
+ ## [0.1.1] - 2021-12-16
10
+
11
+ - Camunda Cloud Access Token Creation
12
+ - Zeebe task workers
13
+ - Camunda Cloud Usertasks graphQL connection
14
+
3
15
  ## [0.1.0] - 2021-12-16
4
16
 
5
- - Initial release
17
+ - Initial release
data/Gemfile CHANGED
@@ -1,12 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in cloudmunda.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
9
-
10
- gem "rspec", "~> 3.0"
11
-
12
- gem "rubocop", "~> 1.21"
8
+ gem 'rails', '>= 6'
9
+ gem 'rake', '~> 13.0'
10
+ gem 'rspec', '~> 3.0'
11
+ gem 'rubocop', '~> 1.21'
data/Gemfile.lock CHANGED
@@ -1,19 +1,151 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudmunda (0.1.0)
4
+ cloudmunda (0.1.3)
5
+ concurrent-ruby (~> 1.0)
6
+ rest-client (~> 2.0)
7
+ zeebe-client (~> 0.16)
5
8
 
6
9
  GEM
7
10
  remote: https://rubygems.org/
8
11
  specs:
12
+ actioncable (6.1.4.1)
13
+ actionpack (= 6.1.4.1)
14
+ activesupport (= 6.1.4.1)
15
+ nio4r (~> 2.0)
16
+ websocket-driver (>= 0.6.1)
17
+ actionmailbox (6.1.4.1)
18
+ actionpack (= 6.1.4.1)
19
+ activejob (= 6.1.4.1)
20
+ activerecord (= 6.1.4.1)
21
+ activestorage (= 6.1.4.1)
22
+ activesupport (= 6.1.4.1)
23
+ mail (>= 2.7.1)
24
+ actionmailer (6.1.4.1)
25
+ actionpack (= 6.1.4.1)
26
+ actionview (= 6.1.4.1)
27
+ activejob (= 6.1.4.1)
28
+ activesupport (= 6.1.4.1)
29
+ mail (~> 2.5, >= 2.5.4)
30
+ rails-dom-testing (~> 2.0)
31
+ actionpack (6.1.4.1)
32
+ actionview (= 6.1.4.1)
33
+ activesupport (= 6.1.4.1)
34
+ rack (~> 2.0, >= 2.0.9)
35
+ rack-test (>= 0.6.3)
36
+ rails-dom-testing (~> 2.0)
37
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
38
+ actiontext (6.1.4.1)
39
+ actionpack (= 6.1.4.1)
40
+ activerecord (= 6.1.4.1)
41
+ activestorage (= 6.1.4.1)
42
+ activesupport (= 6.1.4.1)
43
+ nokogiri (>= 1.8.5)
44
+ actionview (6.1.4.1)
45
+ activesupport (= 6.1.4.1)
46
+ builder (~> 3.1)
47
+ erubi (~> 1.4)
48
+ rails-dom-testing (~> 2.0)
49
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
50
+ activejob (6.1.4.1)
51
+ activesupport (= 6.1.4.1)
52
+ globalid (>= 0.3.6)
53
+ activemodel (6.1.4.1)
54
+ activesupport (= 6.1.4.1)
55
+ activerecord (6.1.4.1)
56
+ activemodel (= 6.1.4.1)
57
+ activesupport (= 6.1.4.1)
58
+ activestorage (6.1.4.1)
59
+ actionpack (= 6.1.4.1)
60
+ activejob (= 6.1.4.1)
61
+ activerecord (= 6.1.4.1)
62
+ activesupport (= 6.1.4.1)
63
+ marcel (~> 1.0.0)
64
+ mini_mime (>= 1.1.0)
65
+ activesupport (6.1.4.1)
66
+ concurrent-ruby (~> 1.0, >= 1.0.2)
67
+ i18n (>= 1.6, < 2)
68
+ minitest (>= 5.1)
69
+ tzinfo (~> 2.0)
70
+ zeitwerk (~> 2.3)
9
71
  ast (2.4.2)
72
+ builder (3.2.4)
73
+ concurrent-ruby (1.1.9)
74
+ crass (1.0.6)
10
75
  diff-lcs (1.4.4)
76
+ domain_name (0.5.20190701)
77
+ unf (>= 0.0.5, < 1.0.0)
78
+ erubi (1.10.0)
79
+ globalid (1.0.0)
80
+ activesupport (>= 5.0)
81
+ google-protobuf (3.19.1-x86_64-darwin)
82
+ googleapis-common-protos-types (1.3.0)
83
+ google-protobuf (~> 3.14)
84
+ grpc (1.42.0-x86_64-darwin)
85
+ google-protobuf (~> 3.18)
86
+ googleapis-common-protos-types (~> 1.0)
87
+ http-accept (1.7.0)
88
+ http-cookie (1.0.4)
89
+ domain_name (~> 0.5)
90
+ i18n (1.8.11)
91
+ concurrent-ruby (~> 1.0)
92
+ loofah (2.13.0)
93
+ crass (~> 1.0.2)
94
+ nokogiri (>= 1.5.9)
95
+ mail (2.7.1)
96
+ mini_mime (>= 0.1.1)
97
+ marcel (1.0.2)
98
+ method_source (1.0.0)
99
+ mime-types (3.4.1)
100
+ mime-types-data (~> 3.2015)
101
+ mime-types-data (3.2022.0105)
102
+ mini_mime (1.1.2)
103
+ minitest (5.14.4)
104
+ netrc (0.11.0)
105
+ nio4r (2.5.8)
106
+ nokogiri (1.12.5-x86_64-darwin)
107
+ racc (~> 1.4)
11
108
  parallel (1.21.0)
12
109
  parser (3.0.3.2)
13
110
  ast (~> 2.4.1)
111
+ racc (1.6.0)
112
+ rack (2.2.3)
113
+ rack-test (1.1.0)
114
+ rack (>= 1.0, < 3)
115
+ rails (6.1.4.1)
116
+ actioncable (= 6.1.4.1)
117
+ actionmailbox (= 6.1.4.1)
118
+ actionmailer (= 6.1.4.1)
119
+ actionpack (= 6.1.4.1)
120
+ actiontext (= 6.1.4.1)
121
+ actionview (= 6.1.4.1)
122
+ activejob (= 6.1.4.1)
123
+ activemodel (= 6.1.4.1)
124
+ activerecord (= 6.1.4.1)
125
+ activestorage (= 6.1.4.1)
126
+ activesupport (= 6.1.4.1)
127
+ bundler (>= 1.15.0)
128
+ railties (= 6.1.4.1)
129
+ sprockets-rails (>= 2.0.0)
130
+ rails-dom-testing (2.0.3)
131
+ activesupport (>= 4.2.0)
132
+ nokogiri (>= 1.6)
133
+ rails-html-sanitizer (1.4.2)
134
+ loofah (~> 2.3)
135
+ railties (6.1.4.1)
136
+ actionpack (= 6.1.4.1)
137
+ activesupport (= 6.1.4.1)
138
+ method_source
139
+ rake (>= 0.13)
140
+ thor (~> 1.0)
14
141
  rainbow (3.0.0)
15
142
  rake (13.0.6)
16
143
  regexp_parser (2.2.0)
144
+ rest-client (2.1.0)
145
+ http-accept (>= 1.7.0, < 2.0)
146
+ http-cookie (>= 1.0.2, < 2.0)
147
+ mime-types (>= 1.16, < 4.0)
148
+ netrc (~> 0.8)
17
149
  rexml (3.2.5)
18
150
  rspec (3.10.0)
19
151
  rspec-core (~> 3.10.0)
@@ -40,13 +172,33 @@ GEM
40
172
  rubocop-ast (1.15.0)
41
173
  parser (>= 3.0.1.1)
42
174
  ruby-progressbar (1.11.0)
175
+ sprockets (4.0.2)
176
+ concurrent-ruby (~> 1.0)
177
+ rack (> 1, < 3)
178
+ sprockets-rails (3.4.1)
179
+ actionpack (>= 5.2)
180
+ activesupport (>= 5.2)
181
+ sprockets (>= 3.0.0)
182
+ thor (1.1.0)
183
+ tzinfo (2.0.4)
184
+ concurrent-ruby (~> 1.0)
185
+ unf (0.1.4)
186
+ unf_ext
187
+ unf_ext (0.0.8)
43
188
  unicode-display_width (2.1.0)
189
+ websocket-driver (0.7.5)
190
+ websocket-extensions (>= 0.1.0)
191
+ websocket-extensions (0.1.5)
192
+ zeebe-client (0.16.1)
193
+ grpc (~> 1.32)
194
+ zeitwerk (2.5.1)
44
195
 
45
196
  PLATFORMS
46
197
  x86_64-darwin-20
47
198
 
48
199
  DEPENDENCIES
49
200
  cloudmunda!
201
+ rails (>= 6)
50
202
  rake (~> 13.0)
51
203
  rspec (~> 3.0)
52
204
  rubocop (~> 1.21)
data/README.md CHANGED
@@ -1,8 +1,16 @@
1
1
  # Cloudmunda
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cloudmunda`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ This Ruby gem makes it easier to connect your Ruby (on Rails) app with Camunda Cloud. 🎉
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ The following is included:
6
+ - Ruby workers for Zeebe
7
+ - API wrapper for Camunda Cloud
8
+ - graphQL wrapper Usertasks
9
+
10
+ To use this library you need:
11
+
12
+ * a [Camunda Cloud Account](https://accounts.cloud.camunda.io/signup)
13
+ * your [Camunda client connection credentials](https://docs.camunda.io/docs/guides/getting-started/setup-client-connection-credentials/)
6
14
 
7
15
  ## Installation
8
16
 
@@ -20,9 +28,159 @@ Or install it yourself as:
20
28
 
21
29
  $ gem install cloudmunda
22
30
 
23
- ## Usage
31
+ ### Rails applications
32
+
33
+ If you're using this gem with a rails application, you could create a `config/initializers/cloudmunda.rb` file and add
34
+ the following:
35
+
36
+ ```ruby
37
+ Cloudmunda.configure do |config|
38
+ config.env = ENV['APP_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
39
+ config.logger = Logger.new($stdout)
40
+ config.timeout = 30
41
+ config.client_id = ENV['ZEEBE_CLIENT_ID']
42
+ config.client_secret = ENV['ZEEBE_CLIENT_SECRET']
43
+ config.zeebe_url = ENV['ZEEBE_URL']
44
+ config.auth_url = ENV['ZEEBE_AUTHORIZATION_SERVER_URL']
45
+ config.audience = ENV['ZEEBE_AUDIENCE']
46
+ config.graphql_url = ENV['GRAPHQL_URL']
47
+ end
48
+ ```
49
+
50
+ The values listed above are the default values that you can override.
51
+
52
+ ## Example Usage
53
+
54
+ This section will explain the usage as you were using a Rails application, but steps should be very similar within plain
55
+ Ruby apps or any other frameworks out there. Feel free to create an issue or PR if additional items are needed.
56
+
57
+ The idea of the example is that when a certain webhook comes in, a Slack message is sent. This might look like a bit
58
+ of overhead to use a business process engine for this, but it's just to show how the library works. Since we're
59
+ communicating with Slack, you'd need a Slack workspace. You can also change the code in the example to send an email or
60
+ just write something in the logs.
61
+
62
+ You can find all the code [here](https://github.com/lienvdsteen/cloudmunda-demo).
63
+
64
+ ### Add Slack and Cloudmunda gem
65
+ In your Gemfile add this line
66
+
67
+ ```ruby
68
+ gem 'cloudmunda'
69
+ gem 'slack-ruby-client' # this is just for our example
70
+ ```
71
+
72
+ Then run
73
+
74
+ ```shell
75
+ bundle install
76
+ ```
77
+
78
+ As said above, create a initializer file so that whenever you are interacting with them gem you have the right settings set:
79
+
80
+ ```shell
81
+ touch config/initializers/cloudmunda.rb
82
+ touch config/initializers/slack.rb # again, this is just for our example
83
+ ```
84
+
85
+ Then open the `cloudmunda.rb` file and copy the following in it:
86
+
87
+ ```ruby
88
+ Cloudmunda.configure do |config|
89
+ config.env = ENV['APP_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
90
+ config.logger = Logger.new($stdout)
91
+ config.timeout = 30
92
+ config.client_id = ENV['ZEEBE_CLIENT_ID']
93
+ config.client_secret = ENV['ZEEBE_CLIENT_SECRET']
94
+ config.zeebe_url = ENV['ZEEBE_URL']
95
+ config.auth_url = ENV['ZEEBE_AUTHORIZATION_SERVER_URL']
96
+ config.audience = ENV['ZEEBE_AUDIENCE']
97
+ config.graphql_url = ENV['GRAPHQL_URL']
98
+ end
99
+ ```
100
+
101
+ Then open the `slack.rb` file and copy the following
24
102
 
25
- TODO: Write usage instructions here
103
+ ```ruby
104
+ Slack.configure do |config|
105
+ config.token = ENV['SLACK_OAUTH_TOKEN']
106
+ end
107
+ ```
108
+
109
+ Note: this assumes you're using ENV variables, you can of course edit this to use something like `Settings.key` or
110
+ how you prefer it. Just make sure not to publish your secrets.
111
+
112
+ ### Deploy the diagram to your Camunda Cloud cluster
113
+ You can either import the [bpmn model example](/diagrams/demo.bpmn) as a diagram in your Camunda Cloud and
114
+ use the UI to deploy or you can start a console (`rails console`) and deploy the diagram with the gem.
115
+
116
+ ```ruby
117
+ Cloudmunda.client.deploy_process(processes: [name: "demo", definition: File.read('diagrams/demo.bpmn')])
118
+ ```
119
+
120
+ ### Create a worker
121
+
122
+ In `app/jobs` create a new file `demo_worker_job.rb` and copy paste the following:
123
+
124
+ ```ruby
125
+ class DemoWorkerJob
126
+ include ::Cloudmunda::Worker
127
+
128
+ type 'webhook-slack-announce'
129
+ max_jobs_to_activate 20
130
+ poll_interval 1
131
+ timeout 45
132
+
133
+ attr_reader :variables
134
+
135
+ def process(job)
136
+ slack_client.chat_postMessage(channel: '#general', text: 'a message', as_user: true)
137
+ end
138
+
139
+ private
140
+
141
+ def slack_client
142
+ @slack_client ||= ::Slack::Web::Client.new
143
+ end
144
+ end
145
+ ```
146
+
147
+ ### Setup the "webhook"
148
+ Add the following to your `routes.rb` file `get 'webhook/received', to: 'webhook#received'` and then create a file
149
+ `webhooks_controller.rb` in the controllers directory and copy paste the following:
150
+
151
+ ```ruby
152
+ class WebhookController < ApplicationController
153
+ def received
154
+ Cloudmunda.client.create_process_instance(
155
+ bpmnProcessId: 'cloudmunda-demo',
156
+ version: 1,
157
+ variables: {text: "hello"}.to_json
158
+ )
159
+
160
+ head :ok
161
+ end
162
+ end
163
+ ```
164
+
165
+ #### Run everything
166
+
167
+ Now everything should be able to execute. Lets start your rails server and then in another terminal tab run the following:
168
+
169
+ ````ruby
170
+ bundle exec cloudmunda \
171
+ --require .
172
+ --client-id $ZEEBE_CLIENT_ID \
173
+ --client-secret $ZEEBE_CLIENT_SECRET \
174
+ --zeebe-url $ZEEBE_URL \
175
+ --zeebe-auth-url $ZEEBE_AUTHORIZATION_SERVER_URL \
176
+ --audience $ZEEBE_AUDIENCE
177
+ ````
178
+
179
+ Then navigate to `localhost:3000/webhook/received`, what will happen is the following:
180
+ 1. It goes to the `received` endpoint in the `WebhookController`
181
+ 2. Here a new process instance is created on Camunda Cloud
182
+ 3. This will then trigger the next step in the diagram, which is the service task
183
+ 4. Through the grpc protocol our worker is linked with this service task and will be executed.
26
184
 
27
185
  ## Development
28
186
 
@@ -33,6 +191,11 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
33
191
  ## Contributing
34
192
 
35
193
  Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cloudmunda. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/cloudmunda/blob/main/CODE_OF_CONDUCT.md).
194
+ Looking for:
195
+ - unit testing: currently nothing is tested
196
+ - additional API endpoints
197
+ - additional graphQL endpoints
198
+ - general improvements
36
199
 
37
200
  ## License
38
201
 
@@ -41,3 +204,9 @@ The gem is available as open source under the terms of the [MIT License](https:/
41
204
  ## Code of Conduct
42
205
 
43
206
  Everyone interacting in the Cloudmunda project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cloudmunda/blob/main/CODE_OF_CONDUCT.md).
207
+
208
+ ## Credits
209
+
210
+ This gem is build on top of what [@gottfrois](https://github.com/gottfrois/) had build in his [beez](https://github.com/gottfrois/beez)
211
+ gem. Everything in this gem related to the Ruby workers is a taken from that gem. 👏 Cloudmunda would **not** be
212
+ possible without this.
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require "rubocop/rake_task"
8
+ require 'rubocop/rake_task'
9
9
 
10
10
  RuboCop::RakeTask.new
11
11
 
data/bin/console CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "bundler/setup"
5
- require "cloudmunda"
4
+ require 'bundler/setup'
5
+ require 'cloudmunda'
6
6
 
7
7
  # You can add fixtures and/or initialization code here to make experimenting
8
8
  # with your gem easier. You can also use a different console, if you like.
@@ -11,5 +11,5 @@ require "cloudmunda"
11
11
  # require "pry"
12
12
  # Pry.start
13
13
 
14
- require "irb"
14
+ require 'irb'
15
15
  IRB.start(__FILE__)
@@ -0,0 +1,47 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:modeler="http://camunda.org/schema/modeler/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" id="Definitions_0rbumvm" targetNamespace="http://bpmn.io/schema/bpmn" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="1.2.0">
3
+ <bpmn:process id="cloudmunda-demo" name="cloudmunda-demo" isExecutable="true">
4
+ <bpmn:startEvent id="StartEvent_1" name="Webhook received">
5
+ <bpmn:outgoing>Flow_0easrsr</bpmn:outgoing>
6
+ </bpmn:startEvent>
7
+ <bpmn:sequenceFlow id="Flow_0easrsr" sourceRef="StartEvent_1" targetRef="Activity_0le34m7" />
8
+ <bpmn:endEvent id="Event_0a948ov" name="Webhook processed">
9
+ <bpmn:incoming>Flow_1g4bjdg</bpmn:incoming>
10
+ </bpmn:endEvent>
11
+ <bpmn:sequenceFlow id="Flow_1g4bjdg" sourceRef="Activity_0le34m7" targetRef="Event_0a948ov" />
12
+ <bpmn:serviceTask id="Activity_0le34m7" name="Send slack message to announce">
13
+ <bpmn:extensionElements>
14
+ <zeebe:taskDefinition type="webhook-slack-announce" />
15
+ </bpmn:extensionElements>
16
+ <bpmn:incoming>Flow_0easrsr</bpmn:incoming>
17
+ <bpmn:outgoing>Flow_1g4bjdg</bpmn:outgoing>
18
+ </bpmn:serviceTask>
19
+ </bpmn:process>
20
+ <bpmndi:BPMNDiagram id="BPMNDiagram_1">
21
+ <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="cloudmunda-demo">
22
+ <bpmndi:BPMNEdge id="Flow_0easrsr_di" bpmnElement="Flow_0easrsr">
23
+ <di:waypoint x="215" y="97" />
24
+ <di:waypoint x="270" y="97" />
25
+ </bpmndi:BPMNEdge>
26
+ <bpmndi:BPMNEdge id="Flow_1g4bjdg_di" bpmnElement="Flow_1g4bjdg">
27
+ <di:waypoint x="370" y="97" />
28
+ <di:waypoint x="432" y="97" />
29
+ </bpmndi:BPMNEdge>
30
+ <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
31
+ <dc:Bounds x="179" y="79" width="36" height="36" />
32
+ <bpmndi:BPMNLabel>
33
+ <dc:Bounds x="174" y="122" width="47" height="27" />
34
+ </bpmndi:BPMNLabel>
35
+ </bpmndi:BPMNShape>
36
+ <bpmndi:BPMNShape id="Event_0a948ov_di" bpmnElement="Event_0a948ov">
37
+ <dc:Bounds x="432" y="79" width="36" height="36" />
38
+ <bpmndi:BPMNLabel>
39
+ <dc:Bounds x="425" y="122" width="51" height="27" />
40
+ </bpmndi:BPMNLabel>
41
+ </bpmndi:BPMNShape>
42
+ <bpmndi:BPMNShape id="Activity_1qerp1u_di" bpmnElement="Activity_0le34m7">
43
+ <dc:Bounds x="270" y="57" width="100" height="80" />
44
+ </bpmndi:BPMNShape>
45
+ </bpmndi:BPMNPlane>
46
+ </bpmndi:BPMNDiagram>
47
+ </bpmn:definitions>
data/exe/cloudmunda ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'cloudmunda/cli'
6
+
7
+ begin
8
+ cli = ::Cloudmunda::CLI.instance
9
+ cli.parse
10
+ cli.run
11
+ rescue StandardError => e
12
+ raise e if $DEBUG
13
+
14
+ warn e.message
15
+ warn e.backtrace.join("\n")
16
+ exit 1
17
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cloudmunda
4
+ module API
5
+ class AccessToken < Cloudmunda::API::OAuthResource
6
+ def self.create(audience_url: Cloudmunda.audience)
7
+ uri = Cloudmunda.auth_url
8
+ payload = {
9
+ grant_type: 'client_credentials',
10
+ audience: audience_url,
11
+ client_id: Cloudmunda.client_id,
12
+ client_secret: Cloudmunda.client_secret
13
+ }
14
+
15
+ create_by_uri(uri: uri, payload: payload)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+ require 'uri'
6
+ require 'base64'
7
+
8
+ module Cloudmunda
9
+ module API
10
+ class Client
11
+ def self.post(url, params = {})
12
+ response = RestClient.post(url, params.to_json, headers.merge(content_headers))
13
+ JSON.parse(response.body)
14
+ end
15
+
16
+ def self.headers
17
+ {
18
+ authorization: "Basic #{Base64.strict_encode64("#{Cloudmunda.client_id}:#{Cloudmunda.client_secret}")}"
19
+ }
20
+ end
21
+
22
+ def self.content_headers
23
+ {
24
+ 'Content-Type': 'application/json'
25
+ }
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'ostruct'
4
+
5
+ module Cloudmunda
6
+ module API
7
+ class OAuthResource < OpenStruct
8
+ def self.create_by_uri(uri:, payload:)
9
+ raw_item = Cloudmunda::API::Client.post(uri, payload)
10
+ raw_item = {} if raw_item == ''
11
+ new(raw_item)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'api/o_auth_resource'
4
+ require_relative 'api/access_token'
5
+ require_relative 'api/client'