Class: GoodData::Process

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Process

Initialize new process

Parameters:

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

    process attributes

Options Hash (attrs):

  • :name (String)

    process name

  • :path (String)

    path to ETL archive

  • :project_id (String)

    id of target project


53
54
55
56
57
# File 'lib/gooddata/process.rb', line 53

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

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id


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

def id
  @id
end

#nameObject

Returns the value of attribute name


9
10
11
# File 'lib/gooddata/process.rb', line 9

def name
  @name
end

#pathObject

Returns the value of attribute path


9
10
11
# File 'lib/gooddata/process.rb', line 9

def path
  @path
end

#project_idObject

Returns the value of attribute project_id


9
10
11
# File 'lib/gooddata/process.rb', line 9

def project_id
  @project_id
end

Class Method Details

.allArray<Process>

Get all processes

Parameters:

  • project_id (String)

    project id

Returns:

  • (Array<Process>)

    Array of GoodData processes


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

def self.all
  GoodData.get('/gdc/account/profile/{user-id}/dataload/processes')['processes']['items'].map do |process|
    new.parse(process)
  end
end

.create(attrs) ⇒ Process

Create CloudConnect Process

Parameters:

  • attrs (Hash)

    process attributes

Options Hash (attrs):

  • :name (String)

    process name

  • :path (String)

    path to ETL archive

  • :project_id (String)

    id of target project

Returns:


39
40
41
42
43
# File 'lib/gooddata/process.rb', line 39

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

.find(project_id, id) ⇒ Process

Get process by id

Parameters:

  • project_id (String)

    project id

  • id (String)

    process id

Returns:


28
29
30
31
# File 'lib/gooddata/process.rb', line 28

def self.find(project_id, id)
  process = GoodData.get("/gdc/projects/#{project_id}/dataload/processes/#{id}")
  new.parse(process)
end

Instance Method Details

#deleteObject

Delete GoodData process


103
104
105
# File 'lib/gooddata/process.rb', line 103

def delete
  GoodData.delete("/gdc/projects/#{project_id}/dataload/processes/#{id}")
end

#parse(attrs) ⇒ Process

Parse GoodData process

Parameters:

  • attrs (Hash)

    Parse JSON response for GoodData process

Returns:


64
65
66
67
68
69
70
71
72
# File 'lib/gooddata/process.rb', line 64

def parse(attrs)
  process_url = attrs['process']['links']['self'].split('/')
  @id = process_url.last
  @project_id = process_url[3]
  @name = attrs['process']['name']
  @executables = attrs['process']['executables']
  @raw = attrs['process']
  self
end

#projectProject

Find project

Returns:


96
97
98
# File 'lib/gooddata/process.rb', line 96

def project
  Project.find(project_id)
end

#saveString

Upload ETL file Save process to GoodData

Returns:

  • (String)

    process id


78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/gooddata/process.rb', line 78

def save  # Build payload

  payload = {
    process: {
      name: name,
      path: path
    }
  }  # Send request

  response = GoodData.post("/gdc/projects/#{@project_id}/dataload/processes", payload)
  parse(response)
  id
end