Assets/Watson/Scripts/Services/RetrieveAndRank/RetrieveAndRank.cs
/// <summary>
/// An example of a method that forwards to the Solr Collections API (https://cwiki.apache.org/confluence/display/solr/Collections+API). This Retrieve and Rank resource improves error handling and resiliency of the Solr Collections API.
/// </summary>
/// <param name="callback"></param>
/// <param name="clusterID">Cluster ID for the collection.</param>
/// <param name="action">Operation to carry out. Either "CREATE", "LIST", or "DELETE"</param>
/// <param name="collectionName">The collectionName required for "CREATE" or "DELETE".</param>
/// <param name="configName">The cluster configuration name to use for "CREATE".</param>
/// <param name="customData"></param>
/// <returns></returns>
An example of a method that forwards to the Solr Collections API . This Retrieve and Rank resource improves error handling and resiliency of the Solr Collections API.
An example of a method that forwards to the Solr Collections API . This Retrieve and Rank resource improves error handling and resiliency of the Solr Collections API .
public bool ForwardCollectionRequest(OnCollections callback, string clusterID, string action, string collectionName = default(string), string configName = default(string), string customData = default(string))
        {
            if (callback == null)
                throw new ArgumentNullException("callback");
            if (string.IsNullOrEmpty(action))
                throw new ArgumentNullException("An Action is required for ForwardCollectionRequest (CREATE, DELETE or LIST)");
            if (string.IsNullOrEmpty(clusterID))
                throw new ArgumentNullException("A clusterID is required for ForwardCollectionRequest!");
            CollectionRequest req = new CollectionRequest();
            req.Callback = callback;
            req.ClusterID = clusterID;
            req.Data = customData;
            req.Action = action;
            req.CollectionName = collectionName;
            req.ConfigName = configName;
            req.Parameters["action"] = action;
            req.Parameters["wt"] = "json";
            req.Timeout = REQUEST_TIMEOUT;
            switch (action)
            {
                case CollectionsAction.LIST:
                    break;
                case CollectionsAction.CREATE:
                    if (string.IsNullOrEmpty(collectionName))
                        throw new ArgumentNullException("A collectionName is required for ForwardCollectionRequest (CREATE)!");
                    if (string.IsNullOrEmpty(configName))
                        throw new ArgumentNullException("A configName is required for ForwardCollectionRequest (CREATE)!");
                    req.Parameters["name"] = collectionName;
                    req.Parameters["collection.configName"] = configName;
                    break;
                case CollectionsAction.DELETE:
                    if (string.IsNullOrEmpty(collectionName))
                        throw new ArgumentNullException("A collectionName is required for ForwardCollectionRequest (DELETE)!");
                    req.Parameters["name"] = collectionName;
                    break;
                default:
                    throw new WatsonException(string.Format("No case exists for action {0}!", action));
            }
            RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, string.Format(SERVICE_CLUSTER_COLLECTIONS, clusterID));
            if (connector == null)
                return false;
            req.OnResponse = OnForwardCollectionRequestResponse;
            return connector.Send(req);
        }
public bool ForwardCollectionRequest ( OnCollections callback , string clusterID , string action , string collectionName = default ( string ) , string configName = default ( string ) , string customData = default ( string ) ) { if ( callback == null ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( action ) ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( clusterID ) ) throw new ArgumentNullException ( " " ) ; CollectionRequest req = new CollectionRequest ( ) ; req . Callback = callback ; req . ClusterID = clusterID ; req . Data = customData ; req . Action = action ; req . CollectionName = collectionName ; req . ConfigName = configName ; req . Parameters [ " " ] = action ; req . Parameters [ " " ] = " " ; req . Timeout = REQUEST_TIMEOUT ; switch ( action ) { case CollectionsAction . LIST : break ; case CollectionsAction . CREATE : if ( string . IsNullOrEmpty ( collectionName ) ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( configName ) ) throw new ArgumentNullException ( " " ) ; req . Parameters [ " " ] = collectionName ; req . Parameters [ " " ] = configName ; break ; case CollectionsAction . DELETE : if ( string . IsNullOrEmpty ( collectionName ) ) throw new ArgumentNullException ( " " ) ; req . Parameters [ " " ] = collectionName ; break ; default : throw new WatsonException ( string . Format ( " " , action ) ) ; } RESTConnector connector = RESTConnector . GetConnector ( SERVICE_ID , string . Format ( SERVICE_CLUSTER_COLLECTIONS , clusterID ) ) ; if ( connector == null ) return false ; req . OnResponse = OnForwardCollectionRequestResponse ; return connector . Send ( req ) ; }
An example of a method that forwards to the Solr Collections API (https://cwiki.apache.org/confluence/display/solr/Collections+API).
An example of a method that forwards to the Solr Collections API ( https : // cwiki . apache . org / confluence / display / solr / Collections + API ) .
None
callback
OnCollections
None
clusterID
string
Cluster ID for the collection.
Cluster ID for the collection .
action
string
Operation to carry out. Either "CREATE", "LIST", or "DELETE"
Operation to carry out . Either " CREATE " " LIST " or " DELETE "
collectionName
string
The collectionName required for "CREATE" or "DELETE".
The collectionName required for " CREATE " or " DELETE " .
configName
string
The cluster configuration name to use for "CREATE".
The cluster configuration name to use for " CREATE " .
customData
string
None