models
内容
casp1032jp
内容
複数のモデルと属性を取得および更新するには、Models リソースを使用します。
注:
models リソースはモデルのグループを操作します。単一のモデルの場合は、model リソースを使用します。ベース URL
http://<hostname><:portnumber>/spectrum/restful/models
POST models (GET トンネリング)
すべてのモデル ハンドルおよび要求した属性を取得するには、POST models を使用します。POST models 要求では、取得するモデルを指定する XML ドキュメントを提供できます。ドキュメントには、モデル ハンドル、XML 検索条件、または OneClick サーバ上の既存の検索条件への参照のリストが含まれています。
重要:
POST models は、複数のモデルの取得に使用される GET トンネリングの形式です。POST models でモデルを作成することはできません。モデルを作成するには、POST model を使用します。- URLhttp://<hostname><:portnumber>/spectrum/restful/models
- HTTP メソッドPOST
- ボディ例は、<$SPECROOT>/RestfulExamples/xml/Models で提供されます。これらの XML ファイルでは、さまざまな目的のための適切に形成された XML の例を提供します。これらの例を基にして独自の XML を作成します。
- GetCiscoRouterModels.xml
- GetModelsByModelHandles.xml
- GetModelsFromExistingSearch.xml
- ボディ コンテンツapplication/xml
- ヘッダapplication/xml、application/json
- 出力SpectroSERVERまたは分散SpectroSERVERの要求入力を満たすモデルの一覧を示す XML または JSON
例 1: Java コール
次に示すのはコールの例です。
Java GenericPoster noun=Models file=resources/xml/Models/GetCiscoRouterModels.xml server=localhost username=jdoe password=spectrum port=8080
例: IP アドレスでデバイス モデルを検索する要求 XML
次に示すのは、モデル GET の POST 本文に正しいロケータ検索を埋め込むことにより IP アドレスでデバイス モデルを検索する方法の例です。この操作は分散
SpectroSERVER
環境内のすべてのランドスケープを検索し、目的の属性を指定できます。- URL後で示す XML ボディを次の URL に POST します。http://<hostname><:portnumber>/spectrum/restful/models
- ボディ<?xml version="1.0" encoding="UTF-8"?><rs:model-request throttlesize="5" xmlns:rs="http://www.ca.com/spectrum/restful/schema/request" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd"><rs:target-models> <rs:models-search> <rs:search-criteria xmlns="http://www.ca.com/spectrum/restful/schema/filter"> <action-models> <filtered-models> <equals> <model-type>SearchManager</model-type> </equals> </filtered-models> <action>FIND_DEV_MODELS_BY_IP</action> <attribute id="AttributeID.NETWORK_ADDRESS"> <value>172.22.96.6</value> </attribute> </action-models> </rs:search-criteria> </rs:models-search> </rs:target-models><rs:requested-attribute id="0x1006e" /> <rs:requested-attribute id="0x10000" /> <rs:requested-attribute id="0x10032" /> <rs:requested-attribute id="0x12de2" /></rs:model-request>
例 2: グローバル コレクションに属しているデバイス名と IP アドレスのリストをクエリします
方法 1:
次に示すのは、グローバル コレクションに属しているデバイス名と IP アドレスをクエリする方法の例です。- URL後で示す XML ボディを次の URL に POST します。http://<hostname><:portnumber>/spectrum/restful/models
- ボディ<?xml version="1.0" encoding="UTF-8"?><rs:model-request throttlesize="5" xmlns:rs="http://www.ca.com/spectrum/restful/schema/request" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd"><rs:target-models> <rs:models-search> <rs:search-criteria xmlns="http://www.ca.com/spectrum/restful/schema/filter"> <filtered-models> <has-substring> <attribute id="0x12adb"> <!-- This attribute stores the list of global collections to which a model belongs --> <value>gc1</value> <!-- Name of the Global Collection --> </attribute> </has-substring> </filtered-models> </rs:search-criteria> </rs:models-search> </rs:target-models><rs:requested-attribute id="0x1006e" /> <!-- Model Name --> <rs:requested-attribute id="0x12d7f" /> <!-- Network Address --></rs:model-request>
方法 2:
<SPECROOT>\tomcat\webapps\spectrum\WEB-INF\topo\config でカスタム検索条件ファイル(xml ファイル)を作成し、次の xml ファイルでそれを使用することもできます。次に示すのは search-devices-criteria.xml の内容です。
<?xml version="1.0" encoding="utf-8"?> <search-criteria id="search-devices-criteria" xmlns="http://www.aprisma.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.aprisma.com../../common/schema/search-criteria-config.xsd"> <action-models> <filtered-models> <equals> <model-type>SearchManager</model-type> </equals> </filtered-models> <action>0x10474</action> <attribute id="AttributeID.MODEL_NAME"> <value>gc1</value> </attribute> </action-models> </search-criteria>
例 3: 以下は、DSS 環境で 1 つのランドスケープから JuniperJUNOSRtr モデル タイプを取得する方法の例です。
- URLhttp://OCServer/spectrum/restful/models
- ボディ<rs:model-request throttlesize="500" xmlns:rs="http://www.ca.com/spectrum/restful/schema/request" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd "> <rs:landscape id="0x100000" /> <rs:target-models> <rs:models-search> <rs:search-criteria xmlns="http://www.ca.com/spectrum/restful/schema/filter"> <filtered-models> <and> <equals> <attribute id="0x10001"> <value>0x3b10002</value> </attribute> </equals> </and> </filtered-models> </rs:search-criteria> </rs:models-search> </rs:target-models> <rs:requested-attribute id="0x1006e" /></rs:model-request>
- レスポンス<?xml version="1.0" encoding="UTF-8" standalone="yes"?><model-response-list xmlns="http://www.ca.com/spectrum/restful/schema/response" total-models="1" throttle="1" error="EndOfResults"> <model-responses> <model mh="0x1001d4"> <attribute id="0x1006e">junM7i-96.19</attribute> </model> </model-responses></model-response-list>注:以下の通り 1 つ以上のランドスケープについて表現することができます。<rs:landscape id="0x100000" /><rs:landscape id="0x600000" />
GET models
GET models は、モデルのハンドルと要求した属性を返します。特定のモデル属性を取得するには、&attr=<
attr_id
> パラメータを使用します。重要:
GET models は、POST (GET トンネリング) models を実行した後でのみ使用できます。POST models で結果セットを生成し、GET models を使用して結果セット内の項目のモデル ハンドルと属性情報を取得します。- URLhttp://<hostname><:portnumber>/spectrum/restful/models?id=<result_set_pointer>[&attr=<attr_ID>][&landscape=<landscape_handle>][&throttlesize=<num>]
- HTTP メソッドGET
- ボディなし
- ボディ コンテンツ使用されません
- ヘッダapplication/xml、application/json
- 出力SpectroSERVERまたは分散SpectroSERVERの要求入力を満たすモデルの一覧を示す XML または JSON
URL パラメータ
- ?id=<result_set_pointer>OneClick サーバでの結果セットの場所を指定します。この値は POST models (GET トンネリング)を使用して生成し、"next" 相対リンクに表示されます。OneClick サーバ上の場所は、非アクティブ状態が 10 分続くと期限切れになります。
- &attr=<attr_ID>(オプション)要求する属性を指定します。複数の属性パラメータを指定できます。注:モデルには多くの属性があります。最高のパフォーマンスのためには、属性の選択を目的の属性に制限する必要があります。サポートされる属性のセットはモデルによって異なります。サポートされていない属性は「NoSuchAttribute」を返します。
- &landscape=<landscape_handle>(オプション)照会するランドスケープをフィルタします。複数のランドスケープ パラメータを指定できます。
- &throttlesize=<num>(オプション)スロットル サイズを指定します。
PUT models
PUT models は、複数のモデルの属性を更新します。検索条件などのさまざまな方法で、モデルを選択できます。選択するすべてのモデルが変更する属性をサポートしている必要はありません。
- URLhttp://<hostname><:portnumber>/spectrum/restful/models
- HTTP メソッドPUT
- ボディRequest.xsd:update-models-request を使用します。Request.xsd は <$SPECROOT>/RestfulExamples/src/xsd にあります。
- ボディ コンテンツapplication/xml、application
- ヘッダapplication/xml、application/json
- 出力各更新の成功または失敗を示す model-response の XML または JSON 形式の一覧。
GET (/models)
グローバル コレクションのモデルを取得するには、この API を使用できます。 この Rest コールはグローバル コレクション名を受け付け、グローバル コレクションの一部であるそれらのデバイスを取得します。
- URLhttp://ocserver:port/spectrum/restful/models
- HTTP メソッドGET
- ボディ<?xml version="1.0" encoding="UTF-8"?><rs:model-request throttlesize="100" xmlns:rs="http://www.ca.com/spectrum/restful/schema/request" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ca.com/spectrum/restful/schema/request ../../../xsd/Request.xsd "> <rs:target-models> <rs:gc name="GC1"/> </rs:target-models> <rs:requested-attribute id="0x1006e" /> <rs:requested-attribute id="0x10000" /> <rs:requested-attribute id="0x10032" /></rs:model-request>
- ボディ コンテンツapplication/xml、application
- ヘッダapplication/xml、application/json
- 出力各更新の成功または失敗を示す model-response の XML または JSON 形式の一覧。