Skip to content

Commit 2c91068

Browse files
Add dynamic dataset type selection.
1 parent b86a5d9 commit 2c91068

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

src/RestClient.php

+11-7
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@ public function getPool(string $name): Pool
4444

4545
public function createDataset(string $volume, string $name, int $size, ?string $comment = null, string $type = Dataset::TYPE_VOLUME): Dataset
4646
{
47-
$path = "{$volume}/{$name}";
48-
$response = $this->client->post('pool/dataset', [
49-
'name' => $path,
50-
'type' => Dataset::TYPE_VOLUME,
51-
'volsize' => $size,
52-
'comments' => $comment ?? '',
53-
], [], 200)->json();
47+
// In the case of a VOLUME use volsize, otherwize use quota.
48+
$sizeKey = ($type === Dataset::TYPE_VOLUME) ? 'volsize' : 'quota';
49+
50+
$payload = [
51+
'name' => "{$volume}/{$name}",
52+
'type' => $type,
53+
$sizeKey => $size,
54+
'comments' => $comment ?? '',
55+
];
56+
57+
$response = $this->client->post('pool/dataset', $payload, [], 200)->json();
5458

5559
return Dataset::fromArray($response);
5660
}

0 commit comments

Comments
 (0)