Giter VIP home page Giter VIP logo

honeybadger-api's Introduction

Honeybadger Read API

A Ruby Library for the Honeybadger Read API for easily pulling your data out of Honeybadger.

Installation

Add this line to your application's Gemfile:

gem "honeybadger-api"

And then execute:

$ bundle

Or install it yourself as:

$ gem install honeybadger-api

Usage

Introduction

Firstly require the library:

require "honeybadger-api"

Then configure your personal API access token. Your personal API access token can be found on your personal profile page:

Honeybadger::Api.configure do |c|
  c.access_token = "xxxxxxxxxxxxxxxxxxxx"
end

After you have setup your API access token you can now make requests.

Projects

# Find a project
Honeybadger::Api::Project.find(project_id)

# Find all the projects
Honeybadger::Api::Project.all

# Retrieve a paginator for projects
paginator = Honeybadger::Api::Project.paginate

There are several methods that you should be aware of when using the paginator.

# Get a paginator for a resource
paginator = Honeybadger::Api::Project.paginate


# Retrieve a paginator for projects starting at a page
paginator = Honeybadger::Api::Project.paginate(:page => 5)

# Whether there are any more previous or next pages
paginator.previous?
=> true
paginator.next?
=> true

# Retrieve the previous or next pages
paginator.previous
paginator.next

# Retrieve the current page number
paginator.current_page

# Return all previously requested pages as a Hash
paginator.pages
=> {
  1 => [
    #<Honeybadger::Api::Project @id=1, @name="Example">,
    #<Honeybadger::Api::Project @id=2, @name="Acme">
  ],
  2 => [
    #<Honeybadger::Api::Project @id=3, @name="Website">
  ]
}

# Return all previously requested pages as a collection
paginator.collection
=> [
  #<Honeybadger::Api::Project @id=1, @name="Example">,
  #<Honeybadger::Api::Project @id=2, @name="Acme">,
  #<Honeybadger::Api::Project @id=3, @name="Website">
]

Deploys

# Find a deploy
Honeybadger::Api::Deploy.find(project_id, deploy_id)

# Find all the deploys
Honeybadger::Api::Deploy.all(project_id)

# Retrieve a paginator for deploys
Honeybadger::Api::Deploy.paginate(project_id)

Faults

# Find a fault
Honeybadger::Api::Fault.find(project_id, fault_id)

# Find all the faults
Honeybadger::Api::Fault.all(project_id)

# Retrieve a paginator for faults
Honeybadger::Api::Fault.paginate(project_id)

Notices

# Find all the notices
Honeybadger::Api::Notice.all(project_id, fault_id)

# Retrieve a paginator for notices
Honeybadger::Api::Notice.paginate(project_id, fault_id)

Comments

# Find a comment
Honeybadger::Api::Comment.find(project_id, fault_id, comment_id)

# Find all the comments
Honeybadger::Api::Comment.all(project_id, fault_id)

# Retrieve a paginator for comments
Honeybadger::Api::Comment.paginate(project_id, fault_id)

Teams

# Find a team
Honeybadger::Api::Team.find(team_id)

# Find all the teams
Honeybadger::Api::Team.all

# Retrieve a paginator for teams
Honeybadger::Api::Team.paginate

Team Members

# Find a team member
Honeybadger::Api::TeamMember.find(team_id, team_member_id)

# Find all the team members
Honeybadger::Api::TeamMember.all(team_id)

# Retrieve a paginator for team members
Honeybadger::Api::TeamMember.paginate(team_id)

Team Invitations

# Find a team invitation
Honeybadger::Api::TeamInvitation.find(team_id, team_invitation_id)

# Find all the team invitations
Honeybadger::Api::TeamInvitation.all(team_id)

# Retrieve a paginator for team invitations
Honeybadger::Api::TeamInvitation.paginate(team_id)

Sites

# Find a site
Honeybadger::Api::Site.find(project_id, site_id)

# Find all the sites
Honeybadger::Api::Site.all(project_id)

# Retrieve a paginator for sites
Honeybadger::Api::Site.paginate(project_id)

Outages

# Find all the outages
Honeybadger::Api::Outage.all(project_id, site_id)

# Retrieve a paginator for outages
Honeybadger::Api::Outage.paginate(project_id, site_id)

Uptime Checks

# Find all the uptime checks
Honeybadger::Api::UptimeCheck.all(project_id, site_id)

# Retrieve a paginator for uptime checks
Honeybadger::Api::UptimeCheck.paginate(project_id, site_id)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

honeybadger-api's People

Contributors

andystabler avatar marostr avatar murraysum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

honeybadger-api's Issues

Notice resource in 2.0.0

After updating to 2.0.0 version i've encountered problem with notice resource. After calling paginate method on Notice i'm receiving error

2.3.1 :001 > Honeybadger::Api::Notice.paginate(XXXX, XXXX)
NoMethodError: undefined method `[]' for nil:NilClass
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/deploy.rb:14:in `initialize'
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/notice.rb:22:in `new'
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/notice.rb:22:in `initialize'
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/notice.rb:42:in `new'
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/notice.rb:42:in `block in handler'
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/paginator.rb:22:in `block in initialize'
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/paginator.rb:21:in `map'
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/paginator.rb:21:in `initialize'
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/request.rb:40:in `new'
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/request.rb:40:in `paginate'
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/request.rb:36:in `paginate'
    from gems/honeybadger-api-2.0.0/lib/honeybadger-api/notice.rb:37:in `paginate'
    from (irb):1

From what i see, Notice resource is now using Deploy resource. Why Deploy is
obligatory now ?

EDIT 1
I think empty deploy key in response is causing that problem

Add URL parameter filtering and ordering

Since the gem was written several of the Read API endpoints now support URL parameter filters and ordering:

  • Fault
  • Notice
  • Deploy
  • Metrics

See Read API docs for details.

Support for these filters and ordering parameters should be in the gem

Error when trying to access next paginator page

Hey,

I'm using latest version and since today, I have a problem with paginator.
Pulling notices like this:
notices = Honeybadger::Api::Notice.paginate(project_id, fault_id, { created_after: created_after })
There is a NoMethodError: undefined method '<' for nil:NilClass when trying to access next page with notices.next?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.