camundapi 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 5a7a3246cd575a30f5a2142fcb504e699196fc8c96d66131c42de2a452f61031
4
+ data.tar.gz: dda9db61d8f2511df983ce3e79199b99e60da0bb8f12371fb61d140ea0a34b88
5
+ SHA512:
6
+ metadata.gz: f278803330cc16f34cc60885e4ed01274ea5493b8dbdfd113762818751ff4c3eb436d746ccfda560533beaa15eabf8220bfb43504d3e56c29bbafea8c14ae687
7
+ data.tar.gz: a2f1895f23b9bbf33fe6798fe69dc07e3e0d8ca8456ca721bc5b54d81e14e0486f3fb59cb2d8ddfcbe054e1faea92df7c4929328dabf5d6ae65a353e7fbea443
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+ NewCops: enable
4
+
5
+ Style/Documentation:
6
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-08-25
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at lienvandensteen@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in camunda.gemspec
6
+ gemspec
7
+
8
+ gem 'rake', '~> 13.0'
9
+
10
+ gem 'rspec', '~> 3.0'
11
+
12
+ gem 'rubocop', '~> 1.21'
13
+ gem 'rubocop-rake', require: false
14
+ gem 'rubocop-rspec', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,94 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ camundapi (0.1.4)
5
+ json
6
+ net-sftp
7
+ rest-client (~> 2.0)
8
+ zeebe-client (~> 0.17.0)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ ast (2.4.2)
14
+ diff-lcs (1.5.0)
15
+ domain_name (0.5.20190701)
16
+ unf (>= 0.0.5, < 1.0.0)
17
+ google-protobuf (3.21.5-x86_64-darwin)
18
+ googleapis-common-protos-types (1.4.0)
19
+ google-protobuf (~> 3.14)
20
+ grpc (1.48.0-x86_64-darwin)
21
+ google-protobuf (~> 3.19)
22
+ googleapis-common-protos-types (~> 1.0)
23
+ http-accept (1.7.0)
24
+ http-cookie (1.0.5)
25
+ domain_name (~> 0.5)
26
+ json (2.6.2)
27
+ mime-types (3.4.1)
28
+ mime-types-data (~> 3.2015)
29
+ mime-types-data (3.2022.0105)
30
+ net-sftp (3.0.0)
31
+ net-ssh (>= 5.0.0, < 7.0.0)
32
+ net-ssh (6.1.0)
33
+ netrc (0.11.0)
34
+ parallel (1.22.1)
35
+ parser (3.1.2.0)
36
+ ast (~> 2.4.1)
37
+ rainbow (3.1.1)
38
+ rake (13.0.6)
39
+ regexp_parser (2.3.1)
40
+ rest-client (2.1.0)
41
+ http-accept (>= 1.7.0, < 2.0)
42
+ http-cookie (>= 1.0.2, < 2.0)
43
+ mime-types (>= 1.16, < 4.0)
44
+ netrc (~> 0.8)
45
+ rexml (3.2.5)
46
+ rspec (3.11.0)
47
+ rspec-core (~> 3.11.0)
48
+ rspec-expectations (~> 3.11.0)
49
+ rspec-mocks (~> 3.11.0)
50
+ rspec-core (3.11.0)
51
+ rspec-support (~> 3.11.0)
52
+ rspec-expectations (3.11.0)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.11.0)
55
+ rspec-mocks (3.11.1)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.11.0)
58
+ rspec-support (3.11.0)
59
+ rubocop (1.28.2)
60
+ parallel (~> 1.10)
61
+ parser (>= 3.1.0.0)
62
+ rainbow (>= 2.2.2, < 4.0)
63
+ regexp_parser (>= 1.8, < 3.0)
64
+ rexml
65
+ rubocop-ast (>= 1.17.0, < 2.0)
66
+ ruby-progressbar (~> 1.7)
67
+ unicode-display_width (>= 1.4.0, < 3.0)
68
+ rubocop-ast (1.17.0)
69
+ parser (>= 3.1.1.0)
70
+ rubocop-rake (0.6.0)
71
+ rubocop (~> 1.0)
72
+ rubocop-rspec (2.11.1)
73
+ rubocop (~> 1.19)
74
+ ruby-progressbar (1.11.0)
75
+ unf (0.1.4)
76
+ unf_ext
77
+ unf_ext (0.0.8.2)
78
+ unicode-display_width (2.1.0)
79
+ zeebe-client (0.17.0)
80
+ grpc (~> 1.32)
81
+
82
+ PLATFORMS
83
+ x86_64-darwin-20
84
+
85
+ DEPENDENCIES
86
+ camundapi!
87
+ rake (~> 13.0)
88
+ rspec (~> 3.0)
89
+ rubocop (~> 1.21)
90
+ rubocop-rake
91
+ rubocop-rspec
92
+
93
+ BUNDLED WITH
94
+ 2.2.31
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Lien Van Den Steen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Camunda
2
+
3
+ This ruby gem is a wrapper for the Camunda API's. You will need to create a client on your Camunda cluster and use the credentials to connect.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'camunda'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle install
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install camunda
20
+
21
+ ## Usage
22
+
23
+ This library has an opinionated approach has how the API wrapper is implemented but it follows a very similar approach for every Camunda API. All the APIs are in their own module (`Camunda::Operate`, `Camunda::Zeebe`, ..).
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/camunda. 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/lienvdsteen/camunda/blob/main/CODE_OF_CONDUCT.md).
34
+
35
+ ## License
36
+
37
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
38
+
39
+ ## Code of Conduct
40
+
41
+ Everyone interacting in the Camunda project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/lienvdsteen/camunda/blob/main/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'camunda'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require 'irb'
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Configuration
5
+ VALID_OPTIONS_KEYS = %i[api_version client_id client_secret zeebe_audience authorization_url operate_audience
6
+ operate_base_url console_audience console_base_url zeebe_url tasklist_audience
7
+ tasklist_base_url].freeze
8
+ attr_accessor(*VALID_OPTIONS_KEYS)
9
+
10
+ # Sets all configuration options to their default values
11
+ # when this module is extended.
12
+ def self.extended(base)
13
+ base.reset
14
+ end
15
+
16
+ def configure
17
+ yield self
18
+ end
19
+
20
+ def config
21
+ VALID_OPTIONS_KEYS.inject({}) do |option, key|
22
+ option.merge!(key => send(key))
23
+ end
24
+ end
25
+
26
+ # Resets all configuration options to the defaults.
27
+ def reset # rubocop:disable Metrics:MethodLength
28
+ self.api_version = 'v1'
29
+ self.client_id = ENV.fetch('CAMUNDA_CLIENT_ID', nil)
30
+ self.client_secret = ENV.fetch('CAMUNDA_CLIENT_SECRET', nil)
31
+ self.zeebe_audience = ENV.fetch('CAMUNDA_AUDIENCE', nil)
32
+ self.zeebe_url = ENV.fetch('CAMUNDA_ZEEBE_URL', nil)
33
+ self.authorization_url = ENV.fetch('CAMUNDA_AUTHORIZATION_URL', nil)
34
+ self.operate_audience = ENV.fetch('CAMUNDA_OPERATE_AUDIENCE', 'operate.camunda.io')
35
+ self.operate_base_url = ENV.fetch('CAMUNDA_OPERATE_BASE_URL', nil)
36
+ self.console_audience = ENV.fetch('CAMUNDA_CONSOLE_AUDIENCE', 'api.cloud.camunda.io')
37
+ self.console_base_url = ENV.fetch('CAMUNDA_CONSOLE_BASE_URL', 'https://console.cloud.camunda.io')
38
+ self.tasklist_audience = ENV.fetch('CAMUNDA_TASKLIST_AUDIENCE', 'tasklist.camunda.io')
39
+ self.tasklist_base_url = ENV.fetch('CAMUNDA_TASKLIST_BASE_URL', nil)
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+ require 'uri'
6
+ require 'base64'
7
+ require 'csv'
8
+
9
+ module Camunda
10
+ module Console
11
+ class API
12
+ def self.get(endpoint, params = {})
13
+ url = build_url(endpoint, params)
14
+ response = RestClient.get(url, headers)
15
+
16
+ JSON.parse(response.body)
17
+ end
18
+
19
+ def self.post(endpoint, params = {})
20
+ url = build_url(endpoint)
21
+ response = RestClient.post(
22
+ url,
23
+ params.to_json,
24
+ headers.merge({ 'Content-Type': 'application/json' })
25
+ )
26
+
27
+ JSON.parse(response.body) if response.code == 200
28
+ end
29
+
30
+ def self.build_url(endpoint, params = {})
31
+ url = "#{Camunda.console_base_url}/#{Camunda.api_version}/#{endpoint}"
32
+ url += "?#{URI.encode_www_form(params)}" unless params.empty?
33
+
34
+ url
35
+ end
36
+
37
+ def self.headers
38
+ {
39
+ Authorization: "Bearer #{oauth_token}",
40
+ Accept: 'application/json'
41
+ }
42
+ end
43
+
44
+ def self.oauth_token
45
+ Camunda::Console::OAuthToken.create['access_token']
46
+ end
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Console
5
+ class Clients < API
6
+ def self.all(cluster_id)
7
+ get("clusters/#{cluster_id}/clients")
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Console
5
+ class Clusters < API
6
+ def self.all
7
+ get('clusters')
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Console
5
+ class OAuthToken < Camunda::OAuthResource
6
+ def self.create
7
+ uri = Camunda.authorization_url
8
+ payload = {
9
+ grant_type: 'client_credentials',
10
+ audience: Camunda.console_audience,
11
+ client_id: Camunda.client_id,
12
+ client_secret: Camunda.client_secret
13
+ }
14
+
15
+ create_by_uri(uri: uri, payload: payload)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'console/o_auth_token'
4
+ require_relative 'console/api'
5
+ require_relative 'console/clients'
6
+ require_relative 'console/clusters'
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ class OAuthResource
5
+ def self.create_by_uri(uri:, payload:)
6
+ headers = {
7
+ 'Content-Type': 'application/json'
8
+ }
9
+
10
+ response = RestClient.post(uri, payload.to_json, headers)
11
+ parsed_response = JSON.parse(response.body)
12
+
13
+ parsed_response = {} if parsed_response == ''
14
+ parsed_response
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rest-client'
4
+ require 'json'
5
+ require 'uri'
6
+ require 'base64'
7
+ require 'csv'
8
+
9
+ module Camunda
10
+ module Operate
11
+ class API
12
+ def self.get(endpoint, params = {})
13
+ url = build_url(endpoint, params)
14
+ response = RestClient.get(url, headers)
15
+
16
+ JSON.parse(response.body)
17
+ end
18
+
19
+ def self.post(endpoint, params = {})
20
+ url = build_url(endpoint)
21
+ response = RestClient.post(
22
+ url,
23
+ params.to_json,
24
+ headers.merge({ 'Content-Type': 'application/json' })
25
+ )
26
+
27
+ JSON.parse(response.body) if response.code == 200
28
+ end
29
+
30
+ def self.build_url(endpoint, params = {})
31
+ url = "#{Camunda.operate_base_url}/#{Camunda.api_version}/#{endpoint}"
32
+ url += "?#{URI.encode_www_form(params)}" unless params.empty?
33
+
34
+ url
35
+ end
36
+
37
+ def self.headers
38
+ {
39
+ Authorization: "Bearer #{oauth_token}"
40
+ }
41
+ end
42
+
43
+ def self.oauth_token
44
+ Camunda::Operate::OAuthToken.create['access_token']
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Operate
5
+ class FlownodeInstances < API
6
+ def self.search(params)
7
+ post('flownode-instances/search', params)
8
+ end
9
+
10
+ def self.find(flownode_id)
11
+ get("flownode-instances/#{flownode_id}")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Operate
5
+ class Incidents < API
6
+ def self.search(params)
7
+ post('incidents/search', params)
8
+ end
9
+
10
+ def self.find(incident_id)
11
+ get("incidents/#{incident_id}")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Operate
5
+ class OAuthToken < Camunda::OAuthResource
6
+ def self.create
7
+ uri = Camunda.authorization_url
8
+ payload = {
9
+ grant_type: 'client_credentials',
10
+ audience: Camunda.operate_audience,
11
+ client_id: Camunda.client_id,
12
+ client_secret: Camunda.client_secret
13
+ }
14
+
15
+ create_by_uri(uri: uri, payload: payload)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Operate
5
+ class ProcessDefinitions < API
6
+ def self.search(params)
7
+ post('process-definitions/search', params)
8
+ end
9
+
10
+ def self.find(definition_id)
11
+ get("process-definitions/#{definition_id}")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Operate
5
+ class ProcessInstances < API
6
+ def self.search(params)
7
+ post('process-instances/search', params)
8
+ end
9
+
10
+ def self.all_active
11
+ params = { filter: { state: 'ACTIVE' } }
12
+ search(params)
13
+ end
14
+
15
+ def self.find(instance_id)
16
+ get("process-instances/#{instance_id}")
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Operate
5
+ class Incidents < API
6
+ def self.search(params)
7
+ post('variables/search', params)
8
+ end
9
+
10
+ def self.find(variable_id)
11
+ get("variables/#{variable_id}")
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'operate/api'
4
+ require_relative 'operate/o_auth_token'
5
+ require_relative 'operate/process_definitions'
6
+ require_relative 'operate/process_instances'
7
+ require_relative 'operate/variables'
8
+ require_relative 'operate/flownode_instances'
9
+ require_relative 'operate/incidents'
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Tasklist
5
+ class API
6
+ def self.post(params = {})
7
+ response = RestClient.post(Camunda.tasklist_base_url, params.to_json, headers)
8
+ JSON.parse(response.body)
9
+ end
10
+
11
+ def self.headers
12
+ oauth_token = Camunda::Tasklist::OAuthToken.create
13
+ {
14
+ authorization: "Bearer #{oauth_token['access_token']}",
15
+ 'Content-Type': 'application/json'
16
+ }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Tasklist
5
+ class OAuthToken < Camunda::OAuthResource
6
+ def self.create
7
+ uri = Camunda.authorization_url
8
+ payload = {
9
+ grant_type: 'client_credentials',
10
+ audience: Camunda.tasklist_audience,
11
+ client_id: Camunda.client_id,
12
+ client_secret: Camunda.client_secret
13
+ }
14
+
15
+ create_by_uri(uri: uri, payload: payload)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Tasklist
5
+ class UserTasks < API
6
+ def self.all # rubocop:disable Metrics:MethodLength
7
+ query = "{
8
+ tasks(query: { state: CREATED })
9
+ {
10
+ id
11
+ taskDefinitionId
12
+ name
13
+ taskState
14
+ assignee
15
+ taskState
16
+ formKey
17
+ processDefinitionId
18
+ completionTime
19
+ processName
20
+ variables {
21
+ name
22
+ value
23
+ }
24
+ }
25
+ }"
26
+ post(query: query)['data']['tasks']
27
+ end
28
+
29
+ def self.run_mutation(mutation)
30
+ post(query: mutation)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'tasklist/o_auth_token'
4
+ require_relative 'tasklist/api'
5
+ require_relative 'tasklist/user_tasks'
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Credits to https://github.com/myponto/ponto-ruby/blob/master/lib/ponto/util.rb
4
+ module Camunda
5
+ module Util
6
+ def self.underscorize_hash(attributes)
7
+ attributes.keys.each_with_object({}) do |key, result|
8
+ result[underscore(key)] = attributes[key]
9
+ end
10
+ end
11
+
12
+ def self.underscore(camel_cased_word)
13
+ return camel_cased_word unless camel_cased_word =~ /[A-Z-]/
14
+
15
+ word = camel_cased_word.to_s.gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
16
+ word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
17
+ word.tr!('-', '_')
18
+ word.tr!(' ', '_')
19
+ word.downcase!
20
+ word
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ VERSION = '0.1.4'
5
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'zeebe/client'
4
+
5
+ module Camunda
6
+ module Zeebe
7
+ class API
8
+ def self.run(method, params = {})
9
+ client.public_send(method, params)
10
+ rescue ::GRPC::Unavailable => e
11
+ Rails.logger.error e.message # TODO: give people options to use other logger
12
+ raise e
13
+ end
14
+
15
+ def self.client
16
+ ::Zeebe::Client::GatewayProtocol::Gateway::Stub.new(Camunda.zeebe_url, authentication_headers)
17
+ end
18
+
19
+ def self.authentication_headers
20
+ token = Camunda::Zeebe::OAuthToken.create
21
+ channel_creds = GRPC::Core::ChannelCredentials.new
22
+ auth_proc = proc { { 'authorization' => "Bearer #{token['access_token']}" } }
23
+ call_creds = GRPC::Core::CallCredentials.new(auth_proc)
24
+ channel_creds.compose(call_creds)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Zeebe
5
+ class OAuthToken < Camunda::OAuthResource
6
+ def self.create
7
+ uri = Camunda.authorization_url
8
+ payload = {
9
+ grant_type: 'client_credentials',
10
+ audience: Camunda.zeebe_audience,
11
+ client_id: Camunda.client_id,
12
+ client_secret: Camunda.client_secret
13
+ }
14
+
15
+ create_by_uri(uri: uri, payload: payload)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Camunda
4
+ module Zeebe
5
+ class ProcessInstances < API
6
+ def self.create(params)
7
+ run(:create_process_instance,
8
+ ::Zeebe::Client::GatewayProtocol::CreateProcessInstanceRequest.new(params))
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'zeebe/o_auth_token'
4
+ require_relative 'zeebe/api'
5
+ require_relative 'zeebe/process_instances'
data/lib/camunda.rb ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'camunda/version'
4
+ require_relative 'camunda/configuration'
5
+ require_relative 'camunda/util'
6
+ require_relative 'camunda/o_auth_resource'
7
+ require_relative 'camunda/operate'
8
+ require_relative 'camunda/console'
9
+ require_relative 'camunda/zeebe'
10
+ require_relative 'camunda/tasklist'
11
+
12
+ module Camunda
13
+ extend Configuration
14
+ end
data/lib/camundapi.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'camunda'
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: camundapi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.4
5
+ platform: ruby
6
+ authors:
7
+ - Lien Van Den Steen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: net-sftp
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rest-client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: zeebe-client
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.17.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.17.0
69
+ description: Ruby wrapper for Camunda's API's
70
+ email:
71
+ - lienvandensteen@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".rspec"
77
+ - ".rubocop.yml"
78
+ - CHANGELOG.md
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - LICENSE.txt
83
+ - README.md
84
+ - Rakefile
85
+ - bin/console
86
+ - bin/setup
87
+ - lib/camunda.rb
88
+ - lib/camunda/configuration.rb
89
+ - lib/camunda/console.rb
90
+ - lib/camunda/console/api.rb
91
+ - lib/camunda/console/clients.rb
92
+ - lib/camunda/console/clusters.rb
93
+ - lib/camunda/console/o_auth_token.rb
94
+ - lib/camunda/o_auth_resource.rb
95
+ - lib/camunda/operate.rb
96
+ - lib/camunda/operate/api.rb
97
+ - lib/camunda/operate/flownode_instances.rb
98
+ - lib/camunda/operate/incidents.rb
99
+ - lib/camunda/operate/o_auth_token.rb
100
+ - lib/camunda/operate/process_definitions.rb
101
+ - lib/camunda/operate/process_instances.rb
102
+ - lib/camunda/operate/variables.rb
103
+ - lib/camunda/tasklist.rb
104
+ - lib/camunda/tasklist/api.rb
105
+ - lib/camunda/tasklist/o_auth_token.rb
106
+ - lib/camunda/tasklist/user_tasks.rb
107
+ - lib/camunda/util.rb
108
+ - lib/camunda/version.rb
109
+ - lib/camunda/zeebe.rb
110
+ - lib/camunda/zeebe/api.rb
111
+ - lib/camunda/zeebe/o_auth_token.rb
112
+ - lib/camunda/zeebe/process_instances.rb
113
+ - lib/camundapi.rb
114
+ homepage: https://github.com/lienvdsteen/camunda
115
+ licenses:
116
+ - MIT
117
+ metadata:
118
+ homepage_uri: https://github.com/lienvdsteen/camunda
119
+ source_code_uri: https://github.com/lienvdsteen/camunda
120
+ changelog_uri: https://github.com/lienvdsteen/camunda/blob/main/CHANGELOG.md
121
+ rubygems_mfa_required: 'true'
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: 2.6.0
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubygems_version: 3.2.31
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Ruby wrapper for Camunda's API's
141
+ test_files: []