camundapi 0.1.4 → 0.2.2
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 +4 -4
- data/CHANGELOG.md +11 -2
- data/Gemfile.lock +1 -1
- data/README.md +55 -3
- data/lib/camunda/base_api.rb +43 -0
- data/lib/camunda/console/api.rb +3 -37
- data/lib/camunda/operate/api.rb +3 -36
- data/lib/camunda/version.rb +1 -1
- data/lib/camunda/zeebe/jobs.rb +16 -0
- data/lib/camunda/zeebe/process_instances.rb +15 -3
- data/lib/camunda/zeebe.rb +1 -0
- data/lib/camunda.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce0cf37d91eec603cb9216880295149771497066ac77871a734a59716546ee49
|
4
|
+
data.tar.gz: 022cb7c04439b91d2fcdf6ee35035ff97e855f08929582c0a9cac48ebc4ee223
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 679049daecee8de3048185a48e9740a038b42e0aab3f2e9b86648fd0b7c369bf88ba323ca20a42a75defbc26bde6e0fece53b1b281ec09ed83cf253042baea40
|
7
|
+
data.tar.gz: 1317daf88a5fe6718b3164f316bd5e6a850a119aadc922178547372c4844d6a5fa0a7394ea0cb10d9ae92c8ec2801a2f98bbd47626f916435cd5d7df561abe69
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
-
## [0.
|
3
|
+
## [0.2.2] - 2022-09-12
|
4
4
|
|
5
|
-
-
|
5
|
+
- Add `Zeebe::Jobs.add_error` so an error can be added to a job.
|
6
|
+
|
7
|
+
## [0.2.1] - 2022-08-30
|
8
|
+
|
9
|
+
- Breaking change in `Zeebe::ProcessInstances.create`. It now takes 3 (2 optional) arguments. Instead of one params variable
|
10
|
+
- Add `Zeebe::ProcessInstances.update_variables`.
|
11
|
+
|
12
|
+
## [0.1.4] - 2022-08-25
|
13
|
+
|
14
|
+
- Initial public release of the gem, with several endpoints for the different APIs added.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ This ruby gem is a wrapper for the Camunda API's. You will need to create a clie
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
9
|
```ruby
|
10
|
-
gem '
|
10
|
+
gem 'camundapi'
|
11
11
|
```
|
12
12
|
|
13
13
|
And then execute:
|
@@ -16,12 +16,64 @@ And then execute:
|
|
16
16
|
|
17
17
|
Or install it yourself as:
|
18
18
|
|
19
|
-
$ gem install
|
19
|
+
$ gem install camundapi
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
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
24
|
|
25
|
+
Depending on which APIs you're going to use, you will have to set the right variables in the config:
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
Camunda.configure do |config|
|
29
|
+
config.client_id = ENV['ZEEBE_CLIENT_ID']
|
30
|
+
config.client_secret = ENV['ZEEBE_CLIENT_SECRET']
|
31
|
+
config.zeebe_audience = ENV['ZEEBE_AUDIENCE']
|
32
|
+
config.authorization_url = ENV['ZEEBE_AUTHORIZATION_SERVER_URL']
|
33
|
+
config.operate_base_url = ENV['CAMUNDA_OPERATE_BASE_URL']
|
34
|
+
config.zeebe_url = ENV['ZEEBE_URL']
|
35
|
+
config.tasklist_base_url = ENV['CAMUNDA_TASKLIST_BASE_URL']
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
In the `Configuarion` class you can see all the available variables and what it defaults to.
|
40
|
+
|
41
|
+
### Operate API
|
42
|
+
Implements the API endpoints you can find [here](https://docs.camunda.io/docs/apis-clients/operate-api/). To use it with this gem, you can execute the following:
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
instance = Camunda::Operate::ProcessInstances.find('key')
|
46
|
+
```
|
47
|
+
|
48
|
+
For all the endpoints here we use the similar approach of having its own class per entity (process definitions, incidents, ..) and the `search` and `find` method is always available.
|
49
|
+
|
50
|
+
### Zeebe API
|
51
|
+
Implements the API endpoints you can find [here](https://docs.camunda.io/docs/apis-clients/grpc/). It makes use of the already existing [Zeebe Ruby gem](https://github.com/zeebe-io/zeebe-client-ruby).
|
52
|
+
This part is a work in progress but the foundations are here to add other classes/methods. It follows the same approach as how we've implemented the Operate API - that is that every entity gets its own class. Use as follows:
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
Camunda::Zeebe::ProcessInstances.create(process_id: 'id-of-a-process')
|
56
|
+
Camunda::Zeebe::ProcessInstances.create(process_id: 'id-of-a-process', variables: {'operational': true})
|
57
|
+
Camunda::Zeebe::ProcessInstances.create(process_id: 'id-of-a-process', variables: {'operational': true}, version: '5')
|
58
|
+
```
|
59
|
+
|
60
|
+
### Console API
|
61
|
+
Implements the API endpoints you can find [here](https://docs.camunda.io/docs/apis-clients/console-api-reference/). To use it with this gem, you can execute the following:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
clusters = Camunda::Console::Clusters.all
|
65
|
+
```
|
66
|
+
|
67
|
+
For all the endpoints here we use the similar approach of having its own class per entity (process definitions, incidents, ..) and the `search` and `find` method is always available.
|
68
|
+
|
69
|
+
### Tasklist API
|
70
|
+
Implements the API endpoints you can find [here](https://docs.camunda.io/docs/apis-clients/tasklist-api/tasklist-api-overview/).
|
71
|
+
This part is a work in progress but the foundations are here to add other classes/methods. It follows the same approach as how we've implemented the Operate API - that is that every entity gets its own class. Use as follows:
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
Camunda::Tasklist::UserTasks.all
|
75
|
+
```
|
76
|
+
|
25
77
|
## Development
|
26
78
|
|
27
79
|
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.
|
@@ -30,7 +82,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
30
82
|
|
31
83
|
## Contributing
|
32
84
|
|
33
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
85
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/lienvdsteen/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
86
|
|
35
87
|
## License
|
36
88
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rest-client'
|
4
|
+
require 'json'
|
5
|
+
require 'uri'
|
6
|
+
require 'base64'
|
7
|
+
|
8
|
+
module Camunda
|
9
|
+
class BaseAPI
|
10
|
+
def self.get(endpoint, params = {})
|
11
|
+
url = build_url(endpoint, params)
|
12
|
+
response = RestClient.get(url, headers)
|
13
|
+
|
14
|
+
JSON.parse(response.body)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.post(endpoint, params = {})
|
18
|
+
url = build_url(endpoint)
|
19
|
+
response = RestClient.post(
|
20
|
+
url,
|
21
|
+
params.to_json,
|
22
|
+
headers
|
23
|
+
)
|
24
|
+
|
25
|
+
JSON.parse(response.body) if response.code == 200
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.build_url(endpoint, params = {})
|
29
|
+
url = "#{base_url}/#{Camunda.api_version}/#{endpoint}"
|
30
|
+
url += "?#{URI.encode_www_form(params)}" unless params.empty?
|
31
|
+
|
32
|
+
url
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.headers
|
36
|
+
{
|
37
|
+
Authorization: "Bearer #{oauth_token}",
|
38
|
+
Accept: 'application/json',
|
39
|
+
'Content-Type': 'application/json'
|
40
|
+
}
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/camunda/console/api.rb
CHANGED
@@ -1,44 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rest-client'
|
4
|
-
require 'json'
|
5
|
-
require 'uri'
|
6
|
-
require 'base64'
|
7
|
-
require 'csv'
|
8
|
-
|
9
3
|
module Camunda
|
10
4
|
module Console
|
11
|
-
class API
|
12
|
-
def self.
|
13
|
-
|
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
|
-
}
|
5
|
+
class API < ::Camunda::BaseAPI
|
6
|
+
def self.base_url
|
7
|
+
Camunda.console_base_url
|
42
8
|
end
|
43
9
|
|
44
10
|
def self.oauth_token
|
data/lib/camunda/operate/api.rb
CHANGED
@@ -1,43 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rest-client'
|
4
|
-
require 'json'
|
5
|
-
require 'uri'
|
6
|
-
require 'base64'
|
7
|
-
require 'csv'
|
8
|
-
|
9
3
|
module Camunda
|
10
4
|
module Operate
|
11
|
-
class API
|
12
|
-
def self.
|
13
|
-
|
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
|
-
}
|
5
|
+
class API < ::Camunda::BaseAPI
|
6
|
+
def self.base_url
|
7
|
+
Camunda.operate_base_url
|
41
8
|
end
|
42
9
|
|
43
10
|
def self.oauth_token
|
data/lib/camunda/version.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Camunda
|
4
|
+
module Zeebe
|
5
|
+
class Jobs < API
|
6
|
+
def self.add_error(job_id:, error_code:, error_message: nil)
|
7
|
+
params = {
|
8
|
+
jobKey: job_id,
|
9
|
+
errorCode: error_code
|
10
|
+
}
|
11
|
+
params[:errorMessage] = error_message if error_message.present?
|
12
|
+
run(:throw_error, ::Zeebe::Client::GatewayProtocol::ThrowErrorRequest.new(params))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -3,9 +3,21 @@
|
|
3
3
|
module Camunda
|
4
4
|
module Zeebe
|
5
5
|
class ProcessInstances < API
|
6
|
-
def self.create(
|
7
|
-
|
8
|
-
|
6
|
+
def self.create(process_id:, variables: {}, version: -1)
|
7
|
+
params = {
|
8
|
+
bpmnProcessId: process_id,
|
9
|
+
variables: variables.to_json,
|
10
|
+
version: version
|
11
|
+
}
|
12
|
+
run(:create_process_instance, ::Zeebe::Client::GatewayProtocol::CreateProcessInstanceRequest.new(params))
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.update_variables(instance_id:, variables:)
|
16
|
+
params = {
|
17
|
+
elementInstanceKey: instance_id,
|
18
|
+
variables: variables.to_json
|
19
|
+
}
|
20
|
+
run(:set_variables, ::Zeebe::Client::GatewayProtocol::SetVariablesRequest.new(params))
|
9
21
|
end
|
10
22
|
end
|
11
23
|
end
|
data/lib/camunda/zeebe.rb
CHANGED
data/lib/camunda.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative 'camunda/version'
|
|
4
4
|
require_relative 'camunda/configuration'
|
5
5
|
require_relative 'camunda/util'
|
6
6
|
require_relative 'camunda/o_auth_resource'
|
7
|
+
require_relative 'camunda/base_api'
|
7
8
|
require_relative 'camunda/operate'
|
8
9
|
require_relative 'camunda/console'
|
9
10
|
require_relative 'camunda/zeebe'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camundapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lien Van Den Steen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- bin/console
|
86
86
|
- bin/setup
|
87
87
|
- lib/camunda.rb
|
88
|
+
- lib/camunda/base_api.rb
|
88
89
|
- lib/camunda/configuration.rb
|
89
90
|
- lib/camunda/console.rb
|
90
91
|
- lib/camunda/console/api.rb
|
@@ -108,6 +109,7 @@ files:
|
|
108
109
|
- lib/camunda/version.rb
|
109
110
|
- lib/camunda/zeebe.rb
|
110
111
|
- lib/camunda/zeebe/api.rb
|
112
|
+
- lib/camunda/zeebe/jobs.rb
|
111
113
|
- lib/camunda/zeebe/o_auth_token.rb
|
112
114
|
- lib/camunda/zeebe/process_instances.rb
|
113
115
|
- lib/camundapi.rb
|