Class: Bugsnag::Api::Client
- Inherits:
-
Object
- Object
- Bugsnag::Api::Client
- Includes:
- Collaborators, Comments, CurrentUser, Errors, EventFields, Events, Organizations, Pivots, Projects, Releases, Stability, Trends
- Defined in:
- lib/bugsnag/api/client.rb,
lib/bugsnag/api/client/errors.rb,
lib/bugsnag/api/client/events.rb,
lib/bugsnag/api/client/pivots.rb,
lib/bugsnag/api/client/trends.rb,
lib/bugsnag/api/client/comments.rb,
lib/bugsnag/api/client/projects.rb,
lib/bugsnag/api/client/releases.rb,
lib/bugsnag/api/client/stability.rb,
lib/bugsnag/api/client/currentuser.rb,
lib/bugsnag/api/client/eventfields.rb,
lib/bugsnag/api/client/collaborators.rb,
lib/bugsnag/api/client/organizations.rb
Overview
Client for the Bugsnag API
Defined Under Namespace
Modules: Collaborators, Comments, CurrentUser, Errors, EventFields, Events, Organizations, Pivots, Projects, Releases, Stability, Trends
Constant Summary collapse
- CONVENIENCE_HEADERS =
Header keys that can be passed in options hash to #get,#head
Set.new([:accept, :content_type])
Instance Method Summary collapse
-
#basic_authenticated? ⇒ Boolean
Indicates if the client was supplied Basic Auth username and password.
-
#configuration ⇒ Bugsnag::Api::Configuration
Get client's configuration options.
-
#configure {|configuration| ... } ⇒ Object
Set configuration options using a block.
-
#deep_merge(l_hash, r_hash) ⇒ Hash
Merges hashes together cleanly, favouring RHS values.
-
#delete(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP DELETE request.
-
#get(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP GET request.
-
#initialize(options = {}) {|configuration| ... } ⇒ Client
constructor
A new instance of Client.
-
#last_response ⇒ Sawyer::Response
Response for last HTTP request.
-
#paginate(url, options = {}, &block) ⇒ Sawyer::Resource
Make one or more HTTP GET requests, optionally fetching the next page of results from URL in Link response header based on value in #auto_paginate.
-
#patch(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PATCH request.
-
#post(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP POST request.
-
#token_authenticated? ⇒ Boolean
Indicates if the client was supplied an auth token.
Methods included from Releases
#release, #releases, #releases_in_group
Methods included from Stability
Methods included from Comments
#comment, #comments, #create_comment, #delete_comment, #update_comment
Methods included from Trends
#trends_buckets, #trends_resolution
Methods included from Pivots
Methods included from Events
#delete_event, #error_events, #event, #events, #latest_event
Methods included from Errors
#delete_errors, #errors, #update_errors
Methods included from CurrentUser
Methods included from EventFields
#create_event_field, #delete_event_field, #event_fields, #update_event_field
Methods included from Projects
#create_project, #delete_project, #project, #regenerate_api_key, #update_project
Methods included from Collaborators
#collaborator, #collaborators, #delete_collaborator, #invite_collaborators, #update_collaborator_permissions, #view_collaborator_projects
Methods included from Organizations
#create_organization, #delete_organization, #organization, #update_organization
Constructor Details
#initialize(options = {}) {|configuration| ... } ⇒ Client
Returns a new instance of Client.
41 42 43 44 |
# File 'lib/bugsnag/api/client.rb', line 41 def initialize( = {}, &block) configuration.load() yield(configuration) if block_given? end |
Instance Method Details
#basic_authenticated? ⇒ Boolean
Indicates if the client was supplied Basic Auth username and password
140 141 142 |
# File 'lib/bugsnag/api/client.rb', line 140 def basic_authenticated? !!(configuration.email && configuration.password) end |
#configuration ⇒ Bugsnag::Api::Configuration
Get client's configuration options
55 56 57 |
# File 'lib/bugsnag/api/client.rb', line 55 def configuration @configuration ||= Configuration.new end |
#configure {|configuration| ... } ⇒ Object
Set configuration options using a block
47 48 49 50 |
# File 'lib/bugsnag/api/client.rb', line 47 def configure yield(configuration) if block_given? reset_agent end |
#deep_merge(l_hash, r_hash) ⇒ Hash
Merges hashes together cleanly, favouring RHS values
155 156 157 158 159 160 161 162 163 |
# File 'lib/bugsnag/api/client.rb', line 155 def deep_merge(l_hash, r_hash) l_hash.merge(r_hash) do |_key, l_val, r_val| if l_val.is_a?(Hash) && r_val.is_a?(Hash) deep_merge(l_val, r_val) else r_val end end end |
#delete(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP DELETE request
91 92 93 |
# File 'lib/bugsnag/api/client.rb', line 91 def delete(url, = {}) request :delete, url, end |
#get(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP GET request
64 65 66 |
# File 'lib/bugsnag/api/client.rb', line 64 def get(url, = {}) request :get, url, parse_query_and_convenience_headers() end |
#last_response ⇒ Sawyer::Response
Response for last HTTP request
131 132 133 |
# File 'lib/bugsnag/api/client.rb', line 131 def last_response @last_response if defined? @last_response end |
#paginate(url, options = {}, &block) ⇒ Sawyer::Resource
Make one or more HTTP GET requests, optionally fetching the next page of results from URL in Link response header based on value in #auto_paginate.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/bugsnag/api/client.rb', line 106 def paginate(url, = {}, &block) opts = parse_query_and_convenience_headers(.dup) if configuration.auto_paginate || configuration.per_page opts[:query][:per_page] ||= configuration.per_page || (configuration.auto_paginate ? 100 : nil) end data = request(:get, url, opts) if configuration.auto_paginate while @last_response.rels[:next] @last_response = @last_response.rels[:next].get if block_given? yield(data, @last_response) else data.concat(@last_response.data) if @last_response.data.is_a?(Array) end end end data end |
#patch(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PATCH request
82 83 84 |
# File 'lib/bugsnag/api/client.rb', line 82 def patch(url, = {}) request :patch, url, end |
#post(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP POST request
73 74 75 |
# File 'lib/bugsnag/api/client.rb', line 73 def post(url, = {}) request :post, url, end |
#token_authenticated? ⇒ Boolean
Indicates if the client was supplied an auth token
148 149 150 |
# File 'lib/bugsnag/api/client.rb', line 148 def token_authenticated? !!configuration.auth_token end |