Attribute | Description |
---|---|
organization | Name of the organization that the stack belongs to |
name | Name of the stack |
created | When this stack was created |
stackOperations | List of operations for this stack |
You can create a stack by providing an organization, the name and operations to apply on the stack. In the following example, the stack applies a resize of 200 x 200 and rotates it by 45 degrees. It's created in the testorganization and given the name teststack.
curl -H 'Content-Type: application/json' -X PUT 'https://api.rokka.io/stacks/testorganization/teststack' -d '[
{
"name": "resize",
"options": {
"width": 200,
"height": 200
}
},
{
"name": "rotate",
"options": {
"angle": 45
}
}
]'
use Rokka\Client\Core\StackOperation;
use Rokka\Client\Core\StackOperationCollection;
$client = \Rokka\Client\Factory::getImageClient('testorganization', 'apiKey', 'apiSecret');
$resize = new StackOperation('resize', ['width' => 200, 'height' => 200]);
$rotate = new StackOperation('rotate', ['angle' => 45]);
$stackOperationCollection = new StackOperationCollection([$resize, $rotate]);
$stack = $client->createStack('teststack', $stackOperationCollection);
echo 'Created stack ' . $stack->getName() . PHP_EOL;
print_r($stack);
Note: The name "dynamic" is reserved and can't be chosen, as it's used for dynamic rendering.
You can retrieve a stack by providing the organization and stack name. This example gets the stack teststack from the organization testorganization.
curl -X GET 'https://api.rokka.io/stacks/testorganization/teststack'
$client = \Rokka\Client\Factory::getImageClient('testorganization', 'apiKey', 'apiSecret');
$stack = $client->getStack('teststack');
echo 'Displaying stack ' . $stack->getName() . PHP_EOL;
print_r($stack);
An example JSON response looks like this.
{
organization: "testorganization",
name: "teststack",
created: {
date: "2015-08-20 08:50:32.000000",
timezone_type: 3,
timezone: "UTC"
},
stackoperations: [
{
name: "resize",
options: {
width: 200,
height: 200
}
},
{
name: "rotate",
options: {
angle: 45
}
}
],
_links: {
self: {
href: "/stacks/testorganization/teststack"
}
}
}
Deleting a stack works like this.
curl -X DELETE 'https://api.rokka.io/stacks/testorganization/teststack'
$client = \Rokka\Client\Factory::getImageClient('testorganization', 'apiKey', 'apiSecret');
$deleted = $client->deleteStack('teststack');
if (true === $deleted) {
echo 'Deleted stack';
} else {
echo 'Did not delete stack!';
}
It is possible to list all stacks for an organization.
curl -X GET 'https://api.rokka.io/stacks/testorganization'
use Rokka\Client\Core\Stack;
$client = \Rokka\Client\Factory::getImageClient('testorganization', 'apiKey', 'apiSecret');
$stacks = $client->listStacks();
foreach ($stacks as $stack) {
/** @var Stack $stack */
echo 'Stack ' . $stack->getName() . PHP_EOL;
}
Attribute | Description |
---|---|
limit | Optional limit |
offset | Optional offset |