Module: Aliyun::Log::Utils

Defined in:
lib/aliyun/log/utils.rb

Class Method Summary collapse

Class Method Details

.get_request_url(endpoint, resources = {}) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/aliyun/log/utils.rb', line 20

def get_request_url(endpoint, resources = {})
  resources ||= {}
  url = URI.parse(endpoint)
  url.host = "#{resources[:project]}." + url.host if resources[:project]
  url.path = get_resource_path(resources)
  url.to_s
end

.get_resource_path(resources = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/aliyun/log/utils.rb', line 9

def get_resource_path(resources = {})
  resources ||= {}
  res = '/'
  if resources[:logstore]
    res = "#{res}logstores"
    res = "#{res}/#{resources[:logstore]}" unless resources[:logstore].empty?
  end
  res = "#{res}/#{resources[:action]}" if resources[:action]
  res
end