Class: SemaphoreApi::Client

Inherits:
Object
  • Object
show all
Includes:
Branches, Builds, Deploys, Projects, Servers, WebHooks
Defined in:
lib/semaphore_api/client.rb,
lib/semaphore_api/client/builds.rb,
lib/semaphore_api/client/deploys.rb,
lib/semaphore_api/client/servers.rb,
lib/semaphore_api/client/branches.rb,
lib/semaphore_api/client/projects.rb,
lib/semaphore_api/client/webhooks.rb

Defined Under Namespace

Modules: Branches, Builds, Deploys, Projects, Servers, WebHooks

Instance Method Summary collapse

Methods included from Deploys

#deploy, #deploy_log, #launch_deploy, #stop_deploy

Methods included from Servers

#server_history, #server_status, #servers

Methods included from Builds

#build, #build_log, #launch_build, #stop_build

Methods included from WebHooks

#create_webhook, #delete_webhook, #edit_webhook, #webhooks

Methods included from Branches

#branch_history, #branch_status, #branches

Methods included from Projects

#project, #projects

Constructor Details

#initialize(auth_token, end_point = nil) ⇒ Client



19
20
21
22
# File 'lib/semaphore_api/client.rb', line 19

def initialize(auth_token, end_point=nil)
  @auth_token = auth_token
  @end_point = end_point
end

Instance Method Details

#agentObject



48
49
50
# File 'lib/semaphore_api/client.rb', line 48

def agent
  @agent ||= Zoid::Agent.new(end_point)
end

#delete(path, options = {}) ⇒ Object



42
43
44
45
46
# File 'lib/semaphore_api/client.rb', line 42

def delete(path, options = {})
  response = agent.delete("/api/v1/#{path}", options.merge(:auth_token => @auth_token))

  response.body
end

#end_pointObject



52
53
54
# File 'lib/semaphore_api/client.rb', line 52

def end_point
  @end_point || "https://semaphoreci.com"
end

#get(path, options = {}) ⇒ Object



24
25
26
27
28
# File 'lib/semaphore_api/client.rb', line 24

def get(path, options = {})
  response = agent.get("/api/v1/#{path}", options.merge(:auth_token => @auth_token))

  response.body
end

#inspectObject

hide auth_token



57
58
59
# File 'lib/semaphore_api/client.rb', line 57

def inspect
  super.gsub! @auth_token, "*******"
end

#post(path, options = {}) ⇒ Object



30
31
32
33
34
# File 'lib/semaphore_api/client.rb', line 30

def post(path, options = {})
  response = agent.post("/api/v1/#{path}", options.merge(:auth_token => @auth_token))

  response.body
end

#put(path, options = {}) ⇒ Object



36
37
38
39
40
# File 'lib/semaphore_api/client.rb', line 36

def put(path, options = {})
  response = agent.put("/api/v1/#{path}", options.merge(:auth_token => @auth_token))

  response.body
end