keboola/syrup-php-client

Keboola Syrup PHP Client

5.5.0 2020-08-17 19:59 UTC

README

Simple PHP wrapper library for Syrup async calls.

Installation

Library is available as composer package. To start using composer in your project follow these steps:

Install composer

curl -s http://getcomposer.org/installer | php
mv ./composer.phar ~/bin/composer # or /usr/local/bin/composer

Create composer.json file in your project root folder:

{
    "require": {
        "php" : ">=5.4.0",
        "keboola/syrup-php-client": "2.0.*"
    }
}

Install package:

composer install

Add autoloader in your bootstrap script:

require 'vendor/autoload.php';

Read more in Composer documentation

Usage examples

Create and run a job

require 'vendor/autoload.php';

use Keboola\Syrup\Client,

$client = new Client([
  'token' => 'YOUR_TOKEN',
  'runId' => 'CURRENT_RUNID'
]);

$response = $client->runJob("test-component", array("config" => 1));

Encrypt component and project specific string for a Docker component (calls docker/test-component/configs/encrypt)

require 'vendor/autoload.php';

use Keboola\Syrup\Client,

$client = new Client([
  'token' => 'YOUR_TOKEN',
  'runId' => 'CURRENT_RUNID',
  'super' => 'docker'
]);

$response = $client->encryptString("test-component", "string", ["path" => "configs"]);

Create a custom job on a component (calls POST provisioning/async/docker) with {"type" => "rstudio"} body

require 'vendor/autoload.php';

use Keboola\Syrup\Client,

$client = new Client([
  'token' => 'YOUR_TOKEN',
  'runId' => 'CURRENT_RUNID',
  'super' => 'provisioning'
]);

$response = $client->runAsyncAction("async/docker", "POST", ["body" => ["type" => "rstudio"]]);

Create a custom DELETE job on a component (calls DELETE provisioning/async/docker/1)

require 'vendor/autoload.php';

use Keboola\Syrup\Client,

$client = new Client([
  'token' => 'YOUR_TOKEN',
  'runId' => 'CURRENT_RUNID',
  'super' => 'provisioning'
]);

$response = $client->runAsyncAction("async/docker/1", "DELETE");