Skip to content

Commit a98f3df

Browse files
committed
Merge branch 'develop'
2 parents ff92aa1 + 4c69b2d commit a98f3df

20 files changed

+157
-65
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 9.4.0 - 2025-09-10
4+
5+
Added support for AssetUpdateStartRequest (private API).
6+
37
## 9.3.0 - 2025-08-18
48

59
When the Assets sessions expires in AssetsClient::downloadFileToPath(), re-authenticate instead of
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
3+
namespace DerSpiegel\WoodWingAssetsClient\PrivateApi\System;
4+
5+
use DerSpiegel\WoodWingAssetsClient\AssetsClient;
6+
use DerSpiegel\WoodWingAssetsClient\Request;
7+
8+
9+
class AssetUpdateStartRequest extends Request
10+
{
11+
public function __construct(
12+
AssetsClient $assetsClient,
13+
readonly string $filterQuery,
14+
readonly bool $extractMetadata = false,
15+
readonly bool $reEmbedMetadata = false,
16+
readonly bool $extractTextContent = false,
17+
readonly bool $deleteRemovedAssetsFromIndex = false,
18+
readonly bool $regenerateThumbnailsAndPreviews = false,
19+
readonly bool $rebuildAutoCreatedRelations = false,
20+
readonly bool $pruneBlacklist = false,
21+
readonly ?bool $runExclusive = null,
22+
readonly ?int $pauseMillis = null,
23+
readonly ?int $numThreads = null,
24+
)
25+
{
26+
parent::__construct($assetsClient);
27+
}
28+
29+
30+
public function __invoke(): array
31+
{
32+
return $this->assetsClient->privateApiRequest(
33+
'POST',
34+
'system/asset/update/start',
35+
$this->toArray()
36+
);
37+
}
38+
39+
40+
protected function toArray(): array
41+
{
42+
$params = [
43+
'filterQuery' => $this->filterQuery,
44+
];
45+
46+
$actionProperties = [
47+
'extractMetadata',
48+
'reEmbedMetadata',
49+
'extractTextContent',
50+
'deleteRemovedAssetsFromIndex',
51+
'regenerateThumbnailsAndPreviews',
52+
'rebuildAutoCreatedRelations',
53+
'pruneBlacklist',
54+
];
55+
56+
foreach ($actionProperties as $propertyName) {
57+
if ($this->$propertyName === true) {
58+
$params[$propertyName] = true;
59+
}
60+
}
61+
62+
$nullableProperties = [
63+
'runExclusive',
64+
'pauseMillis',
65+
'numThreads',
66+
];
67+
68+
foreach ($nullableProperties as $propertyName) {
69+
if ($this->$propertyName !== null) {
70+
$params[$propertyName] = $this->$propertyName;
71+
}
72+
}
73+
74+
return $params;
75+
}
76+
}

tests/Fixtures/IntegrationUtils.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ public static function createJpegAsset(AssetsClient $assetsClient, string $filen
3535

3636
$fp = fopen($tmpFilename, 'r');
3737

38-
return (new CreateRequest($assetsClient,
38+
return new CreateRequest($assetsClient,
3939
filedata: $fp,
4040
metadata: $metadata
41-
))();
41+
)();
4242
}
4343

4444

tests/Integration/AddToContainerRequestTest.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,38 @@ public function test(): void
2626
$assetId = $assetResponse->id;
2727
$this->assertNotEmpty($assetId);
2828

29-
$collectionResponse = (new CreateCollectionRequest(
29+
$collectionResponse = new CreateCollectionRequest(
3030
$this->assetsClient,
3131
assetPath: sprintf('%s/%s.collection', IntegrationUtils::getAssetsTestsFolder(), $basename)
32-
))();
32+
)();
3333

3434
$collectionId = $collectionResponse->id;
3535

36-
(new AddToContainerRequest($this->assetsClient,
36+
new AddToContainerRequest(
37+
$this->assetsClient,
3738
assetId: $assetId,
3839
containerId: $collectionId
39-
))();
40+
)();
41+
42+
sleep(1);
4043

41-
$processResponse = (new RemoveFromContainerRequest($this->assetsClient,
44+
$processResponse = new RemoveFromContainerRequest(
45+
$this->assetsClient,
4246
assetId: $assetId,
4347
containerId: $collectionId
44-
))();
45-
46-
$this->assertEquals(1, $processResponse->processedCount);
48+
)();
49+
50+
$this->assertEquals(
51+
1,
52+
$processResponse->processedCount,
53+
sprintf(
54+
'RemoveFromContainer returns processedCount=1 (assetId=%s, containerId=%s)',
55+
$assetId,
56+
$collectionId
57+
)
58+
);
4759

