Using Steward with cURL

Notify that a job has started

curl -H "X-StewardToken: Your API key" https://steward.io/j/Ax9r34q/start

Notify that a job has ended

curl -H "X-StewardToken: Your API key" https://steward.io/j/Ax9r34q/end

Notify that a job has failed

curl -H "X-StewardToken: Your API key" https://steward.io/j/Ax9r34q/failed

If you wish just to track when your jobs run

curl -H "X-StewardToken: Your API key" https://steward.io/j/Ax9r34q/ping

Using Steward with Lua

Easily integrate with Steward using Lua. The example below requires the luasocket library.

Prerequisites

First, install the luasocket library via LuaRocks by running the following command:

luarocks install luasocket

Usage

local http = require("socket.http")
headers = { ["X-StewardToken"] = "Your API key"}

# Notify Steward job has started.
content, response, header = http.request { url = "https://steward.io/j/Ax9r34q/start", headers= headers}

# Your code here

# Notify Steward job has finished.
content, response, header = http.request { url = "https://steward.io/j/Ax9r34q/end", headers=headers }

Using Steward with Perl

Easily integrate with Steward using Perl. The example below requires the HTTP::Tiny module.

Prerequisites

First, install the HTTP::Tiny library via CPAN by running the following command:

cpanm HTTP::Tiny

Usage

use HTTP::Tiny;

# Simple user agent with Steward authenication token
my $http = HTTP::Tiny->new(
    default_headers => {
        'X-StewardToken' => 'Your API key',
    },
);

# Make request to notify Steward the job is starting.
my $response = $http->get('https://steward.io/j/Ax9r34q/start');

# Your code goes here

# Make request to notify steward the job has ended.
my $response = $http->get('https://steward.io/j/Ax9r34q/end');

Using Steward with PHP

Here are some examples on how to easily integrate with Steward using PHP.

$curl = curl_init();

// Define URL and headers.
curl_setopt($curl, CURLOPT_URL, "https://steward.io/j/Ax9r34q/start");
curl_setopt($curl, CURLOPT_HTTPHEADER, array('X-StewardToken: Your API key'));
$response = curl_exec($curl);

// Add your code here.

// Indicate the job has finished
curl_setopt($curl, CURLOPT_URL, "https://steward.io/j/Ax9r34q/end");
$response = curl_exec($curl);

Using Steward with Python

Here are some examples on how to easily integrate with Steward using Python.

Prerequisites

First, install the Requests HTTP library via PIP by running the following command:

pip install requests

Usage

import requests

headers = {'X-StewardToken': 'Your API key'}

# job started
requests.get('https://steward.io/j/Ax9r34q/start', headers=headers)

# some work

# job completed
requests.get('https://steward.io/j/Ax9r34q/end', headers=headers)

Using Steward with Ruby

Add the Ruby gem to your project's Gemfile

gem 'steward-io'

or install via command line:

gem install steward-io

Now encapsulate your Ruby job code inside a block

require 'steward'

client = Steward::Client.new("Your API key")
client.job "Ax9r34q" do
  # your code goes here...
end

Once the block is finish executing, the client will notify Steward that the job is complete. If the block call raises any exception, the client will instead mark the job was failed and notify Steward.

Using Steward with Windows

VBScript Example

Set objsteward= CreateObject("MSXML2.XMLHTTP")
objsteward.Open "GET", "https://steward.io/j/Ax9r34q/start", false
objsteward.setRequestHeader "X-StewardToken", "Your API key"
objsteward.Send