Class: SmplkitGeneratedClient::Jobs::JobsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ JobsApi

Returns a new instance of JobsApi.



19
20
21
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_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/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_job(job_create_request, opts = {}) ⇒ JobResponse

Create Job Create a job for this account. The caller supplies the job’s id as ‘data.id`. Ids are unique within an account and immutable. An enabled job begins scheduling immediately.

Parameters:

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

    the optional parameters

Returns:



27
28
29
30
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 27

def create_job(job_create_request, opts = {})
  data, _status_code, _headers = create_job_with_http_info(job_create_request, opts)
  data
end

#create_job_with_http_info(job_create_request, opts = {}) ⇒ Array<(JobResponse, Integer, Hash)>

Create Job Create a job for this account. The caller supplies the job&#39;s id as &#x60;data.id&#x60;. Ids are unique within an account and immutable. An enabled job begins scheduling immediately.

Parameters:

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

    the optional parameters

Returns:

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

    JobResponse 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
85
86
87
88
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 37

def create_job_with_http_info(job_create_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: JobsApi.create_job ...'
  end
  # verify the required parameter 'job_create_request' is set
  if @api_client.config.client_side_validation && job_create_request.nil?
    fail ArgumentError, "Missing the required parameter 'job_create_request' when calling JobsApi.create_job"
  end
  # resource path
  local_var_path = '/api/v1/jobs'

  # 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/vnd.api+json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

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

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

  # return_type
  return_type = opts[:debug_return_type] || 'JobResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"JobsApi.create_job",
    :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: JobsApi#create_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_job(job_id, opts = {}) ⇒ nil

Delete Job Delete a job. Its run history is retained; the id may be reused later.

Parameters:

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

    the optional parameters

Returns:

  • (nil)


95
96
97
98
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 95

def delete_job(job_id, opts = {})
  delete_job_with_http_info(job_id, opts)
  nil
end

#delete_job_with_http_info(job_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete Job Delete a job. Its run history is retained; the id may be reused later.

Parameters:

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



105
106
107
108
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
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 105

def delete_job_with_http_info(job_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: JobsApi.delete_job ...'
  end
  # verify the required parameter 'job_id' is set
  if @api_client.config.client_side_validation && job_id.nil?
    fail ArgumentError, "Missing the required parameter 'job_id' when calling JobsApi.delete_job"
  end
  # resource path
  local_var_path = '/api/v1/jobs/{job_id}'.sub('{job_id}', CGI.escape(job_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}

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

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

  # return_type
  return_type = opts[:debug_return_type]

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"JobsApi.delete_job",
    :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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: JobsApi#delete_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_job(job_id, opts = {}) ⇒ JobResponse

Get Job Retrieve a single job by its id.

Parameters:

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

    the optional parameters

Returns:



156
157
158
159
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 156

def get_job(job_id, opts = {})
  data, _status_code, _headers = get_job_with_http_info(job_id, opts)
  data
end

#get_job_with_http_info(job_id, opts = {}) ⇒ Array<(JobResponse, Integer, Hash)>

Get Job Retrieve a single job by its id.

Parameters:

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

    the optional parameters

Returns:

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

    JobResponse data, response status code and response headers



166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 166

def get_job_with_http_info(job_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: JobsApi.get_job ...'
  end
  # verify the required parameter 'job_id' is set
  if @api_client.config.client_side_validation && job_id.nil?
    fail ArgumentError, "Missing the required parameter 'job_id' when calling JobsApi.get_job"
  end
  # resource path
  local_var_path = '/api/v1/jobs/{job_id}'.sub('{job_id}', CGI.escape(job_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/vnd.api+json']) unless header_params['Accept']

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

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

  # return_type
  return_type = opts[:debug_return_type] || 'JobResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"JobsApi.get_job",
    :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: JobsApi#get_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_jobs(opts = {}) ⇒ JobListResponse

List Jobs List this account’s jobs, newest first.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :filter_enabled (Boolean)
  • :page_number (Integer)

    1-based page number to return. Optional; defaults to &#x60;1&#x60; when omitted. Must be &#x60;&gt;&#x3D; 1&#x60; — requests with a smaller value are rejected with a 400 error. (default to 1)

  • :page_size (Integer)

    Number of items per page. Optional; defaults to &#x60;1000&#x60; when omitted. Must be between &#x60;1&#x60; and &#x60;1000&#x60; inclusive — requests outside that range are rejected with a 400 error. (default to 1000)

  • :meta_total (Boolean)

    When &#x60;true&#x60;, the response&#39;s &#x60;meta.pagination&#x60; block includes &#x60;total&#x60; (the total number of matching items across all pages) and &#x60;total_pages&#x60;. Computing these requires an extra &#x60;COUNT&#x60; query, so omit (or pass &#x60;false&#x60;) when the totals are not needed. Defaults to &#x60;false&#x60;. (default to false)

Returns:



222
223
224
225
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 222

def list_jobs(opts = {})
  data, _status_code, _headers = list_jobs_with_http_info(opts)
  data
end

#list_jobs_with_http_info(opts = {}) ⇒ Array<(JobListResponse, Integer, Hash)>

List Jobs List this account&#39;s jobs, newest first.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :filter_enabled (Boolean)
  • :page_number (Integer)

    1-based page number to return. Optional; defaults to &#x60;1&#x60; when omitted. Must be &#x60;&gt;&#x3D; 1&#x60; — requests with a smaller value are rejected with a 400 error. (default to 1)

  • :page_size (Integer)

    Number of items per page. Optional; defaults to &#x60;1000&#x60; when omitted. Must be between &#x60;1&#x60; and &#x60;1000&#x60; inclusive — requests outside that range are rejected with a 400 error. (default to 1000)

  • :meta_total (Boolean)

    When &#x60;true&#x60;, the response&#39;s &#x60;meta.pagination&#x60; block includes &#x60;total&#x60; (the total number of matching items across all pages) and &#x60;total_pages&#x60;. Computing these requires an extra &#x60;COUNT&#x60; query, so omit (or pass &#x60;false&#x60;) when the totals are not needed. Defaults to &#x60;false&#x60;. (default to false)

Returns:

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

    JobListResponse data, response status code and response headers



235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 235

def list_jobs_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: JobsApi.list_jobs ...'
  end
  # resource path
  local_var_path = '/api/v1/jobs'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'filter[enabled]'] = opts[:'filter_enabled'] if !opts[:'filter_enabled'].nil?
  query_params[:'page[number]'] = opts[:'page_number'] if !opts[:'page_number'].nil?
  query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'meta[total]'] = opts[:'meta_total'] if !opts[:'meta_total'].nil?

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

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

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

  # return_type
  return_type = opts[:debug_return_type] || 'JobListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"JobsApi.list_jobs",
    :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: JobsApi#list_jobs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#run_job_now(job_id, opts = {}) ⇒ RunResponse

Run Job Now Trigger one immediate run of the job (a ‘MANUAL` run). The job’s schedule and enabled state are untouched. The run is enqueued and executed by the worker; if the account is over its run allotment the run will fail with reason ‘QUOTA_EXCEEDED` rather than being rejected here.

Parameters:

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

    the optional parameters

Returns:



288
289
290
291
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 288

def run_job_now(job_id, opts = {})
  data, _status_code, _headers = run_job_now_with_http_info(job_id, opts)
  data
end

#run_job_now_with_http_info(job_id, opts = {}) ⇒ Array<(RunResponse, Integer, Hash)>

Run Job Now Trigger one immediate run of the job (a &#x60;MANUAL&#x60; run). The job&#39;s schedule and enabled state are untouched. The run is enqueued and executed by the worker; if the account is over its run allotment the run will fail with reason &#x60;QUOTA_EXCEEDED&#x60; rather than being rejected here.

Parameters:

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

    the optional parameters

Returns:

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

    RunResponse data, response status code and response headers



298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 298

def run_job_now_with_http_info(job_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: JobsApi.run_job_now ...'
  end
  # verify the required parameter 'job_id' is set
  if @api_client.config.client_side_validation && job_id.nil?
    fail ArgumentError, "Missing the required parameter 'job_id' when calling JobsApi.run_job_now"
  end
  # resource path
  local_var_path = '/api/v1/jobs/{job_id}/actions/run'.sub('{job_id}', CGI.escape(job_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/vnd.api+json']) unless header_params['Accept']

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

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

  # return_type
  return_type = opts[:debug_return_type] || 'RunResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"JobsApi.run_job_now",
    :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: JobsApi#run_job_now\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_job(job_id, job_request, opts = {}) ⇒ JobResponse

Update Job Replace an existing job. Every writable field is overwritten. Enabling a paused job is a ‘PUT` with `enabled: true`; pausing is `enabled: false`. Editing the schedule recomputes the next fire time.

