haveapi-client 0.14.0 → 0.15.1
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6e5b127dccda20aa750bc4b96439e60ed9b3187d35a75ded882c3ee5f3ae848
|
4
|
+
data.tar.gz: 1d666724640a558352d3f19d18e3de5c0fc3d5185d472f4d21993540d34ca214
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edd9c2b63c6276f27306bc7da23f8b1fd124aa8415cc7a4bc63177a82e56fd7174f9dea13e5956cad4ec8cf8c9f912aeda5b57235f985be7000b0f60db9e57bd
|
7
|
+
data.tar.gz: e4c7b696131b8ac85fc66e5937394a247ca71545033358e22bf12ba563a79b0b3b21134db5c1e38552d513aa6af69915c6aa52fce80ddba645deebb31f2b9dab
|
@@ -5,8 +5,8 @@ module HaveAPI::CLI
|
|
5
5
|
f.format
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.print(*args)
|
9
|
-
f = new(*args)
|
8
|
+
def self.print(*args, **kwargs)
|
9
|
+
f = new(*args, **kwargs)
|
10
10
|
f.print
|
11
11
|
end
|
12
12
|
|
@@ -84,7 +84,7 @@ module HaveAPI::CLI
|
|
84
84
|
def generate
|
85
85
|
return if @cols.empty?
|
86
86
|
prepare
|
87
|
-
|
87
|
+
|
88
88
|
case @layout
|
89
89
|
when :columns
|
90
90
|
columns
|
@@ -113,7 +113,7 @@ module HaveAPI::CLI
|
|
113
113
|
i += 1
|
114
114
|
ret
|
115
115
|
end.join(' ')
|
116
|
-
|
116
|
+
|
117
117
|
line sprintf(formatters, * @cols.map { |c| c[:label] }) if @header
|
118
118
|
|
119
119
|
@str_objects.each do |o|
|
@@ -128,7 +128,7 @@ module HaveAPI::CLI
|
|
128
128
|
@str_objects.each do |o|
|
129
129
|
@cols.each_index do |i|
|
130
130
|
c = @cols[i]
|
131
|
-
|
131
|
+
|
132
132
|
if o[i].is_a?(::String) && o[i].index("\n")
|
133
133
|
lines = o[i].split("\n")
|
134
134
|
v = ([lines.first] + lines[1..-1].map { |l| (' ' * (w+3)) + l }).join("\n")
|
@@ -139,7 +139,7 @@ module HaveAPI::CLI
|
|
139
139
|
|
140
140
|
line sprintf("%#{w}s: %s", c[:label], v)
|
141
141
|
end
|
142
|
-
|
142
|
+
|
143
143
|
line
|
144
144
|
end
|
145
145
|
end
|
@@ -155,10 +155,10 @@ module HaveAPI::CLI
|
|
155
155
|
|
156
156
|
def prepare
|
157
157
|
@str_objects = []
|
158
|
-
|
158
|
+
|
159
159
|
each_object do |o|
|
160
160
|
arr = []
|
161
|
-
|
161
|
+
|
162
162
|
@cols.each do |c|
|
163
163
|
v = o[ c[:name] ]
|
164
164
|
str = (c[:display] ? c[:display].call(v) : v)
|
@@ -190,7 +190,7 @@ module HaveAPI::CLI
|
|
190
190
|
|
191
191
|
def col_width(i, c)
|
192
192
|
w = c[:label].to_s.length
|
193
|
-
|
193
|
+
|
194
194
|
@str_objects.each do |o|
|
195
195
|
len = o[i].to_s.length
|
196
196
|
w = len if len > w
|
@@ -12,8 +12,8 @@ module HaveAPI::Client
|
|
12
12
|
apply_args(args)
|
13
13
|
end
|
14
14
|
|
15
|
-
def execute(data,
|
16
|
-
|
15
|
+
def execute(data, raw: false)
|
16
|
+
params_arg = {}
|
17
17
|
|
18
18
|
if input
|
19
19
|
params = Params.new(self, data)
|
@@ -22,10 +22,10 @@ module HaveAPI::Client
|
|
22
22
|
raise ValidationError.new(self, params.errors)
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
params_arg = params.to_api
|
26
26
|
end
|
27
27
|
|
28
|
-
ret = @api.call(
|
28
|
+
ret = @api.call(self, params_arg, raw: raw)
|
29
29
|
reset
|
30
30
|
ret
|
31
31
|
end
|
@@ -49,8 +49,8 @@ class HaveAPI::Client::Client
|
|
49
49
|
end
|
50
50
|
|
51
51
|
# See Communicator#authenticate.
|
52
|
-
def authenticate(
|
53
|
-
@api.authenticate(
|
52
|
+
def authenticate(auth_method, **options, &block)
|
53
|
+
@api.authenticate(auth_method, options, &block)
|
54
54
|
end
|
55
55
|
|
56
56
|
# Get uthentication provider
|
@@ -76,7 +76,7 @@ module HaveAPI::Client
|
|
76
76
|
action.aliases(true).each do |name|
|
77
77
|
next unless define_method?(action, name)
|
78
78
|
|
79
|
-
define_singleton_method(name) do |*args, &block|
|
79
|
+
define_singleton_method(name) do |*args, **kwargs, &block|
|
80
80
|
client_opts = @client.opts(:block, :block_interval, :block_timeout)
|
81
81
|
all_args = @prepared_args + args
|
82
82
|
|
@@ -89,28 +89,42 @@ module HaveAPI::Client
|
|
89
89
|
end
|
90
90
|
|
91
91
|
if action.unresolved_args?
|
92
|
-
raise ArgumentError
|
92
|
+
raise ArgumentError, 'one or more object ids missing'
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
if all_args.
|
97
|
-
|
96
|
+
if all_args.length > 1 || (kwargs.any? && all_args.any?)
|
97
|
+
raise ArgumentError, "too many arguments for action #{@name}##{action.name}"
|
98
|
+
end
|
99
|
+
|
100
|
+
arg = all_args.shift
|
98
101
|
|
99
|
-
|
100
|
-
|
102
|
+
user_params =
|
103
|
+
if kwargs.any? && arg
|
104
|
+
raise ArgumentError,
|
105
|
+
'pass the input parameters either as a hash or keyword arguments'
|
106
|
+
elsif kwargs.any?
|
107
|
+
kwargs
|
108
|
+
elsif arg
|
109
|
+
arg
|
110
|
+
end
|
101
111
|
|
102
|
-
|
103
|
-
|
112
|
+
if user_params.nil?
|
113
|
+
input_params = default_action_input_params(action)
|
114
|
+
|
115
|
+
else
|
116
|
+
if user_params.has_key?(:meta)
|
117
|
+
meta = user_params[:meta]
|
104
118
|
|
105
119
|
%i(block block_interval block_timeout).each do |p|
|
106
120
|
client_opts[p] = meta.delete(p) if meta.has_key?(p)
|
107
121
|
end
|
108
122
|
end
|
109
123
|
|
110
|
-
|
124
|
+
input_params = default_action_input_params(action).update(user_params)
|
111
125
|
end
|
112
126
|
|
113
|
-
ret = Response.new(action, action.execute(
|
127
|
+
ret = Response.new(action, action.execute(input_params))
|
114
128
|
|
115
129
|
raise ActionFailed.new(ret) unless ret.ok?
|
116
130
|
|
@@ -137,8 +151,8 @@ module HaveAPI::Client
|
|
137
151
|
}.each do |k, v|
|
138
152
|
wait_opts[v] = client_opts[k] if client_opts.has_key?(k)
|
139
153
|
end
|
140
|
-
|
141
|
-
ret.wait_for_completion(wait_opts) do |state|
|
154
|
+
|
155
|
+
ret.wait_for_completion(**wait_opts) do |state|
|
142
156
|
block.call(return_value, state) if block
|
143
157
|
end
|
144
158
|
end
|
@@ -61,10 +61,10 @@ class HaveAPI::Client::Response
|
|
61
61
|
# it is regularly called with the action's state.
|
62
62
|
#
|
63
63
|
# @see HaveAPI::Client::Action#wait_for_completion
|
64
|
-
def wait_for_completion(
|
64
|
+
def wait_for_completion(**kwargs, &block)
|
65
65
|
id = meta[:action_state_id]
|
66
66
|
return nil unless id
|
67
67
|
|
68
|
-
HaveAPI::Client::Action.wait_for_completion(@action.client, id,
|
68
|
+
HaveAPI::Client::Action.wait_for_completion(@action.client, id, **kwargs, &block)
|
69
69
|
end
|
70
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haveapi-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Skokan
|
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
198
|
- !ruby/object:Gem::Version
|
199
199
|
version: '0'
|
200
200
|
requirements: []
|
201
|
-
rubygems_version: 3.2.
|
201
|
+
rubygems_version: 3.2.26
|
202
202
|
signing_key:
|
203
203
|
specification_version: 4
|
204
204
|
summary: Ruby API and CLI for HaveAPI
|