Sha256: c5b308084b26796ccc84c94448e0a279649a14a6316e4ffb39a3ef49a77c5b35

Contents?: true

Size: 874 Bytes

Versions: 85

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

module PlatformSdk
  module OpsGenie
    # Client for OpsGenie API
    class Client
      attr_reader :connection

      OPSGENIE_API_URL = "https://api.opsgenie.com"

      def initialize(opsgenie_secret, conn = nil)
        raise ArgumentError, "opsgenie_secret cannot be nil" unless opsgenie_secret

        @connection = conn || build_connection(opsgenie_secret)
      end

      def heartbeat(heartbeat_name)
        connection.get("v2/heartbeats/#{heartbeat_name}/ping")
      end

      private

      def build_connection(secret)
        Faraday.new(url: OPSGENIE_API_URL) do |conn|
          conn.request :url_encoded
          conn.request :retry
          conn.response :raise_error
          conn.adapter Faraday.default_adapter
          conn.headers[:Authorization] = "GenieKey #{secret}"
        end
      end
    end
  end
end

Version data entries

85 entries across 85 versions & 1 rubygems

Version Path
strongmind-platform-sdk-3.26.0 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.25.0 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.24.0 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.23.7 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.23.6 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.23.5 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.23.4 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.23.3 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.23.2 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.23.1 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.23.0 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.22.1 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.22.0 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.21.8 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.21.7 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.21.6 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.21.5 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.21.4 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.21.3 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.21.2 lib/platform_sdk/ops_genie/client.rb