public ServiceCall < Classifier > updateClassifier ( UpdateClassifierOptions updateClassifierOptions ) { Validator . notNull ( updateClassifierOptions , "updateClassifierOptions cannot be null" ) ; Validator . isTrue ( ( updateClassifierOptions . positiveExamples ( ) != null ) || ( updateClassifierOptions . negativeExamples ( ) != null ) , "At least one of positiveExamples or negativeExamples must be supplied." ) ; String [ ] pathSegments = { "v3/classifiers" } ; String [ ] pathParameters = { updateClassifierOptions . classifierId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "watson_vision_combined" , "v3" , "updateClassifier" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; MultipartBody . Builder multipartBuilder = new MultipartBody . Builder ( ) ; multipartBuilder . setType ( MultipartBody . FORM ) ; if ( updateClassifierOptions . positiveExamples ( ) != null ) { for ( Map . Entry < String , InputStream > entry : updateClassifierOptions . positiveExamples ( ) . entrySet ( ) ) { String partName = String . format ( "%s_positive_examples" , entry . getKey ( ) ) ; RequestBody part = RequestUtils . inputStreamBody ( entry . getValue ( ) , "application/octet-stream" ) ; multipartBuilder . addFormDataPart ( partName , entry . getKey ( ) , part ) ; } } if ( updateClassifierOptions . negativeExamples ( ) != null ) { RequestBody negativeExamplesBody = RequestUtils . inputStreamBody ( updateClassifierOptions . negativeExamples ( ) , "application/octet-stream" ) ; multipartBuilder . addFormDataPart ( "negative_examples" , updateClassifierOptions . negativeExamplesFilename ( ) , negativeExamplesBody ) ; } builder . body ( multipartBuilder . build ( ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Classifier . class ) ) ; }
Update a classifier .