eco-helpers 2.0.67 → 2.1.1

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: f70487179ebb87c5d44b0050fda66b5e87ed8a79d8e75c16cc5e5d9be131ec53
4
- data.tar.gz: be65600c6f6f2f713322bc3dc2588814643fb2815bc026d8a2d2f757c435736e
3
+ metadata.gz: 7b298bca88b1ee202218bf3e0ab5727db52d8893a4ea969deda1179198b02ddf
4
+ data.tar.gz: dd183eb58a6481851fde1fe257217541a175b4524f61ed1c61c9dff131d484b5
5
5
  SHA512:
6
- metadata.gz: c13a4b7998ca745cf3e5d9c44da3fda08ea4109963179887b51b0d1fc1281e3c3213e14734748418a147aa32395a5b2abc0a6229c45d806a290ab06b1eea20da
7
- data.tar.gz: 33b060518fea320eb17c0a2cd6fc8bd528b8a7cfdd1779af643300aac53adb77dcbd200a1f70dad4ea28c51801d6427bf19b9ce7d676fddd8187401a68f266bf
6
+ metadata.gz: 4d73a73a2dba773d09b83d0713e71f333f44e83acb51c5e6fbde83fbff60350c468ae5a79d60eaf4a9fd446b7416e5bd38ed181769e221df893b20b1a84afc50
7
+ data.tar.gz: 7a157045ebf97b9d0b10dadc5f1951a4eed311cd03335ac9f9b85288ef4fe3aa71bb7939e2266f124a9ee6687076bc5fc0afbaecff213ed2af45f11988b6543f
data/CHANGELOG.md CHANGED
@@ -1,7 +1,35 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.0.67] - 2022-08-11
4
+ ## [2.1.2] - 2022-09-xx
5
+
6
+ ### Added
7
+ ### Changed
8
+ ### Fixed
9
+
10
+ ## [2.1.1] - 2022-09-xx
11
+
12
+ ### Added
13
+ - `Eco::API::Session::Config::Api#version_available?` to know if a version is available for use
14
+ - `Eco::API::Session::Config::Apis`, added `#default_pass` and `#default_email` to use the `GraphQL` api.
15
+
16
+ ### Changed
17
+ - upgraded **dependency** to `ecoportal-api-graphql` **gem**
18
+ - upgraded **dependency** to `ecoportal-api-v2` **gem**
19
+
20
+ ## [2.0.68] - 2022-09-19
21
+
22
+ ### Added
23
+ - `Eco::API::UseCases::OozeSamples::OozeBaseCase`: **added** a couple of functions to support **page creation**: `#new_page` and `#create_page`
24
+
25
+ ### Changed
26
+ - upgraded **dependency** to `ecoportal-api-graphql` **gem**
27
+ - upgraded **dependency** to `ecoportal-api-v2` **gem**
28
+
29
+ ### Fixed
30
+ - `Eco::API::Session::Config::Api`, the `org_id` is **not** a required parameter for `APIv2`
31
+
32
+ ## [2.0.67] - 2022-09-15
5
33
 
6
34
  ### Added
7
35
  - **dependency** to `ecoportal-api-graphql` **gem**
@@ -21,23 +49,14 @@ All notable changes to this project will be documented in this file.
21
49
 
22
50
  ## [2.0.66] - 2022-08-11
23
51
 
24
- ### Added
25
- ### Changed
26
52
  ### Fixed
27
53
  - `Eco::API::UseCases::DefaultCases::Samples::Sftp` manage exception when trying to access remote folder
28
54
 
29
55
  ## [2.0.65] - 2022-08-11
30
56
 
31
- ### Added
32
- ### Changed
33
57
  ### Fixed
34
58
  - Typo of a fix
35
59
 
36
- ## [2.0.64] - 2022-08-11
37
-
38
- ### Changed
39
- - Nothing
40
-
41
60
  ## [2.0.63] - 2022-08-11
42
61
 
43
62
  ### Changed
@@ -50,7 +69,6 @@ All notable changes to this project will be documented in this file.
50
69
  - `Eco::API::Common::Session::Sftp` fetches from config
51
70
  - `Eco::API::Session::Config::Sftp#password`
52
71
 
53
- ### Changed
54
72
  ### Fixed
55
73
  - `Eco::API::UseCases::DefaultCases::CreateCase` had a typo
56
74
 
data/eco-helpers.gemspec CHANGED
@@ -31,8 +31,8 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "redcarpet", ">= 3.5.1", "< 3.6"
32
32
 
33
33
  spec.add_dependency 'ecoportal-api', '>= 0.8.5', '< 0.9'
