アカウント内のすべてのデータベースのリストの取得
アカウントのすべてのデータベースをリストするには、
GET
要求を https://$ACCOUNT.cloudant.com/_all_dbs
に送信します。
HTTP を使用してすべてのデータベースをリストする例を以下に示します。
GET /_all_dbs HTTP/1.1
すべてのデータベースをリストするには、以下の例を参照してください。
curl -H "Authorization: Bearer $API_BEARER_TOKEN" -X GET "$SERVICE_URL/_all_dbs"
import com.ibm.cloud.cloudant.v1.Cloudant;
import com.ibm.cloud.cloudant.v1.model.GetAllDbsOptions;
import java.util.List;
Cloudant service = Cloudant.newInstance();
List<String> response =
service.getAllDbs().execute().getResult();
System.out.println(response);
const { CloudantV1 } = require('@ibm-cloud/cloudant');
const service = CloudantV1.newInstance({});
service.getAllDbs().then(response => {
console.log(response.result);
});
from ibmcloudant.cloudant_v1 import CloudantV1
service = CloudantV1.new_instance()
response = service.get_all_dbs().get_result()
print(response)
getAllDbsOptions := service.NewGetAllDbsOptions()
result, response, err := service.GetAllDbs(getAllDbsOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(result, "", " ")
fmt.Println(string(b))
前の Go の例では、以下のインポート・ブロックが必要です。
import (
"encoding/json"
"fmt"
"github.com/IBM/cloudant-go-sdk/cloudantv1"
)
すべての Go の例では、service
オブジェクトを初期化する必要があります。 詳しくは、API 資料の認証セクションで例を参照してください。
以下の応答例は、すべてのデータベース名を含む JSON 配列です。
[
"_users",
"contacts",
"docs",
"invoices",
"locations"
]