{
    "id": "deviceProfile.json",
    "title": "API ",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "$ref": "#/definitions/",
    "links": [
        {
            "title": "Get all Profiles",
            "href": "/netconf/profiles",
            "method": "GET",
            "rel": "instances",
            "schema": {
                "$ref": "#/definitions/profileList"
            }
        },
        {
            "title": "Create new profiles",
            "href": "/netconf/profiles",
            "method": "POST",
            "rel": "instances",
            "schema": {
                "$ref": "#/definitions/createProfileList"
            },
            "targetSchema": {
                "$ref": "#/definitions/profileList"
            }
        },
        {
            "title": "Update profiles",
            "href": "/netconf/profiles",
            "method": "PUT",
            "rel": "instances",
            "schema": {
                "$ref": "#/definitions/updateProfileList"
            },
            "targetSchema": {
                "$ref": "#/definitions/updatedProfileList"
            }
        },
        {
            "title": "Delete profiles",
            "href": "/netconf/profiles",
            "method": "DELETE",
            "rel": "instances",
            "schema": {
                "$ref": "#/definitions/deleteProfileList"
            }
        },
        {
            "title": "Create a new collection",
            "href": "/netconf/netconfCollection/liveNetwork",
            "method": "POST",
            "rel": "instance",
            "schema": {
                "$ref": "#/definitions/startCollection"
            },
            "targetSchema": {
                "$ref": "#/definitions/collectionStatus"
            }
        },
        {
            "title": "Get the status of a collection job",
            "href": "/netconf/netconfCollection/{id}",
            "method": "GET",
            "rel": "instance",
            "schema": {
                "$ref": "#/definitions/collectionStatus"
            }
        }
    ],
    "definitions": {
        "profileList": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/profile"
            }
        },
        "createProfileList": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/createProfile"
            }
        },
        "updateProfileList": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/updateProfile"
            }
        },
        "updatedProfileList": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/updateProfile"
            }
        },
        "deleteProfileList": {
            "type": "array",
            "items": {
                "$ref": "#/definitions/profile"
            }
        },
        "routerType": {
            "type": "string",
            "description": "Router type, if empty the routerType is unknown",
            "enum": [
                "",
                "ALCATEL",
                "CISCO",
                "ERICSSON",
                "HUAWEI",
                "JUNIPER",
                "NOKIA",
                "GENERIC",
                "NODE",
                "SITE",
                "CE",
                "IOS-XR"
            ]
        },
        "profileId": {
            "type": "string",
            "description": "Read-Only. Device id, the string is the UUID, generated by NorthStar. Example: 68bd763e-8f54-4817-ba23-ba8449350a18"
        },
        "profile": {
            "description": "One device profile object",
            "type": "object",
            "required": [
                "id",
                "ipAddr"
            ],
            "additionalProperties": true,
            "properties": {
                "id": {
                    "$ref": "#/definitions/profileId"
                },
                "MD5String": {
                    "type": "string",
                    "description": "MD5 String for PCEP Authentication"
                },
                "accessMethod": {
                    "type": "string",
                    "description": "Protocol used to connect to the CLI interface",
                    "enum": [
                        "",
                        "telnet|ssh",
                        "ssh|telnet",
                        "ssh",
                        "telnet"
                    ],
                    "default": "ssh"
                },
                "city": {
                    "type": "string",
                    "description": "User-provided city information, information only"
                },
                "country": {
                    "type": "string",
                    "description": "User-provided country information, information only"
                },
                "enLevel": {
                    "type": "integer",
                    "description": "Cisco Specific: enable level",
                    "minimum": 0,
                    "maximum": 15
                },
                "groupName": {
                    "type": "string",
                    "description": "the group to which this device belongs"
                },
                "hostName": {
                    "type": "string",
                    "description": "Device hostname (display only?)"
                },
                "ipAddr": {
                    "type": "string",
                    "description": "IPv4 address used to connect to the device",
                    "format": "ipv4"
                },
                "ipv6Addr": {
                    "type": "string",
                    "description": "IPv6 address used to connect to the device"
                },
                "login": {
                    "type": "string",
                    "description": "Credential: Login"
                },
                "passwd": {
                    "type": "string",
                    "description": "Credential: password (empty on GET request)"
                },
                "model": {
                    "type": "string",
                    "description": "Device Model "
                },
                "routerType": {
                    "$ref": "#/definitions/routerType"
                },
                "os": {
                    "type": "string",
                    "description": "Device OS "
                },
                "osVersion": {
                    "type": "string",
                    "description": "Device OS Version"
                },
                "pLogin": {
                    "type": "string",
                    "description": "Cisco Specific: privileged login"
                },
                "pPasswd": {
                    "type": "string",
                    "description": "Cisco Specific: privileged password"
                },
                "pcepIp": {
                    "type": "string",
                    "description": "PCEP protocol IP address used by the router to connect to NorthStar"
                },
                "retry": {
                    "type": "integer",
                    "description": "Number of retries when connecting to the device"
                },
                "secondaryIp": {
                    "description": "Management IP address",
                    "$ref" : "common.json#/definitions/ipAddress"
                },
                "sshCommand": {
                    "type": "string",
                    "description": "Command used for ssh"
                },
                "telnetPort": {
                    "type": "integer",
                    "description": "Port used for telnet connection",
                    "default": 23
                },
                "timeout": {
                    "type": "integer",
                    "description": "Connection Timeoute",
                    "default": 300
                },
                "userProperties" : {
                    "type": "string",
                    "description": "JSON stringified string of user properties"
                },
                "deviceGroup": {
                    "type": "string",
                    "description": "Device Group"
                },
                "getTopology": {
                    "type": "integer",
                    "description": ""
                },
                "netconfBulkCommit": {
                    "type": "boolean",
                    "description": "Is netconf bulk commit enabled?"
                },
                "netconfEnable": {
                    "type": "boolean",
                    "description": "Is netconf enabled ?"
                },
                "netconfRetry": {
                    "type": "integer",
                    "description": "How many times to retry netconf connection"
                },
                "networkname": {
                    "type": "string",
                    "description": "networkName"
                },
                "prpdEnable": {
                    "type": "boolean",
                    "description": "Is the device has prpd connection enabled ?"
                },
                "prpdIp": {
                    "description": "Prpd listen IP Address",
                    "$ref" : "common.json#/definitions/ipAddress"
                },
                "prpdPort": {
                    "type": "integer",
                    "description": "Prpd listen port",
                    "minimum": 0,
                    "maximum": 65535
                },
                "prpdSSL": {
                    "type": "boolean",
                    "description": "Is the prpd connection using ssl ?"
                },
                "pcepVersion": {
                    "type": "string",
                    "description": "PCEP version supported by the router",
                    "enum": [
                        "",
                        "0",
                        "1",
                        "2",
                        "3",
                        "100"
	
                    ],
                    "default": "0"
                },
                "snmpGetCommunity": {
                    "type": "string",
                    "description": "Snmp V2 get community string"
                },
                "snmpPortNumber": {
                    "type": "integer",
                    "description": "Snmp V2 listen port",
                    "minimum": 0,
                    "maximum": 65535
                },
                "snmpRetry": {
                    "type": "integer",
                    "description": "how many times to rety snmp connection",
                    "minimum": 0
                },
                "snmpSetCommunity": {
                    "type": "string",
                    "description": "Snmp V2 set community string"
                },
                "snmpTimeout": {
                    "type": "integer",
                    "description": "Snmp Timeout"
                },
                "snmpVersion": {
                    "type": "string",
                    "description": "Snmp V2 or V3",
                    "enum": [
                        "",
                        "V1",
                        "V2C",
                        "V3"
                    ],
                    "default": "V2C"
                },
                "v3Auth": {
                    "type":"string",
                    "description": "Snmp V3 Authentication string"
                },
                "v3AuthPasswd": {
                    "type":"string",
                    "description": "Snmp V3 Authentication password"
                },
                "v3ContextEngine": {
                    "type":"string",
                    "description": "Snmp V3 Context Engine"
                },
                "v3ContextName": {
                    "type":"string",
                    "description": "Snmp V3 Context Name"
                },
                "v3Privacy": {
                    "type":"string",
                    "description": "Snmp V3 privacy string"
                },
                "v3PrivacyPasswd": {
                    "type":"string",
                    "description": "Snmp V3 privacy password"
                },
                "v3UserName": {
                    "type":"string",
                    "description": "Snmp V3 Context Engine"
                }
            }
        },
        "encryptedPassword": {
            "type": "string",
            "description": "encrypted password using CryptoJS.AES.encrypt(<passwd>, <ipaddr>)",
            "minLength": 0
        },
        "createProfile": {
            "$ref": "#/definitions/profile"
        },
        "updateProfile": {
            "$ref": "#/definitions/profile"
        },
        "startCollection": {
            "type": "object",
            "properties": {
                "idList": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/profileId"
                    }
                },
                "opts": {
                    "type": "object",
                    "description": "collection options",
                    "properties": {
                        "useMgmt": {
                            "type": "boolean",
                            "description": "use mgmt ip (secondaryIp) is available"
                        },
                        "concurrentJob": {
                            "type": "integer",
                            "description": "Number of concurent job to run"
                        },
                        "runParsing": {
                            "type": "boolean",
                            "description": "run tunnel parsing after cli collection"
                        }
                    }
                }
            }
        },
        "collectionJobId": {
            "type": "integer",
            "description": "the job id. This is generated by Northstar.  The id is required to fetch collection result(s)"
        },
        "collectionStatusType": {
            "type": "string",
            "description": "Indicate the collection status for an individual task",
            "enum": [
                "waiting",
                "running",
                "done",
                "error",
                "not selected"
            ]
        },
        "collectionStatus": {
            "type": "object",
            "properties": {
                "jobId": {
                    "$ref": "#/definitions/collectionJobId"
                },
                "netconfCollection": {
                    "type": "array",
                    "description": "Individual device netconf collection status",
                    "items": {
                        "type": "object",
                        "properties": {
                            "deviceId": {
                                "description": "device id in device profile",
                                "$ref": "#/definitions/profileId"
                            },
                            "configCollection": {
                                "$ref": "#/definitions/collectionStatusType"
                            },
                            "interfaceCollection": {
                                "$ref": "#/definitions/collectionStatusType"
                            },
                            "tunnelCollection": {
                                "$ref": "#/definitions/collectionStatusType"
                            },
                            "transitTunnelCollection": {
                                "$ref": "#/definitions/collectionStatusType"
                            }
                        }
                    }
                },
                "tunnelParsing": {
                    "$ref": "#/definitions/collectionStatusType"
                },
                "configParsing": {
                    "$ref": "#/definitions/collectionStatusType"
                },
                "startTime": {
                    "type": "string",
                    "description": "task start time in iso string format"
                },
                "endTime": {
                    "type": "string",
                    "description": "task end time in iso string format"
                }
            }
        },
        "netconfDeviceDone": {
            "type": "object",
            "description": "Data format on event type netconfDeviceDone--the event indicates completion of collection for a device",
            "properties": {
                "id": {
                    "$ref": "#/definitions/profileId"
                },
                "jobDone": {
                    "type": "string",
                    "description": "Indicates which task is finished",
                    "enum": [
                        "config",
                        "interface",
                        "tunnel_path",
                        "transit_tunnel"
                    ]
                },
                "taskResult": {
                    "type": "string",
                    "enum": [
                        "success",
                        "fail"
                    ]
                },
                "jobId": {
                    "$ref": "#/definitions/collectionJobId"
                }
            }
        },
        "netconfCollectionDone": {
            "type": "array",
            "description": "Data format on event type netconfCollectionDone--the event indicates completeion of collection for a job",
            "items": {
                "$ref": "#/definitions/netconfDeviceDone"
            }
        },
        "netconfConfigParsingDone": {
            "type": "object",
            "description": "This event indicates that the conversion and loading is finished",
            "properties": {
                "jobId": {
                    "$ref": "#/definitions/collectionJobId"
                },
                "outputLocation": {
                    "type": "string",
                    "description": "the value contains the path of the internal data format and location of the collected cli, for debugging"
                }
            }
        },
        "netconfParsingErrorEventData": {
            "type": "object",
            "description": "object contains error message generated during parsing for specified job",
            "properties": {
                "jobId": {
                    "$ref": "#/definitions/collectionJobId"
                },
                "msg": {
                    "type": "string",
                    "description": " Error message"
                }
            }
        },
        "netconfConfigParsingErr": {
            "description": "event indicates that an error occured during config parsing",
            "$ref": "#/definitions/netconfParsingErrorEventData"
        },
        "netconfTunnelParsingDone": {
            "type": "object",
            "description": "event indicates that the conversion and loading of tunnels is finished",
            "properties": {
                "jobId": {
                    "$ref": "#/definitions/collectionJobId"
                }
            }
        },
        "netconfTunnelParsingError": {
            "description": "event indicates that an error occured during tunnel parsing",
            "$ref": "#/definitions/netconfParsingErrorEventData"
        }
    }
}
