/// <reference path="./sigApi.ApiBase.d.ts" />
/// <reference path="./sigApi.SigLocalClient.d.ts" />

declare namespace SigApi {
    interface ApiClientIdentification extends ApiBase {
        /**
         * Adds a local client
         * 
         * @param {number} type         Type of identifier that defines the id (IP address = 1, range of IP addresses = 2)
         * @param {string} identifier   Identifier (IP address), which determines the id
         * @param {number} id           The id which the client should receive when connecting to the DataService (valid id's for local clients are from SIG_CONST.TID_LOCAL_CLIENTS_BEGIN (= 512) to SIG_CONST.TID_LOCAL_CLIENTS_END (= 1023))
         * @param {number} [uid=undefined] A unique identifier
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, data:{ id, error}}), reject: ({uid: number, status: number, errortxt: string})
         * 
         * Returns a Promise, which is resolved with the given uid, the given id (data.id: 0 = error, <>0 = the given id) and an errorcode (data.error: 0 = successful, <>0 = error code)
         * 
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         * 
         * Possible error for resolve:
         * * 0x0011 -> Invalid parameters -> check the parameters
         * * 0x0021 -> Identifier already exists -> check the identifier
         * * 0x000F -> The client id already exists -> choose another client id
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to add a local client -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        addLocalClient(
            type: number,
            identifier: string,
            id: number,
            uid?: number
        ): Promise<{ uid: number, data: { id: number, error: number } }>
        /**
         * Adds a local client for a range
         *
         * @param {number} type         Type of identifier that defines the id (IP address = 1, range of IP addresses = 2)
         * @param {number} onduplicate  Defines what should happen if the id is already assigned (0 = add clients even if the ID is already assigned, 1 = add clients only if the id is not already assigned)
         * @param {string} from         Begin of the range of the identifier (IP address) which determines the id
         * @param {string} to           End of the range of the identifier (IP address) which determines the id
         * @param {number} id           The id which the client should receive when connecting to the DataService (valid id's for local clients are from SIG_CONST.TID_LOCAL_CLIENTS_BEGIN (= 512) to SIG_CONST.TID_LOCAL_CLIENTS_END (= 1023))
         * @param {number} [uid=undefined] A unique identifier
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, data:{ id, error}}), reject: ({uid: number, status: number, errortxt: string})
         * 
         * Returns a Promise, which is resolved with the given uid, the given id (data.id: 0 = error, <>0 = the given id) and an errorcode (data.error: 0 = successful, <>0 = error code)
         * 
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         *      
         * Possible error for resolve:
         * * 0x0011 -> Invalid parameters -> check the parameters
         * * 0x0021 -> The range of the identifier already exists -> choose another range
         * * 0x000F -> The client id already exists -> choose another client id
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to add a local client for a range -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        addLocalClientRange(
            type: number,
            onduplicate: number,
            from: number,
            to: number,
            id: number,
            uid?: number
        ): Promise<{ uid: number, data: { id: number, error: number } }>
        /**
         * Removes a local client
         *
         * @param {number} id              The id of the client to be removed (valid id's for local clients are from SIG_CONST.TID_LOCAL_CLIENTS_BEGIN (= 512) to SIG_CONST.TID_LOCAL_CLIENTS_END (= 1023))
         * @param {number} [uid=undefined] A unique identifier
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, data:{ error}}), reject: ({uid: number, status: number, errortxt: string})
         * 
         * Returns a Promise, which is resolved with the given uid and an errorcode (data.error: 0 = successful, <>0 = error code)
         * 
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         * 
         * Possible error for resolve:
         * * 0x0011 -> Invalid parameters -> check the parameters
         * * 0x0020 -> A client with the given id could not be found -> check the client id
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to remove a local client -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        removeLocalClient(
            id: number,
            uid?: number
        ): Promise<{ uid: number, data: { error: number } }>
        /**
         * Removes a local client range
         *
         * @param {number} type     Type of identifier that defines the id (IP address = 1, range of IP addresses = 2)
         * @param {number} from     Begin of the range of the identifier (IP address) which determines the id
         * @param {number} to       End of the range of the identifier (IP address) which determines the id
         * @param {number} [uid=undefined] A unique identifier
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, data:{ error}}), reject: ({uid: number, status: number, errortxt: string})
         * 
         * Returns a Promise, which is resolved with the given uid and an errorcode (data.error: 0 = successful, <>0 = error code)
         * 
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         * 
         * Possible error for resolve:
         * * 0x0011 -> Invalid parameters -> check the parameters
         * * 0x0020 -> A client range could not be found -> check the client range
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to remove a local client for a range -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        removeLocalClientRange(
            type: number,
            from: number,
            to: number,
            uid?: number
        ): Promise<{ uid: number, data: { error: number } }>
        /**
         * Removes itself as a local client
         *
         * @param {number} [uid=undefined] A unique identifier
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, data:{ error}}), reject: ({uid: number, status: number, errortxt: string})
         * 
         * Returns a Promise, which is resolved with the given uid and an errorcode (data.error: 0 = successful, <>0 = error code)
         * 
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         * 
         * Possible error for resolve:
         * * 0x0020 -> This client could not be found -> probably this client was never added
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to remove itself as a local client -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        removeThisAsLocalClient(
            uid?: number
        ): Promise<{ uid: number, data: { error: number } }>
        /**
         * Gets the current client id
         *
         * @param {number} [uid=undefined] A unique identifier
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, data:{ id, error}}), reject: ({uid: number, status: number, errortxt: string})
         * 
         * Returns a Promise, which is resolved with the given uid, the given id (data.id: 0 = error, <>0 = the given id) and an errorcode (data.error: 0 = successful, <>0 = error code)
         * 
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         * 
         * Possible error for resolve:
         * * 0x0001 -> Unknown error
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to get the current client id -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        getCurrentClientId(
            uid?: number
        ): Promise<{ uid: number, data: { id: number, error: number } }>
        /**
         * Returns a array with all local client id's
         *
         * @param {number} [uid=undefined]  A unique identifier
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, data: [{id, error}]}), reject: ({uid: number, status: number, errortxt: string})
         * 
         * Returns a Promise, which is resolved with an Array of {id, error} (id: 0 = error, <>0 = the given id; error: 0 = successful, <>0 = error code)
         * 
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         * 
         * Possible error for resolve:
         * * 0x0001 -> Unknown error
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to get a list of local clients -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        getLocalClientList(
            uid?: number
        ): Promise<{ uid: number, data: { id: number, error: number }[] }>
        /**
         * Clears the local client list
         *
         * @param {number} [uid=undefined] A unique identifier
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, data:{ error}}), reject: ({uid: number, status: number, errortxt: string})
         * 
         * Returns a Promise, which is resolved with the given uid and an errorcode (data.error: 0 = successful, <>0 = error code)
         * 
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         * 
         * Possible error for resolve:
         * * 0x0001 -> Unknown error
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to clear the local client list -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        clearLocalClientList(
            uid?: number
        ): Promise<{ uid: number, data: { error: number } }>
        /**
         * Returns a array with all local client objects
         *
         * @param {number} [uid=undefined] a unique identifier
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, data: [SigLocalClient]}), reject: ({uid: number, status: number, errortxt: string})
         * 
         * Returns a Promise, which is resolved with the given uid and an Array of SigLocalClient objects
         * 
         * SigLocalClient:
         * * id: 0 = error, <>0 = the given id
         * * error: 0 = successful, <>0 = error code
         * * type: Type of identifier (IP address = 1, range of IP addresses = 2)
         * * identifier: Identifier (IP address), which determines the id
         * * from: Begin of the range of the identifier (IP address), which determines the id
         * * to: End of the range of the identifier (IP address), which determines the id
         * * onduplicate: Defines what should happen if the id is already assigned
         * 
         * If an error occurs, type, identifier, from, to and onduplicate are undefined
         * 
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         *
         * Possible error for resolve:
         * * 0x0001 -> Unknown error
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to get a detailed list of local clients -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        getLocalClientListDetails(
            uid?: number
        ): Promise<{ uid: number, data: SigLocalClient[] }>
        /**
         * Gets a local client for a given id
         * 
         * @param {number} id   The id of the local client to be get (valid id's for local clients are from SIG_CONST.TID_LOCAL_CLIENTS_BEGIN (= 512) to SIG_CONST.TID_LOCAL_CLIENTS_END (= 1023))
         * @param {number} [uid=undefined]  A unique identifier
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, data: SigLocalClient}), reject: ({uid: number, status: number, errortxt: string})
         * 
         * Returns a Promise, which is resolved with the given uid and an SigLocalClient object
         * 
         * SigLocalClient:
         * * id: 0 = error, <>0 = the given id
         * * error: 0 = successful, <>0 = error code
         * * type: Type of identifier (IP address = 1, range of IP addresses = 2)
         * * identifier: Identifier (IP address), which determines the id
         * * from: Begin of the range of the identifier (IP address), which determines the id
         * * to: End of the range of the identifier (IP address), which determines the id
         * * onduplicate: Defines what should happen if the id is already assigned
         * 
         * If an error occurs, type, identifier, from, to and onduplicate are undefined
         * 
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         * 
         * Possible error for resolve:
         * * 0x0011 -> Invalid parameters -> check the parameters
         * * 0x0020 -> A client with the given id could not be found -> check the client id 
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to get a local client for a given id -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        getLocalClientById(
            id: number,
            uid?: number
        ): Promise<{ uid: number, data: SigLocalClient }>
        /**
         * Gets information about the client connection from dataservice
         * 
         * @param {number} [uid=undefined]  A unique identifier
         * 
         * @returns {Promise} Promise -> resolve: ({uid: number, ip: string}), reject: ({uid: number, status: number, errortxt: string})
         * 
         * Returns a Promise, which is resolved with the given uid and the ip address of the runtime
         * 
         * If the promises is rejected, an object with uid, status and errortxt is passed in the reject function
         * 
         * 
         * Possible status for reject:
         * * 0x0001 -> ERROR_UNKNOWN -> Unknown error: see errortext for details
         * * 0x0012 -> ERROR_INSUFFICIENT_PRIVILEGES -> not enough privileges to get a local client for a given id -> check the access level of the current user
         * * 0x0007 -> ERROR_COMMUNICATION -> no response from dataservice for this request -> check if the DS is running
         */
        getClientConnectionInfo(
            uid?: number
        ): Promise<{ uid: number, ip: string }>
    }
}
