aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ievkit/client/jobs.rb
blob: a530b25279dc5c8960d65a3f13c59dc4eca135dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
module Ievkit
  class Client
    module Jobs

      # List jobs for a referential
      #
      # @param referential [String] Data referential name. 
      # @return [Array<Sawyer::Resource>] A list of jobs
      # @example Fetch all jobs for referential test
      #   client.jobs("test")
      def jobs(referential, options = {})
        paginate "referentials/#{referential}/jobs", options
      end
      
      # Get scheduled job
      #
      # @param referential [String] Data referential name.
      # @param job_id [Integer] Id of the scheduled job.
      # @return [Sawyer::Resource] Hash representing scheduled job.
      # @example
      #   client.scheduled_job('test', 1451398)
      def scheduled_job(referential, job_id, options = {})
        get "referentials/#{referential}/scheduled_jobs/#{job_id}", options
      end

      # Get terminated job
      #
      # @param referential [String] Data referential name.
      # @param job_id [Integer] Id of the terminated job.
      # @return [Sawyer::Resource] Hash representing terminated job.
      # @example
      #   client.terminated_job('test', 1451399)
      def terminated_job(referential, job_id, options = {})
        get "referentials/#{referential}/terminated_jobs/#{job_id}", options
      end

      # Create job 
      #
      # @param referential [String] Data referential name.
      # @return [Sawyer::Resource] Hash representing the new job.
      # @example
      #   client.create_job("test",....)
      def create_job(referential, options = {})
        post "jobs", options
      end
      
    end
  end
end