feat: lots of api endpoints
This commit is contained in:
@@ -19,131 +19,163 @@ function generate_database_name(string $type): string
|
||||
return $type.'-database-'.$cuid;
|
||||
}
|
||||
|
||||
function create_standalone_postgresql($environment_id, $destination_uuid): StandalonePostgresql
|
||||
function create_standalone_postgresql($environmentId, $destinationUuid, ?array $otherData = null): StandalonePostgresql
|
||||
{
|
||||
// TODO: If another type of destination is added, this will need to be updated.
|
||||
$destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
|
||||
$destination = StandaloneDocker::where('uuid', $destinationUuid)->first();
|
||||
if (! $destination) {
|
||||
throw new Exception('Destination not found');
|
||||
}
|
||||
$database = new StandalonePostgresql();
|
||||
$database->name = generate_database_name('postgresql');
|
||||
$database->postgres_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$database->environment_id = $environmentId;
|
||||
$database->destination_id = $destination->id;
|
||||
$database->destination_type = $destination->getMorphClass();
|
||||
if ($otherData) {
|
||||
$database->fill($otherData);
|
||||
}
|
||||
$database->save();
|
||||
|
||||
return StandalonePostgresql::create([
|
||||
'name' => generate_database_name('postgresql'),
|
||||
'postgres_password' => \Illuminate\Support\Str::password(length: 64, symbols: false),
|
||||
'environment_id' => $environment_id,
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
]);
|
||||
return $database;
|
||||
}
|
||||
|
||||
function create_standalone_redis($environment_id, $destination_uuid): StandaloneRedis
|
||||
function create_standalone_redis($environment_id, $destination_uuid, ?array $otherData = null): StandaloneRedis
|
||||
{
|
||||
$destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
|
||||
if (! $destination) {
|
||||
throw new Exception('Destination not found');
|
||||
}
|
||||
$database = new StandaloneRedis();
|
||||
$database->name = generate_database_name('redis');
|
||||
$database->redis_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$database->environment_id = $environment_id;
|
||||
$database->destination_id = $destination->id;
|
||||
$database->destination_type = $destination->getMorphClass();
|
||||
if ($otherData) {
|
||||
$database->fill($otherData);
|
||||
}
|
||||
$database->save();
|
||||
|
||||
return StandaloneRedis::create([
|
||||
'name' => generate_database_name('redis'),
|
||||
'redis_password' => \Illuminate\Support\Str::password(length: 64, symbols: false),
|
||||
'environment_id' => $environment_id,
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
]);
|
||||
return $database;
|
||||
}
|
||||
|
||||
function create_standalone_mongodb($environment_id, $destination_uuid): StandaloneMongodb
|
||||
function create_standalone_mongodb($environment_id, $destination_uuid, ?array $otherData = null): StandaloneMongodb
|
||||
{
|
||||
$destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
|
||||
if (! $destination) {
|
||||
throw new Exception('Destination not found');
|
||||
}
|
||||
$database = new StandaloneMongodb();
|
||||
$database->name = generate_database_name('mongodb');
|
||||
$database->mongo_initdb_root_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$database->environment_id = $environment_id;
|
||||
$database->destination_id = $destination->id;
|
||||
$database->destination_type = $destination->getMorphClass();
|
||||
if ($otherData) {
|
||||
$database->fill($otherData);
|
||||
}
|
||||
$database->save();
|
||||
|
||||
return StandaloneMongodb::create([
|
||||
'name' => generate_database_name('mongodb'),
|
||||
'mongo_initdb_root_password' => \Illuminate\Support\Str::password(length: 64, symbols: false),
|
||||
'environment_id' => $environment_id,
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
]);
|
||||
return $database;
|
||||
}
|
||||
function create_standalone_mysql($environment_id, $destination_uuid): StandaloneMysql
|
||||
function create_standalone_mysql($environment_id, $destination_uuid, ?array $otherData = null): StandaloneMysql
|
||||
{
|
||||
$destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
|
||||
if (! $destination) {
|
||||
throw new Exception('Destination not found');
|
||||
}
|
||||
$database = new StandaloneMysql();
|
||||
$database->name = generate_database_name('mysql');
|
||||
$database->mysql_root_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$database->mysql_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$database->environment_id = $environment_id;
|
||||
$database->destination_id = $destination->id;
|
||||
$database->destination_type = $destination->getMorphClass();
|
||||
if ($otherData) {
|
||||
$database->fill($otherData);
|
||||
}
|
||||
$database->save();
|
||||
|
||||
return StandaloneMysql::create([
|
||||
'name' => generate_database_name('mysql'),
|
||||
'mysql_root_password' => \Illuminate\Support\Str::password(length: 64, symbols: false),
|
||||
'mysql_password' => \Illuminate\Support\Str::password(length: 64, symbols: false),
|
||||
'environment_id' => $environment_id,
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
]);
|
||||
return $database;
|
||||
}
|
||||
function create_standalone_mariadb($environment_id, $destination_uuid): StandaloneMariadb
|
||||
function create_standalone_mariadb($environment_id, $destination_uuid, ?array $otherData = null): StandaloneMariadb
|
||||
{
|
||||
$destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
|
||||
if (! $destination) {
|
||||
throw new Exception('Destination not found');
|
||||
}
|
||||
$database = new StandaloneMariadb();
|
||||
$database->name = generate_database_name('mariadb');
|
||||
$database->mariadb_root_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$database->mariadb_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$database->environment_id = $environment_id;
|
||||
$database->destination_id = $destination->id;
|
||||
$database->destination_type = $destination->getMorphClass();
|
||||
|
||||
return StandaloneMariadb::create([
|
||||
'name' => generate_database_name('mariadb'),
|
||||
'mariadb_root_password' => \Illuminate\Support\Str::password(length: 64, symbols: false),
|
||||
'mariadb_password' => \Illuminate\Support\Str::password(length: 64, symbols: false),
|
||||
'environment_id' => $environment_id,
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
]);
|
||||
if ($otherData) {
|
||||
$database->fill($otherData);
|
||||
}
|
||||
$database->save();
|
||||
|
||||
return $database;
|
||||
}
|
||||
function create_standalone_keydb($environment_id, $destination_uuid): StandaloneKeydb
|
||||
function create_standalone_keydb($environment_id, $destination_uuid, ?array $otherData = null): StandaloneKeydb
|
||||
{
|
||||
$destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
|
||||
if (! $destination) {
|
||||
throw new Exception('Destination not found');
|
||||
}
|
||||
$database = new StandaloneKeydb();
|
||||
$database->name = generate_database_name('keydb');
|
||||
$database->keydb_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$database->environment_id = $environment_id;
|
||||
$database->destination_id = $destination->id;
|
||||
$database->destination_type = $destination->getMorphClass();
|
||||
if ($otherData) {
|
||||
$database->fill($otherData);
|
||||
}
|
||||
$database->save();
|
||||
|
||||
return StandaloneKeydb::create([
|
||||
'name' => generate_database_name('keydb'),
|
||||
'keydb_password' => \Illuminate\Support\Str::password(length: 64, symbols: false),
|
||||
'environment_id' => $environment_id,
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
]);
|
||||
return $database;
|
||||
}
|
||||
|
||||
function create_standalone_dragonfly($environment_id, $destination_uuid): StandaloneDragonfly
|
||||
function create_standalone_dragonfly($environment_id, $destination_uuid, ?array $otherData = null): StandaloneDragonfly
|
||||
{
|
||||
$destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
|
||||
if (! $destination) {
|
||||
throw new Exception('Destination not found');
|
||||
}
|
||||
$database = new StandaloneDragonfly();
|
||||
$database->name = generate_database_name('dragonfly');
|
||||
$database->dragonfly_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$database->environment_id = $environment_id;
|
||||
$database->destination_id = $destination->id;
|
||||
$database->destination_type = $destination->getMorphClass();
|
||||
if ($otherData) {
|
||||
$database->fill($otherData);
|
||||
}
|
||||
$database->save();
|
||||
|
||||
return StandaloneDragonfly::create([
|
||||
'name' => generate_database_name('dragonfly'),
|
||||
'dragonfly_password' => \Illuminate\Support\Str::password(length: 64, symbols: false),
|
||||
'environment_id' => $environment_id,
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
]);
|
||||
return $database;
|
||||
}
|
||||
function create_standalone_clickhouse($environment_id, $destination_uuid): StandaloneClickhouse
|
||||
function create_standalone_clickhouse($environment_id, $destination_uuid, ?array $otherData = null): StandaloneClickhouse
|
||||
{
|
||||
$destination = StandaloneDocker::where('uuid', $destination_uuid)->first();
|
||||
if (! $destination) {
|
||||
throw new Exception('Destination not found');
|
||||
}
|
||||
$database = new StandaloneClickhouse();
|
||||
$database->name = generate_database_name('clickhouse');
|
||||
$database->clickhouse_admin_password = \Illuminate\Support\Str::password(length: 64, symbols: false);
|
||||
$database->environment_id = $environment_id;
|
||||
$database->destination_id = $destination->id;
|
||||
$database->destination_type = $destination->getMorphClass();
|
||||
if ($otherData) {
|
||||
$database->fill($otherData);
|
||||
}
|
||||
$database->save();
|
||||
|
||||
return StandaloneClickhouse::create([
|
||||
'name' => generate_database_name('clickhouse'),
|
||||
'clickhouse_admin_password' => \Illuminate\Support\Str::password(length: 64, symbols: false),
|
||||
'environment_id' => $environment_id,
|
||||
'destination_id' => $destination->id,
|
||||
'destination_type' => $destination->getMorphClass(),
|
||||
]);
|
||||
return $database;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user