Class: SingularityClient::API

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

Overview

Handles the singularity api

Class Method Summary collapse

Class Method Details

.add(config, repo, project, type) ⇒ Object

Add to the singularity config the ‘type’ parameter can be pull_request or push



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/singularity_client/api.rb', line 24

def self.add(config, repo, project, type)
  unless type == 'proposal' || type == 'change'
    fail("ERROR invalid type: #{type}. \
          Valid types are \'proposal\' or \'change\'")
  end

  endpoint = "config/#{type}"
  post_data = {
    repository: "#{config.organization}/#{repo}",
    project: project
  }

  request = SingularityClient::Request.new(config)
  request.post(endpoint, post_data)

  puts('success!')
end

.remove(config, repo) ⇒ Object

Remove a repository from the singularity config



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

def self.remove(config, repo)
  endpoint = 'config/repo'

  post_data = {
    repository: "#{config.organization}/#{repo}"
  }

  request = SingularityClient::Request.new(config)
  request.delete(endpoint, post_data)

  puts('success!')
end