This is a sdk for the Scaleway API.
composer require innmind/scaleway-sdkuse Innmind\OperatingSystem\Factory;
use function Innmind\ScalewaySdk\bootstrap;
use Innmind\ScalewaySdk\{
Tokens\NewToken,
Region,
Server,
Marketplace,
ChooseImage,
};
use function Innmind\Immutable\{
first,
unwrap,
};
$os = Factory::build();
$sdk = bootstrap($os->remote()->http(), $os->clock());
$token = $sdk
->tokens()
->create(NewToken::temporary(
'foo@example.com',
'some secret password',
'2FACOD', // if 2FA enabled on your account
));
$organizations = $sdk
->authenticated($token->id())
->users()
->get($token->user())
->organizations();
$organization = first($organizations);
$servers = $sdk
->authenticated($token->id())
->servers(Region::paris1());
$chooseImage = new ChooseImage(
...unwrap($sdk
->authenticated($token->id())
->marketplace()
->images()
->list()),
);
$server = $servers->create(
new Server\Name('my-server'),
$organization,
$chooseImage(
Region::paris1(),
new Marketplace\Image\Name('CentOS 7.6'),
new Marketplace\Product\Server\Name('GP1-XS'),
),
$servers
->authenticated($token->id())
->ips(Region::paris1())
->create($organization),
);
$servers->execute(
$server->id(),
Server\Action::powerOn(),
);This example creates a new CentOS machine. To review all the capabilities of this SDK take a look at the interfaces in the Authenticated directory.