apigee-adminapi.sh は、Edge Management API を呼び出して、多くのメンテナンス
タスクを実行します。
apigee-adminapi.sh について
apigee-adminapi.sh を呼び出す
apigee-adminapi.sh は、管理サーバー ノードから呼び出します。ユーティリティを呼び出す場合は、次のいずれかを環境変数またはコマンドライン オプションとして定義する必要があります。
ADMIN_EMAIL(adminコマンドライン オプションに対応)ADMIN_PASSWORD(pwd)EDGE_SERVER(host)
次の例では、apigee-adminapi.sh を呼び出し、必要な値をコマンドライン
オプションとして渡します。
/opt/apigee/apigee-adminapi/bin/apigee-adminapi.sh buildinfo list --admin user@example.com --pwd abcd1234 --host localhost
次の例では、必要なオプションを一時的な環境変数として定義し、その後
apigee-adminapi.sh ユーティリティを呼び出します。
export ADMIN_EMAIL=user@example.comexport ADMIN_PASSWORD=abcd1234export EDGE_SERVER=192.168.56.101/opt/apigee/apigee-adminapi/bin/apigee-adminapi.sh servers list
パスワードをオプションとして渡さない場合や、環境変数として定義しない場合、
apigee-adminapi.sh はパスワードの入力を求めます。
apigee-adminapi.sh パラメータを設定する
コマンドのすべてのパラメータは、コマンドライン スイッチまたは 環境変数を使用して入力する必要があります。必要に応じて、コマンドライン スイッチの前に単一のダッシュ(-)または二重ダッシュ (--)を付けます。
たとえば、組織名は次のいずれかで指定できます。
-oコマンドライン スイッチを使用する:/opt/apigee/apigee-adminapi/bin/apigee-adminapi.sh orgs -o testOrg
ORGという名前の環境変数を設定する:export ORG=testOrg
/opt/apigee/apigee-adminapi/bin/apigee-adminapi.sh orgs
コマンドに必要なパラメータを省略すると、ユーティリティは不足しているパラメータを説明するエラー メッセージを表示します。
たとえば、--host オプション(EDGE_SERVER 環境変数に対応)を省略すると、apigee-adminapi.sh は次のエラーを返します。
Error with required variable or parameter ADMIN_PASSWORD....OK ADMIN_EMAIL....OK EDGE_SERVER....null
HTTP STATUS CODE: 401 エラーが表示された場合は、パスワードが間違っています。
apigee-adminapi.sh のヘルプを表示する
いつでも Tab キーを押すと、使用可能なコマンド オプションのリストが表示されます。
使用可能なコマンドをすべて表示するには、オプションを指定せずにユーティリティを呼び出します。
/opt/apigee/apigee-adminapi/bin/apigee-adminapi.sh
「apigee-adminapi.sh」と入力して Tab キーを押すと、使用可能な オプションのリストが表示されます。
analytics classification logsessions regions securityprofile userroles buildinfo GET orgs runtime servers users
Tab キーを押すと、コマンドのコンテキストに基づいてオプションが表示されます。次のように入力して Tab キー を押すと、
/opt/apigee/apigee-adminapi/bin/apigee-adminapi.sh orgs
orgs コマンドを完了するためのオプションが表示されます。
add apis apps delete envs list pods userroles
任意のコマンドのヘルプを表示するには、-h オプションを使用します。たとえば、次のように
-h オプションを使用します。
/opt/apigee/apigee-adminapi/bin/apigee-adminapi.sh orgs -h
ユーティリティは、
orgsコマンドで使用可能なすべてのオプションの完全なヘルプ情報を表示します。出力の最初の項目は、
orgs add コマンドのヘルプを示しています。
+++++++++++++++++++++++++++++++++++++++++++ orgs add Required: -o ORG Organization name Optional: -H HEADER add http header in request --admin ADMIN_EMAIL admin email address --pwd ADMIN_PASSWORD admin password --host EDGE_SERVER edge server to make request to --port EDGE_PORT port to use for the http request --ssl set EDGE_PROTO to https, defaults to http --debug ( set in debug mode, turns on verbose in curl ) -h Displays Help
apigee-adminapi.sh にファイルを渡す
apigee-adminapi.sh ユーティリティは curl のラッパーです。そのため、一部の
コマンドは、PUT および POST API 呼び出しに対応しており、リクエストの本文を受け取ります。
たとえば、仮想ホストの作成は、リクエストの本文に仮想ホストに関する情報が必要な POST API 呼び出しに対応しています。
apigee-adminapi.sh ユーティリティを使用して仮想ホストを作成する場合や、リクエストの本文を受け取るコマンドを使用する場合は、次のように必要なすべての情報をコマンドラインで渡すことができます。
/opt/apigee/apigee-adminapi/bin/apigee-adminapi.sh orgs envs virtual_hosts add -e prod -o testOrg --host localhost --admin foo@bar.com -v myVHostUtil -p 9005 -a 192.168.56.101:9005
または、POST のリクエスト の本文に含まれるのと同じ情報を含むファイルを渡すこともできます。たとえば、次のコマンドは仮想ホストを定義するファイルを受け取ります。
/opt/apigee/apigee-adminapi/bin/apigee-adminapi.sh orgs envs virtual_hosts add -e prod -o testOrg --host localhost --admin foo@bar.com -f vhostcreate
ここで、ファイル vhostcreate には呼び出しの POST の本文が含まれています。この例では、XML 形式のリクエストの本文です。
<VirtualHost name="myVHostUtil">
<HostAliases>
<HostAlias>192.168.56.101:9005</HostAlias>
</HostAliases>
<Interfaces/>
<Port>9005</Port>
</VirtualHost>デバッグ情報と API 情報を表示する
--debug オプションを apigee-adminapi.sh ユーティリティに指定すると、
コマンドの詳細情報が表示されます。この情報には、オペレーションを実行するために apigee-adminapi.sh ユーティリティによって生成された curl コマンド
が含まれます。
たとえば、次のコマンドでは --debug オプションを使用します。結果には、基盤となる curl コマンドの出力が詳細モードで表示されます。
/opt/apigee/apigee-adminapi/bin/apigee-adminapi.sh orgs add -o testOrg2 --admin foo@bar.com --host localhost --debug curl -H Content-Type: application/xml -v -X POST -s -k -w \n==> %{http_code} -u ***oo@bar.com:***** http://localhost:8080/v1/o -d <Organization name="testOrg2" type="paid"/> * About to connect() to localhost port 8080 (#0) * Trying ::1... connected * Connected to localhost (::1) port 8080 (#0) * Server auth using Basic with user 'foo@bar.com' > POST /v1/o HTTP/1.1 > Authorization: Basic c2dp234234NvbkBhcGlnZ2342342342342341Q5 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2 > Host: localhost:8080 > Accept: */* > Content-Type: application/xml > Content-Length: 43 > } [data not shown] < HTTP/1.1 201 Created < Content-Type: application/json < Date: Tue, 03 May 2016 02:08:32 GMT < Content-Length: 291 < { [data not shown] * Connection #0 to host localhost left intact * Closing connection #0