innmind / scaleway-sdk
Unofficial Scaleway SDK
2.2.0
2022-01-22 16:18 UTC
Requires
- php: ~7.4|~8.0
- innmind/filesystem: ~4.0
- innmind/http-transport: ~5.0
- innmind/immutable: ~3.3
- innmind/ip: ~2.0
- innmind/json: ^1.1
- innmind/time-continuum: ~2.0
- innmind/url: ^3.5.1
- ramsey/uuid: ^3.8|^4.0
Requires (Dev)
- innmind/black-box: ^4.16
- innmind/coding-standard: ^1.1
- innmind/object-graph: ~2.0
- phpunit/phpunit: ~9.0
- vimeo/psalm: ~4.4
This package is auto-updated.
Last update: 2024-11-26 20:48:57 UTC
README
This is a sdk for the Scaleway API.
Installation
composer require innmind/scaleway-sdk
Usage
use 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.