postman-codegen
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.
Generate the Integration
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-integrationcommand.
Arguments
-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 lowercase.
--config-out
(Optional) If passed, generates a config JSON file for further integration customization.
-clt, --console-log-threshold
Minimum logging threshold for the console logger. Default value is INFO. Possible values are DEBUG, INFO, WARNING, ERROR.
-flt, --file-log-threshold
Minimum logging threshold for the file logger. Default value is DEBUG. Possible values are DEBUG, INFO, WARNING, ERROR.
-lp, --log-file-path
Path to the log file. Default path is <CONTENT_PATH>/demisto_sdk_debug.log.
How the command converts the Postman collection
Collection name converts to integration name.
Collection name converts to command prefix (if command prefix is not passed).
Example:
Virus Totalbecomesvirus-totalCollection name converts to prefix of each command output.
Example:
Virus&& TotalbecomesVirusTotal.Scan.scan_idCollection request name converts to integration command.
Example:
Get Hostsbecomesget-hostsAuthentication
Base authentication type converts to
username/passwordparameter.API Key authentication type converts to
apikeyencrypted parameter.Bearer token authentication type converts to
apikeyencrypted parameter.
Request name converts to command name.
Example:
Get Eventsbecomesget-eventsRequest 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 createdipargumenthttps://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.8becomes the createdresourceargument.Path URL variable converts to a command argument and passed as a part of the request URL.
Example:
https://virustotal.com/vtapi/v2/ip/:ipbecomes theipargumenthttps://virustotal.com/vtapi/v2/ip/8.8.8.8if:ippath variable equals8.8.8.8.Request body. Each leaf value converts to a command argument and
body_formatwhich allows further body customization.Example:
{"key1":"val1","key2":{"key3":"val3"}}becomes createdkey1andkey3arguments andbody_formatwith the following value{"key1":"{{key1}}","key2":{"key3":"{{key3}}"}}Response JSON output converts to command outputs.
Postman collection requirements
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 >
Authorizationsection.Under collection settings, we recommend setting the
Authorizationsection.Requests must contain
Authorizationheader.
Optional requirements
Collection description.
Short request names
Get Endpointsconverts toget-endpoints.Set description to request.
Examples
demisto-sdk postman-codegen -i VirusTotal.collection.json --name 'Virus Total' --command-prefix vtThis command does the following:
Sets the name of the integration to
Virus Total.Sets the
commandprefix tovt(vt-get-url,vt-scan-url).Generates the
integration-VirusTotal.ymlfile in the current directory.
demisto-sdk postman-codegen -i VirusTotal.collection.json --name 'Virus Total' -o /output/path --config-outThis command does the following:
Generates
config-VirusTotal.jsonfile under the/output/pathdirectory.Sets the name of the integration to
Virus Total.
Last updated
Was this helpful?
