nl_tokens: Checks status of iControl REST task
pl_tokens: function checkTask ( taskPath , taskIdToCheck , options ) { const func = function ( ) { const deferred = q . defer ( ) ; this . <mask> ( ` ${ taskPath } ${ taskIdToCheck } ` , undefined , util . NO_RETRY ) . then ( ( response ) => { const statusAttribute = ( options && options . statusAttribute ) ? options . statusAttribute : '_taskState' ; const taskState = response [ statusAttribute ] ; if ( taskState === 'VALIDATING' || taskState === 'STARTED' ) { // this is a normal state, just not done yet - keep waiting deferred . reject ( ) ; } else if ( taskState === 'COMPLETED' || taskState === 'FINISHED' ) { deferred . resolve ( { success : true , response } ) ; } else if ( taskState === 'FAILED' ) { deferred . resolve ( { success : false , response } ) ; } else { deferred . reject ( new Error ( ` ${ taskState } ` ) ) ; } } ) . catch ( ( ) => { // if this throws, assume it is because restjavad has been restarted // and we are done for now deferred . resolve ( { success : true } ) ; } ) ; return deferred . promise ; } ; return util . tryUntil ( this , util . DEFAULT_RETRY , func ) ; }