Parameters:

  • job_id (String)
  • job_request (JobRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



352
353
354
355
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 352

def update_job(job_id, job_request, opts = {})
  data, _status_code, _headers = update_job_with_http_info(job_id, job_request, opts)
  data
end

#update_job_with_http_info(job_id, job_request, opts = {}) ⇒ Array<(JobResponse, Integer, Hash)>

Update Job Replace an existing job. Every writable field is overwritten. Enabling a paused job is a &#x60;PUT&#x60; with &#x60;enabled: true&#x60;; pausing is &#x60;enabled: false&#x60;. Editing the schedule recomputes the next fire time.

Parameters:

  • job_id (String)
  • job_request (JobRequest)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

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

    JobResponse data, response status code and response headers



363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/smplkit/_generated/jobs/lib/smplkit_jobs_client/api/jobs_api.rb', line 363

def update_job_with_http_info(job_id, job_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: JobsApi.update_job ...'
  end
  # verify the required parameter 'job_id' is set
  if @api_client.config.client_side_validation && job_id.nil?
    fail ArgumentError, "Missing the required parameter 'job_id' when calling JobsApi.update_job"
  end
  # verify the required parameter 'job_request' is set
  if @api_client.config.client_side_validation && job_request.nil?
    fail ArgumentError, "Missing the required parameter 'job_request' when calling JobsApi.update_job"
  end
  # resource path
  local_var_path = '/api/v1/jobs/{job_id}'.sub('{job_id}', CGI.escape(job_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/vnd.api+json']) unless header_params['Accept']
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+json'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

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

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

  # return_type
  return_type = opts[:debug_return_type] || 'JobResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['HTTPBearer']

  new_options = opts.merge(
    :operation => :"JobsApi.update_job",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: JobsApi#update_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end