com.parse
Class ParseCloud

Object
  extended by com.parse.ParseCloud

public final class ParseCloud
extends Object

The ParseCloud class defines provides methods for interacting with Parse Cloud Functions. A Cloud Function can be called with ParseCloud.callFunctionInBackground(String, Map, FunctionCallback) using a FunctionCallback. For example, this sample code calls the "validateGame" Cloud Function and calls processResponse if the call succeeded and handleError if it failed.

 ParseCloud.callFunctionInBackground("validateGame", parameters, new FunctionCallback() {
      public void done(Object object, ParseException e) {
        if (e == null) {
          processResponse(object);
        } else {
          handleError();
        }
      }
 }
 
 
 Using the callback methods is usually preferred because the network operation will not block the
 calling thread. However, in some cases it may be easier to use the
 ParseCloud.callFunction(String, Map) call which do block the calling thread. For example, if your
 application has already spawned a background task to perform work, that background task could use
 the blocking calls and avoid the code complexity of callbacks.


Method Summary
static
<T> T
callFunction(String name, Map<String,?> params)
          Calls a cloud function.
static
<T> bolts.Task<T>
callFunctionInBackground(String name, Map<String,?> params)
          Calls a cloud function in the background.
static
<T> void
callFunctionInBackground(String name, Map<String,?> params, FunctionCallback<T> callback)
          Calls a cloud function in the background.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

callFunctionInBackground

public static <T> bolts.Task<T> callFunctionInBackground(String name,
                                                         Map<String,?> params)
Calls a cloud function in the background.

Parameters:
name - The cloud function to call.
params - The parameters to send to the cloud function. This map can contain anything that could be placed in a ParseObject except for ParseObjects themselves.
Returns:
A Task that will be resolved when the cloud function has returned.

callFunction

public static <T> T callFunction(String name,
                                 Map<String,?> params)
                      throws ParseException
Calls a cloud function.

Parameters:
name - The cloud function to call.
params - The parameters to send to the cloud function. This map can contain anything that could be placed in a ParseObject except for ParseObjects themselves.
Returns:
The result of the cloud call. Result may be a @{link Map}< String, ?>, ParseObject, List<?>, or any type that can be set as a field in a ParseObject.
Throws:
ParseException

callFunctionInBackground

public static <T> void callFunctionInBackground(String name,
                                                Map<String,?> params,
                                                FunctionCallback<T> callback)
Calls a cloud function in the background.

Parameters:
name - The cloud function to call.
params - The parameters to send to the cloud function. This map can contain anything that could be placed in a ParseObject except for ParseObjects themselves.
callback - The callback that will be called when the cloud function has returned.