Class: ApprovalApiClient::RequestApi

Inherits:
Object
  • Object
show all
Defined in:
lib/insights-approval-api-client/api/request_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ RequestApi

Returns a new instance of RequestApi.



19
20
21
# File 'lib/insights-approval-api-client/api/request_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/insights-approval-api-client/api/request_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_request(request_in, opts = {}) ⇒ Request

Add an approval request by given parameters Add an approval request by given parameters, available to anyone

Parameters:

  • request_in (RequestIn)

    Parameters need to create a request

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



27
28
29
30
# File 'lib/insights-approval-api-client/api/request_api.rb', line 27

def create_request(request_in, opts = {})
  data, _status_code, _headers = create_request_with_http_info(request_in, opts)
  data
end

#create_request_with_http_info(request_in, opts = {}) ⇒ Array<(Request, Integer, Hash)>

Add an approval request by given parameters Add an approval request by given parameters, available to anyone

Parameters:

  • request_in (RequestIn)

    Parameters need to create a request

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Request, Integer, Hash)>)

    Request data, response status code and response headers



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/insights-approval-api-client/api/request_api.rb', line 37

def create_request_with_http_info(request_in, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RequestApi.create_request ...'
  end
  # verify the required parameter 'request_in' is set
  if @api_client.config.client_side_validation && request_in.nil?
    fail ArgumentError, "Missing the required parameter 'request_in' when calling RequestApi.create_request"
  end
  # resource path
  local_var_path = '/requests'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] || @api_client.object_to_http_body(request_in) 

  # return_type
  return_type = opts[:return_type] || 'Request' 

  # auth_names
  auth_names = opts[:auth_names] || ['Basic_auth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RequestApi#create_request\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_requests(opts = {}) ⇒ RequestCollection

Return an array of requester made approval requests, available to anyone The result depends on the x-rh-persona header (approval/admin, approval/requseter, or approval/approver). Program generated child requests are not included.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_rh_persona (String)

    Current login user&#39;s persona

  • :limit (Integer)

    How many items to return at one time (max 1000) (default to 100)

  • :offset (Integer)

    Starting Offset (default to 0)

  • :filter (Object)

    Filter for querying collections.

  • :sort_by (String)

    Parameter to sort collection

Returns:



95
96
97
98
# File 'lib/insights-approval-api-client/api/request_api.rb', line 95

def list_requests(opts = {})
  data, _status_code, _headers = list_requests_with_http_info(opts)
  data
end

#list_requests_by_request(request_id, opts = {}) ⇒ RequestCollection

Return an array of child requests of a given request id Return an array of child requests of a given request id. The result depends on the x-rh-persona header (approval/admin, approval/requseter, or approval/approver).

Parameters:

  • request_id (String)

    Id of request

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_rh_persona (String)

    Current login user&#39;s persona

Returns:



179
180
181
182
# File 'lib/insights-approval-api-client/api/request_api.rb', line 179

def list_requests_by_request(request_id, opts = {})
  data, _status_code, _headers = list_requests_by_request_with_http_info(request_id, opts)
  data
end

#list_requests_by_request_with_http_info(request_id, opts = {}) ⇒ Array<(RequestCollection, Integer, Hash)>

Return an array of child requests of a given request id Return an array of child requests of a given request id. The result depends on the x-rh-persona header (approval/admin, approval/requseter, or approval/approver).

Parameters:

  • request_id (String)

    Id of request

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_rh_persona (String)

    Current login user&#39;s persona

Returns:

  • (Array<(RequestCollection, Integer, Hash)>)

    RequestCollection data, response status code and response headers



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/insights-approval-api-client/api/request_api.rb', line 190

def list_requests_by_request_with_http_info(request_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RequestApi.list_requests_by_request ...'
  end
  # verify the required parameter 'request_id' is set
  if @api_client.config.client_side_validation && request_id.nil?
    fail ArgumentError, "Missing the required parameter 'request_id' when calling RequestApi.list_requests_by_request"
  end
  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation && request_id !~ pattern
    fail ArgumentError, "invalid value for 'request_id' when calling RequestApi.list_requests_by_request, must conform to the pattern #{pattern}."
  end

  allowable_values = ["approval/admin", "approval/approver", "approval/requester"]
  if @api_client.config.client_side_validation && opts[:'x_rh_persona'] && !allowable_values.include?(opts[:'x_rh_persona'])
    fail ArgumentError, "invalid value for \"x_rh_persona\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/requests/{request_id}/requests'.sub('{' + 'request_id' + '}', CGI.escape(request_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'x-rh-persona'] = opts[:'x_rh_persona'] if !opts[:'x_rh_persona'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'RequestCollection' 

  # auth_names
  auth_names = opts[:auth_names] || ['Basic_auth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RequestApi#list_requests_by_request\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_requests_with_http_info(opts = {}) ⇒ Array<(RequestCollection, Integer, Hash)>

Return an array of requester made approval requests, available to anyone The result depends on the x-rh-persona header (approval/admin, approval/requseter, or approval/approver). Program generated child requests are not included.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :x_rh_persona (String)

    Current login user&#39;s persona

  • :limit (Integer)

    How many items to return at one time (max 1000)

  • :offset (Integer)

    Starting Offset

  • :filter (Object)

    Filter for querying collections.

  • :sort_by (String)

    Parameter to sort collection

Returns:

  • (Array<(RequestCollection, Integer, Hash)>)

    RequestCollection data, response status code and response headers



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# File 'lib/insights-approval-api-client/api/request_api.rb', line 109

def list_requests_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RequestApi.list_requests ...'
  end
  allowable_values = ["approval/admin", "approval/approver", "approval/requester"]
  if @api_client.config.client_side_validation && opts[:'x_rh_persona'] && !allowable_values.include?(opts[:'x_rh_persona'])
    fail ArgumentError, "invalid value for \"x_rh_persona\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 1000
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling RequestApi.list_requests, must be smaller than or equal to 1000.'
  end

  if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling RequestApi.list_requests, must be greater than or equal to 1.'
  end

  if @api_client.config.client_side_validation && !opts[:'offset'].nil? && opts[:'offset'] < 0
    fail ArgumentError, 'invalid value for "opts[:"offset"]" when calling RequestApi.list_requests, must be greater than or equal to 0.'
  end

  # resource path
  local_var_path = '/requests'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  header_params[:'x-rh-persona'] = opts[:'x_rh_persona'] if !opts[:'x_rh_persona'].nil?

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'RequestCollection' 

  # auth_names
  auth_names = opts[:auth_names] || ['Basic_auth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RequestApi#list_requests\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#show_request(id, opts = {}) ⇒ Request

Return an approval request by given id Return an approval request by given id, available to anyone who can access the request

Parameters:

  • id (String)

    Query by id

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



252
253
254
255
# File 'lib/insights-approval-api-client/api/request_api.rb', line 252

def show_request(id, opts = {})
  data, _status_code, _headers = show_request_with_http_info(id, opts)
  data
end

#show_request_content(request_id, opts = {}) ⇒ Object

Return request content of a given request id Return request content of a given request id, available to all

Parameters:

  • request_id (String)

    Id of request

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Object)


319
320
321
322
# File 'lib/insights-approval-api-client/api/request_api.rb', line 319

def show_request_content(request_id, opts = {})
  data, _status_code, _headers = show_request_content_with_http_info(request_id, opts)
  data
end

#show_request_content_with_http_info(request_id, opts = {}) ⇒ Array<(Object, Integer, Hash)>

Return request content of a given request id Return request content of a given request id, available to all

Parameters:

  • request_id (String)

    Id of request

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Object, Integer, Hash)>)

    Object data, response status code and response headers



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# File 'lib/insights-approval-api-client/api/request_api.rb', line 329

def show_request_content_with_http_info(request_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RequestApi.show_request_content ...'
  end
  # verify the required parameter 'request_id' is set
  if @api_client.config.client_side_validation && request_id.nil?
    fail ArgumentError, "Missing the required parameter 'request_id' when calling RequestApi.show_request_content"
  end
  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation && request_id !~ pattern
    fail ArgumentError, "invalid value for 'request_id' when calling RequestApi.show_request_content, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/requests/{request_id}/content'.sub('{' + 'request_id' + '}', CGI.escape(request_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'Object' 

  # auth_names
  auth_names = opts[:auth_names] || ['Basic_auth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RequestApi#show_request_content\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#show_request_with_http_info(id, opts = {}) ⇒ Array<(Request, Integer, Hash)>

Return an approval request by given id Return an approval request by given id, available to anyone who can access the request

Parameters:

  • id (String)

    Query by id

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Request, Integer, Hash)>)

    Request data, response status code and response headers



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/insights-approval-api-client/api/request_api.rb', line 262

def show_request_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RequestApi.show_request ...'
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling RequestApi.show_request"
  end
  pattern = Regexp.new(/^\d+$/)
  if @api_client.config.client_side_validation && id !~ pattern
    fail ArgumentError, "invalid value for 'id' when calling RequestApi.show_request, must conform to the pattern #{pattern}."
  end

  # resource path
  local_var_path = '/requests/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['*/*'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  # return_type
  return_type = opts[:return_type] || 'Request' 

  # auth_names
  auth_names = opts[:auth_names] || ['Basic_auth']

  new_options = opts.merge(
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: RequestApi#show_request\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end