Sha256: 8729becbc294fdc8aa1d9c3541f2e33a859d38ac0df4cb12ffb5b07b829cba90

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

module Fog
  module Orchestration
    class HuaweiCloud
      class Real
        def list_events(options = {})
          if !options.key?(:stack) && !(options.key?(:stack_name) && options.key?(:stack_id))
            raise(ArgumentError, "Missing required options keys: :stack or :stack_name and :stack_id, while calling "\
                                 " .list_events(options)")
          end

          stack        = options.delete(:stack)
          stack_name   = options.delete(:stack_name)
          stack_name ||= stack.stack_name if stack && stack.respond_to?(:stack_name)
          stack_id     = options.delete(:stack_id)
          stack_id   ||= stack.id if stack && stack.respond_to?(:id)

          resource        = options.delete(:resource)
          resource_name   = options.delete(:resource_name)
          resource_name ||= resource.resource_name if resource && resource.respond_to?(:resource_name)

          path = if resource_name
                   "stacks/#{stack_name}/#{stack_id}/resources/#{resource_name}/events"
                 else
                   "stacks/#{stack_name}/#{stack_id}/events"
                 end

          request(:method  => 'GET',
                  :path    => path,
                  :expects => 200,
                  :query   => options)
        end
      end

      class Mock
        def list_events(_options = {})
          events = data[:events].values

          Excon::Response.new(
            :body   => {'events' => events},
            :status => 200
          )
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-huaweicloud-0.0.3 lib/fog/orchestration/huaweicloud/requests/list_events.rb
fog-huaweicloud-0.0.2 lib/fog/orchestration/huaweicloud/requests/list_events.rb
fog-huaweicloud-0.1.3 lib/fog/orchestration/huaweicloud/requests/list_events.rb
fog-huaweicloud-0.1.2 lib/fog/orchestration/huaweicloud/requests/list_events.rb