Module: Tigre

Defined in:
lib/tigre-client.rb,
lib/tigre-client/url.rb,
lib/tigre-client/scan.rb,
lib/tigre-client/sample.rb,
lib/tigre-client/version.rb,
lib/tigre-client/analysis.rb,
lib/tigre-client/occurrence.rb,
lib/tigre-client/common/common_params.rb,
lib/tigre-client/common/common_getters.rb,
lib/tigre-client/common/tag_components.rb,
lib/tigre-client/common/analysis_components.rb

Defined Under Namespace

Modules: AnalysisComponents, Client, CommonGetters, CommonParams, TagComponents Classes: Analysis, Occurrence, Sample, Scan, Url

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.connObject

Returns the value of attribute conn.



21
22
23
# File 'lib/tigre-client.rb', line 21

def conn
  @conn
end

.endpointObject

Returns the value of attribute endpoint.



21
22
23
# File 'lib/tigre-client.rb', line 21

def endpoint
  @endpoint
end

.loggerObject

Returns the value of attribute logger.



21
22
23
# File 'lib/tigre-client.rb', line 21

def logger
  @logger
end

.s3_bucketObject

Returns the value of attribute s3_bucket.



21
22
23
# File 'lib/tigre-client.rb', line 21

def s3_bucket
  @s3_bucket
end

.s3_keyObject

Returns the value of attribute s3_key.



21
22
23
# File 'lib/tigre-client.rb', line 21

def s3_key
  @s3_key
end

.s3_secretObject

Returns the value of attribute s3_secret.



21
22
23
# File 'lib/tigre-client.rb', line 21

def s3_secret
  @s3_secret
end

.serverObject

Returns the value of attribute server.



21
22
23
# File 'lib/tigre-client.rb', line 21

def server
  @server
end

.tokenObject

Returns the value of attribute token.



21
22
23
# File 'lib/tigre-client.rb', line 21

def token
  @token
end

Class Method Details

.build_get_connectionObject



32
33
34
35
36
# File 'lib/tigre-client.rb', line 32

def build_get_connection
  @conn = Faraday.new(:url => "#{Tigre.server}") do |builder|
    builder.adapter :net_http
  end
end

.build_post_connectionObject



38
39
40
41
42
43
44
45
# File 'lib/tigre-client.rb', line 38

def build_post_connection
  @conn = Faraday.new(:url => "#{Tigre.server}") do |builder|
    builder.use Faraday::Request::MultipartWithFile
    builder.use Faraday::Request::Multipart
    builder.use Faraday::Request::UrlEncoded
    builder.adapter :net_http
  end
end

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Tigre)

    the object that the method was called on



23
24
25
26
# File 'lib/tigre-client.rb', line 23

def configure
  yield self
  true
end

.get_connection(uri_string) ⇒ Object



47
48
49
50
51
# File 'lib/tigre-client.rb', line 47

def get_connection(uri_string)
  build_get_connection
  response = Tigre.conn.get(Tigre.endpoint + uri_string, 'API-TOKEN' => Tigre.token)
  [response.status, response.body]
end

.post_connection(uri_string, data) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/tigre-client.rb', line 53

def post_connection(uri_string, data)
  build_post_connection
  response = Tigre.conn.post do |req|
    req.url Tigre.endpoint + uri_string
    req.headers['API-TOKEN'] = Tigre.token
    req.body                 = data
  end
  [response.status, response.body]
end

.put_connection(uri_string, data) ⇒ Object

TODO do we need a post_connection and a post_file_connection? def post_file_connection(uri_string, data)

build_post_connection

response = Tigre.conn.post do |req|
  req.url Tigre.endpoint + uri_string
  req.headers['API-TOKEN'] = Tigre.token
  req.body                 = data
end
[response.status, response.body]

end



75
76
77
78
79
80
81
82
83
# File 'lib/tigre-client.rb', line 75

def put_connection(uri_string, data)
  build_post_connection
  response = Tigre.conn.put do |req|
    req.url Tigre.endpoint + uri_string
    req.headers['API-TOKEN'] = Tigre.token
    req.body                 = data
  end
  [response.status, response.body]
end

.s3_enabled?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/tigre-client.rb', line 28

def s3_enabled?
  !Tigre.s3_key.nil? && !Tigre.s3_secret.nil? && !Tigre.s3_bucket.nil?
end