camundapi 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a7a3246cd575a30f5a2142fcb504e699196fc8c96d66131c42de2a452f61031
4
- data.tar.gz: dda9db61d8f2511df983ce3e79199b99e60da0bb8f12371fb61d140ea0a34b88
3
+ metadata.gz: d67be7eac7a340b836de1b18fc330cf5a3571cb5aea64cb4f3e8ba3debe4600d
4
+ data.tar.gz: 5fc738ba1694020187ff91e141f617a9f6f8e66cd13053383ee3051330b56f4a
5
5
  SHA512:
6
- metadata.gz: f278803330cc16f34cc60885e4ed01274ea5493b8dbdfd113762818751ff4c3eb436d746ccfda560533beaa15eabf8220bfb43504d3e56c29bbafea8c14ae687
7
- data.tar.gz: a2f1895f23b9bbf33fe6798fe69dc07e3e0d8ca8456ca721bc5b54d81e14e0486f3fb59cb2d8ddfcbe054e1faea92df7c4929328dabf5d6ae65a353e7fbea443
6
+ metadata.gz: d3958d4885586cb5f754abf866ac55ebed79a60381be158a122b4529fd18d2c28a3bca242f45cb1e447f65d7886401e17d7c6310fa9d1b3e05005397485c499c
7
+ data.tar.gz: 6ed0efee18895f5be9c84290a059115572d9b35bf7d22f6a77881eca903659254cab6f7cdc47b9d1a275c6723aa9e69c1548090d04e1dfb44129753a9dbb42d1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- camundapi (0.1.4)
4
+ camundapi (0.1.5)
5
5
  json
6
6
  net-sftp
7
7
  rest-client (~> 2.0)
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 'camunda'
10
+ gem 'camundapi'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -16,12 +16,62 @@ And then execute:
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install camunda
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({bpmnProcessId: 'id-of-a-process', version: -1})
56
+ ```
57
+
58
+ ### Console API
59
+ 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:
60
+
61
+ ```ruby
62
+ clusters = Camunda::Console::Clusters.all
63
+ ```
64
+
65
+ 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.
66
+
67
+ ### Tasklist API
68
+ Implements the API endpoints you can find [here](https://docs.camunda.io/docs/apis-clients/tasklist-api/tasklist-api-overview/).
69
+ 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:
70
+
71
+ ```ruby
72
+ Camunda::Tasklist::UserTasks.all
73
+ ```
74
+
25
75
  ## Development
26
76
 
27
77
  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 +80,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
30
80
 
31
81
  ## Contributing
32
82
 
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).
83
+ 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
84
 
35
85
  ## License
36
86
 
@@ -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
@@ -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.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
- }
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
@@ -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.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
- }
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Camunda
4
- VERSION = '0.1.4'
4
+ VERSION = '0.1.5'
5
5
  end
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.1.4
4
+ version: 0.1.5
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-08-25 00:00:00.000000000 Z
11
+ date: 2022-08-26 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