idx int64 0 41.2k | question stringlengths 74 4.04k | target stringlengths 7 750 |
|---|---|---|
26,000 | protected JestClient createJestClient ( Map < String , String > config , String indexName , String defaultIndexName ) { String host = config . get ( "client.host" ) ; String port = config . get ( "client.port" ) ; String protocol = config . get ( "client.protocol" ) ; String initialize = config . get ( "client.initialize" ) ; if ( initialize == null ) { initialize = "true" ; } if ( StringUtils . isBlank ( host ) ) { throw new RuntimeException ( "Missing client.host configuration for ESRegistry." ) ; } if ( StringUtils . isBlank ( port ) ) { throw new RuntimeException ( "Missing client.port configuration for ESRegistry." ) ; } if ( StringUtils . isBlank ( protocol ) ) { protocol = "http" ; } String clientKey = "jest:" + host + ':' + port + '/' + indexName ; synchronized ( clients ) { if ( clients . containsKey ( clientKey ) ) { return clients . get ( clientKey ) ; } else { StringBuilder builder = new StringBuilder ( ) ; builder . append ( protocol ) ; builder . append ( "://" ) ; builder . append ( host ) ; builder . append ( ":" ) ; builder . append ( String . valueOf ( port ) ) ; String connectionUrl = builder . toString ( ) ; JestClientFactory factory = new JestClientFactory ( ) ; Builder httpClientConfig = new HttpClientConfig . Builder ( connectionUrl ) ; updateHttpConfig ( httpClientConfig , config ) ; factory . setHttpClientConfig ( httpClientConfig . build ( ) ) ; updateJestClientFactory ( factory , config ) ; JestClient client = factory . getObject ( ) ; clients . put ( clientKey , client ) ; if ( "true" . equals ( initialize ) ) { initializeClient ( client , indexName , defaultIndexName ) ; } return client ; } } } | Creates a transport client from a configuration map . |
26,001 | protected void updateHttpConfig ( Builder httpClientConfig , Map < String , String > config ) { String username = config . get ( "client.username" ) ; String password = config . get ( "client.password" ) ; String timeout = config . get ( "client.timeout" ) ; if ( StringUtils . isBlank ( timeout ) ) { timeout = "10000" ; } httpClientConfig . connTimeout ( new Integer ( timeout ) ) . readTimeout ( new Integer ( timeout ) ) . maxTotalConnection ( 75 ) . defaultMaxTotalConnectionPerRoute ( 75 ) . multiThreaded ( true ) ; if ( ! StringUtils . isBlank ( username ) ) { httpClientConfig . defaultCredentials ( username , password ) ; } if ( "https" . equals ( config . get ( "protocol" ) ) ) { updateSslConfig ( httpClientConfig , config ) ; } } | Update the http client config . |
26,002 | private void orderPolicies ( PoliciesBean policies ) { int idx = 1 ; for ( PolicyBean policy : policies . getPolicies ( ) ) { policy . setOrderIndex ( idx ++ ) ; } } | Set the order index of all policies . |
26,003 | private Map < String , Object > getEntity ( String type , String id ) throws StorageException { try { JestResult response = esClient . execute ( new Get . Builder ( getIndexName ( ) , id ) . type ( type ) . build ( ) ) ; if ( ! response . isSucceeded ( ) ) { return null ; } return response . getSourceAsObject ( Map . class ) ; } catch ( Exception e ) { throw new StorageException ( e ) ; } } | Gets an entity . Callers must unmarshal the resulting map . |
26,004 | private List < Hit < Map < String , Object > , Void > > listEntities ( String type , SearchSourceBuilder searchSourceBuilder ) throws StorageException { try { String query = searchSourceBuilder . string ( ) ; Search search = new Search . Builder ( query ) . addIndex ( getIndexName ( ) ) . addType ( type ) . build ( ) ; SearchResult response = esClient . execute ( search ) ; @ SuppressWarnings ( { "rawtypes" , "unchecked" } ) List < Hit < Map < String , Object > , Void > > thehits = ( List ) response . getHits ( Map . class ) ; return thehits ; } catch ( Exception e ) { throw new StorageException ( e ) ; } } | Returns a list of entities . |
26,005 | private void deleteEntity ( String type , String id ) throws StorageException { try { JestResult response = esClient . execute ( new Delete . Builder ( id ) . index ( getIndexName ( ) ) . type ( type ) . build ( ) ) ; if ( ! response . isSucceeded ( ) ) { throw new StorageException ( "Document could not be deleted because it did not exist:" + response . getErrorMessage ( ) ) ; } } catch ( StorageException e ) { throw e ; } catch ( Exception e ) { throw new StorageException ( e ) ; } } | Deletes an entity . |
26,006 | private void updateEntity ( String type , String id , XContentBuilder source ) throws StorageException { try { String doc = source . string ( ) ; esClient . execute ( new Index . Builder ( doc ) . setParameter ( Parameters . OP_TYPE , "index" ) . index ( getIndexName ( ) ) . type ( type ) . id ( id ) . build ( ) ) ; } catch ( Exception e ) { throw new StorageException ( e ) ; } } | Updates a single entity . |
26,007 | private static String getPoliciesDocType ( PolicyType type ) { String docType = "planPolicies" ; if ( type == PolicyType . Api ) { docType = "apiPolicies" ; } else if ( type == PolicyType . Client ) { docType = "clientPolicies" ; } return docType ; } | Returns the policies document type to use given the policy type . |
26,008 | private static String id ( String organizationId , String entityId , String version ) { return organizationId + ':' + entityId + ':' + version ; } | A composite ID created from an organization ID entity ID and version . |
26,009 | private < T > Iterator < T > getAll ( String entityType , IUnmarshaller < T > unmarshaller ) throws StorageException { String query = matchAllQuery ( ) ; return getAll ( entityType , unmarshaller , query ) ; } | Returns an iterator over all instances of the given entity type . |
26,010 | private boolean hasOriginHeader ( HttpServletRequest httpReq ) { String origin = httpReq . getHeader ( "Origin" ) ; return origin != null && origin . trim ( ) . length ( ) > 0 ; } | Returns true if the Origin request header is present . |
26,011 | public static AuthHandler getAuth ( Vertx vertx , Router router , VertxEngineConfig apimanConfig ) { String type = apimanConfig . getAuth ( ) . getString ( "type" , "NONE" ) ; JsonObject authConfig = apimanConfig . getAuth ( ) . getJsonObject ( "config" , new JsonObject ( ) ) ; switch ( AuthType . getType ( type ) ) { case BASIC : return BasicAuth . create ( authConfig ) ; case NONE : return NoneAuth . create ( ) ; case KEYCLOAK : return KeycloakOAuthFactory . create ( vertx , router , apimanConfig , authConfig ) ; default : return NoneAuth . create ( ) ; } } | Creates an auth handler of the type indicated in the auth section of config . |
26,012 | public Session createSession ( ) throws OpenViduJavaClientException , OpenViduHttpException { Session s = new Session ( ) ; OpenVidu . activeSessions . put ( s . getSessionId ( ) , s ) ; return s ; } | Creates an OpenVidu session with the default settings |
26,013 | public Recording getRecording ( String recordingId ) throws OpenViduJavaClientException , OpenViduHttpException { HttpGet request = new HttpGet ( OpenVidu . urlOpenViduServer + API_RECORDINGS + "/" + recordingId ) ; HttpResponse response ; try { response = OpenVidu . httpClient . execute ( request ) ; } catch ( IOException e ) { throw new OpenViduJavaClientException ( e . getMessage ( ) , e . getCause ( ) ) ; } try { int statusCode = response . getStatusLine ( ) . getStatusCode ( ) ; if ( ( statusCode == org . apache . http . HttpStatus . SC_OK ) ) { return new Recording ( httpResponseToJson ( response ) ) ; } else { throw new OpenViduHttpException ( statusCode ) ; } } finally { EntityUtils . consumeQuietly ( response . getEntity ( ) ) ; } } | Gets an existing recording |
26,014 | @ SuppressWarnings ( "unchecked" ) public List < Recording > listRecordings ( ) throws OpenViduJavaClientException , OpenViduHttpException { HttpGet request = new HttpGet ( OpenVidu . urlOpenViduServer + API_RECORDINGS ) ; HttpResponse response ; try { response = OpenVidu . httpClient . execute ( request ) ; } catch ( IOException e ) { throw new OpenViduJavaClientException ( e . getMessage ( ) , e . getCause ( ) ) ; } try { int statusCode = response . getStatusLine ( ) . getStatusCode ( ) ; if ( ( statusCode == org . apache . http . HttpStatus . SC_OK ) ) { List < Recording > recordings = new ArrayList < > ( ) ; JSONObject json = httpResponseToJson ( response ) ; JSONArray array = ( JSONArray ) json . get ( "items" ) ; array . forEach ( item -> { recordings . add ( new Recording ( ( JSONObject ) item ) ) ; } ) ; return recordings ; } else { throw new OpenViduHttpException ( statusCode ) ; } } finally { EntityUtils . consumeQuietly ( response . getEntity ( ) ) ; } } | Lists all existing recordings |
26,015 | public void createSession ( Session sessionNotActive , KurentoClientSessionInfo kcSessionInfo ) throws OpenViduException { String sessionId = kcSessionInfo . getRoomName ( ) ; KurentoSession session = ( KurentoSession ) sessions . get ( sessionId ) ; if ( session != null ) { throw new OpenViduException ( Code . ROOM_CANNOT_BE_CREATED_ERROR_CODE , "Session '" + sessionId + "' already exists" ) ; } this . kurentoClient = kcProvider . getKurentoClient ( kcSessionInfo ) ; session = new KurentoSession ( sessionNotActive , kurentoClient , kurentoSessionEventsHandler , kurentoEndpointConfig , kcProvider . destroyWhenUnused ( ) ) ; KurentoSession oldSession = ( KurentoSession ) sessions . putIfAbsent ( sessionId , session ) ; if ( oldSession != null ) { log . warn ( "Session '{}' has just been created by another thread" , sessionId ) ; return ; } String kcName = "[NAME NOT AVAILABLE]" ; if ( kurentoClient . getServerManager ( ) != null ) { kcName = kurentoClient . getServerManager ( ) . getName ( ) ; } log . warn ( "No session '{}' exists yet. Created one using KurentoClient '{}'." , sessionId , kcName ) ; sessionEventsHandler . onSessionCreated ( session ) ; } | Creates a session if it doesn t already exist . The session s id will be indicated by the session info bean . |
26,016 | protected void unregisterElementErrListener ( MediaElement element , final ListenerSubscription subscription ) { if ( element == null || subscription == null ) { return ; } element . removeErrorListener ( subscription ) ; } | Unregisters the error listener from the media element using the provided subscription . |
26,017 | public Set < Participant > getParticipants ( String sessionId ) throws OpenViduException { Session session = sessions . get ( sessionId ) ; if ( session == null ) { throw new OpenViduException ( Code . ROOM_NOT_FOUND_ERROR_CODE , "Session '" + sessionId + "' not found" ) ; } Set < Participant > participants = session . getParticipants ( ) ; participants . removeIf ( p -> p . isClosed ( ) ) ; return participants ; } | Returns all the participants inside a session . |
26,018 | public Participant getParticipant ( String sessionId , String participantPrivateId ) throws OpenViduException { Session session = sessions . get ( sessionId ) ; if ( session == null ) { throw new OpenViduException ( Code . ROOM_NOT_FOUND_ERROR_CODE , "Session '" + sessionId + "' not found" ) ; } Participant participant = session . getParticipantByPrivateId ( participantPrivateId ) ; if ( participant == null ) { throw new OpenViduException ( Code . USER_NOT_FOUND_ERROR_CODE , "Participant '" + participantPrivateId + "' not found in session '" + sessionId + "'" ) ; } return participant ; } | Returns a participant in a session |
26,019 | public Participant getParticipant ( String participantPrivateId ) throws OpenViduException { for ( Session session : sessions . values ( ) ) { if ( ! session . isClosed ( ) ) { if ( session . getParticipantByPrivateId ( participantPrivateId ) != null ) { return session . getParticipantByPrivateId ( participantPrivateId ) ; } } } throw new OpenViduException ( Code . USER_NOT_FOUND_ERROR_CODE , "No participant with private id '" + participantPrivateId + "' was found" ) ; } | Returns a participant |
26,020 | protected void updateRecordingManagerCollections ( Session session , Recording recording ) { this . recordingManager . sessionHandler . setRecordingStarted ( session . getSessionId ( ) , recording ) ; this . recordingManager . sessionsRecordings . put ( session . getSessionId ( ) , recording ) ; this . recordingManager . startingRecordings . remove ( recording . getId ( ) ) ; this . recordingManager . startedRecordings . put ( recording . getId ( ) , recording ) ; } | Changes recording from starting to started updates global recording collections and sends RPC response to clients |
26,021 | protected void sendRecordingStartedNotification ( Session session , Recording recording ) { this . recordingManager . getSessionEventsHandler ( ) . sendRecordingStartedNotification ( session , recording ) ; } | Sends RPC response for recording started event |
26,022 | public Notification getNotification ( ) { try { Notification notif = notifications . take ( ) ; log . debug ( "Dequeued notification {}" , notif ) ; return notif ; } catch ( InterruptedException e ) { log . info ( "Interrupted while polling notifications' queue" ) ; return null ; } } | Blocks until an element is available and then returns it by removing it from the queue . |
26,023 | public ServiceCall < SessionResponse > createSession ( CreateSessionOptions createSessionOptions ) { Validator . notNull ( createSessionOptions , "createSessionOptions cannot be null" ) ; String [ ] pathSegments = { "v2/assistants" , "sessions" } ; String [ ] pathParameters = { createSessionOptions . assistantId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "conversation" , "v2" , "createSession" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( SessionResponse . class ) ) ; } | Create a session . |
26,024 | public ServiceCall < Void > deleteSession ( DeleteSessionOptions deleteSessionOptions ) { Validator . notNull ( deleteSessionOptions , "deleteSessionOptions cannot be null" ) ; String [ ] pathSegments = { "v2/assistants" , "sessions" } ; String [ ] pathParameters = { deleteSessionOptions . assistantId ( ) , deleteSessionOptions . sessionId ( ) } ; RequestBuilder builder = RequestBuilder . delete ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "conversation" , "v2" , "deleteSession" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getVoid ( ) ) ; } | Delete session . |
26,025 | public ServiceCall < MessageResponse > message ( MessageOptions messageOptions ) { Validator . notNull ( messageOptions , "messageOptions cannot be null" ) ; String [ ] pathSegments = { "v2/assistants" , "sessions" , "message" } ; String [ ] pathParameters = { messageOptions . assistantId ( ) , messageOptions . sessionId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "conversation" , "v2" , "message" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; if ( messageOptions . input ( ) != null ) { contentJson . add ( "input" , GsonSingleton . getGson ( ) . toJsonTree ( messageOptions . input ( ) ) ) ; } if ( messageOptions . context ( ) != null ) { contentJson . add ( "context" , GsonSingleton . getGson ( ) . toJsonTree ( messageOptions . context ( ) ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( MessageResponse . class ) ) ; } | Send user input to assistant . |
26,026 | public ServiceCall < IdentifiedLanguages > identify ( IdentifyOptions identifyOptions ) { Validator . notNull ( identifyOptions , "identifyOptions cannot be null" ) ; String [ ] pathSegments = { "v3/identify" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "language_translator" , "v3" , "identify" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; builder . bodyContent ( identifyOptions . text ( ) , "text/plain" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( IdentifiedLanguages . class ) ) ; } | Identify language . |
26,027 | public ServiceCall < IdentifiableLanguages > listIdentifiableLanguages ( ListIdentifiableLanguagesOptions listIdentifiableLanguagesOptions ) { String [ ] pathSegments = { "v3/identifiable_languages" } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "language_translator" , "v3" , "listIdentifiableLanguages" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( listIdentifiableLanguagesOptions != null ) { } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( IdentifiableLanguages . class ) ) ; } | List identifiable languages . |
26,028 | public ServiceCall < TranslationModel > createModel ( CreateModelOptions createModelOptions ) { Validator . notNull ( createModelOptions , "createModelOptions cannot be null" ) ; Validator . isTrue ( ( createModelOptions . forcedGlossary ( ) != null ) || ( createModelOptions . parallelCorpus ( ) != null ) , "At least one of forcedGlossary or parallelCorpus must be supplied." ) ; String [ ] pathSegments = { "v3/models" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "language_translator" , "v3" , "createModel" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; builder . query ( "base_model_id" , createModelOptions . baseModelId ( ) ) ; if ( createModelOptions . name ( ) != null ) { builder . query ( "name" , createModelOptions . name ( ) ) ; } MultipartBody . Builder multipartBuilder = new MultipartBody . Builder ( ) ; multipartBuilder . setType ( MultipartBody . FORM ) ; if ( createModelOptions . forcedGlossary ( ) != null ) { RequestBody forcedGlossaryBody = RequestUtils . inputStreamBody ( createModelOptions . forcedGlossary ( ) , "application/octet-stream" ) ; multipartBuilder . addFormDataPart ( "forced_glossary" , "filename" , forcedGlossaryBody ) ; } if ( createModelOptions . parallelCorpus ( ) != null ) { RequestBody parallelCorpusBody = RequestUtils . inputStreamBody ( createModelOptions . parallelCorpus ( ) , "application/octet-stream" ) ; multipartBuilder . addFormDataPart ( "parallel_corpus" , "filename" , parallelCorpusBody ) ; } builder . body ( multipartBuilder . build ( ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( TranslationModel . class ) ) ; } | Create model . |
26,029 | public ServiceCall < HTMLReturn > convertToHtml ( ConvertToHtmlOptions convertToHtmlOptions ) { Validator . notNull ( convertToHtmlOptions , "convertToHtmlOptions cannot be null" ) ; String [ ] pathSegments = { "v1/html_conversion" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "compare-comply" , "v1" , "convertToHtml" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( convertToHtmlOptions . model ( ) != null ) { builder . query ( "model" , convertToHtmlOptions . model ( ) ) ; } MultipartBody . Builder multipartBuilder = new MultipartBody . Builder ( ) ; multipartBuilder . setType ( MultipartBody . FORM ) ; RequestBody fileBody = RequestUtils . inputStreamBody ( convertToHtmlOptions . file ( ) , convertToHtmlOptions . fileContentType ( ) ) ; multipartBuilder . addFormDataPart ( "file" , convertToHtmlOptions . filename ( ) , fileBody ) ; builder . body ( multipartBuilder . build ( ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( HTMLReturn . class ) ) ; } | Convert document to HTML . |
26,030 | public ServiceCall < CompareReturn > compareDocuments ( CompareDocumentsOptions compareDocumentsOptions ) { Validator . notNull ( compareDocumentsOptions , "compareDocumentsOptions cannot be null" ) ; String [ ] pathSegments = { "v1/comparison" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "compare-comply" , "v1" , "compareDocuments" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( compareDocumentsOptions . file1Label ( ) != null ) { builder . query ( "file_1_label" , compareDocumentsOptions . file1Label ( ) ) ; } if ( compareDocumentsOptions . file2Label ( ) != null ) { builder . query ( "file_2_label" , compareDocumentsOptions . file2Label ( ) ) ; } if ( compareDocumentsOptions . model ( ) != null ) { builder . query ( "model" , compareDocumentsOptions . model ( ) ) ; } MultipartBody . Builder multipartBuilder = new MultipartBody . Builder ( ) ; multipartBuilder . setType ( MultipartBody . FORM ) ; RequestBody file1Body = RequestUtils . inputStreamBody ( compareDocumentsOptions . file1 ( ) , compareDocumentsOptions . file1ContentType ( ) ) ; multipartBuilder . addFormDataPart ( "file_1" , "filename" , file1Body ) ; RequestBody file2Body = RequestUtils . inputStreamBody ( compareDocumentsOptions . file2 ( ) , compareDocumentsOptions . file2ContentType ( ) ) ; multipartBuilder . addFormDataPart ( "file_2" , "filename" , file2Body ) ; builder . body ( multipartBuilder . build ( ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( CompareReturn . class ) ) ; } | Compare two documents . |
26,031 | public ServiceCall < FeedbackReturn > addFeedback ( AddFeedbackOptions addFeedbackOptions ) { Validator . notNull ( addFeedbackOptions , "addFeedbackOptions cannot be null" ) ; String [ ] pathSegments = { "v1/feedback" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "compare-comply" , "v1" , "addFeedback" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; contentJson . add ( "feedback_data" , GsonSingleton . getGson ( ) . toJsonTree ( addFeedbackOptions . feedbackData ( ) ) ) ; if ( addFeedbackOptions . userId ( ) != null ) { contentJson . addProperty ( "user_id" , addFeedbackOptions . userId ( ) ) ; } if ( addFeedbackOptions . comment ( ) != null ) { contentJson . addProperty ( "comment" , addFeedbackOptions . comment ( ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( FeedbackReturn . class ) ) ; } | Add feedback . |
26,032 | public ServiceCall < Void > deleteFeedback ( DeleteFeedbackOptions deleteFeedbackOptions ) { Validator . notNull ( deleteFeedbackOptions , "deleteFeedbackOptions cannot be null" ) ; String [ ] pathSegments = { "v1/feedback" } ; String [ ] pathParameters = { deleteFeedbackOptions . feedbackId ( ) } ; RequestBuilder builder = RequestBuilder . delete ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "compare-comply" , "v1" , "deleteFeedback" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( deleteFeedbackOptions . model ( ) != null ) { builder . query ( "model" , deleteFeedbackOptions . model ( ) ) ; } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getVoid ( ) ) ; } | Delete a specified feedback entry . |
26,033 | public ServiceCall < GetFeedback > getFeedback ( GetFeedbackOptions getFeedbackOptions ) { Validator . notNull ( getFeedbackOptions , "getFeedbackOptions cannot be null" ) ; String [ ] pathSegments = { "v1/feedback" } ; String [ ] pathParameters = { getFeedbackOptions . feedbackId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "compare-comply" , "v1" , "getFeedback" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( getFeedbackOptions . model ( ) != null ) { builder . query ( "model" , getFeedbackOptions . model ( ) ) ; } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( GetFeedback . class ) ) ; } | List a specified feedback entry . |
26,034 | public ServiceCall < BatchStatus > createBatch ( CreateBatchOptions createBatchOptions ) { Validator . notNull ( createBatchOptions , "createBatchOptions cannot be null" ) ; String [ ] pathSegments = { "v1/batches" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "compare-comply" , "v1" , "createBatch" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; builder . query ( "function" , createBatchOptions . function ( ) ) ; if ( createBatchOptions . model ( ) != null ) { builder . query ( "model" , createBatchOptions . model ( ) ) ; } MultipartBody . Builder multipartBuilder = new MultipartBody . Builder ( ) ; multipartBuilder . setType ( MultipartBody . FORM ) ; RequestBody inputCredentialsFileBody = RequestUtils . inputStreamBody ( createBatchOptions . inputCredentialsFile ( ) , "application/json" ) ; multipartBuilder . addFormDataPart ( "input_credentials_file" , "filename" , inputCredentialsFileBody ) ; multipartBuilder . addFormDataPart ( "input_bucket_location" , createBatchOptions . inputBucketLocation ( ) ) ; multipartBuilder . addFormDataPart ( "input_bucket_name" , createBatchOptions . inputBucketName ( ) ) ; RequestBody outputCredentialsFileBody = RequestUtils . inputStreamBody ( createBatchOptions . outputCredentialsFile ( ) , "application/json" ) ; multipartBuilder . addFormDataPart ( "output_credentials_file" , "filename" , outputCredentialsFileBody ) ; multipartBuilder . addFormDataPart ( "output_bucket_location" , createBatchOptions . outputBucketLocation ( ) ) ; multipartBuilder . addFormDataPart ( "output_bucket_name" , createBatchOptions . outputBucketName ( ) ) ; builder . body ( multipartBuilder . build ( ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( BatchStatus . class ) ) ; } | Submit a batch - processing request . |
26,035 | public ServiceCall < BatchStatus > getBatch ( GetBatchOptions getBatchOptions ) { Validator . notNull ( getBatchOptions , "getBatchOptions cannot be null" ) ; String [ ] pathSegments = { "v1/batches" } ; String [ ] pathParameters = { getBatchOptions . batchId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "compare-comply" , "v1" , "getBatch" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( BatchStatus . class ) ) ; } | Get information about a specific batch - processing job . |
26,036 | public ServiceCall < Batches > listBatches ( ListBatchesOptions listBatchesOptions ) { String [ ] pathSegments = { "v1/batches" } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "compare-comply" , "v1" , "listBatches" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( listBatchesOptions != null ) { } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Batches . class ) ) ; } | List submitted batch - processing jobs . |
26,037 | public ServiceCall < BatchStatus > updateBatch ( UpdateBatchOptions updateBatchOptions ) { Validator . notNull ( updateBatchOptions , "updateBatchOptions cannot be null" ) ; String [ ] pathSegments = { "v1/batches" } ; String [ ] pathParameters = { updateBatchOptions . batchId ( ) } ; RequestBuilder builder = RequestBuilder . put ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "compare-comply" , "v1" , "updateBatch" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; builder . query ( "action" , updateBatchOptions . action ( ) ) ; if ( updateBatchOptions . model ( ) != null ) { builder . query ( "model" , updateBatchOptions . model ( ) ) ; } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( BatchStatus . class ) ) ; } | Update a pending or active batch - processing job . |
26,038 | public ServiceCall < Voice > getVoice ( GetVoiceOptions getVoiceOptions ) { Validator . notNull ( getVoiceOptions , "getVoiceOptions cannot be null" ) ; String [ ] pathSegments = { "v1/voices" } ; String [ ] pathParameters = { getVoiceOptions . voice ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "getVoice" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( getVoiceOptions . customizationId ( ) != null ) { builder . query ( "customization_id" , getVoiceOptions . customizationId ( ) ) ; } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Voice . class ) ) ; } | Get a voice . |
26,039 | public ServiceCall < Voices > listVoices ( ListVoicesOptions listVoicesOptions ) { String [ ] pathSegments = { "v1/voices" } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "listVoices" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( listVoicesOptions != null ) { } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Voices . class ) ) ; } | List voices . |
26,040 | public ServiceCall < InputStream > synthesize ( SynthesizeOptions synthesizeOptions ) { Validator . notNull ( synthesizeOptions , "synthesizeOptions cannot be null" ) ; String [ ] pathSegments = { "v1/synthesize" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "synthesize" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } if ( synthesizeOptions . accept ( ) != null ) { builder . header ( "Accept" , synthesizeOptions . accept ( ) ) ; } if ( synthesizeOptions . voice ( ) != null ) { builder . query ( "voice" , synthesizeOptions . voice ( ) ) ; } if ( synthesizeOptions . customizationId ( ) != null ) { builder . query ( "customization_id" , synthesizeOptions . customizationId ( ) ) ; } final JsonObject contentJson = new JsonObject ( ) ; contentJson . addProperty ( "text" , synthesizeOptions . text ( ) ) ; builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getInputStream ( ) ) ; } | Synthesize audio . |
26,041 | public ServiceCall < Pronunciation > getPronunciation ( GetPronunciationOptions getPronunciationOptions ) { Validator . notNull ( getPronunciationOptions , "getPronunciationOptions cannot be null" ) ; String [ ] pathSegments = { "v1/pronunciation" } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "getPronunciation" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; builder . query ( "text" , getPronunciationOptions . text ( ) ) ; if ( getPronunciationOptions . voice ( ) != null ) { builder . query ( "voice" , getPronunciationOptions . voice ( ) ) ; } if ( getPronunciationOptions . format ( ) != null ) { builder . query ( "format" , getPronunciationOptions . format ( ) ) ; } if ( getPronunciationOptions . customizationId ( ) != null ) { builder . query ( "customization_id" , getPronunciationOptions . customizationId ( ) ) ; } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Pronunciation . class ) ) ; } | Get pronunciation . |
26,042 | public ServiceCall < VoiceModel > createVoiceModel ( CreateVoiceModelOptions createVoiceModelOptions ) { Validator . notNull ( createVoiceModelOptions , "createVoiceModelOptions cannot be null" ) ; String [ ] pathSegments = { "v1/customizations" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "createVoiceModel" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; contentJson . addProperty ( "name" , createVoiceModelOptions . name ( ) ) ; if ( createVoiceModelOptions . language ( ) != null ) { contentJson . addProperty ( "language" , createVoiceModelOptions . language ( ) ) ; } if ( createVoiceModelOptions . description ( ) != null ) { contentJson . addProperty ( "description" , createVoiceModelOptions . description ( ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( VoiceModel . class ) ) ; } | Create a custom model . |
26,043 | public ServiceCall < VoiceModel > getVoiceModel ( GetVoiceModelOptions getVoiceModelOptions ) { Validator . notNull ( getVoiceModelOptions , "getVoiceModelOptions cannot be null" ) ; String [ ] pathSegments = { "v1/customizations" } ; String [ ] pathParameters = { getVoiceModelOptions . customizationId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "getVoiceModel" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( VoiceModel . class ) ) ; } | Get a custom model . |
26,044 | public ServiceCall < VoiceModels > listVoiceModels ( ListVoiceModelsOptions listVoiceModelsOptions ) { String [ ] pathSegments = { "v1/customizations" } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "listVoiceModels" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( listVoiceModelsOptions != null ) { if ( listVoiceModelsOptions . language ( ) != null ) { builder . query ( "language" , listVoiceModelsOptions . language ( ) ) ; } } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( VoiceModels . class ) ) ; } | List custom models . |
26,045 | public ServiceCall < Void > updateVoiceModel ( UpdateVoiceModelOptions updateVoiceModelOptions ) { Validator . notNull ( updateVoiceModelOptions , "updateVoiceModelOptions cannot be null" ) ; String [ ] pathSegments = { "v1/customizations" } ; String [ ] pathParameters = { updateVoiceModelOptions . customizationId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "updateVoiceModel" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; if ( updateVoiceModelOptions . name ( ) != null ) { contentJson . addProperty ( "name" , updateVoiceModelOptions . name ( ) ) ; } if ( updateVoiceModelOptions . description ( ) != null ) { contentJson . addProperty ( "description" , updateVoiceModelOptions . description ( ) ) ; } if ( updateVoiceModelOptions . words ( ) != null ) { contentJson . add ( "words" , GsonSingleton . getGson ( ) . toJsonTree ( updateVoiceModelOptions . words ( ) ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getVoid ( ) ) ; } | Update a custom model . |
26,046 | public ServiceCall < Void > addWords ( AddWordsOptions addWordsOptions ) { Validator . notNull ( addWordsOptions , "addWordsOptions cannot be null" ) ; String [ ] pathSegments = { "v1/customizations" , "words" } ; String [ ] pathParameters = { addWordsOptions . customizationId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "addWords" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; contentJson . add ( "words" , GsonSingleton . getGson ( ) . toJsonTree ( addWordsOptions . words ( ) ) ) ; builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getVoid ( ) ) ; } | Add custom words . |
26,047 | public ServiceCall < Void > deleteWord ( DeleteWordOptions deleteWordOptions ) { Validator . notNull ( deleteWordOptions , "deleteWordOptions cannot be null" ) ; String [ ] pathSegments = { "v1/customizations" , "words" } ; String [ ] pathParameters = { deleteWordOptions . customizationId ( ) , deleteWordOptions . word ( ) } ; RequestBuilder builder = RequestBuilder . delete ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "deleteWord" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getVoid ( ) ) ; } | Delete a custom word . |
26,048 | public ServiceCall < Translation > getWord ( GetWordOptions getWordOptions ) { Validator . notNull ( getWordOptions , "getWordOptions cannot be null" ) ; String [ ] pathSegments = { "v1/customizations" , "words" } ; String [ ] pathParameters = { getWordOptions . customizationId ( ) , getWordOptions . word ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "getWord" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Translation . class ) ) ; } | Get a custom word . |
26,049 | public ServiceCall < Words > listWords ( ListWordsOptions listWordsOptions ) { Validator . notNull ( listWordsOptions , "listWordsOptions cannot be null" ) ; String [ ] pathSegments = { "v1/customizations" , "words" } ; String [ ] pathParameters = { listWordsOptions . customizationId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "text_to_speech" , "v1" , "listWords" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Words . class ) ) ; } | List custom words . |
26,050 | public ServiceCall < Classification > classify ( ClassifyOptions classifyOptions ) { Validator . notNull ( classifyOptions , "classifyOptions cannot be null" ) ; String [ ] pathSegments = { "v1/classifiers" , "classify" } ; String [ ] pathParameters = { classifyOptions . classifierId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "natural_language_classifier" , "v1" , "classify" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; contentJson . addProperty ( "text" , classifyOptions . text ( ) ) ; builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Classification . class ) ) ; } | Classify a phrase . |
26,051 | public ServiceCall < ClassificationCollection > classifyCollection ( ClassifyCollectionOptions classifyCollectionOptions ) { Validator . notNull ( classifyCollectionOptions , "classifyCollectionOptions cannot be null" ) ; String [ ] pathSegments = { "v1/classifiers" , "classify_collection" } ; String [ ] pathParameters = { classifyCollectionOptions . classifierId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "natural_language_classifier" , "v1" , "classifyCollection" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; contentJson . add ( "collection" , GsonSingleton . getGson ( ) . toJsonTree ( classifyCollectionOptions . collection ( ) ) ) ; builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( ClassificationCollection . class ) ) ; } | Classify multiple phrases . |
26,052 | public ServiceCall < Classifier > createClassifier ( CreateClassifierOptions createClassifierOptions ) { Validator . notNull ( createClassifierOptions , "createClassifierOptions cannot be null" ) ; String [ ] pathSegments = { "v1/classifiers" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "natural_language_classifier" , "v1" , "createClassifier" ) ; 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 ) ; RequestBody trainingMetadataBody = RequestUtils . inputStreamBody ( createClassifierOptions . metadata ( ) , "application/json" ) ; multipartBuilder . addFormDataPart ( "training_metadata" , "filename" , trainingMetadataBody ) ; RequestBody trainingDataBody = RequestUtils . inputStreamBody ( createClassifierOptions . trainingData ( ) , "text/csv" ) ; multipartBuilder . addFormDataPart ( "training_data" , "filename" , trainingDataBody ) ; builder . body ( multipartBuilder . build ( ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Classifier . class ) ) ; } | Create classifier . |
26,053 | private static void writeInt ( int value , byte [ ] array , int offset ) { for ( int i = 0 ; i < 4 ; i ++ ) { array [ offset + i ] = ( byte ) ( value >>> ( 8 * i ) ) ; } } | Writes an number into an array using 4 bytes . |
26,054 | public static String getMediaTypeFromFile ( final File file ) { if ( file == null ) { return null ; } final String fileName = file . getName ( ) ; final int i = fileName . lastIndexOf ( '.' ) ; if ( i == - 1 ) { return null ; } return MEDIA_TYPES . get ( fileName . substring ( i ) . toLowerCase ( ) ) ; } | Returns the media type for a given file . |
26,055 | public static boolean isValidMediaType ( final String mediaType ) { return ( mediaType != null ) && MEDIA_TYPES . values ( ) . contains ( mediaType . toLowerCase ( ) ) ; } | Checks if the media type is supported by the service . |
26,056 | @ SuppressWarnings ( "unchecked" ) private static void updateEmotionTone ( Map < String , Object > user , List < ToneScore > emotionTone , boolean maintainHistory ) { Double maxScore = 0.0 ; String primaryEmotion = null ; Double primaryEmotionScore = null ; for ( ToneScore tone : emotionTone ) { if ( tone . getScore ( ) > maxScore ) { maxScore = tone . getScore ( ) ; primaryEmotion = tone . getToneName ( ) . toLowerCase ( ) ; primaryEmotionScore = tone . getScore ( ) ; } } if ( maxScore <= PRIMARY_EMOTION_SCORE_THRESHOLD ) { primaryEmotion = "neutral" ; primaryEmotionScore = null ; } Map < String , Object > emotion = ( Map < String , Object > ) ( ( Map < String , Object > ) ( user . get ( "tone" ) ) ) . get ( "emotion" ) ; emotion . put ( "current" , primaryEmotion ) ; if ( maintainHistory ) { List < Map < String , Object > > history = new ArrayList < Map < String , Object > > ( ) ; if ( emotion . get ( "history" ) != null ) { history = ( List < Map < String , Object > > ) emotion . get ( "history" ) ; } Map < String , Object > emotionHistoryObject = new HashMap < String , Object > ( ) ; emotionHistoryObject . put ( "tone_name" , primaryEmotion ) ; emotionHistoryObject . put ( "score" , primaryEmotionScore ) ; history . add ( emotionHistoryObject ) ; emotion . put ( "history" , history ) ; } } | updateEmotionTone updates the user emotion tone with the primary emotion - the emotion tone that has a score greater than or equal to the EMOTION_SCORE_THRESHOLD ; otherwise primary emotion will be neutral . |
26,057 | @ SuppressWarnings ( "unchecked" ) private static void updateLanguageTone ( Map < String , Object > user , List < ToneScore > languageTone , boolean maintainHistory ) { List < String > currentLanguage = new ArrayList < String > ( ) ; Map < String , Object > currentLanguageObject = new HashMap < String , Object > ( ) ; for ( ToneScore tone : languageTone ) { if ( tone . getScore ( ) >= LANGUAGE_HIGH_SCORE_THRESHOLD ) { currentLanguage . add ( tone . getToneName ( ) . toLowerCase ( ) + "_high" ) ; currentLanguageObject . put ( "tone_name" , tone . getToneName ( ) . toLowerCase ( ) ) ; currentLanguageObject . put ( "score" , tone . getScore ( ) ) ; currentLanguageObject . put ( "interpretation" , "likely high" ) ; } else if ( tone . getScore ( ) <= LANGUAGE_NO_SCORE_THRESHOLD ) { currentLanguageObject . put ( "tone_name" , tone . getToneName ( ) . toLowerCase ( ) ) ; currentLanguageObject . put ( "score" , tone . getScore ( ) ) ; currentLanguageObject . put ( "interpretation" , "no evidence" ) ; } else { currentLanguageObject . put ( "tone_name" , tone . getToneName ( ) . toLowerCase ( ) ) ; currentLanguageObject . put ( "score" , tone . getScore ( ) ) ; currentLanguageObject . put ( "interpretation" , "likely medium" ) ; } } Map < String , Object > language = ( Map < String , Object > ) ( ( Map < String , Object > ) user . get ( "tone" ) ) . get ( "language" ) ; language . put ( "current" , currentLanguage ) ; if ( maintainHistory ) { List < Map < String , Object > > history = new ArrayList < Map < String , Object > > ( ) ; if ( language . get ( "history" ) != null ) { history = ( List < Map < String , Object > > ) language . get ( "history" ) ; } history . add ( currentLanguageObject ) ; language . put ( "history" , history ) ; } } | updateLanguageTone updates the user with the language tones interpreted based on the specified thresholds . |
26,058 | @ SuppressWarnings ( "unchecked" ) public static void updateSocialTone ( Map < String , Object > user , List < ToneScore > socialTone , boolean maintainHistory ) { List < String > currentSocial = new ArrayList < String > ( ) ; Map < String , Object > currentSocialObject = new HashMap < String , Object > ( ) ; for ( ToneScore tone : socialTone ) { if ( tone . getScore ( ) >= SOCIAL_HIGH_SCORE_THRESHOLD ) { currentSocial . add ( tone . getToneName ( ) . toLowerCase ( ) + "_high" ) ; currentSocialObject . put ( "tone_name" , tone . getToneName ( ) . toLowerCase ( ) ) ; currentSocialObject . put ( "score" , tone . getScore ( ) ) ; currentSocialObject . put ( "interpretation" , "likely high" ) ; } else if ( tone . getScore ( ) <= SOCIAL_LOW_SCORE_THRESHOLD ) { currentSocial . add ( tone . getToneName ( ) . toLowerCase ( ) + "_low" ) ; currentSocialObject . put ( "tone_name" , tone . getToneName ( ) . toLowerCase ( ) ) ; currentSocialObject . put ( "score" , tone . getScore ( ) ) ; currentSocialObject . put ( "interpretation" , "likely low" ) ; } else { currentSocialObject . put ( "tone_name" , tone . getToneName ( ) . toLowerCase ( ) ) ; currentSocialObject . put ( "score" , tone . getScore ( ) ) ; currentSocialObject . put ( "interpretation" , "likely medium" ) ; } } Map < String , Object > social = ( Map < String , Object > ) ( ( Map < String , Object > ) user . get ( "tone" ) ) . get ( "social" ) ; social . put ( "current" , currentSocial ) ; if ( maintainHistory ) { List < Map < String , Object > > history = new ArrayList < Map < String , Object > > ( ) ; if ( social . get ( "history" ) != null ) { history = ( List < Map < String , Object > > ) social . get ( "history" ) ; } history . add ( currentSocialObject ) ; social . put ( "history" , history ) ; } } | updateSocialTone updates the user with the social tones interpreted based on the specified thresholds . |
26,059 | public ServiceCall < ClassifiedImages > classify ( ClassifyOptions classifyOptions ) { Validator . notNull ( classifyOptions , "classifyOptions cannot be null" ) ; Validator . isTrue ( ( classifyOptions . imagesFile ( ) != null ) || ( classifyOptions . url ( ) != null ) || ( classifyOptions . threshold ( ) != null ) || ( classifyOptions . owners ( ) != null ) || ( classifyOptions . classifierIds ( ) != null ) , "At least one of imagesFile, url, threshold, owners, or classifierIds must be supplied." ) ; String [ ] pathSegments = { "v3/classify" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "watson_vision_combined" , "v3" , "classify" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( classifyOptions . acceptLanguage ( ) != null ) { builder . header ( "Accept-Language" , classifyOptions . acceptLanguage ( ) ) ; } MultipartBody . Builder multipartBuilder = new MultipartBody . Builder ( ) ; multipartBuilder . setType ( MultipartBody . FORM ) ; if ( classifyOptions . imagesFile ( ) != null ) { RequestBody imagesFileBody = RequestUtils . inputStreamBody ( classifyOptions . imagesFile ( ) , classifyOptions . imagesFileContentType ( ) ) ; multipartBuilder . addFormDataPart ( "images_file" , classifyOptions . imagesFilename ( ) , imagesFileBody ) ; } if ( classifyOptions . url ( ) != null ) { multipartBuilder . addFormDataPart ( "url" , classifyOptions . url ( ) ) ; } if ( classifyOptions . threshold ( ) != null ) { multipartBuilder . addFormDataPart ( "threshold" , String . valueOf ( classifyOptions . threshold ( ) ) ) ; } if ( classifyOptions . owners ( ) != null ) { multipartBuilder . addFormDataPart ( "owners" , RequestUtils . join ( classifyOptions . owners ( ) , "," ) ) ; } if ( classifyOptions . classifierIds ( ) != null ) { multipartBuilder . addFormDataPart ( "classifier_ids" , RequestUtils . join ( classifyOptions . classifierIds ( ) , "," ) ) ; } builder . body ( multipartBuilder . build ( ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( ClassifiedImages . class ) ) ; } | Classify images . |
26,060 | public ServiceCall < DetectedFaces > detectFaces ( DetectFacesOptions detectFacesOptions ) { Validator . notNull ( detectFacesOptions , "detectFacesOptions cannot be null" ) ; Validator . isTrue ( ( detectFacesOptions . imagesFile ( ) != null ) || ( detectFacesOptions . url ( ) != null ) , "At least one of imagesFile or url must be supplied." ) ; String [ ] pathSegments = { "v3/detect_faces" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "watson_vision_combined" , "v3" , "detectFaces" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( detectFacesOptions . acceptLanguage ( ) != null ) { builder . header ( "Accept-Language" , detectFacesOptions . acceptLanguage ( ) ) ; } MultipartBody . Builder multipartBuilder = new MultipartBody . Builder ( ) ; multipartBuilder . setType ( MultipartBody . FORM ) ; if ( detectFacesOptions . imagesFile ( ) != null ) { RequestBody imagesFileBody = RequestUtils . inputStreamBody ( detectFacesOptions . imagesFile ( ) , detectFacesOptions . imagesFileContentType ( ) ) ; multipartBuilder . addFormDataPart ( "images_file" , detectFacesOptions . imagesFilename ( ) , imagesFileBody ) ; } if ( detectFacesOptions . url ( ) != null ) { multipartBuilder . addFormDataPart ( "url" , detectFacesOptions . url ( ) ) ; } builder . body ( multipartBuilder . build ( ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( DetectedFaces . class ) ) ; } | Detect faces in images . |
26,061 | public ServiceCall < Void > deleteClassifier ( DeleteClassifierOptions deleteClassifierOptions ) { Validator . notNull ( deleteClassifierOptions , "deleteClassifierOptions cannot be null" ) ; String [ ] pathSegments = { "v3/classifiers" } ; String [ ] pathParameters = { deleteClassifierOptions . classifierId ( ) } ; RequestBuilder builder = RequestBuilder . delete ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "watson_vision_combined" , "v3" , "deleteClassifier" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getVoid ( ) ) ; } | Delete a classifier . |
26,062 | public ServiceCall < Classifier > getClassifier ( GetClassifierOptions getClassifierOptions ) { Validator . notNull ( getClassifierOptions , "getClassifierOptions cannot be null" ) ; String [ ] pathSegments = { "v3/classifiers" } ; String [ ] pathParameters = { getClassifierOptions . classifierId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "watson_vision_combined" , "v3" , "getClassifier" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Classifier . class ) ) ; } | Retrieve classifier details . |
26,063 | public ServiceCall < Classifiers > listClassifiers ( ListClassifiersOptions listClassifiersOptions ) { String [ ] pathSegments = { "v3/classifiers" } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "watson_vision_combined" , "v3" , "listClassifiers" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( listClassifiersOptions != null ) { if ( listClassifiersOptions . verbose ( ) != null ) { builder . query ( "verbose" , String . valueOf ( listClassifiersOptions . verbose ( ) ) ) ; } } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Classifiers . class ) ) ; } | Retrieve a list of classifiers . |
26,064 | 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 . |
26,065 | public ServiceCall < InputStream > getCoreMlModel ( GetCoreMlModelOptions getCoreMlModelOptions ) { Validator . notNull ( getCoreMlModelOptions , "getCoreMlModelOptions cannot be null" ) ; String [ ] pathSegments = { "v3/classifiers" , "core_ml_model" } ; String [ ] pathParameters = { getCoreMlModelOptions . classifierId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "watson_vision_combined" , "v3" , "getCoreMlModel" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/octet-stream" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getInputStream ( ) ) ; } | Retrieve a Core ML model of a classifier . |
26,066 | public ServiceCall < Void > deleteUserData ( DeleteUserDataOptions deleteUserDataOptions ) { Validator . notNull ( deleteUserDataOptions , "deleteUserDataOptions cannot be null" ) ; String [ ] pathSegments = { "v3/user_data" } ; RequestBuilder builder = RequestBuilder . delete ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "watson_vision_combined" , "v3" , "deleteUserData" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; builder . query ( "customer_id" , deleteUserDataOptions . customerId ( ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getVoid ( ) ) ; } | Delete labeled data . |
26,067 | private static void writeToFile ( InputStream in , File file ) { try { OutputStream out = new FileOutputStream ( file ) ; byte [ ] buf = new byte [ 1024 ] ; int len ; while ( ( len = in . read ( buf ) ) > 0 ) { out . write ( buf , 0 , len ) ; } out . close ( ) ; in . close ( ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; } } | Write the input stream to a file . |
26,068 | public ServiceCall < AnalysisResults > analyze ( AnalyzeOptions analyzeOptions ) { Validator . notNull ( analyzeOptions , "analyzeOptions cannot be null" ) ; String [ ] pathSegments = { "v1/analyze" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "natural-language-understanding" , "v1" , "analyze" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; contentJson . add ( "features" , GsonSingleton . getGson ( ) . toJsonTree ( analyzeOptions . features ( ) ) ) ; if ( analyzeOptions . text ( ) != null ) { contentJson . addProperty ( "text" , analyzeOptions . text ( ) ) ; } if ( analyzeOptions . html ( ) != null ) { contentJson . addProperty ( "html" , analyzeOptions . html ( ) ) ; } if ( analyzeOptions . url ( ) != null ) { contentJson . addProperty ( "url" , analyzeOptions . url ( ) ) ; } if ( analyzeOptions . clean ( ) != null ) { contentJson . addProperty ( "clean" , analyzeOptions . clean ( ) ) ; } if ( analyzeOptions . xpath ( ) != null ) { contentJson . addProperty ( "xpath" , analyzeOptions . xpath ( ) ) ; } if ( analyzeOptions . fallbackToRaw ( ) != null ) { contentJson . addProperty ( "fallback_to_raw" , analyzeOptions . fallbackToRaw ( ) ) ; } if ( analyzeOptions . returnAnalyzedText ( ) != null ) { contentJson . addProperty ( "return_analyzed_text" , analyzeOptions . returnAnalyzedText ( ) ) ; } if ( analyzeOptions . language ( ) != null ) { contentJson . addProperty ( "language" , analyzeOptions . language ( ) ) ; } if ( analyzeOptions . limitTextCharacters ( ) != null ) { contentJson . addProperty ( "limit_text_characters" , analyzeOptions . limitTextCharacters ( ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( AnalysisResults . class ) ) ; } | Analyze text . |
26,069 | private String buildStopMessage ( ) { JsonObject stopMessage = new JsonObject ( ) ; stopMessage . addProperty ( ACTION , STOP ) ; return stopMessage . toString ( ) ; } | Builds the stop message . |
26,070 | private void parseArray ( JsonReader in , HashMap < String , Object > objMap , String name ) throws IOException { List < HashMap < String , Object > > array = new ArrayList < > ( ) ; in . beginArray ( ) ; while ( in . peek ( ) != JsonToken . END_ARRAY ) { HashMap < String , Object > arrayItem = new HashMap < > ( ) ; parseNext ( in , arrayItem ) ; array . add ( arrayItem ) ; } in . endArray ( ) ; objMap . put ( name , array ) ; } | Parses a JSON array and adds it to the main object map . |
26,071 | private void parseObject ( JsonReader in , HashMap < String , Object > objMap , String name ) throws IOException { HashMap < String , Object > innerObject = new HashMap < > ( ) ; in . beginObject ( ) ; while ( in . peek ( ) != JsonToken . END_OBJECT ) { parseNext ( in , innerObject ) ; } in . endObject ( ) ; objMap . put ( name , innerObject ) ; } | Parses a JSON object and adds it to the main object map . |
26,072 | private void collapseMap ( HashMap < String , Object > objMap ) { while ( objMap . keySet ( ) . size ( ) == 1 && objMap . keySet ( ) . contains ( "" ) ) { HashMap < String , Object > innerMap = ( HashMap < String , Object > ) objMap . get ( "" ) ; objMap . clear ( ) ; objMap . putAll ( innerMap ) ; } } | Condenses the main object map to eliminate unnecessary nesting and allow for proper type conversion when the map is complete . |
26,073 | public ServiceCall < Profile > profile ( ProfileOptions profileOptions ) { Validator . notNull ( profileOptions , "profileOptions cannot be null" ) ; String [ ] pathSegments = { "v3/profile" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "personality_insights" , "v3" , "profile" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( profileOptions . contentLanguage ( ) != null ) { builder . header ( "Content-Language" , profileOptions . contentLanguage ( ) ) ; } if ( profileOptions . acceptLanguage ( ) != null ) { builder . header ( "Accept-Language" , profileOptions . acceptLanguage ( ) ) ; } if ( profileOptions . contentType ( ) != null ) { builder . header ( "Content-Type" , profileOptions . contentType ( ) ) ; } if ( profileOptions . rawScores ( ) != null ) { builder . query ( "raw_scores" , String . valueOf ( profileOptions . rawScores ( ) ) ) ; } if ( profileOptions . csvHeaders ( ) != null ) { builder . query ( "csv_headers" , String . valueOf ( profileOptions . csvHeaders ( ) ) ) ; } if ( profileOptions . consumptionPreferences ( ) != null ) { builder . query ( "consumption_preferences" , String . valueOf ( profileOptions . consumptionPreferences ( ) ) ) ; } builder . bodyContent ( profileOptions . contentType ( ) , profileOptions . content ( ) , null , profileOptions . body ( ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Profile . class ) ) ; } | Get profile . |
26,074 | private void sendInputStream ( InputStream inputStream ) { byte [ ] buffer = new byte [ ONE_KB ] ; int read ; try { while ( ( ( read = inputStream . read ( buffer ) ) > 0 ) && socketOpen ) { while ( socket . queueSize ( ) > QUEUE_SIZE_LIMIT ) { Thread . sleep ( QUEUE_WAIT_MILLIS ) ; } if ( read == ONE_KB ) { socket . send ( ByteString . of ( buffer ) ) ; } else { socket . send ( ByteString . of ( Arrays . copyOfRange ( buffer , 0 , read ) ) ) ; } } } catch ( IOException | InterruptedException e ) { LOG . log ( Level . SEVERE , e . getMessage ( ) , e ) ; } finally { try { inputStream . close ( ) ; } catch ( IOException e ) { } } } | Send input stream . |
26,075 | public ServiceCall < Environment > createEnvironment ( CreateEnvironmentOptions createEnvironmentOptions ) { Validator . notNull ( createEnvironmentOptions , "createEnvironmentOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "createEnvironment" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; contentJson . addProperty ( "name" , createEnvironmentOptions . name ( ) ) ; if ( createEnvironmentOptions . description ( ) != null ) { contentJson . addProperty ( "description" , createEnvironmentOptions . description ( ) ) ; } if ( createEnvironmentOptions . size ( ) != null ) { contentJson . addProperty ( "size" , createEnvironmentOptions . size ( ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Environment . class ) ) ; } | Create an environment . |
26,076 | public ServiceCall < Environment > getEnvironment ( GetEnvironmentOptions getEnvironmentOptions ) { Validator . notNull ( getEnvironmentOptions , "getEnvironmentOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" } ; String [ ] pathParameters = { getEnvironmentOptions . environmentId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "getEnvironment" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Environment . class ) ) ; } | Get environment info . |
26,077 | public ServiceCall < ListEnvironmentsResponse > listEnvironments ( ListEnvironmentsOptions listEnvironmentsOptions ) { String [ ] pathSegments = { "v1/environments" } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "listEnvironments" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( listEnvironmentsOptions != null ) { if ( listEnvironmentsOptions . name ( ) != null ) { builder . query ( "name" , listEnvironmentsOptions . name ( ) ) ; } } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( ListEnvironmentsResponse . class ) ) ; } | List environments . |
26,078 | public ServiceCall < ListCollectionFieldsResponse > listFields ( ListFieldsOptions listFieldsOptions ) { Validator . notNull ( listFieldsOptions , "listFieldsOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "fields" } ; String [ ] pathParameters = { listFieldsOptions . environmentId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "listFields" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; builder . query ( "collection_ids" , RequestUtils . join ( listFieldsOptions . collectionIds ( ) , "," ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( ListCollectionFieldsResponse . class ) ) ; } | List fields across collections . |
26,079 | public ServiceCall < Configuration > getConfiguration ( GetConfigurationOptions getConfigurationOptions ) { Validator . notNull ( getConfigurationOptions , "getConfigurationOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "configurations" } ; String [ ] pathParameters = { getConfigurationOptions . environmentId ( ) , getConfigurationOptions . configurationId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "getConfiguration" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Configuration . class ) ) ; } | Get configuration details . |
26,080 | public ServiceCall < ListConfigurationsResponse > listConfigurations ( ListConfigurationsOptions listConfigurationsOptions ) { Validator . notNull ( listConfigurationsOptions , "listConfigurationsOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "configurations" } ; String [ ] pathParameters = { listConfigurationsOptions . environmentId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "listConfigurations" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( listConfigurationsOptions . name ( ) != null ) { builder . query ( "name" , listConfigurationsOptions . name ( ) ) ; } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( ListConfigurationsResponse . class ) ) ; } | List configurations . |
26,081 | public ServiceCall < Configuration > updateConfiguration ( UpdateConfigurationOptions updateConfigurationOptions ) { Validator . notNull ( updateConfigurationOptions , "updateConfigurationOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "configurations" } ; String [ ] pathParameters = { updateConfigurationOptions . environmentId ( ) , updateConfigurationOptions . configurationId ( ) } ; RequestBuilder builder = RequestBuilder . put ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "updateConfiguration" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; contentJson . addProperty ( "name" , updateConfigurationOptions . name ( ) ) ; if ( updateConfigurationOptions . description ( ) != null ) { contentJson . addProperty ( "description" , updateConfigurationOptions . description ( ) ) ; } if ( updateConfigurationOptions . conversions ( ) != null ) { contentJson . add ( "conversions" , GsonSingleton . getGson ( ) . toJsonTree ( updateConfigurationOptions . conversions ( ) ) ) ; } if ( updateConfigurationOptions . enrichments ( ) != null ) { contentJson . add ( "enrichments" , GsonSingleton . getGson ( ) . toJsonTree ( updateConfigurationOptions . enrichments ( ) ) ) ; } if ( updateConfigurationOptions . normalizations ( ) != null ) { contentJson . add ( "normalizations" , GsonSingleton . getGson ( ) . toJsonTree ( updateConfigurationOptions . normalizations ( ) ) ) ; } if ( updateConfigurationOptions . source ( ) != null ) { contentJson . add ( "source" , GsonSingleton . getGson ( ) . toJsonTree ( updateConfigurationOptions . source ( ) ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Configuration . class ) ) ; } | Update a configuration . |
26,082 | public ServiceCall < Collection > createCollection ( CreateCollectionOptions createCollectionOptions ) { Validator . notNull ( createCollectionOptions , "createCollectionOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" } ; String [ ] pathParameters = { createCollectionOptions . environmentId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "createCollection" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; contentJson . addProperty ( "name" , createCollectionOptions . name ( ) ) ; if ( createCollectionOptions . description ( ) != null ) { contentJson . addProperty ( "description" , createCollectionOptions . description ( ) ) ; } if ( createCollectionOptions . configurationId ( ) != null ) { contentJson . addProperty ( "configuration_id" , createCollectionOptions . configurationId ( ) ) ; } if ( createCollectionOptions . language ( ) != null ) { contentJson . addProperty ( "language" , createCollectionOptions . language ( ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Collection . class ) ) ; } | Create a collection . |
26,083 | public ServiceCall < Collection > getCollection ( GetCollectionOptions getCollectionOptions ) { Validator . notNull ( getCollectionOptions , "getCollectionOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" } ; String [ ] pathParameters = { getCollectionOptions . environmentId ( ) , getCollectionOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "getCollection" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Collection . class ) ) ; } | Get collection details . |
26,084 | public ServiceCall < ListCollectionFieldsResponse > listCollectionFields ( ListCollectionFieldsOptions listCollectionFieldsOptions ) { Validator . notNull ( listCollectionFieldsOptions , "listCollectionFieldsOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "fields" } ; String [ ] pathParameters = { listCollectionFieldsOptions . environmentId ( ) , listCollectionFieldsOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "listCollectionFields" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( ListCollectionFieldsResponse . class ) ) ; } | List collection fields . |
26,085 | public ServiceCall < ListCollectionsResponse > listCollections ( ListCollectionsOptions listCollectionsOptions ) { Validator . notNull ( listCollectionsOptions , "listCollectionsOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" } ; String [ ] pathParameters = { listCollectionsOptions . environmentId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "listCollections" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; if ( listCollectionsOptions . name ( ) != null ) { builder . query ( "name" , listCollectionsOptions . name ( ) ) ; } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( ListCollectionsResponse . class ) ) ; } | List collections . |
26,086 | public ServiceCall < Collection > updateCollection ( UpdateCollectionOptions updateCollectionOptions ) { Validator . notNull ( updateCollectionOptions , "updateCollectionOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" } ; String [ ] pathParameters = { updateCollectionOptions . environmentId ( ) , updateCollectionOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . put ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "updateCollection" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; if ( updateCollectionOptions . name ( ) != null ) { contentJson . addProperty ( "name" , updateCollectionOptions . name ( ) ) ; } if ( updateCollectionOptions . description ( ) != null ) { contentJson . addProperty ( "description" , updateCollectionOptions . description ( ) ) ; } if ( updateCollectionOptions . configurationId ( ) != null ) { contentJson . addProperty ( "configuration_id" , updateCollectionOptions . configurationId ( ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Collection . class ) ) ; } | Update a collection . |
26,087 | public ServiceCall < Expansions > createExpansions ( CreateExpansionsOptions createExpansionsOptions ) { Validator . notNull ( createExpansionsOptions , "createExpansionsOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "expansions" } ; String [ ] pathParameters = { createExpansionsOptions . environmentId ( ) , createExpansionsOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "createExpansions" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; contentJson . add ( "expansions" , GsonSingleton . getGson ( ) . toJsonTree ( createExpansionsOptions . expansions ( ) ) ) ; builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Expansions . class ) ) ; } | Create or update expansion list . |
26,088 | public ServiceCall < TokenDictStatusResponse > createStopwordList ( CreateStopwordListOptions createStopwordListOptions ) { Validator . notNull ( createStopwordListOptions , "createStopwordListOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "word_lists/stopwords" } ; String [ ] pathParameters = { createStopwordListOptions . environmentId ( ) , createStopwordListOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "createStopwordList" ) ; 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 ) ; RequestBody stopwordFileBody = RequestUtils . inputStreamBody ( createStopwordListOptions . stopwordFile ( ) , "application/octet-stream" ) ; multipartBuilder . addFormDataPart ( "stopword_file" , createStopwordListOptions . stopwordFilename ( ) , stopwordFileBody ) ; builder . body ( multipartBuilder . build ( ) ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( TokenDictStatusResponse . class ) ) ; } | Create stopword list . |
26,089 | public ServiceCall < TokenDictStatusResponse > createTokenizationDictionary ( CreateTokenizationDictionaryOptions createTokenizationDictionaryOptions ) { Validator . notNull ( createTokenizationDictionaryOptions , "createTokenizationDictionaryOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "word_lists/tokenization_dictionary" } ; String [ ] pathParameters = { createTokenizationDictionaryOptions . environmentId ( ) , createTokenizationDictionaryOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "createTokenizationDictionary" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; if ( createTokenizationDictionaryOptions . tokenizationRules ( ) != null ) { contentJson . add ( "tokenization_rules" , GsonSingleton . getGson ( ) . toJsonTree ( createTokenizationDictionaryOptions . tokenizationRules ( ) ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( TokenDictStatusResponse . class ) ) ; } | Create tokenization dictionary . |
26,090 | public ServiceCall < Void > deleteExpansions ( DeleteExpansionsOptions deleteExpansionsOptions ) { Validator . notNull ( deleteExpansionsOptions , "deleteExpansionsOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "expansions" } ; String [ ] pathParameters = { deleteExpansionsOptions . environmentId ( ) , deleteExpansionsOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . delete ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "deleteExpansions" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getVoid ( ) ) ; } | Delete the expansion list . |
26,091 | public ServiceCall < TokenDictStatusResponse > getTokenizationDictionaryStatus ( GetTokenizationDictionaryStatusOptions getTokenizationDictionaryStatusOptions ) { Validator . notNull ( getTokenizationDictionaryStatusOptions , "getTokenizationDictionaryStatusOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "word_lists/tokenization_dictionary" } ; String [ ] pathParameters = { getTokenizationDictionaryStatusOptions . environmentId ( ) , getTokenizationDictionaryStatusOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "getTokenizationDictionaryStatus" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( TokenDictStatusResponse . class ) ) ; } | Get tokenization dictionary status . |
26,092 | public ServiceCall < Expansions > listExpansions ( ListExpansionsOptions listExpansionsOptions ) { Validator . notNull ( listExpansionsOptions , "listExpansionsOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "expansions" } ; String [ ] pathParameters = { listExpansionsOptions . environmentId ( ) , listExpansionsOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "listExpansions" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( Expansions . class ) ) ; } | Get the expansion list . |
26,093 | public ServiceCall < DocumentStatus > getDocumentStatus ( GetDocumentStatusOptions getDocumentStatusOptions ) { Validator . notNull ( getDocumentStatusOptions , "getDocumentStatusOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "documents" } ; String [ ] pathParameters = { getDocumentStatusOptions . environmentId ( ) , getDocumentStatusOptions . collectionId ( ) , getDocumentStatusOptions . documentId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "getDocumentStatus" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( DocumentStatus . class ) ) ; } | Get document details . |
26,094 | public ServiceCall < QueryEntitiesResponse > queryEntities ( QueryEntitiesOptions queryEntitiesOptions ) { Validator . notNull ( queryEntitiesOptions , "queryEntitiesOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "query_entities" } ; String [ ] pathParameters = { queryEntitiesOptions . environmentId ( ) , queryEntitiesOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "queryEntities" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; if ( queryEntitiesOptions . feature ( ) != null ) { contentJson . addProperty ( "feature" , queryEntitiesOptions . feature ( ) ) ; } if ( queryEntitiesOptions . entity ( ) != null ) { contentJson . add ( "entity" , GsonSingleton . getGson ( ) . toJsonTree ( queryEntitiesOptions . entity ( ) ) ) ; } if ( queryEntitiesOptions . context ( ) != null ) { contentJson . add ( "context" , GsonSingleton . getGson ( ) . toJsonTree ( queryEntitiesOptions . context ( ) ) ) ; } if ( queryEntitiesOptions . count ( ) != null ) { contentJson . addProperty ( "count" , queryEntitiesOptions . count ( ) ) ; } if ( queryEntitiesOptions . evidenceCount ( ) != null ) { contentJson . addProperty ( "evidence_count" , queryEntitiesOptions . evidenceCount ( ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( QueryEntitiesResponse . class ) ) ; } | Knowledge Graph entity query . |
26,095 | public ServiceCall < QueryRelationsResponse > queryRelations ( QueryRelationsOptions queryRelationsOptions ) { Validator . notNull ( queryRelationsOptions , "queryRelationsOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "query_relations" } ; String [ ] pathParameters = { queryRelationsOptions . environmentId ( ) , queryRelationsOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "queryRelations" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; if ( queryRelationsOptions . entities ( ) != null ) { contentJson . add ( "entities" , GsonSingleton . getGson ( ) . toJsonTree ( queryRelationsOptions . entities ( ) ) ) ; } if ( queryRelationsOptions . context ( ) != null ) { contentJson . add ( "context" , GsonSingleton . getGson ( ) . toJsonTree ( queryRelationsOptions . context ( ) ) ) ; } if ( queryRelationsOptions . sort ( ) != null ) { contentJson . addProperty ( "sort" , queryRelationsOptions . sort ( ) ) ; } if ( queryRelationsOptions . filter ( ) != null ) { contentJson . add ( "filter" , GsonSingleton . getGson ( ) . toJsonTree ( queryRelationsOptions . filter ( ) ) ) ; } if ( queryRelationsOptions . count ( ) != null ) { contentJson . addProperty ( "count" , queryRelationsOptions . count ( ) ) ; } if ( queryRelationsOptions . evidenceCount ( ) != null ) { contentJson . addProperty ( "evidence_count" , queryRelationsOptions . evidenceCount ( ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( QueryRelationsResponse . class ) ) ; } | Knowledge Graph relationship query . |
26,096 | public ServiceCall < TrainingQuery > addTrainingData ( AddTrainingDataOptions addTrainingDataOptions ) { Validator . notNull ( addTrainingDataOptions , "addTrainingDataOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "training_data" } ; String [ ] pathParameters = { addTrainingDataOptions . environmentId ( ) , addTrainingDataOptions . collectionId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "addTrainingData" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; if ( addTrainingDataOptions . naturalLanguageQuery ( ) != null ) { contentJson . addProperty ( "natural_language_query" , addTrainingDataOptions . naturalLanguageQuery ( ) ) ; } if ( addTrainingDataOptions . filter ( ) != null ) { contentJson . addProperty ( "filter" , addTrainingDataOptions . filter ( ) ) ; } if ( addTrainingDataOptions . examples ( ) != null ) { contentJson . add ( "examples" , GsonSingleton . getGson ( ) . toJsonTree ( addTrainingDataOptions . examples ( ) ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( TrainingQuery . class ) ) ; } | Add query to training data . |
26,097 | public ServiceCall < TrainingExample > createTrainingExample ( CreateTrainingExampleOptions createTrainingExampleOptions ) { Validator . notNull ( createTrainingExampleOptions , "createTrainingExampleOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "training_data" , "examples" } ; String [ ] pathParameters = { createTrainingExampleOptions . environmentId ( ) , createTrainingExampleOptions . collectionId ( ) , createTrainingExampleOptions . queryId ( ) } ; RequestBuilder builder = RequestBuilder . post ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "createTrainingExample" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; final JsonObject contentJson = new JsonObject ( ) ; if ( createTrainingExampleOptions . documentId ( ) != null ) { contentJson . addProperty ( "document_id" , createTrainingExampleOptions . documentId ( ) ) ; } if ( createTrainingExampleOptions . crossReference ( ) != null ) { contentJson . addProperty ( "cross_reference" , createTrainingExampleOptions . crossReference ( ) ) ; } if ( createTrainingExampleOptions . relevance ( ) != null ) { contentJson . addProperty ( "relevance" , createTrainingExampleOptions . relevance ( ) ) ; } builder . bodyJson ( contentJson ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( TrainingExample . class ) ) ; } | Add example to training data query . |
26,098 | public ServiceCall < TrainingQuery > getTrainingData ( GetTrainingDataOptions getTrainingDataOptions ) { Validator . notNull ( getTrainingDataOptions , "getTrainingDataOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "training_data" } ; String [ ] pathParameters = { getTrainingDataOptions . environmentId ( ) , getTrainingDataOptions . collectionId ( ) , getTrainingDataOptions . queryId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "getTrainingData" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( TrainingQuery . class ) ) ; } | Get details about a query . |
26,099 | public ServiceCall < TrainingExample > getTrainingExample ( GetTrainingExampleOptions getTrainingExampleOptions ) { Validator . notNull ( getTrainingExampleOptions , "getTrainingExampleOptions cannot be null" ) ; String [ ] pathSegments = { "v1/environments" , "collections" , "training_data" , "examples" } ; String [ ] pathParameters = { getTrainingExampleOptions . environmentId ( ) , getTrainingExampleOptions . collectionId ( ) , getTrainingExampleOptions . queryId ( ) , getTrainingExampleOptions . exampleId ( ) } ; RequestBuilder builder = RequestBuilder . get ( RequestBuilder . constructHttpUrl ( getEndPoint ( ) , pathSegments , pathParameters ) ) ; builder . query ( "version" , versionDate ) ; Map < String , String > sdkHeaders = SdkCommon . getSdkHeaders ( "discovery" , "v1" , "getTrainingExample" ) ; for ( Entry < String , String > header : sdkHeaders . entrySet ( ) ) { builder . header ( header . getKey ( ) , header . getValue ( ) ) ; } builder . header ( "Accept" , "application/json" ) ; return createServiceCall ( builder . build ( ) , ResponseConverterUtils . getObject ( TrainingExample . class ) ) ; } | Get details for training data example . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.