Skip to content

Commit 392e638

Browse files
authored
add bucket meta query api
1 parent 6776b27 commit 392e638

28 files changed

+1688
-0
lines changed

sample/CloseMetaQuery.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../vendor/autoload.php';
4+
5+
use AlibabaCloud\Oss\V2 as Oss;
6+
7+
// parse args
8+
$optsdesc = [
9+
"region" => ['help' => 'The region in which the bucket is located.', 'required' => True],
10+
"endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False],
11+
"bucket" => ['help' => 'The name of the bucket', 'required' => True],
12+
];
13+
$longopts = \array_map(function ($key) {
14+
return "$key:";
15+
}, array_keys($optsdesc));
16+
$options = getopt("", $longopts);
17+
foreach ($optsdesc as $key => $value) {
18+
if ($value['required'] === True && empty($options[$key])) {
19+
$help = $value['help'];
20+
echo "Error: the following arguments are required: --$key, $help";
21+
exit(1);
22+
}
23+
}
24+
25+
$region = $options["region"];
26+
$bucket = $options["bucket"];
27+
28+
// Loading credentials values from the environment variables
29+
$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider();
30+
31+
// Using the SDK's default configuration
32+
$cfg = Oss\Config::loadDefault();
33+
$cfg->setCredentialsProvider($credentialsProvider);
34+
$cfg->setRegion($region);
35+
if (isset($options["endpoint"])) {
36+
$cfg->setEndpoint($options["endpoint"]);
37+
}
38+
39+
$client = new Oss\Client($cfg);
40+
$request = new \AlibabaCloud\Oss\V2\Models\CloseMetaQueryRequest($bucket);
41+
$result = $client->closeMetaQuery($request);
42+
printf(
43+
'status code:' . $result->statusCode . PHP_EOL .
44+
'request id:' . $result->requestId
45+
);

sample/DoMetaQuery.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../vendor/autoload.php';
4+
5+
use AlibabaCloud\Oss\V2 as Oss;
6+
7+
// parse args
8+
$optsdesc = [
9+
"region" => ['help' => 'The region in which the bucket is located.', 'required' => True],
10+
"endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False],
11+
"bucket" => ['help' => 'The name of the bucket', 'required' => True],
12+
];
13+
$longopts = \array_map(function ($key) {
14+
return "$key:";
15+
}, array_keys($optsdesc));
16+
$options = getopt("", $longopts);
17+
foreach ($optsdesc as $key => $value) {
18+
if ($value['required'] === True && empty($options[$key])) {
19+
$help = $value['help'];
20+
echo "Error: the following arguments are required: --$key, $help";
21+
exit(1);
22+
}
23+
}
24+
25+
$region = $options["region"];
26+
$bucket = $options["bucket"];
27+
28+
// Loading credentials values from the environment variables
29+
$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider();
30+
31+
// Using the SDK's default configuration
32+
$cfg = Oss\Config::loadDefault();
33+
$cfg->setCredentialsProvider($credentialsProvider);
34+
$cfg->setRegion($region);
35+
if (isset($options["endpoint"])) {
36+
$cfg->setEndpoint($options["endpoint"]);
37+
}
38+
39+
$client = new Oss\Client($cfg);
40+
$request = new \AlibabaCloud\Oss\V2\Models\DoMetaQueryRequest($bucket, new \AlibabaCloud\Oss\V2\Models\MetaQuery(
41+
maxResults: 5,
42+
query: "{'Field': 'Size','Value': '1048576','Operation': 'gt'}",
43+
sort: 'Size',
44+
order: \AlibabaCloud\Oss\V2\Models\MetaQueryOrderType::ASC,
45+
aggregations: new \AlibabaCloud\Oss\V2\Models\MetaQueryAggregations(
46+
[
47+
new \AlibabaCloud\Oss\V2\Models\MetaQueryAggregation(
48+
field: 'Size',
49+
operation: 'sum'
50+
),
51+
new \AlibabaCloud\Oss\V2\Models\MetaQueryAggregation(
52+
field: 'Size',
53+
operation: 'max'
54+
),
55+
]
56+
),
57+
));
58+
$result = $client->doMetaQuery($request);
59+
printf(
60+
'status code:' . $result->statusCode . PHP_EOL .
61+
'request id:' . $result->requestId . PHP_EOL .
62+
'result:' . var_export($result, true)
63+
);

