public class ThingIFAPI
extends java.lang.Object
implements android.os.Parcelable
onboard(String, String, String, JSONObject)
method.Modifier and Type | Field and Description |
---|---|
static android.os.Parcelable.Creator<ThingIFAPI> |
CREATOR |
Modifier | Constructor and Description |
---|---|
protected |
ThingIFAPI(android.os.Parcel in) |
Modifier and Type | Method and Description |
---|---|
ThingIFAPI |
copyWithTarget(Target target,
java.lang.String tag)
Create the clone instance that has specified target and tag.
|
java.lang.String |
deleteTrigger(java.lang.String triggerID)
Delete the specified Trigger.
|
int |
describeContents() |
Trigger |
enableTrigger(java.lang.String triggerID,
boolean enable)
Enable/Disable registered Trigger
If its already enabled(/disabled),
this method won't throw Exception and behave as succeeded.
|
KiiApp |
getApp()
Get Kii App
|
java.lang.String |
getAppID()
Get AppID
|
java.lang.String |
getAppKey()
Get AppKey
|
java.lang.String |
getBaseUrl()
Get base URL
|
Command |
getCommand(java.lang.String commandID)
Get specified command.
|
java.lang.String |
getInstallationID()
Get installationID if the push is already installed.
|
Owner |
getOwner()
Get owner who uses the ThingIFAPI.
|
java.util.List<Schema> |
getSchemas()
Get list of schema.
|
static java.lang.String |
getSDKVersion()
Get version of the SDK.
|
java.lang.String |
getTag()
Get a tag.
|
Target |
getTarget()
Get target thing that is operated by the ThingIFAPI.
|
<S extends TargetState> |
getTargetState(java.lang.Class<S> classOfS)
Get the State of specified Target.
|
Trigger |
getTrigger(java.lang.String triggerID)
Get specified Trigger.
|
java.lang.String |
getVendorThingID()
Get the Vendor Thing ID of specified Target.
|
java.lang.String |
installPush(java.lang.String deviceToken,
PushBackend pushBackend)
Install push notification to receive notification from IoT Cloud.
|
java.lang.String |
installPush(java.lang.String deviceToken,
PushBackend pushBackend,
boolean development)
Install push notification to receive notification from IoT Cloud.
|
android.util.Pair<java.util.List<Command>,java.lang.String> |
listCommands(int bestEffortLimit,
java.lang.String paginationKey)
List Commands in the specified Target.
If the Schema of the Command included in the response does not matches with the Schema registered this ThingIfAPI instance, It won't be included in returned value. |
android.util.Pair<java.util.List<TriggeredServerCodeResult>,java.lang.String> |
listTriggeredServerCodeResults(java.lang.String triggerID,
int bestEffortLimit,
java.lang.String paginationKey)
Retrieves list of server code results that was executed by the specified trigger.
|
android.util.Pair<java.util.List<Trigger>,java.lang.String> |
listTriggers(int bestEffortLimit,
java.lang.String paginationKey)
List Triggers belongs to the specified Target.
If the Schema of the Trigger included in the response does not matches with the Schema registered this ThingIfAPI instance, It won't be included in returned value. |
static ThingIFAPI |
loadFromStoredInstance(android.content.Context context)
Try to load the instance of ThingIFAPI using stored serialized instance.
|
static ThingIFAPI |
loadFromStoredInstance(android.content.Context context,
java.lang.String tag)
Try to load the instance of ThingIFAPI using stored serialized instance.
|
Target |
onboard(java.lang.String thingID,
java.lang.String thingPassword)
On board IoT Cloud with the specified thing ID.
|
Target |
onboard(java.lang.String thingID,
java.lang.String thingPassword,
OnboardWithThingIDOptions options)
On board IoT Cloud with the specified thing ID.
|
Target |
onboard(java.lang.String vendorThingID,
java.lang.String thingPassword,
OnboardWithVendorThingIDOptions options)
On board IoT Cloud with the specified vendor thing ID.
|
Target |
onboard(java.lang.String vendorThingID,
java.lang.String thingPassword,
java.lang.String thingType,
org.json.JSONObject thingProperties)
On board IoT Cloud with the specified vendor thing ID.
|
boolean |
onboarded()
Checks whether on boarding is done.
|
EndNode |
onboardEndnodeWithGateway(PendingEndNode pendingEndNode,
java.lang.String endnodePassword)
Endpoints execute onboarding for the thing and merge MQTT channel to the gateway.
|
EndNode |
onboardEndnodeWithGateway(PendingEndNode pendingEndNode,
java.lang.String endnodePassword,
OnboardEndnodeWithGatewayOptions options)
Endpoints execute onboarding for the thing and merge MQTT channel to the gateway.
|
Trigger |
patchTrigger(java.lang.String triggerID,
ServerCode serverCode,
Predicate predicate)
Apply Patch to registered Trigger
Modify registered Trigger with specified patch.
|
Trigger |
patchTrigger(java.lang.String triggerID,
ServerCode serverCode,
Predicate predicate,
TriggerOptions options)
Apply Patch to registered Trigger
Modify registered Trigger with specified patch.
|
Trigger |
patchTrigger(java.lang.String triggerID,
java.lang.String schemaName,
int schemaVersion,
java.util.List<Action> actions,
Predicate predicate)
Apply Patch to registered Trigger
Modify registered Trigger with specified patch.
|
Trigger |
patchTrigger(java.lang.String triggerID,
TriggeredCommandForm form,
Predicate predicate,
TriggerOptions options)
Apply patch to registered trigger.
|
Command |
postNewCommand(CommandForm form)
Post new command to IoT Cloud.
|
Command |
postNewCommand(java.lang.String schemaName,
int schemaVersion,
java.util.List<Action> actions)
Post new command to IoT Cloud.
|
Trigger |
postNewTrigger(ServerCode serverCode,
Predicate predicate)
Post new Trigger with server code to IoT Cloud.
|
Trigger |
postNewTrigger(ServerCode serverCode,
Predicate predicate,
TriggerOptions options)
Post new Trigger with server code to IoT Cloud.
|
Trigger |
postNewTrigger(java.lang.String schemaName,
int schemaVersion,
java.util.List<Action> actions,
Predicate predicate)
Post new Trigger with commands to IoT Cloud.
|
Trigger |
postNewTrigger(TriggeredCommandForm form,
Predicate predicate,
TriggerOptions options)
Post new Trigger with commands to IoT Cloud.
|
static void |
removeAllStoredInstances()
Clear all saved instances in the SharedPreferences.
|
static void |
removeStoredInstance(java.lang.String tag)
Remove saved specified instance in the SharedPreferences.
|
void |
uninstallPush(java.lang.String installationID)
Uninstall push notification.
|
void |
updateVendorThingID(java.lang.String newVendorThingID,
java.lang.String newPassword)
Update the Vendor Thing ID of specified Target.
|
void |
writeToParcel(android.os.Parcel dest,
int flags) |
public static final android.os.Parcelable.Creator<ThingIFAPI> CREATOR
public static ThingIFAPI loadFromStoredInstance(android.content.Context context) throws StoredThingIFAPIInstanceNotFoundException
onboard(String, String, String, JSONObject)
, onboard(String, String)
,
copyWithTarget(Target, String)
and installPush(java.lang.String, com.kii.thingif.PushBackend)
has been successfully completed.
copyWithTarget(Target, String)
is called, only the copied instance is saved.)
api
.context
- contextStoredThingIFAPIInstanceNotFoundException
- when the instance has not stored yet.public static ThingIFAPI loadFromStoredInstance(android.content.Context context, java.lang.String tag) throws StoredThingIFAPIInstanceNotFoundException
loadFromStoredInstance(Context)
document.context
- contexttag
- specified when the ThingIFAPI has been built.StoredThingIFAPIInstanceNotFoundException
- when the instance has not stored yet.public static void removeAllStoredInstances()
public static void removeStoredInstance(java.lang.String tag)
tag
- tag to specify stored instance.public ThingIFAPI copyWithTarget(Target target, java.lang.String tag)
target
- coping target.tag
- A key to store instnace.public Target onboard(java.lang.String vendorThingID, java.lang.String thingPassword, java.lang.String thingType, org.json.JSONObject thingProperties) throws ThingIFException
onboardEndnodeWithGateway(PendingEndNode, String)
instead.vendorThingID
- Thing ID given by vendor. Must be specified.thingPassword
- Thing Password given by vendor. Must be specified.thingType
- Type of the thing given by vendor.
If the thing is already registered, this value would be
ignored by IoT Cloud.thingProperties
- Properties of thing.
If the thing is already registered, this value
would be ignored by IoT Cloud.java.lang.IllegalStateException
- Thrown when this instance is already onboarded.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public Target onboard(java.lang.String vendorThingID, java.lang.String thingPassword, OnboardWithVendorThingIDOptions options) throws ThingIFException
onboardEndnodeWithGateway(PendingEndNode, String)
instead.vendorThingID
- Thing ID given by vendor. Must be specified.thingPassword
- Thing Password given by vendor. Must be specified.options
- optional parameters inside.java.lang.IllegalStateException
- Thrown when this instance is already onboarded.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public Target onboard(java.lang.String thingID, java.lang.String thingPassword) throws ThingIFException
onboard(String, String, String, JSONObject)
.
If you are using a gateway, you need to use onboardEndnodeWithGateway(PendingEndNode, String)
instead.thingID
- Thing ID given by IoT Cloud. Must be specified.thingPassword
- Thing password given by vendor. Must be specified.java.lang.IllegalStateException
- Thrown when this instance is already onboarded.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public Target onboard(java.lang.String thingID, java.lang.String thingPassword, OnboardWithThingIDOptions options) throws ThingIFException
onboard(String, String, OnboardWithVendorThingIDOptions)
.
If you are using a gateway, you need to use onboardEndnodeWithGateway(PendingEndNode, String)
instead.thingID
- Thing ID given by IoT Cloud. Must be specified.thingPassword
- Thing password given by vendor. Must be specified.options
- optional parameters inside.java.lang.IllegalStateException
- Thrown when this instance is already onboarded.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public EndNode onboardEndnodeWithGateway(PendingEndNode pendingEndNode, java.lang.String endnodePassword) throws ThingIFException
pendingEndNode
- Pending endnodeendnodePassword
- Password of the End Nodejava.lang.IllegalStateException
- Thrown when this instance is already onboarded.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public EndNode onboardEndnodeWithGateway(PendingEndNode pendingEndNode, java.lang.String endnodePassword, OnboardEndnodeWithGatewayOptions options) throws ThingIFException
pendingEndNode
- Pending endnodeendnodePassword
- Password of the End Nodeoptions
- optional parameters inside.java.lang.IllegalStateException
- Thrown when this instance is already onboarded.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public boolean onboarded()
public java.lang.String installPush(java.lang.String deviceToken, PushBackend pushBackend) throws ThingIFException
deviceToken
- for GCM, specify token obtained by
InstanceID.getToken().
for JPUSH, specify id obtained by
JPushInterface.getUdid().pushBackend
- Specify backend to use.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.for development/production environment installation.
public java.lang.String installPush(java.lang.String deviceToken, PushBackend pushBackend, boolean development) throws ThingIFException
deviceToken
- for GCM, specify token obtained by
InstanceID.getToken().
for JPUSH, specify id obtained by
JPushInterface.getUdid().pushBackend
- Specify backend to use.development
- Specify development flag to use. Indicates if the installation is for development or production environment.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public java.lang.String getInstallationID()
public void uninstallPush(java.lang.String installationID) throws ThingIFException
installationID
- installation ID returned from
installPush(String, PushBackend)
if null is specified, value obtained by
getInstallationID()
is used.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public Command postNewCommand(java.lang.String schemaName, int schemaVersion, java.util.List<Action> actions) throws ThingIFException
schemaName
- name of the schema.schemaVersion
- version of schema.actions
- Actions to be executed.getCommand(java.lang.String)
.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public Command postNewCommand(CommandForm form) throws ThingIFException
form
- form of command. It contains name of schema, version of
schema, list of actions etc.getCommand(java.lang.String)
.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public Command getCommand(java.lang.String commandID) throws ThingIFException
commandID
- ID of the command to obtain. ID is present in the
instance returned by postNewCommand(java.lang.String, int, java.util.List<com.kii.thingif.command.Action>)
and can be obtained by Command.getCommandID()
ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.UnsupportedSchemaException
- Thrown when the returned response has a schema that cannot handle this instance.UnsupportedActionException
- Thrown when the returned response has a action that cannot handle this instance.public android.util.Pair<java.util.List<Command>,java.lang.String> listCommands(int bestEffortLimit, java.lang.String paginationKey) throws ThingIFException
bestEffortLimit
- Maximum number of the Commands in the response.
if the value is <= 0, default limit internally
defined is applied.
Meaning of 'bestEffort' is if the specified limit
is greater than default limit, default limit is
applied.paginationKey
- Used to get the next page of previously obtained.
If there is further page to obtain, this method
returns paginationKey as the 2nd element of pair.
Applying this key to the argument results continue
to get the result from the next page.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.UnsupportedActionException
- Thrown when the returned response has a action that cannot handle this instance.public Trigger postNewTrigger(java.lang.String schemaName, int schemaVersion, java.util.List<Action> actions, Predicate predicate) throws ThingIFException
Limited version of postNewTrigger(TriggeredCommandForm,
Predicate, TriggerOptions)
.
This method equals to followings:
api.postNewTrigger(
TriggeredCommandForm.Builder.newBuilder(
schemaName,
schemaVersion,
actions).setTargetID(api.getTarget()).build(),
predicate, null).
schemaName
- name of the schema.schemaVersion
- version of schema.actions
- Specify actions included in the Command is fired by the
trigger.predicate
- Specify when the Trigger fires command.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.postNewTrigger(TriggeredCommandForm, Predicate, TriggerOptions)
public Trigger postNewTrigger(TriggeredCommandForm form, Predicate predicate, TriggerOptions options) throws ThingIFException
When thing retrieved by getTarget()
of this ThingIFAPI
instance meets condition described by predicate, A command registered
by TriggeredCommandForm
sends to thing given by TriggeredCommandForm.getTargetID()
.
getTarget()
instance and thing specified by TriggeredCommandForm.getTargetID()
must be same owner's things.
form
- Form of triggered command. It contains name of schema,
version of schema, list of actions, target IDof thing etc. You can see
detail of form in TriggeredCommandForm
.predicate
- Specify when the Trigger fires command.options
- option fileds of this trigger.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.java.lang.IllegalArgumentException
- if form and/or predicate is null.public Trigger postNewTrigger(ServerCode serverCode, Predicate predicate, TriggerOptions options) throws ThingIFException
serverCode
- Specify server code you want to execute.predicate
- Specify when the Trigger fires command.options
- option fileds of this trigger.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public Trigger postNewTrigger(ServerCode serverCode, Predicate predicate) throws ThingIFException
Limited version of postNewTrigger(ServerCode, Predicate,
TriggerOptions)
. This method can not be set title, description and
metadata of Trigger
.
serverCode
- Specify server code you want to execute.predicate
- Specify when the Trigger fires command.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public Trigger getTrigger(java.lang.String triggerID) throws ThingIFException
triggerID
- ID of the Trigger to get.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.UnsupportedSchemaException
- Thrown when the returned response has a schema that cannot handle this instance.UnsupportedActionException
- Thrown when the returned response has a action that cannot handle this instance.public Trigger patchTrigger(java.lang.String triggerID, TriggeredCommandForm form, Predicate predicate, TriggerOptions options) throws ThingIFException
triggerID
- ID of the trigger to apply patch.form
- Form of triggered command. It contains name of schema,
version of schema, list of actions, target IDof thing etc. You can see
detail of form in TriggeredCommandForm
.predicate
- Modified predicate.options
- option fileds of this trigger.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.java.lang.IllegalArgumentException
- This exception is thrown if one or
more following conditions are met.
public Trigger patchTrigger(java.lang.String triggerID, java.lang.String schemaName, int schemaVersion, java.util.List<Action> actions, Predicate predicate) throws ThingIFException
Limited version of patchTrigger(String, TriggeredCommandForm,
Predicate, TriggerOptions)
triggerID
- ID ot the Trigger to apply patchschemaName
- name of the schema. if actions is not null and not
empty, this must be not null. if actions is null or empty, this
argument is ignored.schemaVersion
- version of schema. if actions is null or empty,
this argument is ignored.actions
- Modified actions.
If null or empty, predicate must not be null.predicate
- Modified predicate.
If null, actions must not be null and empty.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.java.lang.IllegalArgumentException
- when both actions and predicates are nullpublic Trigger patchTrigger(java.lang.String triggerID, ServerCode serverCode, Predicate predicate, TriggerOptions options) throws ThingIFException
triggerID
- ID ot the Trigger to apply patchserverCode
- Specify server code you want to execute.predicate
- Modified predicate.options
- option fileds of this trigger.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.java.lang.IllegalArgumentException
- when all of serverCode, predicates
and options are null.public Trigger patchTrigger(java.lang.String triggerID, ServerCode serverCode, Predicate predicate) throws ThingIFException
Limited version of patchTrigger(String, ServerCode, Predicate,
TriggerOptions)
triggerID
- ID ot the Trigger to apply patchserverCode
- Specify server code you want to execute. If null,
predicate must not be null.predicate
- Modified predicate. If null, serverCode must not be
null.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.java.lang.IllegalArgumentException
- when both server and predicates are
null.public Trigger enableTrigger(java.lang.String triggerID, boolean enable) throws ThingIFException
triggerID
- ID of the Trigger to be enabled(/disabled).enable
- specify whether enable of disable the Trigger.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public java.lang.String deleteTrigger(java.lang.String triggerID) throws ThingIFException
triggerID
- ID of the Trigger to be deleted.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public android.util.Pair<java.util.List<TriggeredServerCodeResult>,java.lang.String> listTriggeredServerCodeResults(java.lang.String triggerID, int bestEffortLimit, java.lang.String paginationKey) throws ThingIFException
triggerID
- trigger ID to retrieve server code results.bestEffortLimit
- limit the maximum number of the results in the
Response. It ensures numbers in
response is equals to or less than specified number.
But doesn't ensures number of the results
in the response is equal to specified value.paginationKey
- If specified obtain rest of the items.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public android.util.Pair<java.util.List<Trigger>,java.lang.String> listTriggers(int bestEffortLimit, java.lang.String paginationKey) throws ThingIFException
bestEffortLimit
- limit the maximum number of the Triggers in the
Response. It ensures numbers in
response is equals to or less than specified number.
But doesn't ensures number of the Triggers
in the response is equal to specified value.paginationKey
- If specified obtain rest of the items.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.UnsupportedActionException
- Thrown when the returned response has a action that cannot handle this instance.public <S extends TargetState> S getTargetState(java.lang.Class<S> classOfS) throws ThingIFException
S
- State class.classOfS
- Specify class of the State.ThingIFException
- Thrown when failed to connect IoT Cloud Server.ThingIFRestException
- Thrown when server returns error response.public java.lang.String getVendorThingID() throws ThingIFException
ThingIFException
- Thrown when failed to connect IoT Cloud Server.public void updateVendorThingID(java.lang.String newVendorThingID, java.lang.String newPassword) throws ThingIFException
newVendorThingID
- New vendor thing idnewPassword
- New passwordThingIFException
- Thrown when failed to connect IoT Cloud Server.public KiiApp getApp()
public java.lang.String getAppID()
public java.lang.String getAppKey()
public java.lang.String getBaseUrl()
public java.util.List<Schema> getSchemas()
public Owner getOwner()
public Target getTarget()
public java.lang.String getTag()
public int describeContents()
describeContents
in interface android.os.Parcelable
public void writeToParcel(android.os.Parcel dest, int flags)
writeToParcel
in interface android.os.Parcelable
public static java.lang.String getSDKVersion()
Copyright 2015 Kii Corporation. All rights reserved. (Last updated on 2016-10-13 08:55 UTC)