Retrieves a list of buckets for a given project.
curl -X GET https://www.googleapis.com/storage/v1/b \
--header "Authorization: Bearer CLOUD_STORAGE_TOKEN" \
--data "project=MY_CLOUD_STORAGE_PROJECT"
<?php
$rest = new COM("Chilkat_9_5_0.Rest");
// URL: https://www.googleapis.com/storage/v1/b
$bTls = 1;
$port = 443;
$bAutoReconnect = 1;
$success = $rest->Connect('www.googleapis.com',$port,$bTls,$bAutoReconnect);
if ($success != 1) {
print 'ConnectFailReason: ' . $rest->ConnectFailReason . "\n";
print $rest->LastErrorText . "\n";
exit;
}
$rest->AddQueryParam('project','MY_CLOUD_STORAGE_PROJECT');
$rest->AddHeader('Authorization','Bearer CLOUD_STORAGE_TOKEN');
$sbResponseBody = new COM("Chilkat_9_5_0.StringBuilder");
$success = $rest->FullRequestNoBodySb('GET','/storage/v1/b',$sbResponseBody);
if ($success != 1) {
print $rest->LastErrorText . "\n";
exit;
}
$respStatusCode = $rest->ResponseStatusCode;
if ($respStatusCode >= 400) {
print 'Response Status Code = ' . $respStatusCode . "\n";
print 'Response Header:' . "\n";
print $rest->ResponseHeader . "\n";
print 'Response Body:' . "\n";
print $sbResponseBody->getAsString() . "\n";
exit;
}
$jsonResponse = new COM("Chilkat_9_5_0.JsonObject");
$jsonResponse->LoadSb($sbResponseBody);
// See the Online Tool for Generating JSON Parse Code
$kind = $jsonResponse->stringOf('kind');
$i = 0;
$count_i = $jsonResponse->SizeOfArray('items');
while ($i < $count_i) {
$jsonResponse->I = $i;
$kind = $jsonResponse->stringOf('items[i].kind');
$id = $jsonResponse->stringOf('items[i].id');
$selfLink = $jsonResponse->stringOf('items[i].selfLink');
$projectNumber = $jsonResponse->stringOf('items[i].projectNumber');
$name = $jsonResponse->stringOf('items[i].name');
$timeCreated = $jsonResponse->stringOf('items[i].timeCreated');
$updated = $jsonResponse->stringOf('items[i].updated');
$metageneration = $jsonResponse->stringOf('items[i].metageneration');
$location = $jsonResponse->stringOf('items[i].location');
$storageClass = $jsonResponse->stringOf('items[i].storageClass');
$etag = $jsonResponse->stringOf('items[i].etag');
$i = $i + 1;
}
?>
{
"kind": "storage#buckets",
"items": [
{
"kind": "storage#bucket",
"id": "chilkat-bucket",
"selfLink": "https://www.googleapis.com/storage/v1/b/chilkat-bucket",
"projectNumber": "5332332985",
"name": "chilkat-bucket",
"timeCreated": "2018-10-23T00:04:44.507Z",
"updated": "2018-10-23T00:04:44.507Z",
"metageneration": "1",
"location": "US",
"storageClass": "MULTI_REGIONAL",
"etag": "CAE="
},
{
"kind": "storage#bucket",
"id": "chilkat-images",
"selfLink": "https://www.googleapis.com/storage/v1/b/chilkat-images",
"projectNumber": "5332332985",
"name": "chilkat-images",
"timeCreated": "2018-10-23T11:24:43.000Z",
"updated": "2018-10-23T11:24:43.000Z",
"metageneration": "1",
"location": "US",
"storageClass": "MULTI_REGIONAL",
"etag": "CAE="
}
]
}