Sha256: c5b308084b26796ccc84c94448e0a279649a14a6316e4ffb39a3ef49a77c5b35

Contents?: true

Size: 874 Bytes

Versions: 67

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

67 entries across 67 versions & 1 rubygems

Version Path
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
strongmind-platform-sdk-3.21.1 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.21.0 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.20.3 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.20.2 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.20.1 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.20.0 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.40 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.39 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.38 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.37 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.36 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.35 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.34 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.33 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.32 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.31 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.30 lib/platform_sdk/ops_genie/client.rb
strongmind-platform-sdk-3.19.29 lib/platform_sdk/ops_genie/client.rb