34
- spec.add_dependency 'ecoportal-api-v2', '>= 0.8.31', '< 0.9'
35
- spec.add_dependency 'ecoportal-api-graphql', '>= 0.1.3', '< 0.2'
34
+ spec.add_dependency 'ecoportal-api-v2', '>= 0.9.1', '< 0.10'
35
+ spec.add_dependency 'ecoportal-api-graphql', '>= 0.1.9', '< 0.2'
36
36
  spec.add_dependency 'aws-sdk-s3', '>= 1.83.0', '< 2'
37
37
  spec.add_dependency 'aws-sdk-ses', '>= 1.36.0', '< 2'
38
38
  spec.add_dependency 'dotenv', '>= 2.7.6', '< 2.8'
@@ -3,9 +3,7 @@ module Eco
3
3
  class Session
4
4
  class Config
5
5
  class Api < Hash
6
-
7
6
  class << self
8
-
9
7
  def to_version(str)
10
8
  case str.to_sym
11
9
  when :external, :v1
@@ -32,7 +30,6 @@ module Eco
32
30
  else
33
31
  end
34
32
  end
35
-
36
33
  end
37
34
 
38
35
  def initialize(name, root:, key:, host:, version:,
@@ -117,11 +114,11 @@ module Eco
117
114
  end
118
115
 
119
116
  def email
120
- self["email"]
117
+ self["email"] || @root.default_email
121
118
  end
122
119
 
123
120
  def pass
124
- self["pass"]
121
+ self["pass"] || @root.default_pass
125
122
  end
126
123
 
127
124
  def host
@@ -146,6 +143,11 @@ module Eco
146
143
  !local?
147
144
  end
148
145
 
146
+ # @return [Boolean] whether or not `version` is available
147
+ def version_available?(version)
148
+ api_paramms?(version)
149
+ end
150
+
149
151
  def version(value = nil)
150
152
  self.class.to_version(value || self["version"])
151
153
  end
@@ -186,9 +188,9 @@ module Eco
186
188
  when :v1
187
189
  external_key && host
188
190
  when :v2
189
- org_id && external_key && user_key
191
+ external_key && user_key && host
190
192
  when :graphql
191
- email && pass && org_id
193
+ email && pass && org_id && host
192
194
  end
193
195
  end
194
196
 
@@ -3,7 +3,6 @@ module Eco
3
3
  class Session
4
4
  class Config
5
5
  class Apis < BaseConfig
6
-
7
6
  def apis
8
7
  self["apis"] ||= {}
9
8
  end
@@ -87,6 +86,22 @@ module Eco
87
86
  self["user_key"]
88
87
  end
89
88
 
89
+ def default_email=(email)
90
+ self["default_email"] = email
91
+ end
92
+
93
+ def default_email
94
+ self["default_email"] || ENV['USER_EMAIL']
95
+ end
96
+
97
+ def default_pass=(pass)
98
+ self["default_pass"] = pass
99
+ end
100
+
101
+ def default_pass
102
+ self["default_pass"] || ENV['USER_PASS']
103
+ end
104
+
90
105
  # Method to support CLI one-off API requests
91
106
  def one_off
92
107
  if one_off?
@@ -165,8 +180,6 @@ module Eco
165
180
  end
166
181
  return true
167
182
  end
168
-
169
-
170
183
  end
171
184
  end
172
185
  end
@@ -114,6 +114,7 @@ module Eco
114
114
  end
115
115
 
116
116
  # @see Eco::API::Session::Config::Apis#api
117
+ # @return [Eco::API::Session::Config::Api] the currently active api
117
118
  def api(logger = ::Logger.new(IO::NULL), version: nil)
118
119
  apis.api(logger, version: version)
119
120
  end
@@ -0,0 +1,44 @@
1
+ class Eco::API::UseCases::DefaultCases::TagTree < Eco::API::Common::Loaders::UseCase
2
+ name "tagtree"
3
+ type :other
4
+
5
+ attr_reader :session, :options
6
+ def main(session, options, usecase)
7
+ puts "Use case still in development"
8
+ exit
9
+ options[:end_get] = false
10
+ @session = session; @options = options
11
+ operations.keys.each do |key|
12
+ process(key)
13
+ end
14
+ end
15
+
16
+ def process(key)
17
+ case key
18
+ when :diff
19
+ require_graphql_auth!
20
+
21
+ when :show_backend
22
+ require_graphql_auth!
23
+
24
+ else
25
+ logger.warn("Operation #{key} not supported")
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def require_graphql_auth!
32
+ unless session.config.api.version_available?(:graphql)
33
+ logger.error("Missing parameters for to configure a GraphQL connexion.")
34
+ end
35
+ end
36
+
37
+ def operations
38
+ (options.dig(:tagtree, :operations) || {})
39
+ end
40
+
41
+ def graphql
42
+ @graphql ||= session.api(version: :graphql)
43
+ end
44
+ end
@@ -42,6 +42,7 @@ require_relative 'default_cases/set_supervisor_case'
42
42
  require_relative 'default_cases/supers_hierarchy_case'
43
43
  require_relative 'default_cases/supers_cyclic_identify_case'
44
44
  require_relative 'default_cases/switch_supervisor_case'
45
+ require_relative 'default_cases/tagtree_case'
45
46
  require_relative 'default_cases/to_csv_case'
46
47
  require_relative 'default_cases/to_csv_detailed_case'
47
48
  require_relative 'default_cases/transfer_account_case'
@@ -29,6 +29,23 @@ class Eco::API::UseCases::OozeSamples::OozeBaseCase < Eco::API::Common::Loaders:
29
29
 
30
30
  protected
31
31
 
32
+ def new_page(template_id)
33
+ apiv2.pages.get_new(template_id)
34
+ end
35
+
36
+ def create_page(page = nil, template_id: nil, retrieve: false)
37
+ template_id = template_id.id if template_id.is_a?(Ecoportal::API::V2::Page)
38
+ template_id ||= page.template_id if page.respond_to?(:template_id)
39
+ template_id ||= page["template_id"] if page.is_a?(Hash)
40
+ page = new_page(template_id) unless page || !template_id
41
+ yield(page) if block_given?
42
+ reference = apiv2.pages.create(page, from: template_id)
43
+ ooze_id = reference.page_id
44
+ stage_id = reference.active_stage_id
45
+ return [ooze_id, stage_id] unless retrieve
46
+ ooze(ooze_id, stage_id: stage_id)
47
+ end
48
+
32
49
  def add_field_by_doc(doc, section, after: nil, before: nil, side: :left)
33
50
  unless section.is_a?(Ecoportal::API::V2::Page::Section)
34
51
  raise "You need to specify a section for a new field. Given: #{section.class}"
@@ -87,6 +87,14 @@ ASSETS.cli.config do |cnf|
87
87
  options.deep_merge!(other: {file: {codes_column: col_codes}})
88
88
  end
89
89
 
90
+ desc = "Allows to perform some checks on tagtree structure (requires GraphQL)"
91
+ cases.add("-tagtree", :other, desc, case_name: "tagtree")
92
+ .add_option("-show-backend", "Displays the tagtree as per back-end") do |options|
93
+ options.deep_merge!(tagtree: {operation: {show_backend: true}})
94
+ end.add_option("-diff", "Compares the tagtree.json file with the back-end") do |options|
95
+ options.deep_merge!(tagtree: {operation: {diff: true}})
96
+ end
97
+
90
98
  desc = "Creates a CSV with the paths to each tag"
91
99
  cases.add("-create-tag-paths", :other, desc, case_name: "create-tag-paths")
92
100
 
data/lib/eco/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Eco
2
- VERSION = "2.0.67"
2
+ VERSION = "2.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eco-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.67
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oscar Segura
@@ -136,27 +136,27 @@ dependencies:
136
136
  requirements:
137
137
  - - ">="
138
138
  - !ruby/object:Gem::Version
139
- version: 0.8.31
139
+ version: 0.9.1
140
140
  - - "<"
141
141
  - !ruby/object:Gem::Version
142
- version: '0.9'
142
+ version: '0.10'
143
143
  type: :runtime
144
144
  prerelease: false
145
145
  version_requirements: !ruby/object:Gem::Requirement
146
146
  requirements:
147
147
  - - ">="
148
148
  - !ruby/object:Gem::Version
149
- version: 0.8.31
149
+ version: 0.9.1
150
150
  - - "<"
151
151
  - !ruby/object:Gem::Version
152
- version: '0.9'
152
+ version: '0.10'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: ecoportal-api-graphql
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 0.1.3
159
+ version: 0.1.9
160
160
  - - "<"
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0.2'
@@ -166,7 +166,7 @@ dependencies:
166
166
  requirements:
167
167
  - - ">="
168
168
  - !ruby/object:Gem::Version
169
- version: 0.1.3
169
+ version: 0.1.9
170
170
  - - "<"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '0.2'
@@ -579,6 +579,7 @@ files:
579
579
  - lib/eco/api/usecases/default_cases/supers_cyclic_identify_case.rb
580
580
  - lib/eco/api/usecases/default_cases/supers_hierarchy_case.rb
581
581
  - lib/eco/api/usecases/default_cases/switch_supervisor_case.rb
582
+ - lib/eco/api/usecases/default_cases/tagtree_case.rb
582
583
  - lib/eco/api/usecases/default_cases/to_csv_case.rb
583
584
  - lib/eco/api/usecases/default_cases/to_csv_detailed_case.rb
584
585
  - lib/eco/api/usecases/default_cases/transfer_account_case.rb