48-
(new RemoveByIdRequest($this->assetsClient, assetId: $assetId))();
49-
(new RemoveByIdRequest($this->assetsClient, assetId: $collectionId))();
60+
new RemoveByIdRequest($this->assetsClient, assetId: $assetId)();
61+
new RemoveByIdRequest($this->assetsClient, assetId: $collectionId)();
5062
}
5163
}

tests/Integration/BrowseRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ final class BrowseRequestTest extends IntegrationFixture
1010
{
1111
public function test(): void
1212
{
13-
$response = (new BrowseRequest($this->assetsClient, path: '/'))();
13+
$response = new BrowseRequest($this->assetsClient, path: '/')();
1414

1515
$this->assertGreaterThan(0, $response->items);
1616
}

tests/Integration/CheckoutRequestTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ public function test(): void
2424
$assetId = $assetResponse->id;
2525
$this->assertNotEmpty($assetId);
2626

27-
$response = (new CheckoutRequest($this->assetsClient, id: $assetId))();
27+
$response = new CheckoutRequest($this->assetsClient, id: $assetId)();
2828

2929
$this->assertEquals(IntegrationUtils::getAssetsUsername(), $response->checkedOutBy);
3030

31-
(new UndoCheckoutRequest($this->assetsClient, id: $assetId))();
31+
new UndoCheckoutRequest($this->assetsClient, id: $assetId)();
3232

33-
(new RemoveByIdRequest($this->assetsClient, assetId: $assetId))();
33+
new RemoveByIdRequest($this->assetsClient, assetId: $assetId)();
3434
}
3535
}

tests/Integration/ConnectExceptionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function test(): void
2424

2525
$this->expectException(ConnectException::class);
2626

27-
(new PingRequest($assetsClient, uid: uniqid(true)))();
27+
new PingRequest($assetsClient, uid: uniqid(true))();
2828

2929
$this->assertEquals(false, $assetsClient->health->serviceIsAvailable());
3030
}

tests/Integration/CopyRequestTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ public function test(): void
2727
$source = sprintf('%s/%s', IntegrationUtils::getAssetsTestsFolder(), $sourceFilename);
2828
$target = sprintf('%s/CopyOf%s', IntegrationUtils::getAssetsTestsFolder(), $sourceFilename);
2929

30-
$response = (new CopyRequest(
30+
$response = new CopyRequest(
3131
$this->assetsClient,
3232
source: $source,
3333
target: $target,
3434
fileReplacePolicy: CopyRequest::FILE_REPLACE_POLICY_THROW_EXCEPTION
35-
))();
35+
)();
3636

3737
$this->assertEquals(1, $response->processedCount);
3838

39-
$targetId = (new SearchAssetIdRequest(
39+
$targetId = new SearchAssetIdRequest(
4040
$this->assetsClient,
4141
q: sprintf('assetPath:"%s"', $target),
4242
failIfMultipleHits: true
43-
))();
43+
)();
4444

45-
(new RemoveByIdRequest($this->assetsClient, assetId: $assetId))();
46-
(new RemoveByIdRequest($this->assetsClient, assetId: $targetId))();
45+
new RemoveByIdRequest($this->assetsClient, assetId: $assetId)();
46+
new RemoveByIdRequest($this->assetsClient, assetId: $targetId)();
4747
}
4848
}

tests/Integration/CreateFolderRequestTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ public function test(): void
1515
{
1616
$folderPath = sprintf('%s/Subfolder to delete %s', IntegrationUtils::getAssetsTestsFolder(), uniqid());
1717

18-
$folderResponse = (new CreateFolderRequest($this->assetsClient, path: $folderPath))();
18+
$folderResponse = new CreateFolderRequest($this->assetsClient, path: $folderPath)();
1919

2020
$this->assertEquals($folderPath, $folderResponse->path);
2121

22-
(new UpdateFolderRequest($this->assetsClient,
22+
new UpdateFolderRequest($this->assetsClient,
2323
id: $folderResponse->id,
2424
path: $folderPath,
2525
metadata: ['description' => 'Test subfolder']
26-
))();
26+
)();
2727

28-
(new RemoveFolderRequest($this->assetsClient,
28+
new RemoveFolderRequest($this->assetsClient,
2929
id: $folderResponse->id,
3030
path: $folderPath
31-
))();
31+
)();
3232
}
3333
}

tests/Integration/CreateRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ public function test(): void
2929
$this->assertEquals($basename, $assetMetadata['baseName']);
3030
$this->assertEquals('image', $assetMetadata['assetDomain']);
3131

32-
(new RemoveByIdRequest($this->assetsClient, assetId: $assetId))();
32+
new RemoveByIdRequest($this->assetsClient, assetId: $assetId)();
3333
}
3434
}

0 commit comments

Comments
 (0)