class Fog::Event::HuaweiCloud::Real

Public Class Methods

new(options = {}) click to toggle source
# File lib/fog/event/huaweicloud.rb, line 91
def initialize(options = {})
  initialize_identity options

  @huaweicloud_service_type           = options[:huaweicloud_service_type] || ['event']
  @huaweicloud_service_name           = options[:huaweicloud_service_name]
  @huaweicloud_endpoint_type          = options[:huaweicloud_endpoint_type] || 'publicURL'

  @connection_options               = options[:connection_options] || {}

  authenticate
  set_api_path

  @persistent = options[:persistent] || false
  @connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end
not_found_class() click to toggle source
# File lib/fog/event/huaweicloud.rb, line 87
def self.not_found_class
  Fog::Event::HuaweiCloud::NotFound
end

Public Instance Methods

get_event(message_id) click to toggle source
# File lib/fog/event/huaweicloud/requests/get_event.rb, line 5
def get_event(message_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "events/#{message_id}"
  )
end
list_events(options = []) click to toggle source
# File lib/fog/event/huaweicloud/requests/list_events.rb, line 5
def list_events(options = [])
  data = {
    'q' => []
  }

  options.each do |opt|
    filter = {}

    ['field', 'op', 'value'].each do |key|
      filter[key] = opt[key] if opt[key]
    end

    data['q'] << filter unless filter.empty?
  end

  request(
    :body    => Fog::JSON.encode(data),
    :expects => 200,
    :method  => 'GET',
    :path    => 'events'
  )
end
set_api_path() click to toggle source
# File lib/fog/event/huaweicloud.rb, line 107
def set_api_path
  unless @path.match(SUPPORTED_VERSIONS)
    @path = "/" + Fog::HuaweiCloud.get_supported_version(
      SUPPORTED_VERSIONS,
      @huaweicloud_management_uri,
      @auth_token,
      @connection_options
    )
  end
end