{"type":"api","title":"Create or Update Sensor Templates","meta":{"id":"/apps/pubhub/media/crosswork-network-controller-7-1/f445c17e25a1120e8fbde4bd413083d0fd88b2b3/b44e8ba1-6566-34bf-b4f1-d28c15d76254","info":{"title":"Crosswork Collection Service APIs","description":"Crosswork Collector Services APIs manage application intents for collection jobs across multiple devices and different collection types, including SNMP, CLI, TRAP, MDT, GNMI, and SYSLOG.","version":"1.0.0","contact":{"name":"Crosswork Team, Cisco","email":"support@cisco.com"},"license":{"name":"Cisco Software License Agreement","url":"http://www.cisco.com/public/sw-license-agreement.html"}},"x-parser-conf":{"overview":{"markdownPath":"reference/INFRA/COLLECTIONS/collection-service-overview.md"}},"swagger":"2.0","basePath":"/crosswork/collection/v1","schemes":["https","http"],"securityDefinitions":{"bearerAuth":{"type":"apiKey","description":"bearer auth","name":"Authorization","in":"header"}}},"spec":{"summary":"Create or Update Sensor Templates","description":"Use PutTemplate to create and update Sensor Templates.\nA template is a first-class object that contains a templatized sensor path;\nthat is, a GNMI path or set of parametrized CLI commands, in addition to the collection type and parameters applicable to the sensor path.","operationId":"CollectionService_PutTemplate","responses":{"200":{"description":"OK. The request was successful. The result is contained in the response body","schema":{"type":"object","properties":{"result":{"type":"object","properties":{"request_result":{"description":"The result values indicates whether the request was accepted or rejected, not the outcome of the work itself.","type":"string","enum":["UNKNOWN_RESULT","REJECTED","ACCEPTED"],"default":"UNKNOWN_RESULT","$$ref":"#/definitions/collection_serviceRequestResult"},"error":{"description":"A text message describing the reason for rejection. It can be safely passed on to the operator through logs or the UI.","type":"object","properties":{"error":{"type":"string","description":"Message is a textual description of the reason for rejection. You can safely pass it on to the operator through logs or the UI."}},"title":"Error associated with an object","$$ref":"#/definitions/collection_serviceError"}},"description":"Result is used to convey whether an operation (individual or in a batch) has been accepted or rejected.\nFor sync APIs, an error or rejection indicates failure of the operation.\nA string error message accompanies rejection to support troubleshooting.\nFor notification objects, rejection represents failure to do intended operation.","$$ref":"#/definitions/collection_serviceResult"}},"example":{"result":{"request_result":"ACCEPTED","error":{"error":""}}},"$$ref":"#/definitions/collection_serviceCreateTemplateResponse"}},"default":{"description":"An unexpected error response.","schema":{"type":"object","properties":{"result":{"type":"object","properties":{"request_result":{"description":"The result values indicates whether the request was accepted or rejected, not the outcome of the work itself.","type":"string","enum":["UNKNOWN_RESULT","REJECTED","ACCEPTED"],"default":"UNKNOWN_RESULT","$$ref":"#/definitions/collection_serviceRequestResult"},"error":{"description":"A text message describing the reason for rejection. It can be safely passed on to the operator through logs or the UI.","type":"object","properties":{"error":{"type":"string","description":"Message is a textual description of the reason for rejection. You can safely pass it on to the operator through logs or the UI."}},"title":"Error associated with an object","$$ref":"#/definitions/collection_serviceError"}},"description":"Result is used to convey whether an operation (individual or in a batch) has been accepted or rejected.\nFor sync APIs, an error or rejection indicates failure of the operation.\nA string error message accompanies rejection to support troubleshooting.\nFor notification objects, rejection represents failure to do intended operation.","$$ref":"#/definitions/collection_serviceResult"}},"example":{"result":{"request_result":"REJECTED","error":{"error":"empty request"}}},"$$ref":"#/definitions/createTemplateErrorResponse"}}},"parameters":[{"name":"body","in":"body","description":"Put Template Job.","required":true,"schema":{"type":"object","properties":{"app_id":{"type":"string","title":"The app_id of the application creating the template"},"sensor_template":{"type":"object","properties":{"sensor_template_id":{"type":"string","title":"Unique handle to identify a sensor template"},"collection_type":{"title":"Style of collection. At this time only app-managed lifetimetype is supported for templatized jobs","type":"string","enum":["UNKNOWN_COLLECTOR","MDT_COLLECTOR","SNMP_COLLECTOR","CLI_COLLECTOR","TRAP_COLLECTOR","GNMI_COLLECTOR","SYSLOG_COLLECTOR"],"default":"UNKNOWN_COLLECTOR","$$ref":"#/definitions/common_collection_dataCollectionType"},"sensor_template_Definition":{"title":"Specify the sensor template information e.g. path and parameters","type":"object","properties":{"cli_sensor_template":{"type":"object","properties":{"template_command":{"title":"Example show interface\nshow interface .{{interface_name}}\nshow interface | utility egrep expr .{{interface_name}}","type":"object","properties":{"templatecommand":{"type":"string"},"template_variables":{"type":"array","items":{"type":"string"}}},"$$ref":"#/definitions/common_collection_dataTemplateCommand"},"template_device_package":{"title":"Total size is limited to 512 characters","type":"object","properties":{"device_package_name":{"type":"string","title":"XDE device package name"},"function_name":{"type":"string","title":"XDE function name within package"},"template_params":{"type":"array","items":{"type":"string"},"title":"Template params in Device package\nAll params of device package function are mandatory templatized params"}},"$$ref":"#/definitions/common_collection_dataTemplateDevicePackage"}},"title":"Use with Cli Sensor\nThe message accepts templatized CLI command or a templatized device package with parameters specified wihin curly brackets(see ex below)\nThe message also accepts a list of valid parameter keys to be accepted","$$ref":"#/definitions/common_collection_dataCliSensorTemplate"},"gnmi_sensor_template":{"type":"object","properties":{"gnmi_path":{"type":"string","title":"String encoded GNMI path with template variables specified\nExample: \"Cisco-IOS-XR-l2vpn-oper:l2vpnv2/active/xconnects/xconnect[xconnect-name=.{{xconnect}}]/.{{segment}}/pseudo-wire/state\""},"template_variables":{"type":"array","items":{"type":"string"},"title":"List of paramaters applicable to the sensor specified in go template format : \"{{ .FieldName }}\"\nIf vraibles can be directly be inferred from the path then not needed"}},"title":"Reference: gNMI Specification Section 3.5.1.3\nThis is used when large number of leaf level collections need to be done\nThe message accepts a string encoded GNMI path with parameters specified wihin curly brackets (see ex below)\nThe message also accepts a list of valid parameter keys to be accepted","$$ref":"#/definitions/common_collection_dataGnmiSensorTemplate"}},"$$ref":"#/definitions/common_collection_dataSensorTemplateDefinition"},"cadence_in_millisec":{"type":"string","format":"uint64","title":"Specify the cadence at which path is to be collected"}},"title":"SensorTemplate contains details of templated sensor per collect type","$$ref":"#/definitions/common_collection_dataSensorTemplate"}},"example":{"app_id":"proto_template_test","sensor_template":{"sensor_template_id":"template-test-version-template","collection_type":"CLI_COLLECTOR","sensor_template_Definition":{"cli_sensor_template":{"template_command":{"templatecommand":"show interfaces","template_variables":["command"]}}},"cadence_in_millisec":"10000"}},"title":"CreateTemplateRequest","$$ref":"#/definitions/collection_serviceCreateTemplateRequest"}}],"tags":["CollectionService"],"__originalOperationId":"CollectionService_PutTemplate","consumes":["application/json"],"produces":["application/json"],"method":"put","path":"/template"}}