eco-helpers 2.0.68 → 2.1.2

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: 4252ad8eca24aa081cf86912ec2eb3e8a2417e9221d887700cb1f0572de62e62
4
- data.tar.gz: ff3b1ebcaf7e3e234a3c0a787a10634050acdbf1af2366d1bd799ebf1eb3316b
3
+ metadata.gz: 65d5ec6baab743f216afd4ca77a4d36f9a43a52e841f0c2ca9ef73f63e3423b1
4
+ data.tar.gz: 5906de7dd2f2765c6222ac707b42b6b270914b40c964e7ba579966652a418e72
5
5
  SHA512:
6
- metadata.gz: 2f8f9ef76245e0ee390b8f9118ace7cf46cb071699d94b8dd56591e0df11314a81ba0e83d688e64e6a53d3cfba510de8be5559a4ed948a13806baa14d69e9d80
7
- data.tar.gz: e3ed91fb997fe84596ae2775b5841637eaf70173c2c1767290c10fceef0a9b3417c66c2f17ff46459558ca1f21ae81f248a60e0fd977642b9c8d30acb2dcec63
6
+ metadata.gz: e0494e227d268046a78fb6bf2df120506056bf96bf09464816ebc3a2fb2e6907e89729ed9c9ab848d93bfb9b53bdcf7f3c220c60847ffb403e54f663eca4c3c6
7
+ data.tar.gz: 26b09ee8c9eb63b9cd91772d55f1c52bdc941bff59e83da809d80272978eb8f62d687caf4417404a32d494e2853644b2e3532a151b81f001bc6b9b87f3263067
data/CHANGELOG.md CHANGED
@@ -1,12 +1,37 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
- ## [2.0.69] - 2022-09-xx
4
+ ## [2.1.3] - 2022-09-xx
5
5
 
6
6
  ### Added
7
7
  ### Changed
8
8
  ### Fixed
9
9
 
10
+ ## [2.1.2] - 2022-09-29
11
+
12
+ ### Added
13
+ - `Ecoportal::API::Session::Config#live_tree` to retrieve the tagtree of the back-end
14
+ - Requires `graphql` connection parameters
15
+ - `Ecoportal::API::Session#live_tree` see above
16
+
17
+ ### Changed
18
+ - `Ecoportal::API::Session::Config#tagtree` to use `#live_tree` if there isn't a `tagtree.json` file
19
+ - upgraded **dependency** to `ecoportal-api-graphql` **gem**
20
+ - upgraded **dependency** to `ecoportal-api-v2` **gem**
21
+
22
+ ### Fixed
23
+ - `Ecoportal::API::Session::Config::API#version_available?` **typo**
24
+
25
+ ## [2.1.1] - 2022-09-26
26
+
27
+ ### Added
28
+ - `Eco::API::Session::Config::Api#version_available?` to know if a version is available for use
29
+ - `Eco::API::Session::Config::Apis`, added `#default_pass` and `#default_email` to use the `GraphQL` api.
30
+
31
+ ### Changed
32
+ - upgraded **dependency** to `ecoportal-api-graphql` **gem**
33
+ - upgraded **dependency** to `ecoportal-api-v2` **gem**
34
+
10
35
  ## [2.0.68] - 2022-09-19
11
36
 
12
37
  ### Added
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.32', '< 0.9'
35
- spec.add_dependency 'ecoportal-api-graphql', '>= 0.1.6', '< 0.2'
34
+ spec.add_dependency 'ecoportal-api-v2', '>= 0.9.2', '< 0.10'
35
+ spec.add_dependency 'ecoportal-api-graphql', '>= 0.1.10', '< 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_params?(version)
149
+ end
150
+
149
151
  def version(value = nil)
150
152
  self.class.to_version(value || self["version"])
151
153
  end
@@ -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
@@ -227,6 +228,7 @@ module Eco
227
228
  org["tagtree"] = file
228
229
  end
229
230
 
231
+ # It uses the `tagtree.json` file and in its absence, if `graphql` enabled, the `life_tagtree`
230
232
  # @return [Eco::API::Organization::TagTree]
231
233
  def tagtree(enviro: nil)
232
234
  return @tagtree if instance_variable_defined?(:@tagtree) && @tagtree.enviro == enviro
@@ -234,6 +236,23 @@ module Eco
234
236
  tree = []
235
237
  tree = file_manager.load_json(tree_file) unless !tree_file
236
238
  @tagtree = Eco::API::Organization::TagTree.new(tree, enviro: enviro)
239
+ else
240
+ @tagtree = live_tree(enviro: enviro)
241
+ end
242
+ end
243
+
244
+ # It obtains the first of the live tagtree in the org
245
+ # @note it requires graphql connection configuration parameters
246
+ # @return [Eco::API::Organization::TagTree]
247
+ def live_tree(enviro: nil)
248
+ return @live_tree if instance_variable_defined?(:@live_tree) && @live_tree.enviro == enviro
249
+ if apis.active_api.version_available?(:graphql)
250
+ graphql = apis.api(version: :graphql)
251
+ if tree = graphql.currentOrganization.tagTrees.to_a.first.treeify
252
+ @live_tree = Eco::API::Organization::TagTree.new(tree, enviro: enviro)
253
+ else
254
+ @live_tree = nil
255
+ end
237
256
  end
238
257
  end
239
258
 
@@ -44,6 +44,11 @@ module Eco
44
44
  config.tagtree(enviro: enviro)
45
45
  end
46
46
 
47
+ # @see Eco::API::Session::Config#live_tree
48
+ def live_tree
49
+ config.live_tree
50
+ end
51
+
47
52
  # @see Eco::API::Session::Config#schemas
48
53
  def schemas
49
54
  config.schemas
@@ -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'
@@ -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.68"
2
+ VERSION = "2.1.2"
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.68
4
+ version: 2.1.2
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.32
139
+ version: 0.9.2
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.32
149
+ version: 0.9.2
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.6
159
+ version: 0.1.10
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.6
169
+ version: 0.1.10
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