Class: SemaphoreClient::Api::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/semaphore_client/api/pipeline.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_client) ⇒ Pipeline

Returns a new instance of Pipeline.



4
5
6
# File 'lib/semaphore_client/api/pipeline.rb', line 4

def initialize(http_client)
  @http_client = http_client
end

Instance Method Details

#create(params = nil, options = {}) ⇒ Object



22
23
24
25
# File 'lib/semaphore_client/api/pipeline.rb', line 22

def create(params = nil, options = {})
  create!(params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#create!(params = nil, options = {}) ⇒ Object



27
28
29
30
31
32
# File 'lib/semaphore_client/api/pipeline.rb', line 27

def create!(params = nil, options = {})
  path = "/pipelines"
  response = @http_client.post(path, params, options)

  SemaphoreClient::Model::Pipeline.load(response.body)
end

#get(id, params = nil, options = {}) ⇒ Object



36
37
38
39
# File 'lib/semaphore_client/api/pipeline.rb', line 36

def get(id, params = nil, options = {})
  get!(id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#get!(id, params = nil, options = {}) ⇒ Object



41
42
43
44
45
46
# File 'lib/semaphore_client/api/pipeline.rb', line 41

def get!(id, params = nil, options = {})
  path = "/pipelines/#{id}"
  response = @http_client.get(path, params = {})

  SemaphoreClient::Model::Pipeline.load(response.body)
end

#list(params = nil, options = {}) ⇒ Object



9
10
11
12
# File 'lib/semaphore_client/api/pipeline.rb', line 9

def list(params = nil, options = {})
  list!(params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#list!(params = nil, options = {}) ⇒ Object



14
15
16
17
18
# File 'lib/semaphore_client/api/pipeline.rb', line 14

def list!(params = nil, options = {})
  path = "/pipelines"

  @http_client.get(path, params, options).body.map { |e| SemaphoreClient::Model::Pipeline.load(e) }
end

#update(id, params = nil, options = {}) ⇒ Object



50
51
52
53
# File 'lib/semaphore_client/api/pipeline.rb', line 50

def update(id, params = nil, options = {})
  update!(id, params, options)
rescue SemaphoreClient::Exceptions::ResponseError
end

#update!(id, params = nil, options = {}) ⇒ Object



55
56
57
58
59
60
# File 'lib/semaphore_client/api/pipeline.rb', line 55

def update!(id, params = nil, options = {})
  path = "/pipelines/#{id}"
  response = @http_client.patch(path, params)

  SemaphoreClient::Model::Pipeline.load(response.body)
end