Module: LogStash::Outputs::Qingstor::QingstorValidator

Defined in:
lib/logstash/outputs/qingstor/qingstor_validator.rb

Class Method Summary collapse

Class Method Details

.bucket_valid?(bucket) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
13
14
15
16
17
18
19
# File 'lib/logstash/outputs/qingstor/qingstor_validator.rb', line 10

def self.bucket_valid?(bucket)
  res = bucket.head
  case res[:status_code]
  when 401
    raise LogStash::ConfigurationError, 'Incorrect key id/access key.'
  when 404
    raise LogStash::ConfigurationError, 'Incorrect bucket/region name.'
  end
  true
end

.prefix_valid?(prefix) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
27
# File 'lib/logstash/outputs/qingstor/qingstor_validator.rb', line 21

def self.prefix_valid?(prefix)
  if prefix.start_with?('/') || prefix.length >= 1024
    raise LogStash::ConfigurationError, 'Prefix must not start with'\
      + " '/' and with length less than 1024 "
  end
  true
end