Updated on 2026-08-03 GMT+08:00

Listing Parallel File Systems

If you have any questions during development, post them on the Issues page of GitHub. For details about parameters and usage of each API, see API Reference.

You can call ObsClient->listBuckets to list all buckets and then filter out parallel file systems based on the BucketType property. The following code shows how to list parallel file systems:

<?php
// Import the dependency library.
require 'vendor/autoload.php';
// Import the SDK code library during source code installation.
// require 'obs-autoloader.php';
// Declare the namespace.
use Obs\ObsClient;
// Create an ObsClient instance.
$obsClient = new ObsClient ( [
      //Obtain an AK/SK pair using environment variables or import the AK/SK pair in other ways. Using hard coding may result in leakage.
      //Obtain an AK/SK pair on the management console. For details, see https://support.huaweicloud.com/intl/en-us/usermanual-ca/ca_01_0003.html.
      'key' => getenv('ACCESS_KEY_ID'),
      'secret' => getenv('SECRET_ACCESS_KEY'),
      // Enter the endpoint corresponding to the bucket. CN-Hong Kong is used here as an example. Replace it with the one currently in use.
       'endpoint' => "obs.ap-southeast-1.myhuaweicloud.com",
      'signature' => 'obs'
] );

// List all buckets. Set QueryLocation to true to obtain the bucket location.
$resp = $obsClient->listBuckets ( [
       'QueryLocation' => true
] );
printf ( "Total buckets: %d\n\n", count($resp['Buckets']) );
$posixBuckets = [];
// Note: Calling getBucketMetadata for each bucket to obtain BucketType will generate a large number of API calls if there are many buckets.
// If the listBuckets response of the SDK contains the BucketType field, you can directly obtain the data to reduce the number of API calls.
foreach ($resp['Buckets'] as $bucket) {
       $bucketName = $bucket['Name'];
       try {
              $metadataResp = $obsClient->getBucketMetadata ( [
                     'Bucket' => $bucketName
              ] );
              $bucketType = isset($metadataResp['BucketType']) ? $metadataResp['BucketType'] : 'OBJECT';
              if ($bucketType === 'POSIX') {
                     $posixBuckets[] = $bucketName;
                     printf("[POSIX] %s (created: %s, location: %s)\n",
                            $bucketName,
                            $bucket['CreationDate'],
                            isset($bucket['Location']) ? $bucket['Location'] : 'N/A'
                     );
              }
       } catch (\Obs\ObsException $e) {
              printf("[Error] %s: Status:%d, Message:%s\n", $bucketName, $e->getStatusCode(), $e->getExceptionMessage());
       }
}
printf("\nPOSIX buckets: %d\n", count($posixBuckets));
  • Obtained bucket names are listed in the lexicographical order. The listBuckets operation returns all buckets, including common buckets and parallel file systems.
  • After setting the QueryLocation parameter to true, you can query the region location of a parallel file system when listing buckets.