Skip to content
This repository was archived by the owner on May 27, 2026. It is now read-only.

Innmind/ScalewaySdk

Repository files navigation

Scaleway SDK (unofficial)

Build Status codecov Type Coverage

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages