11/*
2- * Copyright 2018 IBM Corp. All Rights Reserved .
2+ * (C) Copyright IBM Corp. 2019 .
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
55 * the License. You may obtain a copy of the License at
1616import com .ibm .cloud .sdk .core .http .RequestBuilder ;
1717import com .ibm .cloud .sdk .core .http .ResponseConverter ;
1818import com .ibm .cloud .sdk .core .http .ServiceCall ;
19- import com .ibm .cloud .sdk .core .security .AuthenticatorConfig ;
19+ import com .ibm .cloud .sdk .core .security .Authenticator ;
2020import com .ibm .cloud .sdk .core .service .BaseService ;
21- import com .ibm .cloud .sdk .core .util .GsonSingleton ;
2221import com .ibm .cloud .sdk .core .util .ResponseConverterUtils ;
23- import com .ibm .cloud .sdk .core .util .Validator ;
2422import com .ibm .watson .assistant .v2 .model .CreateSessionOptions ;
2523import com .ibm .watson .assistant .v2 .model .DeleteSessionOptions ;
2624import com .ibm .watson .assistant .v2 .model .MessageOptions ;
3533 * dialog editor to create conversation flows between your apps and your users.
3634 *
3735 * @version v2
38- * @see <a href="http ://www .ibm.com/watson/developercloud /assistant.html ">Assistant</a>
36+ * @see <a href="https ://cloud .ibm.com/docs/services /assistant/ ">Assistant</a>
3937 */
4038public class Assistant extends BaseService {
4139
@@ -45,54 +43,19 @@ public class Assistant extends BaseService {
4543 private String versionDate ;
4644
4745 /**
48- * Instantiates a new `Assistant`.
46+ * Constructs a new `Assistant` client with the specified Authenticator .
4947 *
5048 * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API
5149 * calls from failing when the service introduces breaking changes.
52- * @deprecated Use Assistant(String versionDate, AuthenticatorConfig authenticatorConfig) instead
50+ * @param authenticator the Authenticator instance to be configured for this service
5351 */
54- @ Deprecated
55- public Assistant (String versionDate ) {
56- super (SERVICE_NAME );
52+ public Assistant (String versionDate , Authenticator authenticator ) {
53+ super (SERVICE_NAME , authenticator );
5754 if ((getEndPoint () == null ) || getEndPoint ().isEmpty ()) {
5855 setEndPoint (URL );
5956 }
60-
61- Validator .isTrue ((versionDate != null ) && !versionDate .isEmpty (), "version cannot be null." );
62-
63- this .versionDate = versionDate ;
64- }
65-
66- /**
67- * Instantiates a new `Assistant` with username and password.
68- *
69- * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API
70- * calls from failing when the service introduces breaking changes.
71- * @param username the username
72- * @param password the password
73- * @deprecated Use Assistant(String versionDate, AuthenticatorConfig authenticatorConfig) instead
74- */
75- @ Deprecated
76- public Assistant (String versionDate , String username , String password ) {
77- this (versionDate );
78- setUsernameAndPassword (username , password );
79- }
80-
81- /**
82- * Instantiates a new `Assistant` with the specified authentication configuration.
83- *
84- * @param versionDate The version date (yyyy-MM-dd) of the REST API to use. Specifying this value will keep your API
85- * calls from failing when the service introduces breaking changes.
86- * @param authenticatorConfig the authentication configuration for this service
87- */
88- public Assistant (String versionDate , AuthenticatorConfig authenticatorConfig ) {
89- super (SERVICE_NAME );
90- if ((getEndPoint () == null ) || getEndPoint ().isEmpty ()) {
91- setEndPoint (URL );
92- }
93- setAuthenticator (authenticatorConfig );
94-
95- Validator .isTrue ((versionDate != null ) && !versionDate .isEmpty (), "version cannot be null." );
57+ com .ibm .cloud .sdk .core .util .Validator .isTrue ((versionDate != null ) && !versionDate .isEmpty (),
58+ "version cannot be null." );
9659 this .versionDate = versionDate ;
9760 }
9861
@@ -106,7 +69,8 @@ public Assistant(String versionDate, AuthenticatorConfig authenticatorConfig) {
10669 * @return a {@link ServiceCall} with a response type of {@link SessionResponse}
10770 */
10871 public ServiceCall <SessionResponse > createSession (CreateSessionOptions createSessionOptions ) {
109- Validator .notNull (createSessionOptions , "createSessionOptions cannot be null" );
72+ com .ibm .cloud .sdk .core .util .Validator .notNull (createSessionOptions ,
73+ "createSessionOptions cannot be null" );
11074 String [] pathSegments = { "v2/assistants" , "sessions" };
11175 String [] pathParameters = { createSessionOptions .assistantId () };
11276 RequestBuilder builder = RequestBuilder .post (RequestBuilder .constructHttpUrl (getEndPoint (), pathSegments ,
@@ -132,7 +96,8 @@ public ServiceCall<SessionResponse> createSession(CreateSessionOptions createSes
13296 * @return a {@link ServiceCall} with a response type of Void
13397 */
13498 public ServiceCall <Void > deleteSession (DeleteSessionOptions deleteSessionOptions ) {
135- Validator .notNull (deleteSessionOptions , "deleteSessionOptions cannot be null" );
99+ com .ibm .cloud .sdk .core .util .Validator .notNull (deleteSessionOptions ,
100+ "deleteSessionOptions cannot be null" );
136101 String [] pathSegments = { "v2/assistants" , "sessions" };
137102 String [] pathParameters = { deleteSessionOptions .assistantId (), deleteSessionOptions .sessionId () };
138103 RequestBuilder builder = RequestBuilder .delete (RequestBuilder .constructHttpUrl (getEndPoint (), pathSegments ,
@@ -158,7 +123,8 @@ public ServiceCall<Void> deleteSession(DeleteSessionOptions deleteSessionOptions
158123 * @return a {@link ServiceCall} with a response type of {@link MessageResponse}
159124 */
160125 public ServiceCall <MessageResponse > message (MessageOptions messageOptions ) {
161- Validator .notNull (messageOptions , "messageOptions cannot be null" );
126+ com .ibm .cloud .sdk .core .util .Validator .notNull (messageOptions ,
127+ "messageOptions cannot be null" );
162128 String [] pathSegments = { "v2/assistants" , "sessions" , "message" };
163129 String [] pathParameters = { messageOptions .assistantId (), messageOptions .sessionId () };
164130 RequestBuilder builder = RequestBuilder .post (RequestBuilder .constructHttpUrl (getEndPoint (), pathSegments ,
@@ -171,10 +137,11 @@ public ServiceCall<MessageResponse> message(MessageOptions messageOptions) {
171137 builder .header ("Accept" , "application/json" );
172138 final JsonObject contentJson = new JsonObject ();
173139 if (messageOptions .input () != null ) {
174- contentJson .add ("input" , GsonSingleton .getGson ().toJsonTree (messageOptions .input ()));
140+ contentJson .add ("input" , com . ibm . cloud . sdk . core . util . GsonSingleton .getGson ().toJsonTree (messageOptions .input ()));
175141 }
176142 if (messageOptions .context () != null ) {
177- contentJson .add ("context" , GsonSingleton .getGson ().toJsonTree (messageOptions .context ()));
143+ contentJson .add ("context" , com .ibm .cloud .sdk .core .util .GsonSingleton .getGson ().toJsonTree (messageOptions
144+ .context ()));
178145 }
179146 builder .bodyJson (contentJson );
180147 ResponseConverter <MessageResponse > responseConverter = ResponseConverterUtils .getValue (
0 commit comments