xapixctl 1.0.0 → 1.1.0
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/.ruby-version +1 -1
- data/Gemfile.lock +31 -26
- data/README.md +8 -0
- data/lib/xapixctl/cli.rb +61 -21
- data/lib/xapixctl/phoenix_client.rb +125 -0
- data/lib/xapixctl/version.rb +1 -1
- data/xapixctl.gemspec +5 -5
- metadata +35 -17
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6cd8ba6213479cad5bf20ea1e07db40e09dd375f58ccfb12d6183f31707db480
|
|
4
|
+
data.tar.gz: 1056d41e4dfc798aa86d7a9f3bff136cc145c7dd0803c77d47c91440a481b75e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 61a99b2b54e627228d20edb639fceee90d7a93bb503237f69f877a746e20826cd43f60d7ddc66910e94c1596aeee14f5e5cc6359e81ca5c3db3fa5d46d0caaab
|
|
7
|
+
data.tar.gz: d09d9ccd590a01d06cf6509ae0f44a1f44a5f205ef48f3032d997da6fbf64d5f61d785145512cd06f483d40ec976c5e34db4a030719b5e667fccd04b346f4619
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.6.
|
|
1
|
+
2.6.6
|
data/Gemfile.lock
CHANGED
|
@@ -1,85 +1,90 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
xapixctl (1.0.
|
|
5
|
-
activesupport (
|
|
6
|
-
rest-client (
|
|
7
|
-
thor (
|
|
4
|
+
xapixctl (1.0.1)
|
|
5
|
+
activesupport (>= 5.2.3, < 6.0.0)
|
|
6
|
+
rest-client (>= 2.1.0, < 3.0.0)
|
|
7
|
+
thor (>= 0.20.3, < 1.0.0)
|
|
8
8
|
|
|
9
9
|
GEM
|
|
10
10
|
remote: https://rubygems.org/
|
|
11
11
|
specs:
|
|
12
|
-
activesupport (5.2.4.
|
|
12
|
+
activesupport (5.2.4.3)
|
|
13
13
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
14
14
|
i18n (>= 0.7, < 2)
|
|
15
15
|
minitest (~> 5.1)
|
|
16
16
|
tzinfo (~> 1.1)
|
|
17
|
-
ast (2.4.
|
|
18
|
-
concurrent-ruby (1.1.
|
|
17
|
+
ast (2.4.1)
|
|
18
|
+
concurrent-ruby (1.1.6)
|
|
19
19
|
diff-lcs (1.3)
|
|
20
20
|
domain_name (0.5.20190701)
|
|
21
21
|
unf (>= 0.0.5, < 1.0.0)
|
|
22
22
|
http-accept (1.7.0)
|
|
23
23
|
http-cookie (1.0.3)
|
|
24
24
|
domain_name (~> 0.5)
|
|
25
|
-
i18n (1.8.
|
|
25
|
+
i18n (1.8.3)
|
|
26
26
|
concurrent-ruby (~> 1.0)
|
|
27
|
-
jaro_winkler (1.5.4)
|
|
28
27
|
mime-types (3.3.1)
|
|
29
28
|
mime-types-data (~> 3.2015)
|
|
30
|
-
mime-types-data (3.
|
|
31
|
-
minitest (5.14.
|
|
29
|
+
mime-types-data (3.2020.0512)
|
|
30
|
+
minitest (5.14.1)
|
|
32
31
|
netrc (0.11.0)
|
|
33
|
-
parallel (1.19.
|
|
34
|
-
parser (2.7.
|
|
32
|
+
parallel (1.19.2)
|
|
33
|
+
parser (2.7.1.3)
|
|
35
34
|
ast (~> 2.4.0)
|
|
36
35
|
rainbow (3.0.0)
|
|
37
|
-
rake (
|
|
36
|
+
rake (13.0.1)
|
|
37
|
+
regexp_parser (1.7.1)
|
|
38
38
|
relaxed-rubocop (2.5)
|
|
39
39
|
rest-client (2.1.0)
|
|
40
40
|
http-accept (>= 1.7.0, < 2.0)
|
|
41
41
|
http-cookie (>= 1.0.2, < 2.0)
|
|
42
42
|
mime-types (>= 1.16, < 4.0)
|
|
43
43
|
netrc (~> 0.8)
|
|
44
|
+
rexml (3.2.4)
|
|
44
45
|
rspec (3.9.0)
|
|
45
46
|
rspec-core (~> 3.9.0)
|
|
46
47
|
rspec-expectations (~> 3.9.0)
|
|
47
48
|
rspec-mocks (~> 3.9.0)
|
|
48
|
-
rspec-core (3.9.
|
|
49
|
-
rspec-support (~> 3.9.
|
|
50
|
-
rspec-expectations (3.9.
|
|
49
|
+
rspec-core (3.9.2)
|
|
50
|
+
rspec-support (~> 3.9.3)
|
|
51
|
+
rspec-expectations (3.9.2)
|
|
51
52
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
52
53
|
rspec-support (~> 3.9.0)
|
|
53
54
|
rspec-mocks (3.9.1)
|
|
54
55
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
55
56
|
rspec-support (~> 3.9.0)
|
|
56
|
-
rspec-support (3.9.
|
|
57
|
-
rubocop (0.
|
|
58
|
-
jaro_winkler (~> 1.5.1)
|
|
57
|
+
rspec-support (3.9.3)
|
|
58
|
+
rubocop (0.85.1)
|
|
59
59
|
parallel (~> 1.10)
|
|
60
60
|
parser (>= 2.7.0.1)
|
|
61
61
|
rainbow (>= 2.2.2, < 4.0)
|
|
62
|
+
regexp_parser (>= 1.7)
|
|
63
|
+
rexml
|
|
64
|
+
rubocop-ast (>= 0.0.3)
|
|
62
65
|
ruby-progressbar (~> 1.7)
|
|
63
|
-
unicode-display_width (>= 1.4.0, <
|
|
66
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
|
67
|
+
rubocop-ast (0.0.3)
|
|
68
|
+
parser (>= 2.7.0.1)
|
|
64
69
|
ruby-progressbar (1.10.1)
|
|
65
70
|
thor (0.20.3)
|
|
66
71
|
thread_safe (0.3.6)
|
|
67
|
-
tzinfo (1.2.
|
|
72
|
+
tzinfo (1.2.7)
|
|
68
73
|
thread_safe (~> 0.1)
|
|
69
74
|
unf (0.1.4)
|
|
70
75
|
unf_ext
|
|
71
|
-
unf_ext (0.0.7.
|
|
72
|
-
unicode-display_width (1.
|
|
76
|
+
unf_ext (0.0.7.7)
|
|
77
|
+
unicode-display_width (1.7.0)
|
|
73
78
|
|
|
74
79
|
PLATFORMS
|
|
75
80
|
ruby
|
|
76
81
|
|
|
77
82
|
DEPENDENCIES
|
|
78
83
|
bundler (~> 1.17.3)
|
|
79
|
-
rake (~>
|
|
84
|
+
rake (~> 13.0)
|
|
80
85
|
relaxed-rubocop (~> 2.5)
|
|
81
86
|
rspec (~> 3.0)
|
|
82
|
-
rubocop (~> 0.
|
|
87
|
+
rubocop (~> 0.85.0)
|
|
83
88
|
xapixctl!
|
|
84
89
|
|
|
85
90
|
BUNDLED WITH
|
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# xapixctl
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/rb/xapixctl)
|
|
4
|
+
|
|
3
5
|
Xapix client library and command line tool
|
|
4
6
|
|
|
5
7
|
## Installation
|
|
@@ -8,6 +10,12 @@ Install it via:
|
|
|
8
10
|
|
|
9
11
|
$ gem install xapixctl
|
|
10
12
|
|
|
13
|
+
On Windows make sure you have ruby installed:
|
|
14
|
+
|
|
15
|
+
$ choco install ruby -y
|
|
16
|
+
$ refreshenv
|
|
17
|
+
$ gem install xapixctl
|
|
18
|
+
|
|
11
19
|
## Usage
|
|
12
20
|
|
|
13
21
|
To see more details on how to run xapixctl, use:
|
data/lib/xapixctl/cli.rb
CHANGED
|
@@ -15,7 +15,7 @@ module Xapixctl
|
|
|
15
15
|
option :format, aliases: "-f", default: 'text', enum: ['text', 'yaml', 'json'], desc: "Output format"
|
|
16
16
|
desc "get TYPE [ID]", "retrieve either all resources of given TYPE or just the resource of given TYPE and ID"
|
|
17
17
|
long_desc <<-LONGDESC
|
|
18
|
-
`
|
|
18
|
+
`xapixctl get TYPE` will retrieve the list of all resources of given type.
|
|
19
19
|
|
|
20
20
|
If requested on an organization (i.e. no project given), the following types are available:
|
|
21
21
|
\x5 Project
|
|
@@ -26,10 +26,10 @@ module Xapixctl
|
|
|
26
26
|
Use the format to switch between the different output formats.
|
|
27
27
|
|
|
28
28
|
Examples:
|
|
29
|
-
\x5> $
|
|
30
|
-
\x5> $
|
|
31
|
-
\x5> $
|
|
32
|
-
\x5> $
|
|
29
|
+
\x5> $ xapixctl get -o xapix Project
|
|
30
|
+
\x5> $ xapixctl get -o xapix Project some-project
|
|
31
|
+
\x5> $ xapixctl get -o xapix -p some-project DataSource
|
|
32
|
+
\x5> $ xapixctl get -o xapix -p some-project DataSource get-a-list
|
|
33
33
|
LONGDESC
|
|
34
34
|
def get(resource_type, resource_id = nil)
|
|
35
35
|
if resource_id
|
|
@@ -57,13 +57,13 @@ module Xapixctl
|
|
|
57
57
|
option :format, aliases: "-f", default: 'text', enum: ['text', 'yaml', 'json'], desc: "Output format"
|
|
58
58
|
desc "export", "retrieves all resources within a project"
|
|
59
59
|
long_desc <<-LONGDESC
|
|
60
|
-
`
|
|
60
|
+
`xapixctl export` will retrieve the list of all resources of given type.
|
|
61
61
|
|
|
62
62
|
Use the format to switch between the different output formats.
|
|
63
63
|
|
|
64
64
|
Examples:
|
|
65
|
-
\x5> $
|
|
66
|
-
\x5> $
|
|
65
|
+
\x5> $ xapixctl export -o xapix -p some-project
|
|
66
|
+
\x5> $ xapixctl export -o xapix -p some-project -f yaml > some_project.yaml
|
|
67
67
|
LONGDESC
|
|
68
68
|
def export
|
|
69
69
|
connection.resource('Project', options[:project], org: options[:org], format: options[:format].to_sym) do |res|
|
|
@@ -78,7 +78,7 @@ module Xapixctl
|
|
|
78
78
|
option :file, aliases: "-f", required: true
|
|
79
79
|
desc "apply", "Create or update a resource from a file"
|
|
80
80
|
long_desc <<-LONGDESC
|
|
81
|
-
`
|
|
81
|
+
`xapixctl apply -f FILE` will apply the given resource description.
|
|
82
82
|
|
|
83
83
|
If applied on an organization (i.e. no project given), the project is taken from the resource description.
|
|
84
84
|
|
|
@@ -88,11 +88,11 @@ module Xapixctl
|
|
|
88
88
|
You can also read from stdin by using '-'.
|
|
89
89
|
|
|
90
90
|
Examples:
|
|
91
|
-
\x5> $
|
|
92
|
-
\x5> $
|
|
91
|
+
\x5> $ xapixctl apply -o xapix -f get_a_list.yaml
|
|
92
|
+
\x5> $ xapixctl apply -o xapix -p some-project -f get_a_list.yaml
|
|
93
93
|
|
|
94
94
|
To copy over all data sources from one project to another:
|
|
95
|
-
\x5> $
|
|
95
|
+
\x5> $ xapixctl get -o xapix-old -p some-project DataSource -f yaml | xapixctl apply -o xapix-new -f -
|
|
96
96
|
LONGDESC
|
|
97
97
|
def apply
|
|
98
98
|
resources_from_file(options[:file]) do |desc|
|
|
@@ -109,16 +109,16 @@ module Xapixctl
|
|
|
109
109
|
option :file, aliases: "-f"
|
|
110
110
|
desc "delete [TYPE ID] [-f FILE]", "delete the resources in the file"
|
|
111
111
|
long_desc <<-LONGDESC
|
|
112
|
-
`
|
|
113
|
-
\x5`
|
|
112
|
+
`xapixctl delete -f FILE` will delete all the resources listed in the file.
|
|
113
|
+
\x5`xapixctl delete TYPE ID` will delete the resource by given TYPE and ID.
|
|
114
114
|
|
|
115
115
|
The given file should be in YAML format and can contain multiple resource definitions, each as it's own YAML document.
|
|
116
116
|
You can also read from stdin by using '-'.
|
|
117
117
|
|
|
118
118
|
Examples:
|
|
119
|
-
\x5> $
|
|
120
|
-
\x5> $
|
|
121
|
-
\x5> $
|
|
119
|
+
\x5> $ xapixctl delete -o xapix -p some-project -f get_a_list.yaml
|
|
120
|
+
\x5> $ xapixctl delete -o xapix -p some-project DataSource get-a-list
|
|
121
|
+
\x5> $ xapixctl delete -o xapix Project some-project
|
|
122
122
|
LONGDESC
|
|
123
123
|
def delete(resource_type = nil, resource_id = nil)
|
|
124
124
|
if resource_type && resource_id
|
|
@@ -141,14 +141,54 @@ module Xapixctl
|
|
|
141
141
|
end
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
+
option :org, aliases: "-o", desc: "Organization", required: true
|
|
145
|
+
option :project, aliases: "-p", desc: "Project", required: true
|
|
146
|
+
option :format, aliases: "-f", default: 'text', enum: ['text', 'yaml', 'json'], desc: "Output format"
|
|
147
|
+
desc "preview ID", "Preview a pipeline"
|
|
148
|
+
long_desc <<-LONGDESC
|
|
149
|
+
`xapixctl preview` will return a preview of the given pipeline.
|
|
150
|
+
|
|
151
|
+
The preview function will not call any external data sources but calculate a preview based on the provided sample data.
|
|
152
|
+
|
|
153
|
+
To preview a pipeline attached to an endpoint, please use `xapixctl preview-ep` to see the correct preview.
|
|
154
|
+
|
|
155
|
+
Examples:
|
|
156
|
+
\x5> $ xapixctl preview -o xapix -p some-project pipeline
|
|
157
|
+
LONGDESC
|
|
158
|
+
def preview(pipeline)
|
|
159
|
+
connection.pipeline_preview(pipeline, org: options[:org], project: options[:project], format: options[:format].to_sym) do |res|
|
|
160
|
+
res.on_success { |preview| puts preview }
|
|
161
|
+
res.on_error { |err, result| warn_api_error('could not fetch preview', err, result) }
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
option :org, aliases: "-o", desc: "Organization", required: true
|
|
166
|
+
option :project, aliases: "-p", desc: "Project", required: true
|
|
167
|
+
option :format, aliases: "-f", default: 'text', enum: ['text', 'yaml', 'json'], desc: "Output format"
|
|
168
|
+
desc "preview-ep ID", "Preview an endpoint"
|
|
169
|
+
long_desc <<-LONGDESC
|
|
170
|
+
`xapixctl preview-ep` will return a preview of the given endpoint.
|
|
171
|
+
|
|
172
|
+
The preview function will not call any external data sources but calculate a preview based on the provided sample data.
|
|
173
|
+
|
|
174
|
+
Examples:
|
|
175
|
+
\x5> $ xapixctl preview-ep -o xapix -p some-project endpoint
|
|
176
|
+
LONGDESC
|
|
177
|
+
def preview_ep(endpoint)
|
|
178
|
+
connection.endpoint_preview(endpoint, org: options[:org], project: options[:project], format: options[:format].to_sym) do |res|
|
|
179
|
+
res.on_success { |preview| puts preview }
|
|
180
|
+
res.on_error { |err, result| warn_api_error('could not fetch preview', err, result) }
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
144
184
|
option :org, aliases: "-o", desc: "Organization", required: true
|
|
145
185
|
option :project, aliases: "-p", desc: "Project", required: true
|
|
146
186
|
desc "publish", "Publishes the current version of the given project"
|
|
147
187
|
long_desc <<-LONGDESC
|
|
148
|
-
`
|
|
188
|
+
`xapixctl publish` will publish the given project.
|
|
149
189
|
|
|
150
190
|
Examples:
|
|
151
|
-
\x5> $
|
|
191
|
+
\x5> $ xapixctl publish -o xapix -p some-project
|
|
152
192
|
LONGDESC
|
|
153
193
|
def publish
|
|
154
194
|
connection.publish(org: options[:org], project: options[:project]) do |res|
|
|
@@ -161,12 +201,12 @@ module Xapixctl
|
|
|
161
201
|
option :project, aliases: "-p", desc: "Project", required: true
|
|
162
202
|
desc "logs CORRELATION_ID", "Retrieves the execution logs for the given correlation ID"
|
|
163
203
|
long_desc <<-LONGDESC
|
|
164
|
-
`
|
|
204
|
+
`xapixctl logs CORRELATION_ID` will retrieve execution logs for the given correlation ID.
|
|
165
205
|
|
|
166
206
|
The correlation ID is included as X-Correlation-Id header in the response of each request.
|
|
167
207
|
|
|
168
208
|
Examples:
|
|
169
|
-
\x5> $
|
|
209
|
+
\x5> $ xapixctl logs be9c8608-e291-460d-bc20-5a394c4079d4 -o xapix -p some-project
|
|
170
210
|
LONGDESC
|
|
171
211
|
def logs(correlation_id)
|
|
172
212
|
connection.logs(correlation_id, org: options[:org], project: options[:project]) do |res|
|
|
@@ -43,6 +43,28 @@ module Xapixctl
|
|
|
43
43
|
text: ->(data) { (TEXT_FORMATTERS[data.dig('metadata', 'type')] || TEXT_FORMATTERS[:all]).call(data) }
|
|
44
44
|
}.freeze
|
|
45
45
|
|
|
46
|
+
PREVIEW_FORMATTERS = {
|
|
47
|
+
json: ->(data) { JSON.pretty_generate(data) },
|
|
48
|
+
yaml: ->(data) { Psych.dump(data) },
|
|
49
|
+
text: ->(data) do
|
|
50
|
+
preview = data['preview']
|
|
51
|
+
if ['RestJson', 'SoapXml'].include?(data['content_type'])
|
|
52
|
+
res = StringIO.new
|
|
53
|
+
if preview.is_a?(Hash)
|
|
54
|
+
res.puts "HTTP #{preview['status']}"
|
|
55
|
+
preview['headers']&.each { |h, v| res.puts "#{h}: #{v}" }
|
|
56
|
+
res.puts
|
|
57
|
+
res.puts preview['body']
|
|
58
|
+
else
|
|
59
|
+
res.puts preview
|
|
60
|
+
end
|
|
61
|
+
res.string
|
|
62
|
+
else
|
|
63
|
+
Psych.dump(preview)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
}.freeze
|
|
67
|
+
|
|
46
68
|
class Connection
|
|
47
69
|
DEFAULT_SUCCESS_HANDLER = ->(result) { result }
|
|
48
70
|
DEFAULT_ERROR_HANDLER = ->(err, _response) { warn "Could not get data: #{err}" }
|
|
@@ -98,6 +120,20 @@ module Xapixctl
|
|
|
98
120
|
run { @client[resource_path(org, project, resource_type, resource_id)].delete }
|
|
99
121
|
end
|
|
100
122
|
|
|
123
|
+
def pipeline_preview(pipeline_id, org:, project:, format: :hash, &block)
|
|
124
|
+
result_handler(block).
|
|
125
|
+
prepare_data(->(data) { data['pipeline_preview'] }).
|
|
126
|
+
formatter(PREVIEW_FORMATTERS[format]).
|
|
127
|
+
run { @client[pipeline_preview_path(org, project, pipeline_id)].get }
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def endpoint_preview(endpoint_id, org:, project:, format: :hash, &block)
|
|
131
|
+
result_handler(block).
|
|
132
|
+
prepare_data(->(data) { data['endpoint_preview'] }).
|
|
133
|
+
formatter(PREVIEW_FORMATTERS[format]).
|
|
134
|
+
run { @client[endpoint_preview_path(org, project, endpoint_id)].get }
|
|
135
|
+
end
|
|
136
|
+
|
|
101
137
|
def publish(org:, project:, &block)
|
|
102
138
|
result_handler(block).
|
|
103
139
|
run { @client[project_publications_path(org, project)].post('') }
|
|
@@ -122,6 +158,10 @@ module Xapixctl
|
|
|
122
158
|
end
|
|
123
159
|
end
|
|
124
160
|
|
|
161
|
+
def onboarding(org:, project:)
|
|
162
|
+
OnboardingConnection.new(@client, @default_success_handler, @default_error_handler, org, project)
|
|
163
|
+
end
|
|
164
|
+
|
|
125
165
|
private
|
|
126
166
|
|
|
127
167
|
def result_handler(block)
|
|
@@ -142,6 +182,14 @@ module Xapixctl
|
|
|
142
182
|
project ? "projects/#{org}/#{project}/resource" : "orgs/#{org}/resource"
|
|
143
183
|
end
|
|
144
184
|
|
|
185
|
+
def pipeline_preview_path(org, project, pipeline)
|
|
186
|
+
"/projects/#{org}/#{project}/pipelines/#{pipeline}/preview"
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def endpoint_preview_path(org, project, endpoint)
|
|
190
|
+
"/projects/#{org}/#{project}/endpoints/#{endpoint}/preview"
|
|
191
|
+
end
|
|
192
|
+
|
|
145
193
|
def project_publications_path(org, project)
|
|
146
194
|
"/projects/#{org}/#{project}/publications"
|
|
147
195
|
end
|
|
@@ -159,5 +207,82 @@ module Xapixctl
|
|
|
159
207
|
resource_type.sub(%r[/.*], '') # cut off everything after first slash
|
|
160
208
|
end
|
|
161
209
|
end
|
|
210
|
+
|
|
211
|
+
class OnboardingConnection
|
|
212
|
+
def initialize(client, default_success_handler, default_error_handler, org, project)
|
|
213
|
+
@client = client
|
|
214
|
+
@default_success_handler = default_success_handler
|
|
215
|
+
@default_error_handler = default_error_handler
|
|
216
|
+
@org = org
|
|
217
|
+
@project = project
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# Notes on parameters:
|
|
221
|
+
# - Query parameters should be part of the URL
|
|
222
|
+
# - Path parameters should be marked with `{name}` in the URL, and values should be given in path_params hash
|
|
223
|
+
# - Headers should be given in headers hash
|
|
224
|
+
# - Cookies should be given in cookies hash
|
|
225
|
+
# - The body has to be given as a string
|
|
226
|
+
# - The required authentication schemes should be listed, referring to previously created schemes
|
|
227
|
+
#
|
|
228
|
+
# This returns a hash like the following:
|
|
229
|
+
# "data_source" => { "id" => id, "resource_description" => resource_description }
|
|
230
|
+
#
|
|
231
|
+
# To successfully onboard a DB using the API, the following steps are needed:
|
|
232
|
+
# 1. setup the data source using add_rest_data_source.
|
|
233
|
+
# 2. retrieve a preview using preview_data_source using the id returned by previous step
|
|
234
|
+
# 3. confirm preview
|
|
235
|
+
# 4. call accept_data_source_preview to complete onboarding
|
|
236
|
+
#
|
|
237
|
+
def add_rest_data_source(http_method:, url:, path_params: {}, headers: {}, cookies: {}, body: nil, auth_schemes: [], &block)
|
|
238
|
+
data_source_details = {
|
|
239
|
+
http_method: http_method, url: url,
|
|
240
|
+
parameters: { path: path_params.to_query, header: headers.to_query, cookies: cookies.to_query, body: body },
|
|
241
|
+
auth_schemes: auth_schemes
|
|
242
|
+
}
|
|
243
|
+
result_handler(block).
|
|
244
|
+
run { @client[rest_data_source_path].post(data_source: data_source_details) }
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
# Notes on parameters:
|
|
248
|
+
# - To call a data source which requires authentication, provide a hash with each required auth scheme as key and
|
|
249
|
+
# as the value a reference to a previously created credential.
|
|
250
|
+
# Example: { scheme_ref1 => credential_ref1, scheme_ref2 => credential_ref2 }
|
|
251
|
+
#
|
|
252
|
+
# This returns a hashified preview like the following:
|
|
253
|
+
# { "preview" => {
|
|
254
|
+
# "sample" => { "status" => integer, "body" => { ... }, "headers" => { ... }, "cookies" => { ... } },
|
|
255
|
+
# "fetched_at" => Timestamp },
|
|
256
|
+
# "data_source" => { "id" => id, "resource_description" => resource_description } }
|
|
257
|
+
#
|
|
258
|
+
def preview_data_source(data_source_id, authentications: {}, &block)
|
|
259
|
+
preview_data = {
|
|
260
|
+
authentications: authentications.map { |scheme, cred| { auth_scheme_id: scheme, auth_credential_id: cred } }
|
|
261
|
+
}
|
|
262
|
+
result_handler(block).
|
|
263
|
+
run { @client[data_source_preview_path(data_source_id)].post(preview_data) }
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
# This returns a hashified preview like the following:
|
|
267
|
+
|
|
268
|
+
def accept_data_source_preview(data_source_id, &block)
|
|
269
|
+
result_handler(block).
|
|
270
|
+
run { @client[data_source_preview_path(data_source_id)].patch('') }
|
|
271
|
+
end
|
|
272
|
+
|
|
273
|
+
private
|
|
274
|
+
|
|
275
|
+
def result_handler(block)
|
|
276
|
+
ResultHandler.new(default_success_handler: @default_success_handler, default_error_handler: @default_error_handler, &block)
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
def rest_data_source_path
|
|
280
|
+
"/projects/#{@org}/#{@project}/onboarding/data_sources/rest"
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def data_source_preview_path(id)
|
|
284
|
+
"/projects/#{@org}/#{@project}/onboarding/data_sources/#{id}/preview"
|
|
285
|
+
end
|
|
286
|
+
end
|
|
162
287
|
end
|
|
163
288
|
end
|
data/lib/xapixctl/version.rb
CHANGED
data/xapixctl.gemspec
CHANGED
|
@@ -24,13 +24,13 @@ Gem::Specification.new do |spec|
|
|
|
24
24
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
25
25
|
spec.require_paths = ["lib"]
|
|
26
26
|
|
|
27
|
-
spec.add_dependency "activesupport", "
|
|
28
|
-
spec.add_dependency "rest-client", "
|
|
29
|
-
spec.add_dependency "thor", "
|
|
27
|
+
spec.add_dependency "activesupport", ">= 5.2.3", "< 6.0.0"
|
|
28
|
+
spec.add_dependency "rest-client", ">= 2.1.0", "< 3.0.0"
|
|
29
|
+
spec.add_dependency "thor", ">= 0.20.3", "< 1.0.0"
|
|
30
30
|
|
|
31
31
|
spec.add_development_dependency "bundler", "~> 1.17.3"
|
|
32
|
-
spec.add_development_dependency "rake", "~>
|
|
32
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
|
33
33
|
spec.add_development_dependency "relaxed-rubocop", "~> 2.5"
|
|
34
34
|
spec.add_development_dependency "rspec", "~> 3.0"
|
|
35
|
-
spec.add_development_dependency "rubocop", "~> 0.
|
|
35
|
+
spec.add_development_dependency "rubocop", "~> 0.85.0"
|
|
36
36
|
end
|
metadata
CHANGED
|
@@ -1,57 +1,75 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: xapixctl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Michael Reinsch
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-06-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
19
|
version: 5.2.3
|
|
20
|
+
- - "<"
|
|
21
|
+
- !ruby/object:Gem::Version
|
|
22
|
+
version: 6.0.0
|
|
20
23
|
type: :runtime
|
|
21
24
|
prerelease: false
|
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
26
|
requirements:
|
|
24
|
-
- - "
|
|
27
|
+
- - ">="
|
|
25
28
|
- !ruby/object:Gem::Version
|
|
26
29
|
version: 5.2.3
|
|
30
|
+
- - "<"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: 6.0.0
|
|
27
33
|
- !ruby/object:Gem::Dependency
|
|
28
34
|
name: rest-client
|
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
|
30
36
|
requirements:
|
|
31
|
-
- - "
|
|
37
|
+
- - ">="
|
|
32
38
|
- !ruby/object:Gem::Version
|
|
33
39
|
version: 2.1.0
|
|
40
|
+
- - "<"
|
|
41
|
+
- !ruby/object:Gem::Version
|
|
42
|
+
version: 3.0.0
|
|
34
43
|
type: :runtime
|
|
35
44
|
prerelease: false
|
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
46
|
requirements:
|
|
38
|
-
- - "
|
|
47
|
+
- - ">="
|
|
39
48
|
- !ruby/object:Gem::Version
|
|
40
49
|
version: 2.1.0
|
|
50
|
+
- - "<"
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: 3.0.0
|
|
41
53
|
- !ruby/object:Gem::Dependency
|
|
42
54
|
name: thor
|
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
|
44
56
|
requirements:
|
|
45
|
-
- - "
|
|
57
|
+
- - ">="
|
|
46
58
|
- !ruby/object:Gem::Version
|
|
47
59
|
version: 0.20.3
|
|
60
|
+
- - "<"
|
|
61
|
+
- !ruby/object:Gem::Version
|
|
62
|
+
version: 1.0.0
|
|
48
63
|
type: :runtime
|
|
49
64
|
prerelease: false
|
|
50
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
66
|
requirements:
|
|
52
|
-
- - "
|
|
67
|
+
- - ">="
|
|
53
68
|
- !ruby/object:Gem::Version
|
|
54
69
|
version: 0.20.3
|
|
70
|
+
- - "<"
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: 1.0.0
|
|
55
73
|
- !ruby/object:Gem::Dependency
|
|
56
74
|
name: bundler
|
|
57
75
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -72,14 +90,14 @@ dependencies:
|
|
|
72
90
|
requirements:
|
|
73
91
|
- - "~>"
|
|
74
92
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
93
|
+
version: '13.0'
|
|
76
94
|
type: :development
|
|
77
95
|
prerelease: false
|
|
78
96
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
97
|
requirements:
|
|
80
98
|
- - "~>"
|
|
81
99
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
100
|
+
version: '13.0'
|
|
83
101
|
- !ruby/object:Gem::Dependency
|
|
84
102
|
name: relaxed-rubocop
|
|
85
103
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -114,15 +132,15 @@ dependencies:
|
|
|
114
132
|
requirements:
|
|
115
133
|
- - "~>"
|
|
116
134
|
- !ruby/object:Gem::Version
|
|
117
|
-
version: 0.
|
|
135
|
+
version: 0.85.0
|
|
118
136
|
type: :development
|
|
119
137
|
prerelease: false
|
|
120
138
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
139
|
requirements:
|
|
122
140
|
- - "~>"
|
|
123
141
|
- !ruby/object:Gem::Version
|
|
124
|
-
version: 0.
|
|
125
|
-
description:
|
|
142
|
+
version: 0.85.0
|
|
143
|
+
description:
|
|
126
144
|
email:
|
|
127
145
|
- michael@xapix.io
|
|
128
146
|
executables:
|
|
@@ -153,7 +171,7 @@ licenses:
|
|
|
153
171
|
metadata:
|
|
154
172
|
homepage_uri: https://github.com/xapix-io/xapixctl
|
|
155
173
|
source_code_uri: https://github.com/xapix-io/xapixctl
|
|
156
|
-
post_install_message:
|
|
174
|
+
post_install_message:
|
|
157
175
|
rdoc_options: []
|
|
158
176
|
require_paths:
|
|
159
177
|
- lib
|
|
@@ -168,8 +186,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
168
186
|
- !ruby/object:Gem::Version
|
|
169
187
|
version: '0'
|
|
170
188
|
requirements: []
|
|
171
|
-
rubygems_version: 3.0.
|
|
172
|
-
signing_key:
|
|
189
|
+
rubygems_version: 3.0.8
|
|
190
|
+
signing_key:
|
|
173
191
|
specification_version: 4
|
|
174
192
|
summary: xapix client library and command line tool
|
|
175
193
|
test_files: []
|