Class: PolyAnalyst6API::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/polyanalyst6api/project.rb

Overview

This class maintains all the operations with a project

Instance Method Summary collapse

Constructor Details

#initialize(session, uuid) ⇒ Project

Returns an instance of Project.

Parameters:

  • session (Session)

    An instance of Session

  • uuid (String)

    The uuid of a project you want to interact with


9
10
11
12
# File 'lib/polyanalyst6api/project.rb', line 9

def initialize(session, uuid)
  @session = session
  @uuid = uuid
end

Instance Method Details

#abort!bool

Stops project execution

Returns:

  • (bool)

    true - execution stopped; false - something went wrong


45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/polyanalyst6api/project.rb', line 45

def abort!
  params = {
    method: :post,
    url: '/project/global-abort',
    params: {
      prjUUID: @uuid
    }
  }
  @session.request(params).perform! do |resp|
    return false unless resp.code == 200
  end
  true
end

#dataset_preview(type, name) ⇒ Array<Hash>

Returns the first 1000 rows of a dataset

Examples:

project = Project.new(Session.new, '4c44659c-4edb-4f3e-8342-b10451b96f3f')
project.dataset_preview('DataSource', 'Dataset 01.csv')

Parameters:

  • type (String)

    The type of a node

  • name (String)

    The name of a node

Returns:

  • (Array<Hash>)

    A list of rows info


82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/polyanalyst6api/project.rb', line 82

def dataset_preview(type, name)
  params = {
    method: :get,
    url: '/dataset/preview',
    params: {
      prjUUID: @uuid,
      name: name,
      type: type
    }
  }
  @session.request(params).perform!
end

#execute!(nodes = []) ⇒ bool

Executes the passed nodes

Parameters:

  • nodes (Array<Hash>) (defaults to: [])

    A subset of nodes returned by the method nodes

Returns:

  • (bool)

    true - execution started; false - something went wrong


28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/polyanalyst6api/project.rb', line 28

def execute!(nodes = [])
  params = {
    method: :post,
    url: '/project/execute',
    params: {
      prjUUID: @uuid,
      nodes: nodes
    }
  }
  @session.request(params).perform! do |resp|
    return false unless resp.code == 202
  end
  true
end

#nodesArray<Hash>

Returns a list of project nodes

Returns:

  • (Array<Hash>)

    A list with nodes info


16
17
18
19
20
21
22
23
# File 'lib/polyanalyst6api/project.rb', line 16

def nodes
  params = {
    method: :get,
    url: '/project/nodes',
    params: { prjUUID: @uuid }
  }
  @session.request(params).perform!['nodes']
end

#save!bool

Saves the project

Returns:

  • (bool)

    true - saved successfully; false - something went wrong


61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/polyanalyst6api/project.rb', line 61

def save!
  params = {
    method: :post,
    url: '/project/save',
    params: {
      prjUUID: @uuid
    }
  }
  @session.request(params).perform! do |resp|
    return false unless resp.code == 202
  end
  true
end