nrde 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b562ec5d20744becfa8769ce9d1e27d8cc08cc8aa4ead95b3ba5f742ed3103e5
4
- data.tar.gz: 2bb3ccc4280daf8e5deb87b5705ba15f125e3ee4f499c640153dc2afe41afd7c
3
+ metadata.gz: 1ac4822862e2771ca55f0d2f931146fee3bdbda3b3c7c2ea880385aa39f49c78
4
+ data.tar.gz: 890f618df80dea799587ef5f61351d7a4a3ac220e7731fc270b6864d46d9f2ef
5
5
  SHA512:
6
- metadata.gz: d9dd644be1aeaef995b92c0a5190a2982570adce07cbfd8f1489f31c0329d3249f17ff6aab5a63a88ae6be5f28b4b1fcfd56868bfe04a9ee9e7118a0f06bbc41
7
- data.tar.gz: 9a6d1527f6e10dada836269c27088dd80736ccd893f84baa070402ffcc7f19f0514e2b4f3adf999db3bad768590b1816f8230992b8cb20630b8fb1139950b5f3
6
+ metadata.gz: 5523605e028d87d290b763d1bdb27773ad45b8158f39d2160a86e8f40e0d67ac493725c8a9d376cc70f43fb72bd96731722b00c5ed9ac2fca801cb39e37bc7fa
7
+ data.tar.gz: abed605ac8eff82f19a92fce02e108fb410abd0968cb30e3893eaaecdb61c104b6491259d87f27dd857cb22b2be9db476168da5956fac5dd76d18d62c4562ab4
data/.gitignore CHANGED
@@ -8,4 +8,4 @@
8
8
  /tmp/
9
9
 
10
10
  # rspec failure tracking
11
- .rspec_status
11
+ .rspec_status
@@ -0,0 +1,30 @@
1
+ module Nrde
2
+ module DashboardExporter
3
+ def exporter(guid, width = '2000', height = '2000', personal_api_key = nil, new_relic_region = 'US')
4
+ begin
5
+ raise "A New Relic API key is required." if personal_api_key.nil?
6
+ headers = {}
7
+ headers["Content-Type"] = "application/json"
8
+ headers["API-Key"] = personal_api_key
9
+ endpointUrl = new_relic_region == 'EU' ? 'https://api.eu.newrelic.com/graphql' : 'https://api.newrelic.com/graphql'
10
+ raise "Dashboard GUID required." if guid.nil?
11
+ nr_query_json = {"query" => "mutation { dashboardCreateSnapshotUrl(guid: \"#{guid}\")}"}
12
+
13
+ #Get Dashborad Snapshot URL
14
+ uri = URI.parse(endpointUrl)
15
+ https = Net::HTTP.new(uri.host,uri.port)
16
+ https.use_ssl = true
17
+ req = Net::HTTP::Post.new(uri.path, headers)
18
+ req.body = nr_query_json.to_json
19
+ res = https.request(req)
20
+ nr_snapshopt_url = JSON.parse(res.body)['data']['dashboardCreateSnapshotUrl']
21
+ #Download File as PDF
22
+ nr_download_uri = URI("#{nr_snapshopt_url}&width=#{width}&height=#{height}")
23
+ response = Net::HTTP.get_response(nr_download_uri)
24
+ return response
25
+ rescue => e
26
+ Rails.logger.error "PDF Download failed #{nr_download_uri} #{response.code}"
27
+ end
28
+ end
29
+ end
30
+ end
data/lib/nrde/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nrde
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/nrde.gemspec CHANGED
@@ -8,14 +8,14 @@ Gem::Specification.new do |spec|
8
8
 
9
9
  spec.summary = %q{Download Newrelic Dashbord as PDF.}
10
10
  spec.description = %q{Download NR Dashbord as PDF to Send reports over Email}
11
- spec.homepage = "https://rubygems.org/"
11
+ spec.homepage = "https://github.com/Sathishwar/nrde"
12
12
  spec.license = "MIT"
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
14
14
 
15
15
  #spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
- #spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
18
+ spec.metadata["source_code_uri"] = "https://github.com/Sathishwar/nrde"
19
19
  #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nrde
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sathish Narayanan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-23 00:00:00.000000000 Z
11
+ date: 2021-09-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Download NR Dashbord as PDF to Send reports over Email
14
14
  email:
@@ -28,13 +28,15 @@ files:
28
28
  - bin/console
29
29
  - bin/setup
30
30
  - lib/nrde.rb
31
+ - lib/nrde/dashboard_exporter.rb
31
32
  - lib/nrde/version.rb
32
33
  - nrde.gemspec
33
- homepage: https://rubygems.org/
34
+ homepage: https://github.com/Sathishwar/nrde
34
35
  licenses:
35
36
  - MIT
36
37
  metadata:
37
- homepage_uri: https://rubygems.org/
38
+ homepage_uri: https://github.com/Sathishwar/nrde
39
+ source_code_uri: https://github.com/Sathishwar/nrde
38
40
  post_install_message:
39
41
  rdoc_options: []
40
42
  require_paths:
@@ -50,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
52
  - !ruby/object:Gem::Version
51
53
  version: '0'
52
54
  requirements: []
53
- rubygems_version: 3.0.9
55
+ rubygems_version: 3.1.4
54
56
  signing_key:
55
57
  specification_version: 4
56
58
  summary: Download Newrelic Dashbord as PDF.