Skip to content
Ruby
Branch: master
Clone or download
Latest commit d3ead32 Oct 18, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples Change Device#delete_locations! to follow the same signature as Strea… Jul 22, 2016
lib Version bump to 2.8.0 Oct 18, 2017
.gitignore
CONTRIBUTING.md
LICENSE Add LICENSE Oct 18, 2013
README.md Add Integrations Oct 18, 2017
TUTORIAL.md minor tutorial udpates Mar 24, 2015
m2x.gemspec Include CA file on gem files Dec 30, 2014

README.md

AT&T M2X Ruby Client

AT&T M2X is a cloud-based fully managed time-series data storage service for network connected machine-to-machine (M2M) devices and the Internet of Things (IoT).

The AT&T M2X API provides all the needed operations and methods to connect your devices to AT&T's M2X service. This library aims to provide a simple wrapper to interact with the AT&T M2X API for Ruby. Refer to the Glossary of Terms to understand the nomenclature used throughout this documentation.

Getting Started

  1. Signup for an M2X Account.
  2. Obtain your Master Key from the Master Keys tab of your Account Settings screen.
  3. Create your first Device and copy its Device ID.
  4. Review the M2X API Documentation.

Installation

$ gem install m2x

Usage

In order to communicate with the M2X API, you need an instance of M2X::Client. You need to pass your API key in the constructor to access your data.

m2x = M2X::Client.new(<YOUR-API-KEY>)

This provides an interface to your data in M2X

  • Distribution

    distribution = m2x.distribution("<DISTRIBUTION-ID>")
    
    distributions = m2x.distributions
  • Device

    device = m2x.device("<DEVICE-ID>")
    
    devices = m2x.devices
  • Collection

    collection = m2x.collection("<COLLECTION-ID>")
    
    collections = m2x.collections
  • Key

    key = m2x.key("<KEY-TOKEN>")
    
    keys = m2x.keys
  • Job

    job = m2x.job("<JOB-ID>")
  • Integration

    integration = m2x.integration("<INTEGRATION-ID>")
    
    integrations = m2x.integrations

Refer to the documentation on each class for further usage instructions.

Time

For devices that do not have a Real Time Clock, M2X provides a set of endpoints that returns the server's time.

m2x.time
=> {"seconds"=>1435970368, "millis"=>1435970368451, "iso8601"=>"2015-07-04T00:39:28.451Z"}

m2x.time_seconds
=> "1435970400"

m2x.time_millis
=> "1435970418134"

m2x.time_iso8601
=> "2015-07-04T00:40:37.504Z"

Examples

Scripts demonstrating usage of the M2X Ruby Client Library can be found in the examples directory. Each example leverages system environment variables to inject user specific information such as the M2X API Key or Device ID. Review the example you would like to try first to determine which environment variables are required (hint: search for ENV.fetch in the example). Then make sure to set the required environment variable(s) when running the script.

For example, in order to run the m2x-uptime script, you will need a Device ID and API Key. If you have yet to create an M2X Device, access your M2X account, create a new Device, and copy the Device ID and API Key values. The script will send your CPU load average to three different streams named load_1m, load_5m and load_15. In order to execute this script, run:

$ API_KEY=<YOUR-API-KEY> DEVICE=<YOUR-DEVICE-ID> ruby ./m2x-uptime.rb

Tutorials

Please refer to the M2X Ruby Client Tutorials for additional hands on examples.

Versioning

This gem aims to adhere to Semantic Versioning 2.0.0. As a summary, given a version number MAJOR.MINOR.PATCH:

  1. MAJOR will increment when backwards-incompatible changes are introduced to the client.
  2. MINOR will increment when backwards-compatible functionality is added.
  3. PATCH will increment with backwards-compatible bug fixes.

Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

Note: the client version does not necessarily reflect the version used in the AT&T M2X API.

License

This gem is provided under the MIT license. See LICENSE for applicable terms.

You can’t perform that action at this time.