sample/GetMetaQueryStatus.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../vendor/autoload.php';
4+
5+
use AlibabaCloud\Oss\V2 as Oss;
6+
7+
// parse args
8+
$optsdesc = [
9+
"region" => ['help' => 'The region in which the bucket is located.', 'required' => True],
10+
"endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False],
11+
"bucket" => ['help' => 'The name of the bucket', 'required' => True],
12+
];
13+
$longopts = \array_map(function ($key) {
14+
return "$key:";
15+
}, array_keys($optsdesc));
16+
$options = getopt("", $longopts);
17+
foreach ($optsdesc as $key => $value) {
18+
if ($value['required'] === True && empty($options[$key])) {
19+
$help = $value['help'];
20+
echo "Error: the following arguments are required: --$key, $help";
21+
exit(1);
22+
}
23+
}
24+
25+
$region = $options["region"];
26+
$bucket = $options["bucket"];
27+
28+
// Loading credentials values from the environment variables
29+
$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider();
30+
31+
// Using the SDK's default configuration
32+
$cfg = Oss\Config::loadDefault();
33+
$cfg->setCredentialsProvider($credentialsProvider);
34+
$cfg->setRegion($region);
35+
if (isset($options["endpoint"])) {
36+
$cfg->setEndpoint($options["endpoint"]);
37+
}
38+
39+
$client = new Oss\Client($cfg);
40+
$request = new Oss\Models\GetMetaQueryStatusRequest($bucket);
41+
$result = $client->getMetaQueryStatus($request);
42+
43+
printf(
44+
'status code:' . $result->statusCode . PHP_EOL .
45+
'request id:' . $result->requestId . PHP_EOL .
46+
'meta query status:' . var_export($result->metaQueryStatus, true)
47+
);

sample/OpenMetaQuery.php

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
require_once __DIR__ . '/../vendor/autoload.php';
4+
5+
use AlibabaCloud\Oss\V2 as Oss;
6+
7+
// parse args
8+
$optsdesc = [
9+
"region" => ['help' => 'The region in which the bucket is located.', 'required' => True],
10+
"endpoint" => ['help' => 'The domain names that other services can use to access OSS.', 'required' => False],
11+
"bucket" => ['help' => 'The name of the bucket', 'required' => True],
12+
];
13+
$longopts = \array_map(function ($key) {
14+
return "$key:";
15+
}, array_keys($optsdesc));
16+
$options = getopt("", $longopts);
17+
foreach ($optsdesc as $key => $value) {
18+
if ($value['required'] === True && empty($options[$key])) {
19+
$help = $value['help'];
20+
echo "Error: the following arguments are required: --$key, $help";
21+
exit(1);
22+
}
23+
}
24+
25+
$region = $options["region"];
26+
$bucket = $options["bucket"];
27+
28+
// Loading credentials values from the environment variables
29+
$credentialsProvider = new Oss\Credentials\EnvironmentVariableCredentialsProvider();
30+
31+
// Using the SDK's default configuration
32+
$cfg = Oss\Config::loadDefault();
33+
$cfg->setCredentialsProvider($credentialsProvider);
34+
$cfg->setRegion($region);
35+
if (isset($options["endpoint"])) {
36+
$cfg->setEndpoint($options["endpoint"]);
37+
}
38+
39+
$client = new Oss\Client($cfg);
40+
$request = new Oss\Models\OpenMetaQueryRequest($bucket);
41+
$result = $client->openMetaQuery($request);
42+
43+
printf(
44+
'status code:' . $result->statusCode . PHP_EOL .
45+
'request id:' . $result->requestId
46+
);

