Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
scheduler takeover
Browse files Browse the repository at this point in the history
  • Loading branch information
tausa committed Dec 13, 2016
1 parent 8a6215f commit 2719683
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/Endpoints/Scheduler/Scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@ public function __construct(Client $client)
}

/**
* @return PromiseInterface
* @param array $params
* @return \GuzzleHttp\Promise\PromiseInterface
*/
public function takeover(/* todo args */): PromiseInterface
public function takeover(array $params): PromiseInterface
{
// todo
return $this->client->getConfiguration()->getGuzzle()->sendAsync(
new Request('PUT', $this->client->getConfiguration()->getBaseUri() . '/scheduler/takeover', [], $this->client->getConfiguration()->getFormat()->formatParams($params))
);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/Format/FormatInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,10 @@ interface FormatInterface
* @return callable
*/
public function setFormat(callable $handler): callable;

/**
* @param array $params
* @return string
*/
public function formatParams(array $params): string;
}
12 changes: 11 additions & 1 deletion src/Format/JsonFormat.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?php
declare(strict_types=1);
declare(strict_types = 1);

namespace Lookyman\Rundeck\Api\Format;

use Psr\Http\Message\RequestInterface;

class JsonFormat implements FormatInterface
{

/**
* @param callable $handler
* @return callable
Expand All @@ -17,4 +18,13 @@ public function setFormat(callable $handler): callable
return $handler($request->withAddedHeader('Content-Type', 'application/json')->withAddedHeader('Accept', 'application/json'), $options);
};
}

/**
* @param array $params
* @return string
*/
public function formatParams(array $params): string
{
return \GuzzleHttp\json_encode($params);
}
}

0 comments on commit 2719683

Please sign in to comment.