Code Monkey home page Code Monkey logo

a2-api-example's Introduction

a2-api-example

Chef Automate 2 has an API that the UI uses to access all of its data. While the OpenAPI docs are exposed at https://automate.example.com/api/v0/openapi/ui/, there isn't a great getting started guide. I learn best by example, so this repository contains a quick script showing how to get data out of the Automate API using Ruby.

Configuration

You'll need an API key. You can get this from the Automate UI or by running chef-automate admin-token. This script uses environment variables for configuration. The easiest way to get started is to cp .env.example .env and editing .env with your API key and Automate server hostname.

Usage

After configuration, run bundle install to install dependencies. Example run:

$ ruby a2_api_example.rb
Node Counts:
{
  "total": 1,
  "success": 0,
  "failure": 0,
  "missing": 1
}

Run Counts:
{
  "total": 6,
  "success": 4,
  "failure": 2
}

Compliance Summary:
{
  "controls_summary": null,
  "node_summary": null,
  "report_summary": {
    "stats": {
      "nodes": "0",
      "platforms": 0,
      "environments": 0,
      "profiles": 0
    },
    "status": "unknown",
    "duration": 0,
    "start_date": ""
  }
}

Notes

The Chef Automate API isn't complete yet. Breaking changes may be introduced that breaks this (or your own) code. Use at your own risk for now!

I'd love to turn all of the endpoints into a class that can be used. I'm sure there's a way to do this from the OpenAPI specifications. If you'd like to pair on this, please let me know!

a2-api-example's People

Contributors

kevinreedy avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

tiobagio

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.