The postman-codegen command generates an integration file (YAML) from a Postman Collection.
You can use the demisto-sdk postman-codegen
command to generate an integration (YAML file) from a Postman Collection v2.1. Note the generated integration is in the YAML format.
You can generate the integration either as a two-step process or a single step.
Single step - Use this method to generate directly an integration YAML file.
Two steps - Use this method if you need more configuration and customization of the generated integration and code.
Generate an integration config file.
Update the config file as needed.
Generate the integration from the config file using the
demisto-sdk generate-integration
command.
Argument | Description |
---|---|
-h, --help | Show command help. |
-i, --input | Postman collection 2.1 JSON file |
-o, --output | (Optional) The output directory. Default is the current directory. |
-n, --name | (Optional) Sets the integration name. |
-op, --output-prefix | (Optional) Sets the global integration output prefix. Default is the integration name without spaces and special characters. |
-cp, --command-prefix | (Optional) The prefix for every command in the integration. Default is the integration name in lower case. |
--config-out | (Optional) If passed, generates config JSON file for further integration customization. |
-clt, --console-log-threshold | Minimum logging threshold for the console logger. Default value is |
-flt, --file-log-threshold | Minimum logging threshold for the file logger. Default value is |
-lp, --log-file-path | Path to the log file. Default path is |
Collection name converts to integration name.
Collection name converts to command prefix (if command prefix is not passed).
Example:
Virus Total
becomesvirus-total
Collection name converts to prefix of each command output.
Example:
Virus&& Total
becomesVirusTotal.Scan.scan_id
Collection request name converts to integration command.
Example:
Get Hosts
becomesget-hosts
Authentication
Base authentication type converts to username/password parameter.
API Key authentication type converts to apikey encrypted parameter.
Bearer token authentication type converts to apikey encrypted parameter.
Request name converts to command name.
Example:
Get Events
becomesget-events
Request URL variables convert to command arguments and are passed as part of the request URL.
Example:
https://virustotal.com/vtapi/v2/ip/{{ip}}
becomes the createdip
argumenthttps://virustotal.com/vtapi/v2/ip/8.8.8.8
.Request query parameters convert to command arguments.
Example:
https://virustotal.com/vtapi/v2/ip?resource=8.8.8.8
becomes createdresource
argument.Path URL variable converts to command argument and passed as a part of the request URL.
Example:
https://virustotal.com/vtapi/v2/ip/:ip
becomes theip
argumenthttps://virustotal.com/vtapi/v2/ip/8.8.8.8
if:ip
path variable equals 8.8.8.8.Request body. Each leaf value converts to command argument and
body_format
which allows further body customization.Example:
{"key1":"val1","key2":{"key3":"val3"}}
becomes createdkey1
andkey3
arguments andbody_format
with the following value{"key1":"{{key1}}","key2":{"key3":"{{key3}}"}}
Response JSON output converts to command outputs.
Mandatory requirements
Collection v2.1 is supported
Each request should be saved and contain at least one successful response, which is also saved.
If a URL contains variables such as
https://virustotal.com/vtapi/v2/ip/8.8.8.8
, set it as variable such ashttps://virustotal.com/vtapi/v2/ip/{{ip}}
Define the authentication method under Collection edit page > Authorization section.
Under collection settings, we recommend setting the Authorization section
Requests must contain Authorization header
Optional requirements
Collection description
Short request names
Get Endpoints
converts toget-endpoints
Set description to request
demisto-sdk postman-codegen -i VirusTotal.collection.json --name 'Virus Total' --command-prefix vt
This command does the following:
Sets the name of the integration to
Virus Total
.Sets the commands prefix to
vt
(vt-get-url
,vt-scan-url
).Generates the
integration-VirusTotal.yml
file in the current directory.
demisto-sdk postman-codegen -i VirusTotal.collection.json --name 'Virus Total' -o /output/path --config-out
This command does the following:
Generates
config-VirusTotal.json
file under/output/path
directory.Sets the name of the integration
Virus Total
.