Skip to content

Commit 63f27ab

Browse files
committed
Initial commit
This adds the README.md, .gitignore and the basics of the API client like the entrypoint HypernodeClient class and its factory. This also includes the first feature: updating one or more settings for a Hypernode and querying/polling the logbook for a log to be completed.
0 parents  commit 63f27ab

14 files changed

+3472
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
vendor

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Hypernode API PHP Client
2+
3+
_**Please note: this project is still in its early stages and the API may be subject to change.**_
4+
5+
## Installation
6+
7+
```bash
8+
composer require hypernode/api-client
9+
```
10+
11+
The API client is HTTP client agnostic, which means that it's compatible with
12+
any HTTP client implementing [PSR-18 interface](https://www.php-fig.org/psr/psr-18/).
13+
14+
Popular HTTP client implementations are: [Guzzle](https://packagist.org/packages/guzzlehttp/guzzle) and [Symfony HTTP Client](https://packagist.org/packages/symfony/http-client).
15+
16+
A full list of implementations, can be [found here](https://packagist.org/providers/psr/http-client-implementation).
17+
18+
## Usage
19+
20+
### Acquiring an API token
21+
22+
An API token can be requested at support@hypernode.com.
23+
24+
### Using the client
25+
26+
``` php
27+
use Hypernode\Api\HypernodeClientFactory;
28+
29+
require_once 'vendor/autoload.php';
30+
31+
$client = HypernodeClientFactory::create(getenv('HYPERNODE_API_TOKEN'));
32+
33+
// For the Hypernode `johndoe` PHP version to 8.1 and Node.js version to 18
34+
$job = $client->settings->setBatch('johndoe', [
35+
'php_version' => '8.1',
36+
'nodejs_version' => '18'
37+
]);
38+
39+
// If something has changed, wait for the changes to be applied.
40+
while ($job && !$job->completed()) {
41+
sleep(2);
42+
$job->refresh();
43+
}
44+
```
45+
46+
## Supported features
47+
48+
Here's a list of Hypernode API features implemented in the client.
49+
50+
- Updating one or multiple Hypernode settings at once.
51+
- Querying/polling the logbook for the status of a job.

composer.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "hypernode/api-client",
3+
"description": "Hypernode API Client for PHP",
4+
"type": "library",
5+
"autoload": {
6+
"psr-4": {
7+
"Hypernode\\Api\\": "src/"
8+
}
9+
},
10+
"authors": [
11+
{
12+
"name": "Hypernode"
13+
}
14+
],
15+
"require": {
16+
"ext-curl": "*",
17+
"ext-json": "*",
18+
"symfony/polyfill-php80": "^1.0",
19+
"psr/http-client-implementation": "^1.0",
20+
"php-http/client-common": "^2.5",
21+
"php-http/discovery": "^1.14"
22+
},
23+
"require-dev": {
24+
"friendsofphp/php-cs-fixer": "^3.9",
25+
"guzzlehttp/guzzle": "^7.4",
26+
"nikic/php-parser": "^4.14"
27+
}
28+
}

0 commit comments

Comments
 (0)