Coder Social home page Coder Social logo

mms-api's Introduction

mms-api Build Status

Minimalistic MMS API agent for ruby

Installation

gem install mms-api

API coverage

The MMS Public API follows the principles of the REST architectural style to expose a number of internal resources which enable programmatic access to MMS’s features. Current implementation support only a few of API features.

Resource Get All Get One Create Update Delete
Groups + +
Hosts + +
Clusters + +
Snapshots + +
Alerts + +
Restore Jobs + + +

Library usage

Source code itself is well-documented so when writing code it should auto-complete and hint in all supported usages.

Client

Most important part of the api is client. In order to make any request you need to instantiate client with correct params.

client = MMS::Client.new('username', 'api_key')

This client is used by all other classes connecting to api no matter if it's Resource or helper class like Agent.

Agent

Agent is simple wrapper class for listing all accessible resources.

client = MMS::Client.new('username', 'api_key')
agent = MMS::Agent.new(client)

agent.alerts.each do |alert|
    alert.ack('now')
end

List of resource-listing agent methods:

  • groups
  • hosts
  • clusters
  • snapshots
  • alerts
  • restorejobs

Resources

You can find lists of resource by using agent as pointed above, or by various resource methods. Each resource have a find method loading certain resource with provided id (plus corresponding parent ids), e.g.

client = new MMS::Client.new('username', 'api_key')
host = MMS::Resource::Host.find(client, 'group_id', 'host_id')

Additionally some resources have additional instance methods to retrieve sub-resources, e.g.

client = new MMS::Client.new('username', 'api_key')
group = MMS::Resource::Group.find(client, 'group_id')
hosts = group.hosts

Cli usage

There is a built-in cli with several commands retrieving api resource lists.

Configuration

Cli uses configuration with all values set to default ones. Config itself has config_file property which merges itself with params from the file. By default config_file points to home directory, but it can be changed to points to any file.

[email protected]
apikey=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
apiurl=https://mms.mydomain.tld/api/public/v1.0
default_group_id=your-group-id
default_cluster_id=your-cluster-id

Additionally some options can be modified using cli options.

Available commands

$ mms-api --help
Usage:
     [OPTIONS] SUBCOMMAND [ARG] ...

Parameters:
    SUBCOMMAND                    subcommand
    [ARG] ...                     subcommand arguments

Subcommands:
    groups                        Groups
    hosts                         Hosts
    clusters                      Clusters
    alerts                        Alerts
    snapshots                     Snapshots
    restorejobs                   Restorejobs

Options:
    -h, --help                    print help
    -u, --username <string>       MMS user
    -k, --apikey <string>         MMS api-key
    -a, --apiurl <string>         MMS api url. Full url including version: https://mms.mydomain.tld/api/public/v1.0
    -v, --version                 Version
    -g, --default-group-id <string> Default MMS group id
    -c, --default-cluster-id <string> Default MMS cluster id
    --cfg <string>                Config file path
    -i, --ignore                  Ignore flag of --group-id and -cluster-id (default: false)
    -j, --json                    Print JSON output (default: false)
    -l, --limit <integer>         Limit for result items

mms-api's People

Contributors

drags avatar kris-lab avatar tattish avatar tomaszdurka avatar

Watchers

 avatar  avatar

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.