src/Client.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@
120120
* @method \GuzzleHttp\Promise\Promise putBucketTransferAccelerationAsync(Models\PutBucketTransferAccelerationRequest $request, array $args = []) Configures transfer acceleration for a bucket. After you enable transfer acceleration for a bucket, the object access speed is accelerated for users worldwide. The transfer acceleration feature is applicable to scenarios where data needs to be transferred over long geographical distances. This feature can also be used to download or upload objects that are gigabytes or terabytes in size.
121121
* @method Models\GetBucketTransferAccelerationResult getBucketTransferAcceleration(Models\GetBucketTransferAccelerationRequest $request, array $args = []) Queries the transfer acceleration configurations of a bucket.
122122
* @method \GuzzleHttp\Promise\Promise getBucketTransferAccelerationAsync(Models\GetBucketTransferAccelerationRequest $request, array $args = []) Queries the transfer acceleration configurations of a bucket.
123+
* @method Models\GetMetaQueryStatusResult getMetaQueryStatus(Models\GetMetaQueryStatusRequest $request, array $args = []) Queries the information about the metadata index library of a bucket.
124+
* @method \GuzzleHttp\Promise\Promise getMetaQueryStatusAsync(Models\GetMetaQueryStatusRequest $request, array $args = []) Queries the information about the metadata index library of a bucket.
125+
* @method Models\CloseMetaQueryResult closeMetaQuery(Models\CloseMetaQueryRequest $request, array $args = []) Disables the metadata management feature for an Object Storage Service (OSS) bucket. After the metadata management feature is disabled for a bucket, OSS automatically deletes the metadata index library of the bucket and you cannot perform metadata indexing.
126+
* @method \GuzzleHttp\Promise\Promise closeMetaQueryAsync(Models\CloseMetaQueryRequest $request, array $args = []) Disables the metadata management feature for an Object Storage Service (OSS) bucket. After the metadata management feature is disabled for a bucket, OSS automatically deletes the metadata index library of the bucket and you cannot perform metadata indexing.
127+
* @method Models\DoMetaQueryResult doMetaQuery(Models\DoMetaQueryRequest $request, array $args = []) Queries the objects in a bucket that meet the specified conditions by using the data indexing feature. The information about the objects is listed based on the specified fields and sorting methods.
128+
* @method \GuzzleHttp\Promise\Promise doMetaQueryAsync(Models\DoMetaQueryRequest $request, array $args = []) Queries the objects in a bucket that meet the specified conditions by using the data indexing feature. The information about the objects is listed based on the specified fields and sorting methods.
129+
* @method Models\OpenMetaQueryResult openMetaQuery(Models\OpenMetaQueryRequest $request, array $args = []) Enables metadata management for a bucket. After you enable the metadata management feature for a bucket, Object Storage Service (OSS) creates a metadata index library for the bucket and creates metadata indexes for all objects in the bucket. After the metadata index library is created, OSS continues to perform quasi-real-time scans on incremental objects in the bucket and creates metadata indexes for the incremental objects.
130+
* @method \GuzzleHttp\Promise\Promise openMetaQueryAsync(Models\OpenMetaQueryRequest $request, array $args = []) Enables metadata management for a bucket. After you enable the metadata management feature for a bucket, Object Storage Service (OSS) creates a metadata index library for the bucket and creates metadata indexes for all objects in the bucket. After the metadata index library is created, OSS continues to perform quasi-real-time scans on incremental objects in the bucket and creates metadata indexes for the incremental objects.
123131
* @method Models\PutBucketAccessMonitorResult putBucketAccessMonitor(Models\PutBucketAccessMonitorRequest $request, array $args = []) Modifies the access tracking status of a bucket.
124132
* @method \GuzzleHttp\Promise\Promise putBucketAccessMonitorAsync(Models\PutBucketAccessMonitorRequest $request, array $args = []) Modifies the access tracking status of a bucket.
125133
* @method Models\GetBucketAccessMonitorResult getBucketAccessMonitor(Models\GetBucketAccessMonitorRequest $request, array $args = []) Queries the access tracking status of a bucket.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace AlibabaCloud\Oss\V2\Models;
5+
6+
use AlibabaCloud\Oss\V2\Types\RequestModel;
7+
use AlibabaCloud\Oss\V2\Annotation\TagProperty;
8+
use AlibabaCloud\Oss\V2\Annotation\RequiredProperty;
9+
10+
/**
11+
* The request for the CloseMetaQuery operation.
12+
* Class CloseMetaQueryRequest
13+
* @package AlibabaCloud\Oss\V2\Models
14+
*/
15+
final class CloseMetaQueryRequest extends RequestModel
16+
{
17+
/**
18+
* The name of the bucket.
19+
* @var string|null
20+
*/
21+
#[RequiredProperty()]
22+
#[TagProperty(tag: '', position: 'host', rename: 'bucket', type: 'string')]
23+
public ?string $bucket;
24+
25+
/**
26+
* CloseMetaQueryRequest constructor.
27+
* @param string|null $bucket The name of the bucket.
28+
* @param array|null $options
29+
*/
30+
public function __construct(
31+
?string $bucket = null,
32+
?array $options = null
33+
)
34+
{
35+
$this->bucket = $bucket;
36+
parent::__construct($options);
37+
}
38+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace AlibabaCloud\Oss\V2\Models;
5+
6+
use AlibabaCloud\Oss\V2\Types\ResultModel;
7+
8+
/**
9+
* The result for the CloseMetaQuery operation.
10+
* Class CloseMetaQueryResult
11+
* @package AlibabaCloud\Oss\V2\Models
12+
*/
13+
final class CloseMetaQueryResult extends ResultModel
14+
{
15+
}

src/Models/DoMetaQueryRequest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace AlibabaCloud\Oss\V2\Models;
5+
6+
use AlibabaCloud\Oss\V2\Types\RequestModel;
7+
use AlibabaCloud\Oss\V2\Annotation\TagProperty;
8+
use AlibabaCloud\Oss\V2\Annotation\RequiredProperty;
9+
10+
/**
11+
* The request for the DoMetaQuery operation.
12+
* Class DoMetaQueryRequest
13+
* @package AlibabaCloud\Oss\V2\Models
14+
*/
15+
final class DoMetaQueryRequest extends RequestModel
16+
{
17+
/**
18+
* The name of the bucket.
19+
* @var string|null
20+
*/
21+
#[RequiredProperty()]
22+
#[TagProperty(tag: '', position: 'host', rename: 'bucket', type: 'string')]
23+
public ?string $bucket;
24+
25+
/**
26+
* The request body schema.
27+
* @var MetaQuery|null
28+
*/
29+
#[RequiredProperty()]
30+
#[TagProperty(tag: '', position: 'body', rename: 'MetaQuery', type: 'xml')]
31+
public ?MetaQuery $metaQuery;
32+
33+
/**
34+
* DoMetaQueryRequest constructor.
35+
* @param string|null $bucket The name of the bucket.
36+
* @param MetaQuery|null $metaQuery The request body schema.
37+
* @param array|null $options
38+
*/
39+
public function __construct(
40+
?string $bucket = null,
41+
?MetaQuery $metaQuery = null,
42+
?array $options = null
43+
)
44+
{
45+
$this->bucket = $bucket;
46+
$this->metaQuery = $metaQuery;
47+
parent::__construct($options);
48+
}
49+
}

src/Models/DoMetaQueryResult.php

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace AlibabaCloud\Oss\V2\Models;
5+
6+
use AlibabaCloud\Oss\V2\Types\ResultModel;
7+
use AlibabaCloud\Oss\V2\Annotation\XmlElement;
8+
use AlibabaCloud\Oss\V2\Annotation\XmlRoot;
9+
10+
/**
11+
* The result for the DoMetaQuery operation.
12+
* Class DoMetaQueryResult
13+
* @package AlibabaCloud\Oss\V2\Models
14+
*/
15+
final class DoMetaQueryResult extends ResultModel
16+
{
17+
/**
18+
* The list of file information.
19+
* @var MetaQueryAggregations|null
20+
*/
21+
#[XmlElement(rename: 'Aggregations', type: MetaQueryAggregations::class)]
22+
public ?MetaQueryAggregations $aggregations;
23+
24+
/**
25+
* The token that is used for the next query when the total number of objects exceeds the value of MaxResults.The value of NextToken is used to return the unreturned results in the next query.This parameter has a value only when not all objects are returned.
26+
* @var string|null
27+
*/
28+
#[XmlElement(rename: 'NextToken', type: 'string')]
29+
public ?string $nextToken;
30+
31+
/**
32+
* The list of file information.
33+
* @var MetaQueryFiles|null
34+
*/
35+
#[XmlElement(rename: 'Files', type: MetaQueryFiles::class)]
36+
public ?MetaQueryFiles $files;
37+
38+
/**
39+
* DoMetaQueryRequest constructor.
40+
* @param MetaQueryAggregations|null $aggregations The list of file information.
41+
* @param string|null $nextToken The token that is used for the next query when the total number of objects exceeds the value of MaxResults.
42+
* @param MetaQueryFiles|null $files The list of file information.
43+
*/
44+
public function __construct(
45+
?MetaQueryAggregations $aggregations = null,
46+
?string $nextToken = null,
47+
?MetaQueryFiles $files = null
48+
)
49+
{
50+
$this->aggregations = $aggregations;
51+
$this->nextToken = $nextToken;
52+
$this->files = $files;
53+
}
54+
}

0 commit comments

Comments
 (0)