Complete base implementation of services for administrative server creation
This commit is contained in:
parent
f842aae3d3
commit
8daec38622
22 changed files with 633 additions and 141 deletions
|
@ -59,7 +59,7 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
|
|||
'io' => (int) $server->io,
|
||||
'cpu' => (int) $server->cpu,
|
||||
'disk' => (int) $server->disk,
|
||||
'image' => (int) $server->image,
|
||||
'image' => $server->image,
|
||||
],
|
||||
'service' => [
|
||||
'type' => $server->option->service->folder,
|
||||
|
@ -97,9 +97,15 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function reinstall()
|
||||
public function reinstall($data = null)
|
||||
{
|
||||
return $this->getHttpClient()->request('POST', '/server/reinstall');
|
||||
if (is_null($data)) {
|
||||
return $this->getHttpClient()->request('POST', '/server/reinstall');
|
||||
}
|
||||
|
||||
return $this->getHttpClient()->request('POST', '/server/reinstall', [
|
||||
'json' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,4 +131,12 @@ class ServerRepository extends BaseRepository implements ServerRepositoryInterfa
|
|||
{
|
||||
return $this->getHttpClient()->request('POST', '/server/unsuspend');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
return $this->getHttpClient()->request('DELETE', '/servers');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -176,4 +176,19 @@ abstract class EloquentRepository extends Repository implements RepositoryInterf
|
|||
{
|
||||
return $this->getBuilder()->insert($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @return bool|\Illuminate\Database\Eloquent\Model
|
||||
*/
|
||||
public function updateOrCreate(array $where, array $fields, $validate = true, $force = false)
|
||||
{
|
||||
$instance = $this->withColumns('id')->findWhere($where)->first();
|
||||
|
||||
if (! $instance) {
|
||||
return $this->create(array_merge($where, $fields), $validate, $force);
|
||||
}
|
||||
|
||||
return $this->update($instance->id, $fields, $validate, $force);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,4 +129,22 @@ class ServerRepository extends SearchableRepository implements ServerRepositoryI
|
|||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDaemonServiceData($id)
|
||||
{
|
||||
$instance = $this->getBuilder()->with('option.service', 'pack')->find($id, $this->getColumns());
|
||||
|
||||
if (! $instance) {
|
||||
throw new RecordNotFoundException();
|
||||
}
|
||||
|
||||
return [
|
||||
'type' => $instance->option->service->folder,
|
||||
'option' => $instance->option->tag,
|
||||
'pack' => (! is_null($instance->pack_id)) ? $instance->pack->uuid : null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue