@@ -32,7 +32,7 @@ namespace IBM.Watson.Assistant.V2
3232 public partial class AssistantService : BaseService
3333 {
3434 private const string serviceId = "assistant" ;
35- private const string defaultServiceUrl = "https://gateway.watsonplatform.net/ assistant/api " ;
35+ private const string defaultServiceUrl = "https://api.us-south. assistant.watson.cloud.ibm.com " ;
3636
3737 #region VersionDate
3838 private string versionDate ;
@@ -246,8 +246,6 @@ private void OnDeleteSessionResponse(RESTConnector.Request req, RESTConnector.Re
246246 ///
247247 /// Send user input to an assistant and receive a response, with conversation state (including context data)
248248 /// stored by Watson Assistant for the duration of the session.
249- ///
250- /// There is no rate limit for this operation.
251249 /// </summary>
252250 /// <param name="callback">The callback function that is invoked when the operation completes.</param>
253251 /// <param name="assistantId">Unique identifier of the assistant. To find the assistant ID in the Watson
@@ -341,8 +339,6 @@ private void OnMessageResponse(RESTConnector.Request req, RESTConnector.Response
341339 ///
342340 /// Send user input to an assistant and receive a response, with conversation state (including context data)
343341 /// managed by your application.
344- ///
345- /// There is no rate limit for this operation.
346342 /// </summary>
347343 /// <param name="callback">The callback function that is invoked when the operation completes.</param>
348344 /// <param name="assistantId">Unique identifier of the assistant. To find the assistant ID in the Watson
@@ -427,5 +423,183 @@ private void OnMessageStatelessResponse(RESTConnector.Request req, RESTConnector
427423 if ( ( ( RequestObject < MessageResponseStateless > ) req ) . Callback != null )
428424 ( ( RequestObject < MessageResponseStateless > ) req ) . Callback ( response , resp . Error ) ;
429425 }
426+ /// <summary>
427+ /// List log events for an assistant.
428+ ///
429+ /// List the events from the log of an assistant.
430+ ///
431+ /// This method is available only with Premium plans.
432+ /// </summary>
433+ /// <param name="callback">The callback function that is invoked when the operation completes.</param>
434+ /// <param name="assistantId">Unique identifier of the assistant. To find the assistant ID in the Watson
435+ /// Assistant user interface, open the assistant settings and click **API Details**. For information about
436+ /// creating assistants, see the
437+ /// [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-assistant-add#assistant-add-task).
438+ ///
439+ /// **Note:** Currently, the v2 API does not support creating assistants.</param>
440+ /// <param name="sort">How to sort the returned log events. You can sort by **request_timestamp**. To reverse
441+ /// the sort order, prefix the parameter value with a minus sign (`-`). (optional)</param>
442+ /// <param name="filter">A cacheable parameter that limits the results to those matching the specified filter.
443+ /// For more information, see the
444+ /// [documentation](https://cloud.ibm.com/docs/assistant?topic=assistant-filter-reference#filter-reference).
445+ /// (optional)</param>
446+ /// <param name="pageLimit">The number of records to return in each page of results. (optional)</param>
447+ /// <param name="cursor">A token identifying the page of results to retrieve. (optional)</param>
448+ /// <returns><see cref="LogCollection" />LogCollection</returns>
449+ public bool ListLogs ( Callback < LogCollection > callback , string assistantId , string sort = null , string filter = null , long ? pageLimit = null , string cursor = null )
450+ {
451+ if ( callback == null )
452+ throw new ArgumentNullException ( "`callback` is required for `ListLogs`" ) ;
453+ if ( string . IsNullOrEmpty ( assistantId ) )
454+ throw new ArgumentNullException ( "`assistantId` is required for `ListLogs`" ) ;
455+
456+ RequestObject < LogCollection > req = new RequestObject < LogCollection >
457+ {
458+ Callback = callback ,
459+ HttpMethod = UnityWebRequest . kHttpVerbGET ,
460+ DisableSslVerification = DisableSslVerification
461+ } ;
462+
463+ foreach ( KeyValuePair < string , string > kvp in customRequestHeaders )
464+ {
465+ req . Headers . Add ( kvp . Key , kvp . Value ) ;
466+ }
467+
468+ ClearCustomRequestHeaders ( ) ;
469+
470+ foreach ( KeyValuePair < string , string > kvp in Common . GetSdkHeaders ( "conversation" , "V2" , "ListLogs" ) )
471+ {
472+ req . Headers . Add ( kvp . Key , kvp . Value ) ;
473+ }
474+
475+ req . Parameters [ "version" ] = VersionDate ;
476+ if ( ! string . IsNullOrEmpty ( sort ) )
477+ {
478+ req . Parameters [ "sort" ] = sort ;
479+ }
480+ if ( ! string . IsNullOrEmpty ( filter ) )
481+ {
482+ req . Parameters [ "filter" ] = filter ;
483+ }
484+ if ( pageLimit != null )
485+ {
486+ req . Parameters [ "page_limit" ] = pageLimit ;
487+ }
488+ if ( ! string . IsNullOrEmpty ( cursor ) )
489+ {
490+ req . Parameters [ "cursor" ] = cursor ;
491+ }
492+
493+ req . OnResponse = OnListLogsResponse ;
494+
495+ Connector . URL = GetServiceUrl ( ) + string . Format ( "/v2/assistants/{0}/logs" , assistantId ) ;
496+ Authenticator . Authenticate ( Connector ) ;
497+
498+ return Connector . Send ( req ) ;
499+ }
500+
501+ private void OnListLogsResponse ( RESTConnector . Request req , RESTConnector . Response resp )
502+ {
503+ DetailedResponse < LogCollection > response = new DetailedResponse < LogCollection > ( ) ;
504+ foreach ( KeyValuePair < string , string > kvp in resp . Headers )
505+ {
506+ response . Headers . Add ( kvp . Key , kvp . Value ) ;
507+ }
508+ response . StatusCode = resp . HttpResponseCode ;
509+
510+ try
511+ {
512+ string json = Encoding . UTF8 . GetString ( resp . Data ) ;
513+ response . Result = JsonConvert . DeserializeObject < LogCollection > ( json ) ;
514+ response . Response = json ;
515+ }
516+ catch ( Exception e )
517+ {
518+ Log . Error ( "AssistantService.OnListLogsResponse()" , "Exception: {0}" , e . ToString ( ) ) ;
519+ resp . Success = false ;
520+ }
521+
522+ if ( ( ( RequestObject < LogCollection > ) req ) . Callback != null )
523+ ( ( RequestObject < LogCollection > ) req ) . Callback ( response , resp . Error ) ;
524+ }
525+ /// <summary>
526+ /// Delete labeled data.
527+ ///
528+ /// Deletes all data associated with a specified customer ID. The method has no effect if no data is associated
529+ /// with the customer ID.
530+ ///
531+ /// You associate a customer ID with data by passing the `X-Watson-Metadata` header with a request that passes
532+ /// data. For more information about personal data and customer IDs, see [Information
533+ /// security](https://cloud.ibm.com/docs/assistant?topic=assistant-information-security#information-security).
534+ ///
535+ /// This operation is limited to 4 requests per minute. For more information, see **Rate limiting**.
536+ /// </summary>
537+ /// <param name="callback">The callback function that is invoked when the operation completes.</param>
538+ /// <param name="customerId">The customer ID for which all data is to be deleted.</param>
539+ /// <returns><see cref="object" />object</returns>
540+ public bool DeleteUserData ( Callback < object > callback , string customerId )
541+ {
542+ if ( callback == null )
543+ throw new ArgumentNullException ( "`callback` is required for `DeleteUserData`" ) ;
544+ if ( string . IsNullOrEmpty ( customerId ) )
545+ throw new ArgumentNullException ( "`customerId` is required for `DeleteUserData`" ) ;
546+
547+ RequestObject < object > req = new RequestObject < object >
548+ {
549+ Callback = callback ,
550+ HttpMethod = UnityWebRequest . kHttpVerbDELETE ,
551+ DisableSslVerification = DisableSslVerification
552+ } ;
553+
554+ foreach ( KeyValuePair < string , string > kvp in customRequestHeaders )
555+ {
556+ req . Headers . Add ( kvp . Key , kvp . Value ) ;
557+ }
558+
559+ ClearCustomRequestHeaders ( ) ;
560+
561+ foreach ( KeyValuePair < string , string > kvp in Common . GetSdkHeaders ( "conversation" , "V2" , "DeleteUserData" ) )
562+ {
563+ req . Headers . Add ( kvp . Key , kvp . Value ) ;
564+ }
565+
566+ req . Parameters [ "version" ] = VersionDate ;
567+ if ( ! string . IsNullOrEmpty ( customerId ) )
568+ {
569+ req . Parameters [ "customer_id" ] = customerId ;
570+ }
571+
572+ req . OnResponse = OnDeleteUserDataResponse ;
573+
574+ Connector . URL = GetServiceUrl ( ) + "/v2/user_data" ;
575+ Authenticator . Authenticate ( Connector ) ;
576+
577+ return Connector . Send ( req ) ;
578+ }
579+
580+ private void OnDeleteUserDataResponse ( RESTConnector . Request req , RESTConnector . Response resp )
581+ {
582+ DetailedResponse < object > response = new DetailedResponse < object > ( ) ;
583+ foreach ( KeyValuePair < string , string > kvp in resp . Headers )
584+ {
585+ response . Headers . Add ( kvp . Key , kvp . Value ) ;
586+ }
587+ response . StatusCode = resp . HttpResponseCode ;
588+
589+ try
590+ {
591+ string json = Encoding . UTF8 . GetString ( resp . Data ) ;
592+ response . Result = JsonConvert . DeserializeObject < object > ( json ) ;
593+ response . Response = json ;
594+ }
595+ catch ( Exception e )
596+ {
597+ Log . Error ( "AssistantService.OnDeleteUserDataResponse()" , "Exception: {0}" , e . ToString ( ) ) ;
598+ resp . Success = false ;
599+ }
600+
601+ if ( ( ( RequestObject < object > ) req ) . Callback != null )
602+ ( ( RequestObject < object > ) req ) . Callback ( response , resp . Error ) ;
603+ }
430604 }
431605}
0 commit comments