The following samples uses Basic authentication to call an API for acquiring records from "Device list".
リスト 2.57 Calling API for acquiring Device list records¶
BASEURL="https://servername"ORGANAIZATION_ID="Organization ID"WORKSPACE_ID="Workspace ID"MENU="device_list"USERNAME="User name"PASSWORD="Password"BASE64_BASIC=$(echo-n"Please set a user name:Please set a password"|base64)# Acquire all records from Device listcurl-XGET-u"${USERNAME}:${PASSWORD}""${BASEURL}/api/${ORGANAIZATION_ID}/workspaces/${WORKSPACE_ID}/ita/menu/${MENU}/filter/"# Acquire all records from Device listcurl-XGET\"${BASEURL}/api/${ORGANAIZATION_ID}/workspaces/${WORKSPACE_ID}/ita/menu/${MENU}/filter/"\-H"Authorization: Basic ${BASE64_BASIC}"\# Acquire records that meets the requirements from Device list(Requirement:Exclude deleted data)curl-XPOST\"${BASEURL}/api/${ORGANAIZATION_ID}/workspaces/${WORKSPACE_ID}/ita/menu/${MENU}/filter/"\-H"Authorization: Basic ${BASE64_BASIC}"\-H"Content-Type: application/json"\--data-raw"{\"discard\":{\"LIST\":[\"0\"]}}"
Tip
For acquiring lists with requirements
The following search methods are available when using requirements.
表 2.77 Available search options when using requirements¶
Option
Description
Setting example
Restrictions
NORMAL
Executes a broad search.
Searches for records containing specific words and phrases.
{"Target key":{"NORMAL":"Search Requirements"}}
LIST
Ececutes a complete search.
Searches for records containing specific words and phrases.
{"Target key":{"LIST":["Search Requirements"]}}
RANGE
Executes a search within a specified area.
Searches for mathcing records within a specified area.
When only START is specified, the system will search for records after the specified time.
When only END is specified, the system will search for records before the specified time.
Records with their logic deleted are called deleted records.
Their status is displayed through their discard value.
- "0":Active records
- "1":Deleted records
Records with the deleted status cannot be validated.
Tip
File output
The file data is output as a base64 encoded character string. Use a base64 decoded depending on the situation.
Tip
Encoded items
Some items (such as passwords) are saved in an encoded format.
The value for the items output by the List acquisition API will be set to "null" and the registered value will not be output.
※For more infotmation regarding items that are saved in an encoded format, see the manual for the appropriate menus.
2.2. Registering and editing(Menu MaintenanceAll Record bulk operation)¶
The following Content-Types can be selected as API Parameter specification method for registering and editing.
application/json format
Sends parameters as JSON data.
File data is written and sent as base64 string within parameters.
multipart/form-data format
Sends parameters and files as form data.
The keys of the form data in the file are used by connecting the index of the JSON data of the parameter and the target key with ". to connect the keys.
| The following samples uses Basic authentication to call an API for acquiring records from "Ansible common ▶ Device list" and "Ansible-Legacy ▶ Playbook file collection".
json_parameters=' [ { "parameter": { "Target key": "Value", }, "type":"Register" } ]'X.<Targetkey>=@echo.yml
# For X, specify a numeric value that corresponds to the json_parameters index.
The following are examples of parameters when registering and updating.
"last_update_date_time" value when updating records
For last_update_date_time, use the value of the latest applicable record obtained by FILTER.
If it doesnt match the latest value, the record will not update.
Tip
File operation using application/json
Registering and updating files
Specify the value which will be registered or updated to the specified key under the parameter or file.
For file names, specify the key for the target below the parameter and specify the key for the target below the file. Make sure to specify a base64 encoded string for the file.
Changing the file name
For only changing the file name, change the value of the target key under the parameter and specify a base64-encoded string for the file in the target key under the file.
Make sure to specify it to the target key below the file, even if there is no change in the data.
If only the target key below the parameter is changed and the target key below the file does not exist, it will excluded from the update.
Deleting the file
Specify the key for the target below the parameter as "" or as null. "null" will be recognized as a file name.
Tip
File operation using multipart/form-data
Registering and updating files
Specify the value which will be registered or updated to the specified key under the parameter.
For file names, specify the key for the target below the parameter.
For file data, specify the index of the JSON data + the target key connected by “." and specify the path to the file in the -F key specification.
Changing the file name
If you want to change only the file name, change the value of the target key under parameters, and connect the target key of the index+ of JSON data in json_parameters with “. and specify the path of the file as the key of -F.
Make sure to specify the index of the JSON data + the target key connected by “." to specify the path to the file and the -F key specification, even if there are no changes to the data.
If only the target key below the parameter is changed and the target key below the file does not exist, it will excluded from the update.
Deleting the file
Specify the key for the target below the parameter as "" or as null. "null" will be recognized as a file name.
Tip
Updating only the values of other items without changing the data and file name of the file
Make sure to change only the value of the item to be changed under “parameter” and update without including the key of the item under “file” or without specifying the file with -F.
BASEURL="https://servername"ORGANAIZATION_ID="Organization ID"WORKSPACE_ID="Workspace ID"MENU="playbook_files"USERNAME="User name"PASSWORD="Password"BASE64_BASIC=$(echo-n"Please set a user name:Please set a password"|base64)# Content-Type: application/json
curl-XPOST\"${BASEURL}/api/${ORGANAIZATION_ID}/workspaces/${WORKSPACE_ID}/ita/menu/${MENU}/maintenance/all/"\-H"Authorization: Basic ${BASE64_BASIC}"\-H"Content-Type: application/json"\--data-raw"[{\"file\":{\"playbook_file\":\"LSBuYW1lOiBydW4gImVjaG8iCiAgY29tbWFuZDogZWNobyB7eyBWQVJfU1RSXzEgfX0=\"},\"parameter\":{\"discard\":\"0\",\"item_no\":null,\"playbook_name\":\"echo\",\"playbook_file\":\"echo.yml\",\"remarks\":null,\"last_update_date_time\":null,\"last_updated_user\":null},\"type\":\"Register\"}]"# Content-Type: Multipart/form-data
curl-XPOST
"${BASEURL}/api/${ORGANAIZATION_ID}/workspaces/${WORKSPACE_ID}/ita/menu/${MENU}/maintenance/all/"\-H"Authorization: Basic ${BASE64_BASIC}"\-F"json_parameters=[{\"parameter\":{\"discard\":\"0\",\"item_no\":null,\"playbook_name\":\"echo\",\"playbook_file\":\"echo.yml\",\"remarks\":null,\"last_update_date_time\":null,\"last_updated_user\":null},\"type\":\"Register\"}] "\-F"0.playbook_file=@echo.yml"
2.3. API parameter related information(Acquire Menu Information)¶
Creating parameters for record bulk operation
For more information regarding record bulk operation parameter and item structure, see the following.
リスト 2.68 API for acquiring Menu structure information¶
BASEURL="https://servername"ORGANAIZATION_ID="Organization ID"WORKSPACE_ID="Workspace Id"MENU="Target menu"USERNAME="User name"PASSWORD="Password"BASE64_BASIC=$(echo-n"Please set a user name:Please set a password"|base64)
curl-XGET\"${BASEURL}/api/${ORGANAIZATION_ID}/workspaces/${WORKSPACE_ID}/ita/menu/${MENU}/info/"\-H"Authorization: Basic ${BASE64_BASIC}"\
BASEURL="https://servername"ORGANAIZATION_ID="Organization ID"WORKSPACE_ID="Workspace ID"MENU="Target menu"USERNAME="User name"PASSWORD="Password"BASE64_BASIC=$(echo-n"Please set a user name:Please set a password"|base64)
curl-XGET\"${BASEURL}/api/${ORGANAIZATION_ID}/workspaces/${WORKSPACE_ID}/ita/menu/${MENU}/column/"\-H"Authorization: Basic ${BASE64_BASIC}"\
Example: "Playbook file collection" response
リスト 2.71 Menu collumn information:Playbook file collection¶
リスト 2.72 API for acquiring pulldown item information¶
BASEURL="https://servername"ORGANAIZATION_ID="Organization ID"WORKSPACE_ID="Workspace ID"MENU="Target menu"USERNAME="User name"PASSWORD="Password"BASE64_BASIC=$(echo-n"Please set a user name:Please set a password"|base64)
curl-XGET\"${BASEURL}/api/${ORGANAIZATION_ID}/workspaces/${WORKSPACE_ID}/ita/menu/${MENU}/info/pulldown/"\-H"Authorization: Basic ${BASE64_BASIC}"\
This API performs Conductor execution from operation generation to parameter application.
Note that this API will not confirm if the Conductor has ended or not. To check the Conductor status, do so from Conductor ▶ Conductor operation history.
For existing operations, the value set for the operation "operation_name_select" is specified by the "scheduled implementation date" (YYYY/MM/DD hh:mm)_"operation name" of the relevant operation.
3.3.4. Executing Conductors using parameters applied with new operations¶
Examples when there is something wrong with the string specified to the Menu name(REST):sample_menu_001's first record's (0 origin)'s key:collumn 1.
{
"message": {
"1": { The Menu name(REST)'s record number is displayed with 0 origin.
"column_1": [ "Character length error (threshold : Value<=8byte, Value : 30byte), menu : sample_menu_001"] Key:Item REST name that met an error、Value:Error contents、menu : Menu name(REST) which met an error
}
},
"result": "499-00201",
"ts": "Execution date/time"
}
If a parameter is applied to "Host group management", the conductor will be executed without processing host analysis belonging to the specified host group.
To apply parameters to the "Host group management" menu, make sure to register the API for operating the records on beforehand.
・"Menu MaintenanceAll"
・"Menu Maintenance"
3.5.2. Applying parameters to variable extractable menus¶
Parameters aplied to variable extractable menus are executed with conductor in a state where the variables used within the specified parameters are not harvested.
Make sure to register the following API to apply parameters to variable extractable menus.