eco-helpers 1.5.2 → 1.5.7
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 +40 -1
- data/eco-helpers.gemspec +1 -1
- data/lib/eco/api/common/version_patches.rb +1 -0
- data/lib/eco/api/common/version_patches/object.rb +10 -0
- data/lib/eco/api/microcases/people_refresh.rb +1 -1
- data/lib/eco/api/microcases/with_each_starter.rb +1 -1
- data/lib/eco/api/session.rb +1 -1
- data/lib/eco/api/session/batch/request_stats.rb +5 -1
- data/lib/eco/api/usecases/default_cases/org_data_convert_case.rb +25 -7
- data/lib/eco/api/usecases/default_cases/restore_db_case.rb +25 -13
- data/lib/eco/api/usecases/use_case.rb +1 -1
- data/lib/eco/api/usecases/use_case_io.rb +0 -1
- data/lib/eco/cli/config/default/usecases.rb +21 -0
- data/lib/eco/cli/config/default/workflow.rb +1 -1
- data/lib/eco/cli/config/use_cases.rb +1 -1
- data/lib/eco/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7620c9cd737d1ba284868030b84b2589b0cd55c71708fee487c79dbce3fa3313
|
4
|
+
data.tar.gz: 444174de9c8634744060d411dcbad7229ef6c2acf24065f001ff29ecd41c6d4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae26e27d3b51f2b11cc50f6a6c6acc6229172b6a0416ca6feb633727b7fb45c9f19307d8d355ea14f77a67a041cf6886b54299f555b45990ff2c16ff6857f130
|
7
|
+
data.tar.gz: a11ca5b39ca0067c912b2ae59b5bfff1f59caa8ee23565b91f3dc8d694c966cc593a9efb5b7ca1c9c53cae4855f6fa4e59c3a792c6068c5179637641f22a5300
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,46 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
-
## [1.5.
|
4
|
+
## [1.5.7] - 2020-12-17
|
5
|
+
|
6
|
+
### Added
|
7
|
+
### Changed
|
8
|
+
### Fixed
|
9
|
+
- `Eco::API::Sesssion#parse_attribute` was not using phase argument
|
10
|
+
|
11
|
+
## [1.5.6] - 2020-12-04
|
12
|
+
|
13
|
+
### Added
|
14
|
+
### Changed
|
15
|
+
### Fixed
|
16
|
+
- `Eco::API::UseCases::DefaultCases::RestoreDBCase` fixed typo and slightly improved
|
17
|
+
- fixed some back-end errors when chaining usecases
|
18
|
+
- `Eco::API::UseCases::DefaultCases::OrgDataConvertCase` improved
|
19
|
+
|
20
|
+
## [1.5.5] - 2020-12-03
|
21
|
+
|
22
|
+
### Added
|
23
|
+
### Changed
|
24
|
+
### Fixed
|
25
|
+
- rubies previous to `2.5` do not have `yield_self`
|
26
|
+
|
27
|
+
## [1.5.4] - 2020-12-02
|
28
|
+
|
29
|
+
### Added
|
30
|
+
- update `ecoportal-api` dependency
|
31
|
+
### Changed
|
32
|
+
### Fixed
|
33
|
+
- `Eco::API::MicroCases#people_refresh` typo
|
34
|
+
|
35
|
+
## [1.5.3] - 2020-11-30
|
36
|
+
|
37
|
+
### Added
|
38
|
+
### Changed
|
39
|
+
### Fixed
|
40
|
+
- `Eco::API::Session::Batch::RequestStats#blanked_value?` better blank detection
|
41
|
+
- `Eco::API::MicroCases#with_each_starter` rectified typo
|
42
|
+
|
43
|
+
## [1.5.2] - 2020-11-26
|
5
44
|
|
6
45
|
### Added
|
7
46
|
- **custom** usecases, policies and error handlers can now be **declared within its own class**
|
data/eco-helpers.gemspec
CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.add_development_dependency "yard", ">= 0.9.18", "< 0.10"
|
29
29
|
s.add_development_dependency "redcarpet", ">= 3.5.0", "< 3.6"
|
30
30
|
|
31
|
-
s.add_dependency 'ecoportal-api', '>= 0.7.
|
31
|
+
s.add_dependency 'ecoportal-api', '>= 0.7.3', '< 0.8'
|
32
32
|
s.add_dependency 'ecoportal-api-oozes', '>= 0.7.2', '< 0.8'
|
33
33
|
s.add_dependency 'aws-sdk-s3', '>= 1.64.0', '< 2'
|
34
34
|
s.add_dependency 'aws-sdk-ses', '>= 1.29.0', '< 2'
|
@@ -23,7 +23,7 @@ module Eco
|
|
23
23
|
missing = people.length - entries.length
|
24
24
|
logger.error("Missed to obtain #{missing} people during the refresh") if missing > 0
|
25
25
|
|
26
|
-
Eco::API::Organization::People.new(
|
26
|
+
Eco::API::Organization::People.new(entries)
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
data/lib/eco/api/session.rb
CHANGED
@@ -2,6 +2,8 @@ class Eco::API::UseCases::DefaultCases::OrgDataConvertCase < Eco::API::Common::L
|
|
2
2
|
name "org-data-convert"
|
3
3
|
type :import
|
4
4
|
|
5
|
+
attr_reader :session, :options
|
6
|
+
|
5
7
|
def org_data_convert(people)
|
6
8
|
pp "Going to convert data from '#{source_enviro}' to '#{ASSETS.active_config}'"
|
7
9
|
puts "\n"
|
@@ -50,27 +52,43 @@ class Eco::API::UseCases::DefaultCases::OrgDataConvertCase < Eco::API::Common::L
|
|
50
52
|
|
51
53
|
def policy_groups_convert(ids)
|
52
54
|
ids.map do |id|
|
53
|
-
unless name =
|
54
|
-
|
55
|
+
unless name = source_policy_groups.to_name(id) || ignore_missing_policy_groups?
|
56
|
+
msg = "Ops, do not know #{id} usergroup for source environment"
|
57
|
+
msg += "\nUse the option -ignore-missing-policy-groups if you do not care"
|
58
|
+
error(msg)
|
55
59
|
end
|
56
60
|
session.policy_groups.to_id(name).tap do |new_id|
|
57
|
-
unless new_id
|
58
|
-
|
61
|
+
unless new_id || ignore_missing_policy_groups?
|
62
|
+
msg = "Ops, do not know #{name} usergroup for destination environment"
|
63
|
+
msg += "\nUse the option -ignore-missing-policy-groups if you do not care"
|
64
|
+
error(msg)
|
59
65
|
end
|
60
66
|
end
|
61
|
-
end
|
67
|
+
end.compact
|
68
|
+
end
|
69
|
+
|
70
|
+
def source_policy_groups
|
71
|
+
source_config.policy_groups
|
62
72
|
end
|
63
73
|
|
64
74
|
def source_config
|
65
|
-
@source_config ||= ASSETS.config(key: source_enviro, update_active: false)
|
75
|
+
@source_config ||= ASSETS.config(key: source_enviro, update_active: false).tap do |config|
|
76
|
+
unless config
|
77
|
+
error("The source environment '#{source_enviro}' does not exit or is not configured")
|
78
|
+
end
|
79
|
+
end
|
66
80
|
end
|
67
81
|
|
68
82
|
def source_enviro
|
69
83
|
@source_enviro ||= options.dig(:source_enviro).tap do |enviro|
|
70
|
-
error("A source
|
84
|
+
error("A source environment is required to migrate data from") unless enviro
|
71
85
|
end
|
72
86
|
end
|
73
87
|
|
88
|
+
def ignore_missing_policy_groups?
|
89
|
+
options.dig(:ignore, :missing, :policy_groups)
|
90
|
+
end
|
91
|
+
|
74
92
|
def logger
|
75
93
|
@session.logger
|
76
94
|
end
|
@@ -2,7 +2,11 @@ class Eco::API::UseCases::DefaultCases::RestoreDBCase < Eco::API::Common::Loader
|
|
2
2
|
name "restore-db"
|
3
3
|
type :sync
|
4
4
|
|
5
|
+
attr_reader :session, :options
|
6
|
+
|
5
7
|
def main(entries, people, session, options, usecase)
|
8
|
+
@session = session; @options = options
|
9
|
+
|
6
10
|
micro = session.micro
|
7
11
|
require_people_as_entries!(entries)
|
8
12
|
|
@@ -26,21 +30,21 @@ class Eco::API::UseCases::DefaultCases::RestoreDBCase < Eco::API::Common::Loader
|
|
26
30
|
|
27
31
|
person.new? ? restart.add(person) : update.add(person)
|
28
32
|
|
29
|
-
core_copy(entry, person
|
30
|
-
person.details = entry.details
|
33
|
+
core_copy(entry, person) unless options.dig(:exclude, :core)
|
34
|
+
person.details = entry.details unless options.dig(:exclude, :details)
|
31
35
|
|
32
36
|
unless options.dig(:exclude, :account) || !entry.account
|
33
37
|
person.account ||= {}
|
34
|
-
account_copy(entry.account, person.account
|
38
|
+
account_copy(entry.account, person.account)
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
38
|
-
report_re_starters(re_starters
|
42
|
+
report_re_starters(re_starters)
|
39
43
|
end
|
40
44
|
|
41
45
|
private
|
42
46
|
|
43
|
-
def core_copy(entry, person
|
47
|
+
def core_copy(entry, person)
|
44
48
|
person.external_id = entry.external_id unless options.dig(:exclude, :external_id)
|
45
49
|
person.name = entry.name unless options.dig(:exclude, :name)
|
46
50
|
person.email = entry.email unless options.dig(:exclude, :email)
|
@@ -49,8 +53,8 @@ class Eco::API::UseCases::DefaultCases::RestoreDBCase < Eco::API::Common::Loader
|
|
49
53
|
person.freemium = entry.freemium
|
50
54
|
end
|
51
55
|
|
52
|
-
def account_copy(src, dst
|
53
|
-
if src
|
56
|
+
def account_copy(src, dst)
|
57
|
+
if src
|
54
58
|
dst.default_tag = src.default_tag unless options.dig(:exclude, :filter_tags)
|
55
59
|
dst.policy_group_ids = src.policy_group_ids unless options.dig(:exclude, :policy_groups)
|
56
60
|
|
@@ -59,27 +63,31 @@ class Eco::API::UseCases::DefaultCases::RestoreDBCase < Eco::API::Common::Loader
|
|
59
63
|
dst.permissions_custom = src.permissions_custom
|
60
64
|
end
|
61
65
|
|
62
|
-
|
63
|
-
|
66
|
+
unless options.dig(:exclude, :login_providers) || options.dig(:source_enviro)
|
67
|
+
dst.login_provider_ids = src.login_provider_ids
|
68
|
+
end
|
64
69
|
|
65
70
|
if src.preferences
|
66
71
|
dst.doc["preferences"] = JSON.parse((src.doc["preferences"] || {}).to_json)
|
67
72
|
end
|
68
73
|
|
69
|
-
|
70
|
-
|
74
|
+
unless options.dig(:source_enviro)
|
75
|
+
dst.starred_ids = src.starred_ids
|
76
|
+
dst.landing_page_id = src.landing_page_id
|
77
|
+
end
|
78
|
+
|
71
79
|
dst&.send_invites = options[:send_invites] if options.key?(:send_invites)
|
72
80
|
end
|
73
81
|
end
|
74
82
|
|
75
|
-
def require_people_as_entries!(entries
|
83
|
+
def require_people_as_entries!(entries)
|
76
84
|
unless entries.is_a?(Eco::API::Organization::People)
|
77
85
|
logger.error("Your input should be an 'Eco::API::Organization::People' object. Got: #{entries.class}")
|
78
86
|
exit(1)
|
79
87
|
end
|
80
88
|
end
|
81
89
|
|
82
|
-
def report_re_starters(re_starters
|
90
|
+
def report_re_starters(re_starters)
|
83
91
|
unless re_starters.empty?
|
84
92
|
logger.error("There were #{re_starters.length} entries of the backup that do not exist in the (filtered?) people manager")
|
85
93
|
logger.error("Some examples:")
|
@@ -89,4 +97,8 @@ class Eco::API::UseCases::DefaultCases::RestoreDBCase < Eco::API::Common::Loader
|
|
89
97
|
end
|
90
98
|
end
|
91
99
|
|
100
|
+
def logger
|
101
|
+
session.logger
|
102
|
+
end
|
103
|
+
|
92
104
|
end
|
@@ -36,7 +36,7 @@ module Eco
|
|
36
36
|
# @option kargs [Eco::API:Session] :session
|
37
37
|
# @option kargs [Hash] :options hash with symbol keys (i.e. behaviour modifiers, cli trackers, filters, etc.)
|
38
38
|
def launch(io: nil, **kargs)
|
39
|
-
params = io&.params(keyed: true) || {}
|
39
|
+
params = io&.params(keyed: true, all: true) || {}
|
40
40
|
kargs = params.merge(kargs).merge(usecase: self)
|
41
41
|
|
42
42
|
UseCaseIO.new(**kargs).tap do |uio|
|
@@ -55,6 +55,27 @@ ASSETS.cli.config do |cnf|
|
|
55
55
|
options.deep_merge!(super: {new: new_id})
|
56
56
|
end
|
57
57
|
|
58
|
+
desc = "Usage '-org-data-convert backup.json -restore-db-from'."
|
59
|
+
desc += " Transforms an input .json file to the values of the destination environment "
|
60
|
+
desc += " (names missmatch won't solve: i.e. usergroups)"
|
61
|
+
cases.add("-org-data-convert", :import, desc, case_name: "org-data-convert") do |input, session, options|
|
62
|
+
unless input && input.is_a?(Eco::API::Organization::People)
|
63
|
+
file = SCR.get_file("-org-data-convert", required: true)
|
64
|
+
input = Eco::API::Organization::People.new(JSON.parse(File.read(file)))
|
65
|
+
session.logger.info("Source DB: loaded #{input.length} entries.")
|
66
|
+
end
|
67
|
+
|
68
|
+
if source_enviro = SCR.get_arg("-source-enviro", with_param: true)
|
69
|
+
options.merge!(source_enviro: source_enviro)
|
70
|
+
else
|
71
|
+
session.logger.error("You need to specify a -source-enviro for the conversion to work out")
|
72
|
+
exit(1)
|
73
|
+
end
|
74
|
+
|
75
|
+
options.deep_merge!(ignore: {missing: {policy_groups: true}}) if SCR.get_arg("-ignore-missing-policy-groups")
|
76
|
+
|
77
|
+
end
|
78
|
+
|
58
79
|
desc = "Restores the people manager by using a backup.json file"
|
59
80
|
cases.add("-restore-db-from", :sync, desc, case_name: "restore-db") do |input, people, session, options|
|
60
81
|
unless input && input.is_a?(Eco::API::Organization::People)
|
@@ -94,7 +94,7 @@ module Eco
|
|
94
94
|
when Eco::API::UseCases::UseCaseIO
|
95
95
|
io.chain(usecase: usecase)
|
96
96
|
when Eco::API::UseCases::BaseIO
|
97
|
-
params = io.params(keyed: true).merge(usecase: usecase)
|
97
|
+
params = io.params(keyed: true, all: true).merge(usecase: usecase)
|
98
98
|
Eco::API::UseCases::UseCaseIO.new(**params)
|
99
99
|
end
|
100
100
|
end
|
data/lib/eco/version.rb
CHANGED
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: 1.5.
|
4
|
+
version: 1.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oscar Segura
|
@@ -116,7 +116,7 @@ dependencies:
|
|
116
116
|
requirements:
|
117
117
|
- - ">="
|
118
118
|
- !ruby/object:Gem::Version
|
119
|
-
version: 0.7.
|
119
|
+
version: 0.7.3
|
120
120
|
- - "<"
|
121
121
|
- !ruby/object:Gem::Version
|
122
122
|
version: '0.8'
|
@@ -126,7 +126,7 @@ dependencies:
|
|
126
126
|
requirements:
|
127
127
|
- - ">="
|
128
128
|
- !ruby/object:Gem::Version
|
129
|
-
version: 0.7.
|
129
|
+
version: 0.7.3
|
130
130
|
- - "<"
|
131
131
|
- !ruby/object:Gem::Version
|
132
132
|
version: '0.8'
|
@@ -296,6 +296,7 @@ files:
|
|
296
296
|
- lib/eco/api/common/version_patches/exception.rb
|
297
297
|
- lib/eco/api/common/version_patches/hash.rb
|
298
298
|
- lib/eco/api/common/version_patches/hash/deep_merge.rb
|
299
|
+
- lib/eco/api/common/version_patches/object.rb
|
299
300
|
- lib/eco/api/custom.rb
|
300
301
|
- lib/eco/api/custom/error_handler.rb
|
301
302
|
- lib/eco/api/custom/namespace.rb
|