Class: GoodData::Schedule

Inherits:
Object
  • Object
show all
Defined in:
lib/gooddata/schedule.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Schedule

Initialize new schedule

Options Hash (attrs):

  • :account_id (String)

    customer account id

  • :project_id (String)

    GoodData project id

  • :process_id (String)

    GoodData process id

  • :graph (String)

    graph path


31
32
33
34
35
# File 'lib/gooddata/schedule.rb', line 31

def initialize(attrs = {})
  attrs.each do |key, value|
    send("#{key}=", value)
  end
end

Instance Attribute Details

#account_idObject

Returns the value of attribute account_id


8
9
10
# File 'lib/gooddata/schedule.rb', line 8

def 
  @account_id
end

#credsObject

Returns the value of attribute creds


8
9
10
# File 'lib/gooddata/schedule.rb', line 8

def creds
  @creds
end

#graphObject

Returns the value of attribute graph


8
9
10
# File 'lib/gooddata/schedule.rb', line 8

def graph
  @graph
end

#process_idObject

Returns the value of attribute process_id


8
9
10
# File 'lib/gooddata/schedule.rb', line 8

def process_id
  @process_id
end

#project_idObject

Returns the value of attribute project_id


8
9
10
# File 'lib/gooddata/schedule.rb', line 8

def project_id
  @project_id
end

Class Method Details

.create(attrs) ⇒ Schedult

Create GoodData project

Options Hash (attrs):

  • :account_id (String)

    customer account id

  • :project_id (String)

    GoodData project id

  • :process_id (String)

    GoodData process id

  • :graph (String)

    graph path


16
17
18
19
20
# File 'lib/gooddata/schedule.rb', line 16

def self.create(attrs)
  schedule = new(attrs)
  schedule.save
  schedule
end

Instance Method Details

#save(environment = 'production') ⇒ Object

Save schedule to GoodData


41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/gooddata/schedule.rb', line 41

def save(environment = 'production')
  payload = {
    schedule: {
      type: 'MSETL',
      timezone: 'UTC',
      cron: '0 12 * * *',
      params: {
        PROCESS_ID: process_id,
        GRAPH: graph,
        S3_SUBFOLDER: environment,
        S3_ID: ,
        S3_ACCESSKEY: creds[:S3_ACCESSKEY],
        MODE: 'DEMANDBASE/PRODUCTION'
      },
      hiddenParams: {
        S3_SECRETKEY: creds[:S3_SECRETKEY]
      }
    }
  }
  GoodData.post("/gdc/projects/#{project_id}/schedules", payload)
end