saloon, hetzner requests, spatie/ssh, serverprovider enum
This commit is contained in:
9
app/Enums/ServerProvider.php
Normal file
9
app/Enums/ServerProvider.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum ServerProvider: string
|
||||
{
|
||||
case Hetzner = 'Hetzner';
|
||||
case DigitalOcean = 'DigitalOcean';
|
||||
}
|
||||
22
app/Http/Integrations/Connectors/HetznerConnector.php
Normal file
22
app/Http/Integrations/Connectors/HetznerConnector.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Integrations\Connectors;
|
||||
|
||||
use Saloon\Http\Connector;
|
||||
|
||||
class HetznerConnector extends Connector
|
||||
{
|
||||
public function resolveBaseUrl(): string
|
||||
{
|
||||
return "https://api.hetzner.cloud/v1";
|
||||
}
|
||||
|
||||
protected function defaultHeaders(): array
|
||||
{
|
||||
return [
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json',
|
||||
'Authorization' => 'Bearer ' . config('services.hetzner.key'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Integrations\Requests\Hetzner\Images;
|
||||
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class ListImagesRequest extends Request
|
||||
{
|
||||
protected Method $method = Method::GET;
|
||||
|
||||
public function __construct(
|
||||
protected ?string $name = null,
|
||||
protected bool $includeDeprecated = false,
|
||||
protected ?string $architecture = null,
|
||||
protected ?string $labelSelector = null,
|
||||
) {}
|
||||
|
||||
protected function defaultQuery(): array
|
||||
{
|
||||
return [
|
||||
'name' => $this->name,
|
||||
'include_deprecated' => $this->includeDeprecated,
|
||||
'architecture' => $this->architecture,
|
||||
'label_selector' => $this->labelSelector,
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '/images';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Integrations\Requests\Hetzner\Locations;
|
||||
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
|
||||
class ListLocationsRequest extends Request
|
||||
{
|
||||
protected Method $method = Method::GET;
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '/locations';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Integrations\Requests\Hetzner\ServerTypes;
|
||||
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
|
||||
class ListServerTypesRequest extends Request
|
||||
{
|
||||
protected Method $method = Method::GET;
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '/server_types';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Integrations\Requests\Hetzner\Servers;
|
||||
|
||||
use Saloon\Contracts\Body\HasBody;
|
||||
use Saloon\Enums\Method;
|
||||
use Saloon\Http\Request;
|
||||
use Saloon\Traits\Body\HasJsonBody;
|
||||
|
||||
class CreateServerRequest extends Request implements HasBody
|
||||
{
|
||||
use HasJsonBody;
|
||||
|
||||
protected Method $method = Method::POST;
|
||||
|
||||
public function __construct(
|
||||
protected ?string $image = null,
|
||||
protected ?string $name = null,
|
||||
protected ?string $serverType = null,
|
||||
protected ?string $location = null,
|
||||
) {}
|
||||
|
||||
protected function defaultBody(): array
|
||||
{
|
||||
return [
|
||||
'image' => $this->image,
|
||||
'name' => $this->name,
|
||||
'server_type' => $this->serverType,
|
||||
'location' => $this->location,
|
||||
];
|
||||
}
|
||||
|
||||
public function resolveEndpoint(): string
|
||||
{
|
||||
return '/servers';
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Enums\ServerProvider;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||
|
||||
@@ -9,6 +10,13 @@ class Server extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'provider' => ServerProvider::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function services(): HasMany
|
||||
{
|
||||
return $this->hasMany(Service::class);
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
"inertiajs/inertia-laravel": "^2.0",
|
||||
"laravel/framework": "^12.0",
|
||||
"laravel/tinker": "^2.10.1",
|
||||
"saloonphp/saloon": "3.0",
|
||||
"spatie/ssh": "^1.13",
|
||||
"tightenco/ziggy": "^2.4"
|
||||
},
|
||||
"require-dev": {
|
||||
@@ -79,4 +81,4 @@
|
||||
},
|
||||
"minimum-stability": "stable",
|
||||
"prefer-stable": true
|
||||
}
|
||||
}
|
||||
|
||||
142
composer.lock
generated
142
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "855d890ad6f8126c618922c69a4ae044",
|
||||
"content-hash": "9d020e23e3b4787ce468533e44c3783c",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brick/math",
|
||||
@@ -3360,6 +3360,146 @@
|
||||
],
|
||||
"time": "2024-04-27T21:32:50+00:00"
|
||||
},
|
||||
{
|
||||
"name": "saloonphp/saloon",
|
||||
"version": "v3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/saloonphp/saloon.git",
|
||||
"reference": "b36be6b45e2170e1325cf034bc378e31318afe11"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/saloonphp/saloon/zipball/b36be6b45e2170e1325cf034bc378e31318afe11",
|
||||
"reference": "b36be6b45e2170e1325cf034bc378e31318afe11",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"guzzlehttp/guzzle": "^7.6",
|
||||
"guzzlehttp/promises": "^1.5 || ^2.0",
|
||||
"guzzlehttp/psr7": "^2.0",
|
||||
"php": "^8.1",
|
||||
"psr/http-factory": "^1.0",
|
||||
"psr/http-message": "^1.1 || ^2.0"
|
||||
},
|
||||
"conflict": {
|
||||
"sammyjo20/saloon": "*"
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-simplexml": "*",
|
||||
"friendsofphp/php-cs-fixer": "^3.5",
|
||||
"illuminate/collections": "^9.39 || ^10.0",
|
||||
"league/flysystem": "^3.0",
|
||||
"pestphp/pest": "^2.6",
|
||||
"phpstan/phpstan": "^1.9",
|
||||
"spatie/ray": "^1.33",
|
||||
"symfony/dom-crawler": "^6.0"
|
||||
},
|
||||
"suggest": {
|
||||
"illuminate/collections": "Required for the response collect() method.",
|
||||
"symfony/dom-crawler": "Required for the response dom() method."
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Saloon\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sam Carré",
|
||||
"email": "29132017+Sammyjo20@users.noreply.github.com",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "Build beautiful API integrations and SDKs with Saloon",
|
||||
"homepage": "https://github.com/saloonphp/saloon",
|
||||
"keywords": [
|
||||
"api",
|
||||
"api-integrations",
|
||||
"saloon",
|
||||
"sammyjo20",
|
||||
"sdk"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/saloonphp/saloon/issues",
|
||||
"source": "https://github.com/saloonphp/saloon/tree/v3.0.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://github.com/sammyjo20",
|
||||
"type": "github"
|
||||
},
|
||||
{
|
||||
"url": "https://ko-fi.com/sammyjo20",
|
||||
"type": "ko_fi"
|
||||
}
|
||||
],
|
||||
"time": "2023-10-01T08:13:44+00:00"
|
||||
},
|
||||
{
|
||||
"name": "spatie/ssh",
|
||||
"version": "1.13.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/spatie/ssh.git",
|
||||
"reference": "cfccf0873611a2d1b030f65d1dd319c8005d993f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/spatie/ssh/zipball/cfccf0873611a2d1b030f65d1dd319c8005d993f",
|
||||
"reference": "cfccf0873611a2d1b030f65d1dd319c8005d993f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.4|^8.0",
|
||||
"symfony/process": "^4.4|^5.3|^6.0|^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"pestphp/pest": "^1.22",
|
||||
"spatie/pest-plugin-snapshots": "^1.1",
|
||||
"symfony/var-dumper": "^5.3|6.0|^7.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Spatie\\Ssh\\": "src"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Freek Van der Herten",
|
||||
"email": "freek@spatie.be",
|
||||
"homepage": "https://spatie.be",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "A lightweight package to execute commands over an SSH connection",
|
||||
"homepage": "https://github.com/spatie/ssh",
|
||||
"keywords": [
|
||||
"spatie",
|
||||
"ssh"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/spatie/ssh/issues",
|
||||
"source": "https://github.com/spatie/ssh/tree/1.13.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
"url": "https://spatie.be/open-source/support-us",
|
||||
"type": "custom"
|
||||
}
|
||||
],
|
||||
"time": "2024-12-23T10:27:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/clock",
|
||||
"version": "v7.2.0",
|
||||
|
||||
@@ -35,4 +35,8 @@ return [
|
||||
],
|
||||
],
|
||||
|
||||
'hetzner' => [
|
||||
'key' => env('HETZNER_KEY'),
|
||||
]
|
||||
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user