/// <summary> /// List classifiers. /// /// Returns an empty array if no classifiers are available. /// </summary> /// <param name="customData">Custom data object to pass data including custom request headers.</param> /// <returns><see cref="ClassifierList" />ClassifierList</returns> public ClassifierList ListClassifiers(Dictionary <string, object> customData = null) { ClassifierList result = null; try { IClient client; if (_tokenManager == null) { client = this.Client.WithAuthentication(this.UserName, this.Password); } else { client = this.Client.WithAuthentication(_tokenManager.GetToken()); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/classifiers"); if (customData != null) { restRequest.WithCustomData(customData); } result = restRequest.As <ClassifierList>().Result; if (result == null) { result = new ClassifierList(); } result.CustomData = restRequest.CustomData; } catch (AggregateException ae) { throw ae.Flatten(); } return(result); }
private IEnumerator ExampleListClassifiers() { ClassifierList listClassifiersResponse = null; service.ListClassifiers( callback: (DetailedResponse <ClassifierList> response, IBMError error) => { Log.Debug("NaturalLanguageClassifierServiceV1", "ListClassifiers result: {0}", response.Response); listClassifiersResponse = response.Result; } ); while (listClassifiersResponse == null) { yield return(null); } }
/// <summary> /// List classifiers. Returns an empty array if no classifiers are available. /// </summary> /// <returns><see cref="ClassifierList" />ClassifierList</returns> public ClassifierList ListClassifiers() { ClassifierList result = null; try { var request = this.Client.WithAuthentication(this.UserName, this.Password) .GetAsync($"{this.Endpoint}/v1/classifiers"); result = request.As <ClassifierList>().Result; } catch (AggregateException ae) { throw ae.Flatten(); } return(result); }
/// <summary> /// List classifiers. /// /// Returns an empty array if no classifiers are available. /// </summary> /// <param name="customData">Custom data object to pass data including custom request headers.</param> /// <returns><see cref="ClassifierList" />ClassifierList</returns> public ClassifierList ListClassifiers(Dictionary <string, object> customData = null) { ClassifierList result = null; try { IClient client = this.Client; if (_tokenManager != null) { client = this.Client.WithAuthentication(_tokenManager.GetToken()); } if (_tokenManager == null) { client = this.Client.WithAuthentication(this.UserName, this.Password); } var restRequest = client.GetAsync($"{this.Endpoint}/v1/classifiers"); if (customData != null) { restRequest.WithCustomData(customData); } restRequest.WithHeader("X-IBMCloud-SDK-Analytics", "service_name=natural_language_classifier;service_version=v1;operation_id=ListClassifiers"); result = restRequest.As <ClassifierList>().Result; if (result == null) { result = new ClassifierList(); } result.CustomData = restRequest.CustomData; } catch (AggregateException ae) { throw ae.Flatten(); } return(result); }
public IEnumerator TestListClassifiers() { Log.Debug("NaturalLanguageClassifierServiceV1IntegrationTests", "Attempting to ListClassifiers..."); ClassifierList listClassifiersResponse = null; service.ListClassifiers( callback: (DetailedResponse <ClassifierList> response, IBMError error) => { Log.Debug("NaturalLanguageClassifierServiceV1IntegrationTests", "ListClassifiers result: {0}", response.Response); listClassifiersResponse = response.Result; classifierId = listClassifiersResponse.Classifiers[0].ClassifierId; Assert.IsNotNull(listClassifiersResponse); Assert.IsNotNull(listClassifiersResponse.Classifiers); Assert.IsTrue(listClassifiersResponse.Classifiers.Count > 0); Assert.IsNull(error); } ); while (listClassifiersResponse == null) { yield return(null); } }